Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8718 from JosJuice/android-tv-long-press
Android TV: Fix crash when long pressing a game
  • Loading branch information
JMC47 committed Apr 22, 2020
2 parents 2673280 + 163b176 commit f83adde
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 22 deletions.
Expand Up @@ -463,7 +463,8 @@ public static boolean displayAlertMsg(final String caption, final String text,
{
// Create object used for waiting.
final Object lock = new Object();
AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity)
AlertDialog.Builder builder = new AlertDialog.Builder(emulationActivity,
R.style.DolphinDialogBase)
.setTitle(caption)
.setMessage(text);

Expand Down
Expand Up @@ -738,7 +738,7 @@ private void toggleControls()
{
final SharedPreferences.Editor editor = mPreferences.edit();
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);
if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
{
Expand Down Expand Up @@ -795,7 +795,7 @@ else if (mPreferences.getInt("wiiController", 3) == 4)
public void chooseDoubleTapButton()
{
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 =
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUCK);
Expand Down Expand Up @@ -857,7 +857,7 @@ public void onStopTrackingTouch(SeekBar seekBar)
value.setText(String.valueOf(seekbar.getProgress() + 50));
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.setView(view);
builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) ->
Expand All @@ -876,7 +876,7 @@ public void onStopTrackingTouch(SeekBar seekBar)
private void chooseController()
{
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.setSingleChoiceItems(R.array.controllersEntries,
mPreferences.getInt("wiiController", 3),
Expand All @@ -902,7 +902,7 @@ private void chooseController()
private void showMotionControlsOptions()
{
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.setSingleChoiceItems(R.array.motionControlsEntries,
mPreferences.getInt("motionControlsEnabled", 0),
Expand Down Expand Up @@ -938,7 +938,7 @@ private void chooseOrientation()
}

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.setSingleChoiceItems(R.array.orientationEntries, initialIndex,
(dialog, indexSelected) ->
Expand Down Expand Up @@ -1055,7 +1055,7 @@ private void setIRSensitivity()
}
});

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.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
Expand Down Expand Up @@ -1090,7 +1090,7 @@ private void setIRSensitivity()

private void resetOverlay()
{
new AlertDialog.Builder(this)
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
.setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
{
Expand Down
Expand Up @@ -137,7 +137,7 @@ public boolean onLongClick(View view)

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.");

Expand Down
Expand Up @@ -82,7 +82,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)

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.");

Expand Down
Expand Up @@ -35,7 +35,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
{
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);

Expand Down
Expand Up @@ -45,7 +45,8 @@ public static GamePropertiesDialog newInstance(String path, String gameId, int p
@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);
Expand Down
Expand Up @@ -218,7 +218,7 @@ public void showExternalStorageNotMountedHint()
@Override
public void showGameIniJunkDeletionQuestion()
{
new AlertDialog.Builder(this)
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
.setTitle(getString(R.string.game_ini_junk_title))
.setMessage(getString(R.string.game_ini_junk_question))
.setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings())
Expand Down
Expand Up @@ -192,7 +192,8 @@ public void onSingleChoiceClick(SingleChoiceSetting item, int position)

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.setSingleChoiceItems(item.getChoicesId(), value, this);
Expand All @@ -205,7 +206,8 @@ public void onStringSingleChoiceClick(StringSingleChoiceSetting item, int positi
mClickedItem = item;
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.setSingleChoiceItems(item.getChoicesId(), item.getSelectValueIndex(), this);
Expand All @@ -221,7 +223,8 @@ public void onSingleChoiceDynamicDescriptionsClick(SingleChoiceSettingDynamicDes

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.setSingleChoiceItems(item.getChoicesId(), value, this);
Expand All @@ -234,7 +237,8 @@ public void onSliderClick(SliderSetting item, int position)
mClickedItem = item;
mClickedPosition = position;
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());
View view = inflater.inflate(R.layout.dialog_seekbar, null);
Expand Down
Expand Up @@ -58,7 +58,7 @@ public void onClick(View clicked)
String alertTitle = mContext.getString(mItem.getNameId());
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)
.setMessage(alertText);

Expand Down
Expand Up @@ -44,7 +44,7 @@ private static void showMessage(Context context, SharedPreferences preferences)
sPrefsEditor.putBoolean(analyticsAsked, true);
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))
.setMessage(context.getString(R.string.analytics_desc))
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
Expand Down
Expand Up @@ -62,7 +62,7 @@ public static boolean hasWriteAccess(Context context)
private static void showMessageOKCancel(final FragmentActivity activity, String message,
DialogInterface.OnClickListener okListener)
{
new AlertDialog.Builder(activity)
new AlertDialog.Builder(activity, R.style.DolphinDialogBase)
.setMessage(message)
.setPositiveButton(android.R.string.ok, okListener)
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) ->
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/app/src/main/res/values/styles.xml
Expand Up @@ -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>
Expand Down

0 comments on commit f83adde

Please sign in to comment.