From 4701d2480d55d5747821a71d00097e9300099128 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 7 Nov 2020 23:31:15 +1000 Subject: [PATCH] Android: Display game code in list --- .../stenzek/duckstation/GameListEntry.java | 18 ++++++++++++++---- .../main/res/layout/game_list_view_entry.xml | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) 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 1a3381963..2936fa3bd 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 @@ -90,12 +90,22 @@ public class GameListEntry { return mCompatibilityRating; } + private String getSubTitle() { + String sizeString = String.format("%.2f MB", (double) mSize / 1048576.0); + String fileName; + int lastSlash = mPath.lastIndexOf('/'); + if (lastSlash > 0 && lastSlash < mPath.length() - 1) + fileName = mPath.substring(lastSlash + 1); + else + fileName = mPath; + + return String.format("%s (%s)", fileName, sizeString); + } + public void fillView(View view) { ((TextView) view.findViewById(R.id.game_list_view_entry_title)).setText(mTitle); - ((TextView) view.findViewById(R.id.game_list_view_entry_path)).setText(mPath); - - String sizeString = String.format("%.2f MB", (double) mSize / 1048576.0); - ((TextView) view.findViewById(R.id.game_list_view_entry_size)).setText(sizeString); + ((TextView) view.findViewById(R.id.game_list_view_entry_subtitle)).setText(getSubTitle()); + ((TextView) view.findViewById(R.id.game_list_view_entry_code)).setText(mCode); int regionDrawableId; switch (mRegion) { diff --git a/android/app/src/main/res/layout/game_list_view_entry.xml b/android/app/src/main/res/layout/game_list_view_entry.xml index 4ae1a3223..0fd6a73db 100644 --- a/android/app/src/main/res/layout/game_list_view_entry.xml +++ b/android/app/src/main/res/layout/game_list_view_entry.xml @@ -32,7 +32,7 @@ app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file