Merge pull request #11005 from t895/cover-only

Android: Add option to disable game cover text
This commit is contained in:
JosJuice 2022-08-23 18:24:51 +02:00 committed by GitHub
commit 299aef945b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 106 additions and 16 deletions

View File

@ -72,9 +72,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
{ {
Context context = holder.itemView.getContext(); Context context = holder.itemView.getContext();
GameFile gameFile = mGameFiles.get(position); GameFile gameFile = mGameFiles.get(position);
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); PicassoUtils.loadGameCover(holder, holder.imageScreenshot, gameFile);
holder.textGameTitle.setText(gameFile.getTitle());
if (GameFileCacheManager.findSecondDisc(gameFile) != null) if (GameFileCacheManager.findSecondDisc(gameFile) != null)
{ {

View File

@ -50,15 +50,14 @@ public final class GameRowPresenter extends Presenter
GameFile gameFile = (GameFile) item; GameFile gameFile = (GameFile) item;
holder.imageScreenshot.setImageDrawable(null); holder.imageScreenshot.setImageDrawable(null);
PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); PicassoUtils.loadGameCover(null, holder.imageScreenshot, gameFile);
holder.cardParent.setTitleText(gameFile.getTitle()); holder.cardParent.setTitleText(gameFile.getTitle());
if (GameFileCacheManager.findSecondDisc(gameFile) != null) if (GameFileCacheManager.findSecondDisc(gameFile) != null)
{ {
holder.cardParent holder.cardParent.setContentText(
.setContentText( context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1));
context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1));
} }
else else
{ {

View File

@ -79,6 +79,8 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_DEBUG_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, MAIN_DEBUG_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG,
"JitRegisterCacheOff", false), "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, MAIN_JOYSTICK_REL_CENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
"JoystickRelCenter", true), "JoystickRelCenter", true),
MAIN_PHONE_RUMBLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, MAIN_PHONE_RUMBLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,

View File

@ -321,6 +321,8 @@ public final class SettingsFragmentPresenter
R.string.osd_messages_description)); R.string.osd_messages_description));
sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_USE_GAME_COVERS, sl.add(new CheckBoxSetting(mContext, BooleanSetting.MAIN_USE_GAME_COVERS,
R.string.download_game_covers, 0)); 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<SettingsItem> sl) private void addAudioSettings(ArrayList<SettingsItem> sl)

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.net.Uri; import android.net.Uri;
import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import com.squareup.picasso.Callback; import com.squareup.picasso.Callback;
@ -14,6 +15,7 @@ import com.squareup.picasso.Picasso;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
import java.io.File; import java.io.File;
@ -35,8 +37,23 @@ public class PicassoUtils
.into(imageView); .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(); Context context = imageView.getContext();
File cover = new File(gameFile.getCustomCoverPath()); File cover = new File(gameFile.getCustomCoverPath());
if (cover.exists()) if (cover.exists())
@ -49,7 +66,18 @@ public class PicassoUtils
.centerInside() .centerInside()
.config(Bitmap.Config.ARGB_8888) .config(Bitmap.Config.ARGB_8888)
.error(R.drawable.no_banner) .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()) else if ((cover = new File(gameFile.getCoverPath(context))).exists())
{ {
@ -61,7 +89,18 @@ public class PicassoUtils
.centerInside() .centerInside()
.config(Bitmap.Config.ARGB_8888) .config(Bitmap.Config.ARGB_8888)
.error(R.drawable.no_banner) .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 // 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. // 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(), CoverHelper.saveCover(((BitmapDrawable) imageView.getDrawable()).getBitmap(),
gameFile.getCoverPath(context)); gameFile.getCoverPath(context));
PicassoUtils.disableInnerTitle(gameViewHolder);
} }
@Override @Override
@ -104,6 +144,7 @@ public class PicassoUtils
CoverHelper.saveCover( CoverHelper.saveCover(
((BitmapDrawable) imageView.getDrawable()).getBitmap(), ((BitmapDrawable) imageView.getDrawable()).getBitmap(),
gameFile.getCoverPath(context)); gameFile.getCoverPath(context));
PicassoUtils.disableInnerTitle(gameViewHolder);
} }
@Override @Override
@ -127,11 +168,13 @@ public class PicassoUtils
((BitmapDrawable) imageView.getDrawable()) ((BitmapDrawable) imageView.getDrawable())
.getBitmap(), .getBitmap(),
gameFile.getCoverPath(context)); gameFile.getCoverPath(context));
PicassoUtils.disableInnerTitle(gameViewHolder);
} }
@Override @Override
public void onError(Exception ex) public void onError(Exception ex)
{ {
PicassoUtils.enableInnerTitle(gameViewHolder, gameFile);
} }
}); });
} }
@ -148,7 +191,34 @@ public class PicassoUtils
.fit() .fit()
.centerInside() .centerInside()
.config(Bitmap.Config.ARGB_8888) .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);
} }
} }
} }

