From c1de8c32c137665c2cdf7cd6960c927ed9ed2880 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 7 Nov 2020 23:25:42 +1000 Subject: [PATCH] Android: Provide game list file title to Java-side --- android/app/src/cpp/android_host_interface.cpp | 13 ++++++++----- .../github/stenzek/duckstation/GameListEntry.java | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index b110196c3..7c64b9b84 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -806,9 +806,10 @@ DEFINE_JNI_ARGS_METHOD(jarray, AndroidHostInterface_getGameListEntries, jobject jclass entry_class = env->FindClass("com/github/stenzek/duckstation/GameListEntry"); Assert(entry_class != nullptr); - jmethodID entry_constructor = env->GetMethodID(entry_class, "", - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JLjava/lang/" - "String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + jmethodID entry_constructor = + env->GetMethodID(entry_class, "", + "(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); AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); @@ -820,10 +821,12 @@ DEFINE_JNI_ARGS_METHOD(jarray, AndroidHostInterface_getGameListEntries, jobject { const Timestamp modified_ts( Timestamp::FromUnixTimestamp(static_cast(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 code = env->NewStringUTF(entry.code.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 type = env->NewStringUTF(GameList::EntryTypeToString(entry.type)); 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")); jlong size = entry.total_size; - jobject entry_jobject = env->NewObject(entry_class, entry_constructor, path, code, title, size, modified_time, - region, type, compatibility_rating); + jobject entry_jobject = env->NewObject(entry_class, entry_constructor, path, code, title, file_title, size, + modified_time, region, type, compatibility_rating); env->SetObjectArrayElement(entry_array, counter++, entry_jobject); } diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/GameListEntry.java b/android/app/src/main/java/com/github/stenzek/duckstation/GameListEntry.java index e7d01a300..1a3381963 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/GameListEntry.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/GameListEntry.java @@ -24,6 +24,7 @@ public class GameListEntry { private String mPath; private String mCode; private String mTitle; + private String mFileTitle; private long mSize; private String mModifiedTime; private DiscRegion mRegion; @@ -31,11 +32,12 @@ public class GameListEntry { 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) { mPath = path; mCode = code; mTitle = title; + mFileTitle = fileTitle; mSize = size; mModifiedTime = modifiedTime; @@ -70,6 +72,8 @@ public class GameListEntry { return mTitle; } + public String getFileTitle() { return mFileTitle; } + public String getModifiedTime() { return mModifiedTime; }