Merge pull request #8718 from JosJuice/android-tv-long-press

Android TV: Fix crash when long pressing a game
This commit is contained in:
JMC47 2020-04-22 04:25:44 -04:00 committed by GitHub
commit f83addee68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 22 deletions

View File

@ -463,7 +463,8 @@ public final class NativeLibrary
{ {
// Create object used for waiting. // Create object used for waiting.
final Object lock = new Object(); final Object lock = new Object();
AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity) AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity,
R.style.DolphinDialogBase)
.setTitle(caption) .setTitle(caption)
.setMessage(text); .setMessage(text);

View File

@ -738,7 +738,7 @@ public final class EmulationActivity extends AppCompatActivity
{ {
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
boolean[] enabledButtons = new boolean[14]; boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_toggle_controls); builder.setTitle(R.string.emulation_toggle_controls);
if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0) if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
{ {
@ -795,7 +795,7 @@ public final class EmulationActivity extends AppCompatActivity
public void chooseDoubleTapButton() public void chooseDoubleTapButton()
{ {
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
int currentController = int currentController =
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUCK); mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUCK);
@ -857,7 +857,7 @@ public final class EmulationActivity extends AppCompatActivity
value.setText(String.valueOf(seekbar.getProgress() + 50)); value.setText(String.valueOf(seekbar.getProgress() + 50));
units.setText("%"); units.setText("%");
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_control_scale); builder.setTitle(R.string.emulation_control_scale);
builder.setView(view); builder.setView(view);
builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) ->
@ -876,7 +876,7 @@ public final class EmulationActivity extends AppCompatActivity
private void chooseController() private void chooseController()
{ {
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_choose_controller); builder.setTitle(R.string.emulation_choose_controller);
builder.setSingleChoiceItems(R.array.controllersEntries, builder.setSingleChoiceItems(R.array.controllersEntries,
mPreferences.getInt("wiiController", 3), mPreferences.getInt("wiiController", 3),
@ -902,7 +902,7 @@ public final class EmulationActivity extends AppCompatActivity
private void showMotionControlsOptions() private void showMotionControlsOptions()
{ {
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_motion_controls); builder.setTitle(R.string.emulation_motion_controls);
builder.setSingleChoiceItems(R.array.motionControlsEntries, builder.setSingleChoiceItems(R.array.motionControlsEntries,
mPreferences.getInt("motionControlsEnabled", 0), mPreferences.getInt("motionControlsEnabled", 0),
@ -938,7 +938,7 @@ public final class EmulationActivity extends AppCompatActivity
} }
final SharedPreferences.Editor editor = mPreferences.edit(); final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_screen_orientation); builder.setTitle(R.string.emulation_screen_orientation);
builder.setSingleChoiceItems(R.array.orientationEntries, initialIndex, builder.setSingleChoiceItems(R.array.orientationEntries, initialIndex,
(dialog, indexSelected) -> (dialog, indexSelected) ->
@ -1055,7 +1055,7 @@ public final class EmulationActivity extends AppCompatActivity
} }
}); });
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(getString(R.string.emulation_ir_sensitivity)); builder.setTitle(getString(R.string.emulation_ir_sensitivity));
builder.setView(view); builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
@ -1090,7 +1090,7 @@ public final class EmulationActivity extends AppCompatActivity
private void resetOverlay() private void resetOverlay()
{ {
new AlertDialog.Builder(this) new AlertDialog.Builder(this, R.style.DolphinDialogBase)
.setTitle(getString(R.string.emulation_touch_overlay_reset)) .setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> .setPositiveButton(R.string.yes, (dialogInterface, i) ->
{ {

View File

@ -137,7 +137,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
if (gameId.isEmpty()) 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.setTitle("Game Settings");
builder.setMessage("Files without game IDs don't support game-specific settings."); builder.setMessage("Files without game IDs don't support game-specific settings.");

View File

@ -82,7 +82,7 @@ public final class GameRowPresenter extends Presenter
if (gameId.isEmpty()) 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.setTitle("Game Settings");
builder.setMessage("Files without game IDs don't support game-specific settings."); builder.setMessage("Files without game IDs don't support game-specific settings.");

View File

@ -35,7 +35,8 @@ public final class GameDetailsDialog extends DialogFragment
{ {
GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH)); 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() ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater()
.inflate(R.layout.dialog_game_details, null); .inflate(R.layout.dialog_game_details, null);

View File

@ -45,7 +45,8 @@ public class GamePropertiesDialog extends DialogFragment
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) 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 path = requireArguments().getString(ARG_PATH);
String gameId = requireArguments().getString(ARG_GAMEID); String gameId = requireArguments().getString(ARG_GAMEID);

View File

@ -218,7 +218,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
@Override @Override
public void showGameIniJunkDeletionQuestion() public void showGameIniJunkDeletionQuestion()
{ {
new AlertDialog.Builder(this) new AlertDialog.Builder(this, R.style.DolphinDialogBase)
.setTitle(getString(R.string.game_ini_junk_title)) .setTitle(getString(R.string.game_ini_junk_title))
.setMessage(getString(R.string.game_ini_junk_question)) .setMessage(getString(R.string.game_ini_junk_question))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings()) .setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings())

View File

@ -192,7 +192,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
int value = getSelectionForSingleChoiceValue(item); int value = getSelectionForSingleChoiceValue(item);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getNameId());
builder.setSingleChoiceItems(item.getChoicesId(), value, this); builder.setSingleChoiceItems(item.getChoicesId(), value, this);
@ -205,7 +206,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mClickedItem = item; mClickedItem = item;
mClickedPosition = position; mClickedPosition = position;
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getNameId());
builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(), this); builder.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(), this);
@ -221,7 +223,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
int value = getSelectionForSingleChoiceDynamicDescriptionsValue(item); int value = getSelectionForSingleChoiceDynamicDescriptionsValue(item);
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
builder.setTitle(item.getNameId()); builder.setTitle(item.getNameId());
builder.setSingleChoiceItems(item.getChoicesId(), value, this); builder.setSingleChoiceItems(item.getChoicesId(), value, this);
@ -234,7 +237,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mClickedItem = item; mClickedItem = item;
mClickedPosition = position; mClickedPosition = position;
mSeekbarProgress = item.getSelectedValue(); mSeekbarProgress = item.getSelectedValue();
AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(mView.getActivity(),
R.style.DolphinDialogBase);
LayoutInflater inflater = LayoutInflater.from(mView.getActivity()); LayoutInflater inflater = LayoutInflater.from(mView.getActivity());
View view = inflater.inflate(R.layout.dialog_seekbar, null); View view = inflater.inflate(R.layout.dialog_seekbar, null);

