summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2022-11-23 22:06:49 +0100
committerGitHub <noreply@github.com>2022-11-23 22:06:49 +0100
commitddf63bacb9fec7bdc9cc2df3601cddce2bc8f7af (patch)
tree174147a669d9ee00ef9349ba0c2ef48b637b3a6e /Source/Android/app/src/main/java
parent0ef6d30a0dde197ccb2736dd46191e7f867f3502 (diff)
parent6e5f546d4e3b96cfbc3365af28a05ef0219d7456 (diff)
Merge pull request #11296 from t895/tv-game-details-fix
Android: Fix GameDetailsDialog on leanback
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java146
1 files changed, 107 insertions, 39 deletions
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 dec25dbf2a..176f5b7610 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
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@@ -14,6 +15,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.databinding.DialogGameDetailsBinding;
+import org.dolphinemu.dolphinemu.databinding.DialogGameDetailsTvBinding;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.utils.GlideUtils;
@@ -39,66 +41,132 @@ public final class GameDetailsDialog extends DialogFragment
{
GameFile gameFile = GameFileCacheManager.addOrGet(getArguments().getString(ARG_GAME_PATH));
- DialogGameDetailsBinding binding = DialogGameDetailsBinding.inflate(getLayoutInflater());
-
String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()];
String description = gameFile.getDescription();
String fileSize = NativeLibrary.FormatSize(gameFile.getFileSize(), 2);
- binding.textGameTitle.setText(gameFile.getTitle());
- binding.textDescription.setText(gameFile.getDescription());
- if (description.isEmpty())
+ // TODO: Remove dialog_game_details_tv if we switch to an AppCompatActivity for leanback
+ DialogGameDetailsBinding binding;
+ DialogGameDetailsTvBinding tvBinding;
+ MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
+ if (requireActivity() instanceof AppCompatActivity)
{
- binding.textDescription.setVisibility(View.GONE);
- }
+ binding = DialogGameDetailsBinding.inflate(getLayoutInflater());
- binding.textCountry.setText(country);
- binding.textCompany.setText(gameFile.getCompany());
- binding.textGameId.setText(gameFile.getGameId());
- binding.textRevision.setText(String.valueOf(gameFile.getRevision()));
+ binding.textGameTitle.setText(gameFile.getTitle());
+ binding.textDescription.setText(gameFile.getDescription());
+ if (description.isEmpty())
+ {
+ binding.textDescription.setVisibility(View.GONE);
+ }
- if (!gameFile.shouldShowFileFormatDetails())
- {
- binding.labelFileFormat.setText(R.string.game_details_file_size);
- binding.textFileFormat.setText(fileSize);
+ binding.textCountry.setText(country);
+ binding.textCompany.setText(gameFile.getCompany());
+ binding.textGameId.setText(gameFile.getGameId());
+ binding.textRevision.setText(String.valueOf(gameFile.getRevision()));
+
+ if (!gameFile.shouldShowFileFormatDetails())
+ {
+ binding.labelFileFormat.setText(R.string.game_details_file_size);
+ binding.textFileFormat.setText(fileSize);
- binding.labelCompression.setVisibility(View.GONE);
- binding.textCompression.setVisibility(View.GONE);
- binding.labelBlockSize.setVisibility(View.GONE);
- binding.textBlockSize.setVisibility(View.GONE);
+ binding.labelCompression.setVisibility(View.GONE);
+ binding.textCompression.setVisibility(View.GONE);
+ binding.labelBlockSize.setVisibility(View.GONE);
+ binding.textBlockSize.setVisibility(View.GONE);
+ }
+ else
+ {
+ long blockSize = gameFile.getBlockSize();
+ String compression = gameFile.getCompressionMethod();
+
+ binding.textFileFormat.setText(
+ getResources().getString(R.string.game_details_size_and_format,
+ gameFile.getFileFormatName(), fileSize));
+
+ if (compression.isEmpty())
+ {
+ binding.textCompression.setText(R.string.game_details_no_compression);
+ }
+ else
+ {
+ binding.textCompression.setText(gameFile.getCompressionMethod());
+ }
+
+ if (blockSize > 0)
+ {
+ binding.textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0));
+ }
+ else
+ {
+ binding.labelBlockSize.setVisibility(View.GONE);
+ binding.textBlockSize.setVisibility(View.GONE);
+ }
+ }
+
+ GlideUtils.loadGameBanner(binding.banner, gameFile);
+
+ builder.setView(binding.getRoot());
}
else
{
- long blockSize = gameFile.getBlockSize();
- String compression = gameFile.getCompressionMethod();
-
- binding.textFileFormat.setText(getResources().getString(R.string.game_details_size_and_format,
- gameFile.getFileFormatName(), fileSize));
+ tvBinding = DialogGameDetailsTvBinding.inflate(getLayoutInflater());
- if (compression.isEmpty())
- {
- binding.textCompression.setText(R.string.game_details_no_compression);
- }
- else
+ tvBinding.textGameTitle.setText(gameFile.getTitle());
+ tvBinding.textDescription.setText(gameFile.getDescription());
+ if (description.isEmpty())
{
- binding.textCompression.setText(gameFile.getCompressionMethod());
+ tvBinding.textDescription.setVisibility(View.GONE);
}
- if (blockSize > 0)
+ tvBinding.textCountry.setText(country);
+ tvBinding.textCompany.setText(gameFile.getCompany());
+ tvBinding.textGameId.setText(gameFile.getGameId());
+ tvBinding.textRevision.setText(String.valueOf(gameFile.getRevision()));
+
+ if (!gameFile.shouldShowFileFormatDetails())
{
- binding.textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0));
+ tvBinding.labelFileFormat.setText(R.string.game_details_file_size);
+ tvBinding.textFileFormat.setText(fileSize);
+
+ tvBinding.labelCompression.setVisibility(View.GONE);
+ tvBinding.textCompression.setVisibility(View.GONE);
+ tvBinding.labelBlockSize.setVisibility(View.GONE);
+ tvBinding.textBlockSize.setVisibility(View.GONE);
}
else
{
- binding.labelBlockSize.setVisibility(View.GONE);
- binding.textBlockSize.setVisibility(View.GONE);
+ long blockSize = gameFile.getBlockSize();
+ String compression = gameFile.getCompressionMethod();
+
+ tvBinding.textFileFormat.setText(
+ getResources().getString(R.string.game_details_size_and_format,
+ gameFile.getFileFormatName(), fileSize));
+
+ if (compression.isEmpty())
+ {
+ tvBinding.textCompression.setText(R.string.game_details_no_compression);
+ }
+ else
+ {
+ tvBinding.textCompression.setText(gameFile.getCompressionMethod());
+ }
+
+ if (blockSize > 0)
+ {
+ tvBinding.textBlockSize.setText(NativeLibrary.FormatSize(blockSize, 0));
+ }
+ else
+ {
+ tvBinding.labelBlockSize.setVisibility(View.GONE);
+ tvBinding.textBlockSize.setVisibility(View.GONE);
+ }
}
- }
- GlideUtils.loadGameBanner(binding.banner, gameFile);
+ GlideUtils.loadGameBanner(tvBinding.banner, gameFile);
- return new MaterialAlertDialogBuilder(requireActivity())
- .setView(binding.getRoot())
- .create();
+ builder.setView(tvBinding.getRoot());
+ }
+ return builder.create();
}
}