Remove double back key press to close the app

This commit is contained in:
Herbert Reiter
2021-06-09 22:09:22 +02:00
parent 07a9fa630c
commit e8833dd11b
3 changed files with 2 additions and 14 deletions
@@ -88,7 +88,6 @@ public class MainActivity extends AppCompatActivity {
private RequestDispatcher requestDispatcher;
private WebView webview;
private long backButtonPressedTimestamp;
private ExecutorService synchronizationExecutorService;
@@ -273,17 +272,8 @@ public class MainActivity extends AppCompatActivity {
if (backForwardList.getCurrentIndex() > 0) {
webview.goBack();
} else {
long currentTimeMillis = System.currentTimeMillis();
if (backButtonPressedTimestamp + 5000 < currentTimeMillis) {
// First click on back button or previous click was more than 5 seconds ago
Log.d(TAG, "Back button 1x, show close hint");
showToast(getString(R.string.action_back_close_hint));
backButtonPressedTimestamp = currentTimeMillis;
} else {
// Second click on back button within 5 seconds -> close app
Log.d(TAG, "Back button 2x, closing app");
finish();
}
// Close app
finish();
}
}
-1
View File
@@ -4,7 +4,6 @@
<string name="about_version">Version %1$s</string>
<string name="action_help">Hilfe</string>
<string name="action_about">Über</string>
<string name="action_back_close_hint">Erneut drücken um die App zu beenden.</string>
<string name="action_settings">Einstellungen</string>
<string name="action_startpage">Startseite</string>
<string name="action_synchronize">Synchronisieren</string>
-1
View File
@@ -4,7 +4,6 @@
<string name="about_homepage_url" translatable="false">https://www.moasdawiki.net/</string>
<string name="about_version">Version %1$s</string>
<string name="action_about">About</string>
<string name="action_back_close_hint">Press again to exit the app.</string>
<string name="action_help">Help</string>
<string name="action_settings">Settings</string>
<string name="action_startpage">Start page</string>