Skip to content

Commit

Permalink
Android: Only show emulation menu toast if boot succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Nov 9, 2020
1 parent 0280f35 commit d06830b
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -81,10 +81,12 @@ public final class EmulationActivity extends AppCompatActivity
private String[] mPaths;
private boolean mIgnoreWarnings;
private static boolean sUserPausedEmulation;
private boolean mMenuToastShown;

public static final String EXTRA_SELECTED_GAMES = "SelectedGames";
public static final String EXTRA_IGNORE_WARNINGS = "IgnoreWarnings";
public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation";
public static final String EXTRA_MENU_TOAST_SHOWN = "MenuToastShown";

@Retention(SOURCE)
@IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE,
Expand Down Expand Up @@ -212,8 +214,8 @@ protected void onCreate(Bundle savedInstanceState)
mPaths = gameToEmulate.getStringArrayExtra(EXTRA_SELECTED_GAMES);
mIgnoreWarnings = gameToEmulate.getBooleanExtra(EXTRA_IGNORE_WARNINGS, false);
sUserPausedEmulation = gameToEmulate.getBooleanExtra(EXTRA_USER_PAUSED_EMULATION, false);
mMenuToastShown = false;
activityRecreated = false;
Toast.makeText(this, R.string.emulation_menu_help, Toast.LENGTH_LONG).show();
}
else
{
Expand Down Expand Up @@ -260,8 +262,9 @@ protected void onSaveInstanceState(@NonNull Bundle outState)
mEmulationFragment.saveTemporaryState();
}
outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths);
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, mIgnoreWarnings);
outState.putBoolean(EXTRA_IGNORE_WARNINGS, mIgnoreWarnings);
outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation);
outState.putBoolean(EXTRA_MENU_TOAST_SHOWN, mMenuToastShown);
super.onSaveInstanceState(outState);
}

Expand All @@ -270,6 +273,7 @@ protected void restoreState(Bundle savedInstanceState)
mPaths = savedInstanceState.getStringArray(EXTRA_SELECTED_GAMES);
mIgnoreWarnings = savedInstanceState.getBoolean(EXTRA_IGNORE_WARNINGS);
sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION);
mMenuToastShown = savedInstanceState.getBoolean(EXTRA_MENU_TOAST_SHOWN);
}

@Override
Expand Down Expand Up @@ -306,6 +310,13 @@ protected void onStop()

public void onTitleChanged()
{
if (!mMenuToastShown)
{
// The reason why this doesn't run earlier is because we want to be sure the boot succeeded.
Toast.makeText(this, R.string.emulation_menu_help, Toast.LENGTH_LONG).show();
mMenuToastShown = true;
}

setTitle(NativeLibrary.GetCurrentTitleDescription());
updateMotionListener();

Expand Down

0 comments on commit d06830b

Please sign in to comment.