From 2caa1f3b437ecd5ba7e9124cb2e6cf67a570f84c Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 22 Aug 2022 08:19:43 -0400 Subject: [PATCH] Android: Add option to disable game cover text --- .../dolphinemu/adapters/GameAdapter.java | 4 +- .../dolphinemu/adapters/GameRowPresenter.java | 7 +- .../settings/model/BooleanSetting.java | 2 + .../ui/SettingsFragmentPresenter.java | 2 + .../dolphinemu/utils/PicassoUtils.java | 78 ++++++++++++++++++- .../viewholders/GameViewHolder.java | 2 + .../app/src/main/res/layout/card_game.xml | 17 +++- .../app/src/main/res/values/strings.xml | 2 + .../Core/ConfigLoaders/IsSettingSaveable.cpp | 8 +- 9 files changed, 106 insertions(+), 16 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index d481640c9b..e35645ee60 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -72,9 +72,7 @@ public final class GameAdapter extends RecyclerView.Adapter impl { Context context = holder.itemView.getContext(); GameFile gameFile = mGameFiles.get(position); - PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); - - holder.textGameTitle.setText(gameFile.getTitle()); + PicassoUtils.loadGameCover(holder, holder.imageScreenshot, gameFile); if (GameFileCacheManager.findSecondDisc(gameFile) != null) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java index b961104e14..6261ea6827 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java @@ -50,15 +50,14 @@ public final class GameRowPresenter extends Presenter GameFile gameFile = (GameFile) item; holder.imageScreenshot.setImageDrawable(null); - PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); + PicassoUtils.loadGameCover(null, holder.imageScreenshot, gameFile); holder.cardParent.setTitleText(gameFile.getTitle()); if (GameFileCacheManager.findSecondDisc(gameFile) != null) { - holder.cardParent - .setContentText( - context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1)); + holder.cardParent.setContentText( + context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1)); } else { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java index d09aaa75b1..0c02f1b9a0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java @@ -79,6 +79,8 @@ public enum BooleanSetting implements AbstractBooleanSetting MAIN_DEBUG_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitRegisterCacheOff", false), + MAIN_SHOW_GAME_TITLES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, + "ShowGameTitles", true), MAIN_JOYSTICK_REL_CENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "JoystickRelCenter", true), MAIN_PHONE_RUMBLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index 137d2e3dc5..38976684d6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -321,6 +321,8 @@ public final class SettingsFragmentPresenter R.string.osd_messages_description)); sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_USE_GAME_COVERS, R.string.download_game_covers, 0)); + sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_SHOW_GAME_TITLES, + R.string.show_titles_in_game_list, R.string.show_titles_in_game_list_description)); } private void addAudioSettings(ArrayList sl) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java index 876f022480..69aabffa7f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java @@ -6,6 +6,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; +import android.view.View; import android.widget.ImageView; import com.squareup.picasso.Callback; @@ -14,6 +15,7 @@ import com.squareup.picasso.Picasso; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.model.GameFile; +import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; import java.io.File; @@ -35,8 +37,23 @@ public class PicassoUtils .into(imageView); } - public static void loadGameCover(ImageView imageView, GameFile gameFile) + public static void loadGameCover(GameViewHolder gameViewHolder, ImageView imageView, + GameFile gameFile) { + if (BooleanSetting.MAIN_SHOW_GAME_TITLES.getBooleanGlobal() && gameViewHolder != null) + { + gameViewHolder.textGameTitle.setText(gameFile.getTitle()); + gameViewHolder.textGameTitle.setVisibility(View.VISIBLE); + gameViewHolder.textGameTitleInner.setVisibility(View.GONE); + gameViewHolder.textGameCaption.setVisibility(View.VISIBLE); + } + else if (gameViewHolder != null) + { + gameViewHolder.textGameTitleInner.setText(gameFile.getTitle()); + gameViewHolder.textGameTitle.setVisibility(View.GONE); + gameViewHolder.textGameCaption.setVisibility(View.GONE); + } + Context context = imageView.getContext(); File cover = new File(gameFile.getCustomCoverPath()); if (cover.exists()) @@ -49,7 +66,18 @@ public class PicassoUtils .centerInside() .config(Bitmap.Config.ARGB_8888) .error(R.drawable.no_banner) - .into(imageView); + .into(imageView, new Callback() + { + @Override public void onSuccess() + { + PicassoUtils.disableInnerTitle(gameViewHolder); + } + + @Override public void onError(Exception e) + { + PicassoUtils.enableInnerTitle(gameViewHolder, gameFile); + } + }); } else if ((cover = new File(gameFile.getCoverPath(context))).exists()) { @@ -61,7 +89,18 @@ public class PicassoUtils .centerInside() .config(Bitmap.Config.ARGB_8888) .error(R.drawable.no_banner) - .into(imageView); + .into(imageView, new Callback() + { + @Override public void onSuccess() + { + PicassoUtils.disableInnerTitle(gameViewHolder); + } + + @Override public void onError(Exception e) + { + PicassoUtils.enableInnerTitle(gameViewHolder, gameFile); + } + }); } // GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting // the cover will be by the disk's region, second will be the US cover, and third EN. @@ -82,6 +121,7 @@ public class PicassoUtils { CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(), gameFile.getCoverPath(context)); + PicassoUtils.disableInnerTitle(gameViewHolder); } @Override @@ -104,6 +144,7 @@ public class PicassoUtils CoverHelper.saveCover( ((BitmapDrawable) imageView.getDrawable()).getBitmap(), gameFile.getCoverPath(context)); + PicassoUtils.disableInnerTitle(gameViewHolder); } @Override @@ -127,11 +168,13 @@ public class PicassoUtils ((BitmapDrawable) imageView.getDrawable()) .getBitmap(), gameFile.getCoverPath(context)); + PicassoUtils.disableInnerTitle(gameViewHolder); } @Override public void onError(Exception ex) { + PicassoUtils.enableInnerTitle(gameViewHolder, gameFile); } }); } @@ -148,7 +191,34 @@ public class PicassoUtils .fit() .centerInside() .config(Bitmap.Config.ARGB_8888) - .into(imageView); + .into(imageView, new Callback() + { + @Override public void onSuccess() + { + PicassoUtils.disableInnerTitle(gameViewHolder); + } + + @Override public void onError(Exception e) + { + PicassoUtils.enableInnerTitle(gameViewHolder, gameFile); + } + }); + } + } + + private static void enableInnerTitle(GameViewHolder gameViewHolder, GameFile gameFile) + { + if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.getBooleanGlobal()) + { + gameViewHolder.textGameTitleInner.setVisibility(View.VISIBLE); + } + } + + private static void disableInnerTitle(GameViewHolder gameViewHolder) + { + if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.getBooleanGlobal()) + { + gameViewHolder.textGameTitleInner.setVisibility(View.GONE); } } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java index cdcf4a03c0..b829847488 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java @@ -19,6 +19,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder { public ImageView imageScreenshot; public TextView textGameTitle; + public TextView textGameTitleInner; public TextView textGameCaption; public GameFile gameFile; @@ -31,6 +32,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder imageScreenshot = itemView.findViewById(R.id.image_game_screen); textGameTitle = itemView.findViewById(R.id.text_game_title); + textGameTitleInner = itemView.findViewById(R.id.text_game_title_inner); textGameCaption = itemView.findViewById(R.id.text_game_caption); } } diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index 7bead263f4..2e7eb280d3 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -19,6 +19,7 @@ android:layout_width="115dp" android:layout_height="161dp" android:layout_gravity="center" + android:layout_marginBottom="8dp" app:cardCornerRadius="4dp"> + + + Show On-Screen Display Messages Display messages over the emulation screen area. These messages include memory card writes, video backend and CPU information, and JIT cache clearing. Download Game Covers from GameTDB.com + Show Titles in Game List + Show the title and creator below each game cover. Please select a region diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 3eb8245a29..92411968b4 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -39,10 +39,10 @@ bool IsSettingSaveable(const Config::Location& config_location) // TODO: Kill the current Android controller mappings system if (config_location.section == "Android") { - static constexpr std::array android_setting_saveable = { - "ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter", - "LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay", - "IRMode", "IRAlwaysRecenter"}; + static constexpr std::array android_setting_saveable = { + "ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter", + "LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay", + "IRMode", "IRAlwaysRecenter", "ShowGameTitles"}; return std::any_of( android_setting_saveable.cbegin(), android_setting_saveable.cend(),