View File

@ -58,7 +58,7 @@ public final class ConfirmRunnableViewHolder extends SettingViewHolder
String alertTitle = mContext.getString(mItem.getNameId()); String alertTitle = mContext.getString(mItem.getNameId());
String alertText = mContext.getString(mItem.getAlertText()); String alertText = mContext.getString(mItem.getAlertText());
AlertDialog.Builder builder = new AlertDialog.Builder(mContext) AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase)
.setTitle(alertTitle) .setTitle(alertTitle)
.setMessage(alertText); .setMessage(alertText);

View File

@ -44,7 +44,7 @@ public class Analytics
sPrefsEditor.putBoolean(analyticsAsked, true); sPrefsEditor.putBoolean(analyticsAsked, true);
sPrefsEditor.apply(); sPrefsEditor.apply();
new AlertDialog.Builder(context, R.style.Theme_AppCompat_Dialog_Alert) new AlertDialog.Builder(context, R.style.DolphinDialogBase)
.setTitle(context.getString(R.string.analytics)) .setTitle(context.getString(R.string.analytics))
.setMessage(context.getString(R.string.analytics_desc)) .setMessage(context.getString(R.string.analytics_desc))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> .setPositiveButton(R.string.yes, (dialogInterface, i) ->

View File

@ -62,7 +62,7 @@ public class PermissionsHandler
private static void showMessageOKCancel(final FragmentActivity activity, String message, private static void showMessageOKCancel(final FragmentActivity activity, String message,
DialogInterface.OnClickListener okListener) DialogInterface.OnClickListener okListener)
{ {
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity, R.style.DolphinDialogBase)
.setMessage(message) .setMessage(message)
.setPositiveButton(android.R.string.ok, okListener) .setPositiveButton(android.R.string.ok, okListener)
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> .setNegativeButton(android.R.string.cancel, (dialogInterface, i) ->

View File

@ -27,7 +27,7 @@
<!-- Themes for Dialogs --> <!-- 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"> <style name="DolphinEmulationBase" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">@color/dolphin_blue</item> <item name="colorPrimary">@color/dolphin_blue</item>