From d494e0230c2ebfd580bb66b2a741d19ef830d658 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 21 Jun 2020 20:41:50 +0200 Subject: Show file format details in game properties --- .../org/dolphinemu/dolphinemu/NativeLibrary.java | 2 + .../dolphinemu/dialogs/GameDetailsDialog.java | 48 +++++++++++++ .../org/dolphinemu/dolphinemu/model/GameFile.java | 10 +++ .../src/main/res/layout/dialog_game_details.xml | 82 ++++++++++++++++++++-- Source/Android/app/src/main/res/values/strings.xml | 5 ++ Source/Android/jni/GameList/GameFile.cpp | 41 +++++++++++ Source/Android/jni/MainAndroid.cpp | 8 +++ 7 files changed, 191 insertions(+), 5 deletions(-) (limited to 'Source/Android') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index f37169ddee..3751385be8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -449,6 +449,8 @@ public final class NativeLibrary public static native boolean InstallWAD(String file); + public static native String FormatSize(long bytes, int decimals); + private static boolean alertResult = false; public static boolean displayAlertMsg(final String caption, final String text, diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index 88120e3c42..a0597390e5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; +import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.services.GameFileCacheService; @@ -50,8 +51,17 @@ public final class GameDetailsDialog extends DialogFragment TextView textGameId = contents.findViewById(R.id.text_game_id); TextView textRevision = contents.findViewById(R.id.text_revision); + TextView textFileFormat = contents.findViewById(R.id.text_file_format); + TextView textCompression = contents.findViewById(R.id.text_compression); + TextView textBlockSize = contents.findViewById(R.id.text_block_size); + + TextView labelFileFormat = contents.findViewById(R.id.label_file_format); + TextView labelCompression = contents.findViewById(R.id.label_compression); + TextView labelBlockSize = contents.findViewById(R.id.label_block_size); + String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()]; String description = gameFile.getDescription(); + String fileSize = NativeLibrary.FormatSize(gameFile.getFileSize(), 2); textTitle.setText(gameFile.getTitle()); textDescription.setText(gameFile.getDescription()); @@ -59,11 +69,49 @@ public final class GameDetailsDialog extends DialogFragment { textDescription.setVisibility(View.GONE); } + textCountry.setText(country); textCompany.setText(gameFile.getCompany()); textGameId.setText(gameFile.getGameId()); textRevision.setText(Integer.toString(gameFile.getRevision())); + if (!gameFile.shouldShowFileFormatDetails()) + { + labelFileFormat.setText(R.string.game_details_file_size); + textFileFormat.setText(fileSize); + + labelCompression.setVisibility(View.GONE); + textCompression.setVisibility(View.GONE); + labelBlockSize.setVisibility(View.GONE); + textBlockSize.setVisibility(View.GONE); + } + else + { + long blockSize = gameFile.getBlockSize(); + String compression = gameFile.getCompressionMethod(); + + textFileFormat.setText(String.format("%1$s (%2$s)", gameFile.getBlobTypeString(), fileSize)); + + if (compression.isEmpty()) + { + textCompression.setText(R.string.game_details_no_compression); + } + else + { + textCompression.setText(gameFile.getCompressionMethod()); + } + + if (blockSize > 0) + { + textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0)); + } + else + { + labelBlockSize.setVisibility(View.GONE); + textBlockSize.setVisibility(View.GONE); + } + } + PicassoUtils.loadGameBanner(banner, gameFile); builder.setView(contents); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java index dea006f24e..666103cf05 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java @@ -38,6 +38,16 @@ public class GameFile public native int getRevision(); + public native String getBlobTypeString(); + + public native long getBlockSize(); + + public native String getCompressionMethod(); + + public native boolean shouldShowFileFormatDetails(); + + public native long getFileSize(); + public native int[] getBanner(); public native int getBannerWidth(); diff --git a/Source/Android/app/src/main/res/layout/dialog_game_details.xml b/Source/Android/app/src/main/res/layout/dialog_game_details.xml index fc6b360320..58816600bf 100644 --- a/Source/Android/app/src/main/res/layout/dialog_game_details.xml +++ b/Source/Android/app/src/main/res/layout/dialog_game_details.xml @@ -42,7 +42,7 @@ app:layout_constraintTop_toBottomOf="@id/text_description" /> + app:layout_constraintTop_toBottomOf="@id/divider_1" /> + app:layout_constraintTop_toBottomOf="@id/label_game_id" /> + app:constraint_referenced_ids="label_country,label_company,label_game_id,label_revision,label_file_format,label_compression,label_block_size" /> + + + + + + + + + + + + + + diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 94590230f6..dfc69dfaf1 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -317,6 +317,11 @@ Company Game ID Revision + File Size + File Format + Compression + Block Size + No Compression Take Screenshot diff --git a/Source/Android/jni/GameList/GameFile.cpp b/Source/Android/jni/GameList/GameFile.cpp index efad21681f..f1af2584c3 100644 --- a/Source/Android/jni/GameList/GameFile.cpp +++ b/Source/Android/jni/GameList/GameFile.cpp @@ -10,6 +10,7 @@ #include +#include "DiscIO/Blob.h" #include "DiscIO/Enums.h" #include "UICommon/GameFile.h" #include "jni/AndroidCommon/AndroidCommon.h" @@ -62,6 +63,16 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getDiscNumb jobject obj); JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getRevision(JNIEnv* env, jobject obj); +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_getBlobTypeString(JNIEnv* env, jobject obj); +JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBlockSize(JNIEnv* env, + jobject obj); +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_getCompressionMethod(JNIEnv* env, jobject obj); +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_shouldShowFileFormatDetails(JNIEnv* env, jobject obj); +JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env, + jobject obj); JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBanner(JNIEnv* env, jobject obj); JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBannerWidth(JNIEnv* env, @@ -143,6 +154,36 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getRevision return GetRef(env, obj)->GetRevision(); } +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_getBlobTypeString(JNIEnv* env, jobject obj) +{ + return ToJString(env, DiscIO::GetName(GetRef(env, obj)->GetBlobType(), true)); +} + +JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBlockSize(JNIEnv* env, + jobject obj) +{ + return GetRef(env, obj)->GetBlockSize(); +} + +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_getCompressionMethod(JNIEnv* env, jobject obj) +{ + return ToJString(env, GetRef(env, obj)->GetCompressionMethod()); +} + +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_shouldShowFileFormatDetails(JNIEnv* env, jobject obj) +{ + return GetRef(env, obj)->ShouldShowFileFormatDetails(); +} + +JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env, + jobject obj) +{ + return GetRef(env, obj)->GetFileSize(); +} + JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBanner(JNIEnv* env, jobject obj) { diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index adcba61345..469d719869 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -742,6 +742,14 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallW return static_cast(WiiUtils::InstallWAD(path)); } +JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_FormatSize(JNIEnv* env, + jobject obj, + jlong bytes, + jint decimals) +{ + return ToJString(env, UICommon::FormatSize(bytes, decimals)); +} + #ifdef __cplusplus } #endif -- cgit v1.2.3