From 4fd42d994eedfde55901ba6dc410742ca13a2e81 Mon Sep 17 00:00:00 2001
From: JosJuice <josjuice@gmail.com>
Date: Wed, 1 Apr 2020 15:21:37 +0200
Subject: [PATCH] Android TV: Fix crash when long pressing a game

Also fixes the same crash when accessing the game details
(which only can be accessed after long pressing a game).
The problem was that we were not using a theme that had
an AppCompat theme as a parent.

Unfortunately, the game details dialog uses white on white on
Android TV, and I don't know how to fix this in a clean way.
---
 .../org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java   | 2 +-
 .../org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java   | 3 ++-
 .../dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java    | 3 ++-
 Source/Android/app/src/main/res/values/styles.xml              | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

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 d2d720db53..dd560b52d2 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
@@ -82,7 +82,7 @@ public final class GameRowPresenter extends Presenter
 
       if (gameId.isEmpty())
       {
-        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+        AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.DolphinDialogBase);
         builder.setTitle("Game Settings");
         builder.setMessage("Files without game IDs don't support game-specific settings.");
 
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 a0332d2bd4..88120e3c42 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
@@ -35,7 +35,8 @@ public final class GameDetailsDialog extends DialogFragment
   {
     GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH));
 
-    AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
+    AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(),
+            R.style.DolphinDialogBase);
     ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater()
             .inflate(R.layout.dialog_game_details, null);
 
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java
index aa6fc806d9..09ae7a0075 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java
@@ -45,7 +45,8 @@ public class GamePropertiesDialog extends DialogFragment
   @Override
   public Dialog onCreateDialog(Bundle savedInstanceState)
   {
-    AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
+    AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(),
+            R.style.DolphinDialogBase);
 
     String path = requireArguments().getString(ARG_PATH);
     String gameId = requireArguments().getString(ARG_GAMEID);
diff --git a/Source/Android/app/src/main/res/values/styles.xml b/Source/Android/app/src/main/res/values/styles.xml
index 086b4c6082..8a292d4113 100644
--- a/Source/Android/app/src/main/res/values/styles.xml
+++ b/Source/Android/app/src/main/res/values/styles.xml
@@ -27,7 +27,7 @@
 
     <!-- Themes for Dialogs -->
 
-    <!-- Inherit from the Base Dolphin Dialog Theme -->
+    <style name="DolphinDialogBase" parent="Theme.AppCompat.DayNight.Dialog.Alert" />
 
     <style name="DolphinEmulationBase" parent="Theme.AppCompat.DayNight.DarkActionBar">
         <item name="colorPrimary">@color/dolphin_blue</item>