android: frontend: Add a confirmation dialog on game exit.

This commit is contained in:
bunnei 2019-07-24 14:34:03 -04:00
parent bcfa9393b7
commit 92555e6228
2 changed files with 21 additions and 19 deletions

View File

@ -24,7 +24,6 @@ import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Callback; import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
@ -100,7 +99,6 @@ public final class EmulationActivity extends AppCompatActivity {
private int mPosition; private int mPosition;
private boolean mDeviceHasTouchScreen; private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible; private boolean mMenuVisible;
private boolean mBackPressedOnce;
private boolean activityRecreated; private boolean activityRecreated;
private String mScreenPath; private String mScreenPath;
private String mSelectedTitle; private String mSelectedTitle;
@ -250,22 +248,24 @@ public final class EmulationActivity extends AppCompatActivity {
toggleMenu(); toggleMenu();
} }
} else { } else {
if (mBackPressedOnce) { NativeLibrary.PauseEmulation();
new AlertDialog.Builder(this)
.setTitle(R.string.emulation_close_game)
.setMessage(R.string.emulation_close_game_message)
.setIcon(R.drawable.ic_launcher)
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
{
mEmulationFragment.stopEmulation(); mEmulationFragment.stopEmulation();
exitWithAnimation(); exitWithAnimation();
} else { })
mBackPressedOnce = true; .setNegativeButton(R.string.cancel, (dialogInterface, i) ->
Toast.makeText(this, "Press back again to exit", Toast.LENGTH_SHORT).show(); {
} }).setOnDismissListener(dialogInterface ->
{
Handler mHandler = new Handler(); NativeLibrary.UnPauseEmulation();
mHandler.postDelayed(new Runnable() { })
@Override .create()
public void run() { .show();
mBackPressedOnce = false;
mHandler.removeCallbacks(this);
}
}, 2000);
} }
} }

View File

@ -159,6 +159,8 @@
<string name="emulation_screen_layout_sidebyside">Side by Side Screens</string> <string name="emulation_screen_layout_sidebyside">Side by Side Screens</string>
<string name="emulation_swap_screens">Swap Screens</string> <string name="emulation_swap_screens">Swap Screens</string>
<string name="emulation_touch_overlay_reset">Reset Overlay</string> <string name="emulation_touch_overlay_reset">Reset Overlay</string>
<string name="emulation_close_game">Close Game</string>
<string name="emulation_close_game_message">Are you sure that you would like to close the current game?</string>
<string name="write_permission_needed">You need to allow write access to external storage for the emulator to work</string> <string name="write_permission_needed">You need to allow write access to external storage for the emulator to work</string>
<string name="load_settings">Loading Settings...</string> <string name="load_settings">Loading Settings...</string>