diff options
| author | JosJuice <josjuice@gmail.com> | 2022-11-23 22:06:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 22:06:49 +0100 |
| commit | ddf63bacb9fec7bdc9cc2df3601cddce2bc8f7af (patch) | |
| tree | 174147a669d9ee00ef9349ba0c2ef48b637b3a6e /Source/Android/app/src/main | |
| parent | 0ef6d30a0dde197ccb2736dd46191e7f867f3502 (diff) | |
| parent | 6e5f546d4e3b96cfbc3365af28a05ef0219d7456 (diff) | |
Merge pull request #11296 from t895/tv-game-details-fix
Android: Fix GameDetailsDialog on leanback
Diffstat (limited to 'Source/Android/app/src/main')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java | 146 | ||||
| -rw-r--r-- | Source/Android/app/src/main/res/layout/dialog_game_details_tv.xml | 240 |
2 files changed, 347 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(); } } diff --git a/Source/Android/app/src/main/res/layout/dialog_game_details_tv.xml b/Source/Android/app/src/main/res/layout/dialog_game_details_tv.xml new file mode 100644 index 0000000000..bc919c75e8 --- /dev/null +++ b/Source/Android/app/src/main/res/layout/dialog_game_details_tv.xml @@ -0,0 +1,240 @@ +<?xml version="1.0" encoding="utf-8"?> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:transitionName="card_game"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="24dp" + android:paddingEnd="24dp" + android:paddingBottom="24dp"> + + <TextView + android:id="@+id/text_game_title" + style="@android:style/TextAppearance.Material.Headline" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:ellipsize="end" + android:textColor="@android:color/black" + tools:text="Rhythm Heaven Fever" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/text_description" + style="@android:style/TextAppearance.Material.Caption" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:textColor="@android:color/black" + tools:text="Zany rhythm action!" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/text_game_title" /> + + <ImageView + android:id="@+id/banner" + android:layout_width="144dp" + android:layout_height="48dp" + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:textColor="@android:color/black" + tools:src="@drawable/no_banner" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/text_description" /> + + <View + android:id="@+id/divider_1" + android:layout_width="0dp" + android:layout_height="1dp" + android:layout_marginTop="32dp" + android:background="#1F000000" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/banner" /> + + <TextView + android:id="@+id/label_country" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_country" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/divider_1" /> + + <TextView + android:id="@+id/label_company" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_company" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_country" /> + + <TextView + android:id="@+id/label_game_id" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_game_id" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_company" /> + + <TextView + android:id="@+id/label_revision" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_revision" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_game_id" /> + + <androidx.constraintlayout.widget.Barrier + android:id="@+id/label_barrier" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + app:barrierDirection="end" + app:constraint_referenced_ids="label_country,label_company,label_game_id,label_revision,label_file_format,label_compression,label_block_size" /> + + <TextView + android:id="@+id/text_country" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="United States" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_country" /> + + <TextView + android:id="@+id/text_company" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="Nintendo" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_company" /> + + <TextView + android:id="@+id/text_game_id" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="SOME01" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_game_id" /> + + <TextView + android:id="@+id/text_revision" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="0" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_revision" /> + + <View + android:id="@+id/divider_2" + android:layout_width="0dp" + android:layout_height="1dp" + android:layout_marginTop="32dp" + android:background="#1F000000" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_revision" /> + + <TextView + android:id="@+id/label_file_format" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_file_format" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/divider_2" /> + + <TextView + android:id="@+id/label_compression" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_compression" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_file_format" /> + + <TextView + android:id="@+id/label_block_size" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="start" + android:text="@string/game_details_block_size" + android:textColor="@android:color/black" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/label_compression" /> + + <TextView + android:id="@+id/text_file_format" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="ISO (4.38 GiB)" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_file_format" /> + + <TextView + android:id="@+id/text_compression" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="No Compression" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_compression" /> + + <TextView + android:id="@+id/text_block_size" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:gravity="end" + android:textColor="@android:color/black" + tools:text="0 B" + app:layout_constraintStart_toEndOf="@id/label_barrier" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBaseline_toBaselineOf="@id/label_block_size" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + +</ScrollView> |
