Android: Provide game list file title to Java-side

This commit is contained in:
Connor McLaughlin 2020-11-07 23:25:42 +10:00
parent d23b9b508d
commit c1de8c32c1
2 changed files with 13 additions and 6 deletions

View File

@ -806,9 +806,10 @@ DEFINE_JNI_ARGS_METHOD(jarray, AndroidHostInterface_getGameListEntries, jobject
jclass entry_class = env->FindClass("com/github/stenzek/duckstation/GameListEntry"); jclass entry_class = env->FindClass("com/github/stenzek/duckstation/GameListEntry");
Assert(entry_class != nullptr); Assert(entry_class != nullptr);
jmethodID entry_constructor = env->GetMethodID(entry_class, "<init>", jmethodID entry_constructor =
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JLjava/lang/" env->GetMethodID(entry_class, "<init>",
"String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JLjava/lang/"
"String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
Assert(entry_constructor != nullptr); Assert(entry_constructor != nullptr);
AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj);
@ -820,10 +821,12 @@ DEFINE_JNI_ARGS_METHOD(jarray, AndroidHostInterface_getGameListEntries, jobject
{ {
const Timestamp modified_ts( const Timestamp modified_ts(
Timestamp::FromUnixTimestamp(static_cast<Timestamp::UnixTimestampValue>(entry.last_modified_time))); Timestamp::FromUnixTimestamp(static_cast<Timestamp::UnixTimestampValue>(entry.last_modified_time)));
const std::string file_title_str(System::GetTitleForPath(entry.path.c_str()));
jstring path = env->NewStringUTF(entry.path.c_str()); jstring path = env->NewStringUTF(entry.path.c_str());
jstring code = env->NewStringUTF(entry.code.c_str()); jstring code = env->NewStringUTF(entry.code.c_str());
jstring title = env->NewStringUTF(entry.title.c_str()); jstring title = env->NewStringUTF(entry.title.c_str());
jstring file_title = env->NewStringUTF(file_title_str.c_str());
jstring region = env->NewStringUTF(DiscRegionToString(entry.region)); jstring region = env->NewStringUTF(DiscRegionToString(entry.region));
jstring type = env->NewStringUTF(GameList::EntryTypeToString(entry.type)); jstring type = env->NewStringUTF(GameList::EntryTypeToString(entry.type));
jstring compatibility_rating = jstring compatibility_rating =
@ -831,8 +834,8 @@ DEFINE_JNI_ARGS_METHOD(jarray, AndroidHostInterface_getGameListEntries, jobject
jstring modified_time = env->NewStringUTF(modified_ts.ToString("%Y/%m/%d, %H:%M:%S")); jstring modified_time = env->NewStringUTF(modified_ts.ToString("%Y/%m/%d, %H:%M:%S"));
jlong size = entry.total_size; jlong size = entry.total_size;
jobject entry_jobject = env->NewObject(entry_class, entry_constructor, path, code, title, size, modified_time, jobject entry_jobject = env->NewObject(entry_class, entry_constructor, path, code, title, file_title, size,
region, type, compatibility_rating); modified_time, region, type, compatibility_rating);
env->SetObjectArrayElement(entry_array, counter++, entry_jobject); env->SetObjectArrayElement(entry_array, counter++, entry_jobject);
} }

View File

@ -24,6 +24,7 @@ public class GameListEntry {
private String mPath; private String mPath;
private String mCode; private String mCode;
private String mTitle; private String mTitle;
private String mFileTitle;
private long mSize; private long mSize;
private String mModifiedTime; private String mModifiedTime;
private DiscRegion mRegion; private DiscRegion mRegion;
@ -31,11 +32,12 @@ public class GameListEntry {
private CompatibilityRating mCompatibilityRating; private CompatibilityRating mCompatibilityRating;
public GameListEntry(String path, String code, String title, long size, String modifiedTime, String region, public GameListEntry(String path, String code, String title, String fileTitle, long size, String modifiedTime, String region,
String type, String compatibilityRating) { String type, String compatibilityRating) {
mPath = path; mPath = path;
mCode = code; mCode = code;
mTitle = title; mTitle = title;
mFileTitle = fileTitle;
mSize = size; mSize = size;
mModifiedTime = modifiedTime; mModifiedTime = modifiedTime;
@ -70,6 +72,8 @@ public class GameListEntry {
return mTitle; return mTitle;
} }
public String getFileTitle() { return mFileTitle; }
public String getModifiedTime() { public String getModifiedTime() {
return mModifiedTime; return mModifiedTime;
} }