android: Remove unused JNI functions and use better names for game icon variables

This commit is contained in:
FearlessTobi 2020-04-16 03:23:02 +02:00 committed by bunnei
parent bb8a0c2bea
commit 89be9610d1
12 changed files with 28 additions and 260 deletions

View File

@ -110,34 +110,12 @@ public final class NativeLibrary {
public static native void InitGameIni(String gameID);
/**
* Gets a value from a key in the given ini-based config file.
* Gets the embedded icon within the given ROM.
*
* @param configFile The ini-based config file to get the value from.
* @param Section The section key that the actual key is in.
* @param Key The key to get the value from.
* @param Default The value to return in the event the given key doesn't exist.
* @return the value stored at the key, or a default value if it doesn't exist.
* @param filename the file path to the ROM.
* @return an integer array containing the color data for the icon.
*/
public static native String GetConfig(String configFile, String Section, String Key,
String Default);
/**
* Sets a value to a key in the given ini config file.
*
* @param configFile The ini-based config file to add the value to.
* @param Section The section key for the ini key
* @param Key The actual ini key to set.
* @param Value The string to set the ini key to.
*/
public static native void SetConfig(String configFile, String Section, String Key, String Value);
/**
* Gets the embedded banner within the given ISO/ROM.
*
* @param filename the file path to the ISO/ROM.
* @return an integer array containing the color data for the banner.
*/
public static native int[] GetBanner(String filename);
public static native int[] GetIcon(String filename);
/**
* Gets the embedded title of the given ISO/ROM.
@ -151,62 +129,16 @@ public final class NativeLibrary {
public static native String GetGameId(String filename);
public static native int GetCountry(String filename);
public static native String GetCompany(String filename);
public static native long GetFilesize(String filename);
public static native String GetGitRevision();
/**
* Saves a screen capture of the game
*/
public static native void SaveScreenShot();
/**
* Saves a game state to the slot number.
*
* @param slot The slot location to save state to.
* @param wait If false, returns as early as possible.
* If true, returns once the savestate has been written to disk.
*/
public static native void SaveState(int slot, boolean wait);
/**
* Saves a game state to the specified path.
*
* @param path The path to save state to.
* @param wait If false, returns as early as possible.
* If true, returns once the savestate has been written to disk.
*/
public static native void SaveStateAs(String path, boolean wait);
/**
* Loads a game state from the slot number.
*
* @param slot The slot location to load state from.
*/
public static native void LoadState(int slot);
/**
* Loads a game state from the specified path.
*
* @param path The path to load state from.
*/
public static native void LoadStateAs(String path);
/**
* Sets the current working user directory
* If not set, it auto-detects a location
*/
public static native void SetUserDirectory(String directory);
/**
* Returns the current working user directory
*/
public static native String GetUserDirectory();
// Create the config.ini file.
public static native void CreateConfigFile();
@ -249,23 +181,6 @@ public final class NativeLibrary {
*/
public static native boolean IsRunning();
/**
* Enables or disables CPU block profiling
*
* @param enable
*/
public static native void SetProfiling(boolean enable);
/**
* Writes out the block profile results
*/
public static native void WriteProfileResults();
/**
* Native EGL functions not exposed by Java bindings
**/
public static native void eglBindAPI(int api);
/**
* Returns the performance stats for the current game
**/

View File

@ -83,7 +83,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
public void onBindViewHolder(@NonNull GameViewHolder holder, int position) {
if (mDatasetValid) {
if (mCursor.moveToPosition(position)) {
PicassoUtils.loadGameBanner(holder.imageScreenshot,
PicassoUtils.loadGameIcon(holder.imageIcon,
mCursor.getString(GameDatabase.GAME_COLUMN_PATH));
holder.textGameTitle.setText(mCursor.getString(GameDatabase.GAME_COLUMN_TITLE).replaceAll("[\\t\\n\\r]+", " "));
@ -97,9 +97,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
holder.path = mCursor.getString(GameDatabase.GAME_COLUMN_PATH);
holder.title = mCursor.getString(GameDatabase.GAME_COLUMN_TITLE);
holder.description = mCursor.getString(GameDatabase.GAME_COLUMN_DESCRIPTION);
holder.country = mCursor.getInt(GameDatabase.GAME_COLUMN_COUNTRY);
holder.company = mCursor.getString(GameDatabase.GAME_COLUMN_COMPANY);
holder.screenshotPath = mCursor.getString(GameDatabase.GAME_COLUMN_SCREENSHOT_PATH);
final int backgroundColorId = isValidGame(holder.path) ? R.color.card_view_background : R.color.card_view_disabled;
holder.setBackgroundColor(ContextCompat.getColor(CitraApplication.getAppContext(), backgroundColorId));

View File

@ -7,31 +7,22 @@ import android.os.Environment;
import java.nio.file.Paths;
public final class Game {
private static final String PATH_SCREENSHOT_FOLDER =
"file://" + Environment.getExternalStorageDirectory().getPath() + "/citra-emu/ScreenShots/";
private String mTitle;
private String mDescription;
private String mPath;
private String mGameId;
private String mScreenshotPath;
private String mCompany;
private int mCountry;
public Game(String title, String description, int country, String path,
String gameId, String company, String screenshotPath) {
public Game(String title, String description, String path,
String gameId, String company) {
mTitle = title;
mDescription = description;
mCountry = country;
mPath = path;
mGameId = gameId;
mCompany = company;
mScreenshotPath = screenshotPath;
}
public static ContentValues asContentValues(String title, String description,
int country, String path, String gameId, String company) {
public static ContentValues asContentValues(String title, String description, String path, String gameId, String company) {
ContentValues values = new ContentValues();
if (gameId.isEmpty()) {
@ -39,15 +30,11 @@ public final class Game {
gameId = Paths.get(path).getFileName().toString();
}
String screenPath = PATH_SCREENSHOT_FOLDER + gameId + "/" + gameId + "-1.png";
values.put(GameDatabase.KEY_GAME_TITLE, title);
values.put(GameDatabase.KEY_GAME_DESCRIPTION, description);
values.put(GameDatabase.KEY_GAME_COUNTRY, country);
values.put(GameDatabase.KEY_GAME_PATH, path);
values.put(GameDatabase.KEY_GAME_ID, gameId);
values.put(GameDatabase.KEY_GAME_COMPANY, company);
values.put(GameDatabase.KEY_GAME_SCREENSHOT_PATH, screenPath);
return values;
}
@ -55,11 +42,9 @@ public final class Game {
public static Game fromCursor(Cursor cursor) {
return new Game(cursor.getString(GameDatabase.GAME_COLUMN_TITLE),
cursor.getString(GameDatabase.GAME_COLUMN_DESCRIPTION),
cursor.getInt(GameDatabase.GAME_COLUMN_COUNTRY),
cursor.getString(GameDatabase.GAME_COLUMN_PATH),
cursor.getString(GameDatabase.GAME_COLUMN_GAME_ID),
cursor.getString(GameDatabase.GAME_COLUMN_COMPANY),
cursor.getString(GameDatabase.GAME_COLUMN_SCREENSHOT_PATH));
cursor.getString(GameDatabase.GAME_COLUMN_COMPANY));
}
public String getTitle() {
@ -74,10 +59,6 @@ public final class Game {
return mCompany;
}
public int getCountry() {
return mCountry;
}
public String getPath() {
return mPath;
}
@ -85,8 +66,4 @@ public final class Game {
public String getGameId() {
return mGameId;
}
public String getScreenshotPath() {
return mScreenshotPath;
}
}

View File

@ -25,19 +25,15 @@ public final class GameDatabase extends SQLiteOpenHelper {
public static final int GAME_COLUMN_PATH = 1;
public static final int GAME_COLUMN_TITLE = 2;
public static final int GAME_COLUMN_DESCRIPTION = 3;
public static final int GAME_COLUMN_COUNTRY = 4;
public static final int GAME_COLUMN_GAME_ID = 5;
public static final int GAME_COLUMN_COMPANY = 6;
public static final int GAME_COLUMN_SCREENSHOT_PATH = 7;
public static final int FOLDER_COLUMN_PATH = 1;
public static final String KEY_DB_ID = "_id";
public static final String KEY_GAME_PATH = "path";
public static final String KEY_GAME_TITLE = "title";
public static final String KEY_GAME_DESCRIPTION = "description";
public static final String KEY_GAME_COUNTRY = "country";
public static final String KEY_GAME_ID = "game_id";
public static final String KEY_GAME_COMPANY = "company";
public static final String KEY_GAME_SCREENSHOT_PATH = "screenshot_path";
public static final String KEY_FOLDER_PATH = "path";
public static final String TABLE_NAME_FOLDERS = "folders";
public static final String TABLE_NAME_GAMES = "games";
@ -55,10 +51,8 @@ public final class GameDatabase extends SQLiteOpenHelper {
+ KEY_GAME_PATH + TYPE_STRING + SEPARATOR
+ KEY_GAME_TITLE + TYPE_STRING + SEPARATOR
+ KEY_GAME_DESCRIPTION + TYPE_STRING + SEPARATOR
+ KEY_GAME_COUNTRY + TYPE_INTEGER + SEPARATOR
+ KEY_GAME_ID + TYPE_STRING + SEPARATOR
+ KEY_GAME_COMPANY + TYPE_STRING + SEPARATOR
+ KEY_GAME_SCREENSHOT_PATH + TYPE_STRING + ")";
+ KEY_GAME_COMPANY + TYPE_STRING + ")";
private static final String SQL_CREATE_FOLDERS = "CREATE TABLE " + TABLE_NAME_FOLDERS + "("
+ KEY_DB_ID + TYPE_PRIMARY + SEPARATOR
@ -192,7 +186,6 @@ public final class GameDatabase extends SQLiteOpenHelper {
ContentValues game = Game.asContentValues(name,
NativeLibrary.GetDescription(filePath).replace("\n", " "),
NativeLibrary.GetCountry(filePath),
filePath,
gameId,
NativeLibrary.GetCompany(filePath));

View File

@ -49,7 +49,6 @@ public final class DirectoryInitialization {
if (PermissionsHandler.hasWriteAccess(context)) {
if (setCitraUserDirectory()) {
initializeInternalStorage(context);
CreateUserDirectories();
NativeLibrary.CreateConfigFile();
directoryState = DirectoryInitializationState.CITRA_DIRECTORIES_INITIALIZED;
} else {
@ -87,8 +86,6 @@ public final class DirectoryInitialization {
}
private static native void CreateUserDirectories();
private static native void SetSysDirectory(String path);
private static boolean setCitraUserDirectory() {

View File

@ -10,7 +10,7 @@ import org.citra.citra_emu.NativeLibrary;
import java.nio.IntBuffer;
public class GameBannerRequestHandler extends RequestHandler {
public class GameIconRequestHandler extends RequestHandler {
@Override
public boolean canHandleRequest(Request data) {
return "iso".equals(data.uri.getScheme());
@ -19,7 +19,7 @@ public class GameBannerRequestHandler extends RequestHandler {
@Override
public Result load(Request request, int networkPolicy) {
String url = request.uri.getHost() + request.uri.getPath();
int[] vector = NativeLibrary.GetBanner(url);
int[] vector = NativeLibrary.GetIcon(url);
Bitmap bitmap = Bitmap.createBitmap(48, 48, Bitmap.Config.RGB_565);
bitmap.copyPixelsFromBuffer(IntBuffer.wrap(vector));
return new Result(bitmap, Picasso.LoadedFrom.DISK);

View File

@ -9,9 +9,9 @@ import com.squareup.picasso.Picasso;
import org.citra.citra_emu.R;
public class PicassoUtils {
public static void loadGameBanner(ImageView imageView, String gamePath) {
public static void loadGameIcon(ImageView imageView, String gamePath) {
Picasso picassoInstance = new Picasso.Builder(imageView.getContext())
.addRequestHandler(new GameBannerRequestHandler())
.addRequestHandler(new GameIconRequestHandler())
.build();
picassoInstance
@ -21,7 +21,7 @@ public class PicassoUtils {
.fit()
.centerInside()
.config(Bitmap.Config.RGB_565)
.error(R.drawable.no_banner)
.error(R.drawable.no_icon)
.transform(new PicassoRoundedCornersTransformation())
.into(imageView);
}

View File

@ -14,7 +14,7 @@ import org.citra.citra_emu.R;
*/
public class GameViewHolder extends RecyclerView.ViewHolder {
private View itemView;
public ImageView imageScreenshot;
public ImageView imageIcon;
public TextView textGameTitle;
public TextView textCompany;
public TextView textFileName;
@ -25,9 +25,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
public String path;
public String title;
public String description;
public int country;
public String company;
public String screenshotPath;
public GameViewHolder(View itemView) {
super(itemView);
@ -35,7 +33,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
this.itemView = itemView;
itemView.setTag(this);
imageScreenshot = itemView.findViewById(R.id.image_game_screen);
imageIcon = itemView.findViewById(R.id.image_game_screen);
textGameTitle = itemView.findViewById(R.id.text_game_title);
textCompany = itemView.findViewById(R.id.text_company);
textFileName = itemView.findViewById(R.id.text_filename);

View File

@ -264,9 +264,9 @@ void Java_org_citra_citra_1emu_NativeLibrary_onTouchMoved(JNIEnv* env,
window->OnTouchMoved((int)x, (int)y);
}
jintArray Java_org_citra_citra_1emu_NativeLibrary_GetBanner(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jstring j_file) {
jintArray Java_org_citra_citra_1emu_NativeLibrary_GetIcon(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jstring j_file) {
std::string filepath = GetJString(env, j_file);
std::vector<u16> icon_data = GameInfo::GetIcon(filepath);
@ -274,11 +274,11 @@ jintArray Java_org_citra_citra_1emu_NativeLibrary_GetBanner(JNIEnv* env,
return 0;
}
jintArray banner = env->NewIntArray(static_cast<jsize>(icon_data.size()));
env->SetIntArrayRegion(banner, 0, env->GetArrayLength(banner),
jintArray icon = env->NewIntArray(static_cast<jsize>(icon_data.size()));
env->SetIntArrayRegion(icon, 0, env->GetArrayLength(icon),
reinterpret_cast<jint*>(icon_data.data()));
return banner;
return icon;
}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetTitle(JNIEnv* env, [[maybe_unused]] jclass clazz,
@ -306,11 +306,6 @@ jstring Java_org_citra_citra_1emu_NativeLibrary_GetGameId(JNIEnv* env,
return j_filename;
}
jint Java_org_citra_citra_1emu_NativeLibrary_GetCountry(JNIEnv* env, [[maybe_unused]] jclass clazz,
jstring j_filename) {
return 0;
}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetCompany(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jstring j_filename) {
@ -325,62 +320,11 @@ jstring Java_org_citra_citra_1emu_NativeLibrary_GetCompany(JNIEnv* env,
return env->NewStringUTF(Common::UTF16ToUTF8(publisher).data());
}
jlong Java_org_citra_citra_1emu_NativeLibrary_GetFilesize(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jstring j_filename) {
return 0;
}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetVersionString(JNIEnv* env,
[[maybe_unused]] jclass clazz) {
return nullptr;
}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetGitRevision(JNIEnv* env,
[[maybe_unused]] jclass clazz) {
return nullptr;
}
void Java_org_citra_citra_1emu_NativeLibrary_SaveScreenShot(JNIEnv* env,
[[maybe_unused]] jclass clazz) {}
void Java_org_citra_citra_1emu_NativeLibrary_eglBindAPI(JNIEnv* env, [[maybe_unused]] jclass clazz,
jint api) {}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetConfig(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jstring j_file, jstring j_section,
jstring j_key, jstring j_default) {
return nullptr;
}
void Java_org_citra_citra_1emu_NativeLibrary_SetConfig(JNIEnv* env, [[maybe_unused]] jclass clazz,
jstring j_file, jstring j_section,
jstring j_key, jstring j_value) {}
void Java_org_citra_citra_1emu_NativeLibrary_SetFilename(JNIEnv* env, [[maybe_unused]] jclass clazz,
jstring j_file) {}
void Java_org_citra_citra_1emu_NativeLibrary_SaveState(JNIEnv* env, [[maybe_unused]] jclass clazz,
jint slot, jboolean wait) {}
void Java_org_citra_citra_1emu_NativeLibrary_SaveStateAs(JNIEnv* env, [[maybe_unused]] jclass clazz,
jstring path, jboolean wait) {}
void Java_org_citra_citra_1emu_NativeLibrary_LoadState(JNIEnv* env, [[maybe_unused]] jclass clazz,
jint slot) {}
void Java_org_citra_citra_1emu_NativeLibrary_LoadStateAs(JNIEnv* env, [[maybe_unused]] jclass clazz,
jstring path) {}
void Java_org_citra_citra_1emu_utils_DirectoryInitialization_CreateUserDirectories(
JNIEnv* env, [[maybe_unused]] jclass clazz) {}
jstring Java_org_citra_citra_1emu_NativeLibrary_GetUserDirectory(JNIEnv* env,
[[maybe_unused]] jclass clazz) {
return nullptr;
}
void Java_org_citra_citra_1emu_NativeLibrary_CreateConfigFile(JNIEnv* env,
[[maybe_unused]] jclass clazz) {
Config{};
@ -391,13 +335,6 @@ jint Java_org_citra_citra_1emu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
return 0;
}
void Java_org_citra_citra_1emu_NativeLibrary_SetProfiling(JNIEnv* env,
[[maybe_unused]] jclass clazz,
jboolean enable) {}
void Java_org_citra_citra_1emu_NativeLibrary_WriteProfileResults(JNIEnv* env,
[[maybe_unused]] jclass clazz) {}
void Java_org_citra_citra_1emu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z(
JNIEnv* env, [[maybe_unused]] jclass clazz, jstring j_file, jstring j_savestate,
jboolean j_delete_savestate) {}

View File

@ -41,9 +41,9 @@ JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_onTouchMoved(JNIE
jclass clazz, jfloat x,
jfloat y);
JNIEXPORT jintArray JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetBanner(JNIEnv* env,
jclass clazz,
jstring j_file);
JNIEXPORT jintArray JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetIcon(JNIEnv* env,
jclass clazz,
jstring j_file);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetTitle(JNIEnv* env,
jclass clazz,
@ -57,57 +57,13 @@ JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetGameId(JNIE
jclass clazz,
jstring j_filename);
JNIEXPORT jint JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetCountry(JNIEnv* env, jclass clazz,
jstring j_filename);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetCompany(JNIEnv* env,
jclass clazz,
jstring j_filename);
JNIEXPORT jlong JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetFilesize(JNIEnv* env,
jclass clazz,
jstring j_filename);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetVersionString(JNIEnv* env,
jclass clazz);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetGitRevision(JNIEnv* env,
jclass clazz);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SaveScreenShot(JNIEnv* env,
jclass clazz);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_eglBindAPI(JNIEnv* env, jclass clazz,
jint api);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetConfig(
JNIEnv* env, jclass clazz, jstring j_file, jstring j_section, jstring j_key, jstring j_default);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SetConfig(
JNIEnv* env, jclass clazz, jstring j_file, jstring j_section, jstring j_key, jstring j_value);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SetFilename(JNIEnv* env, jclass clazz,
jstring j_file);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SaveState(JNIEnv* env, jclass clazz,
jint slot, jboolean wait);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SaveStateAs(JNIEnv* env,
jclass clazz,
jstring path,
jboolean wait);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_LoadState(JNIEnv* env, jclass clazz,
jint slot);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_LoadStateAs(JNIEnv* env,
jclass clazz,
jstring path);
JNIEXPORT void JNICALL
Java_org_citra_citra_1emu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv* env,
jclass clazz);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SetUserDirectory(JNIEnv* env,
jclass clazz,
jstring j_directory);
@ -115,9 +71,6 @@ JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SetUserDirectory(
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_utils_DirectoryInitialization_SetSysDirectory(
JNIEnv* env, jclass clazz, jstring path_);
JNIEXPORT jstring JNICALL Java_org_citra_citra_1emu_NativeLibrary_GetUserDirectory(JNIEnv* env,
jclass clazz);
JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_SetSysDirectory(JNIEnv* env,
jclass clazz,
jstring path);

View File

Before

Width:  |  Height:  |  Size: 929 B

After

Width:  |  Height:  |  Size: 929 B

View File

@ -9,9 +9,9 @@
android:layout_height="match_parent" />
<ImageView
android:id="@+id/image_screenshot"
android:id="@+id/image_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionName="image_game_screenshot" />
android:transitionName="image_game_icon" />
</FrameLayout>