View File

@ -19,6 +19,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder
{ {
public ImageView imageScreenshot; public ImageView imageScreenshot;
public TextView textGameTitle; public TextView textGameTitle;
public TextView textGameTitleInner;
public TextView textGameCaption; public TextView textGameCaption;
public GameFile gameFile; public GameFile gameFile;
@ -31,6 +32,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder
imageScreenshot = itemView.findViewById(R.id.image_game_screen); imageScreenshot = itemView.findViewById(R.id.image_game_screen);
textGameTitle = itemView.findViewById(R.id.text_game_title); 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); textGameCaption = itemView.findViewById(R.id.text_game_caption);
} }
} }

View File

@ -19,6 +19,7 @@
android:layout_width="115dp" android:layout_width="115dp"
android:layout_height="161dp" android:layout_height="161dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginBottom="8dp"
app:cardCornerRadius="4dp"> app:cardCornerRadius="4dp">
<ImageView <ImageView
@ -26,6 +27,21 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"/> android:layout_weight="1"/>
<TextView
android:id="@+id/text_game_title_inner"
style="@android:style/TextAppearance.Material.Subhead"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:ellipsize="end"
android:gravity="center|top"
android:maxLines="2"
android:visibility="visible"
tools:text="The Legend of Zelda: The Wind Waker" />
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
@ -34,7 +50,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start" android:layout_gravity="start"
android:layout_marginTop="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
tools:layout_width="140dp" tools:layout_width="140dp"

View File

@ -193,6 +193,8 @@
<string name="osd_messages">Show On-Screen Display Messages</string> <string name="osd_messages">Show On-Screen Display Messages</string>
<string name="osd_messages_description">Display messages over the emulation screen area. These messages include memory card writes, video backend and CPU information, and JIT cache clearing.</string> <string name="osd_messages_description">Display messages over the emulation screen area. These messages include memory card writes, video backend and CPU information, and JIT cache clearing.</string>
<string name="download_game_covers">Download Game Covers from GameTDB.com</string> <string name="download_game_covers">Download Game Covers from GameTDB.com</string>
<string name="show_titles_in_game_list">Show Titles in Game List</string>
<string name="show_titles_in_game_list_description">Show the title and creator below each game cover.</string>
<!-- Online Update Region Select Fragment --> <!-- Online Update Region Select Fragment -->
<string name="region_select_title">Please select a region</string> <string name="region_select_title">Please select a region</string>

View File

@ -39,10 +39,10 @@ bool IsSettingSaveable(const Config::Location& config_location)
// TODO: Kill the current Android controller mappings system // TODO: Kill the current Android controller mappings system
if (config_location.section == "Android") if (config_location.section == "Android")
{ {
static constexpr std::array<const char*, 10> android_setting_saveable = { static constexpr std::array<const char*, 11> android_setting_saveable = {
"ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter", "ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter",
"LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay", "LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay",
"IRMode", "IRAlwaysRecenter"}; "IRMode", "IRAlwaysRecenter", "ShowGameTitles"};
return std::any_of( return std::any_of(
android_setting_saveable.cbegin(), android_setting_saveable.cend(), android_setting_saveable.cbegin(), android_setting_saveable.cend(),