diff --git a/broken_tests/src/org/opendatakit/tables/fragments/AbsWebTableFragmentStub.java b/broken_tests/src/org/opendatakit/tables/fragments/AbsWebTableFragmentStub.java index c0adb11c..4f8e2f85 100644 --- a/broken_tests/src/org/opendatakit/tables/fragments/AbsWebTableFragmentStub.java +++ b/broken_tests/src/org/opendatakit/tables/fragments/AbsWebTableFragmentStub.java @@ -65,4 +65,13 @@ public void databaseUnavailable() { // we assume the service connection is mocked and does not require any of these calls } + @Override + public void onBackPressed() { + if (ODKWebView.canGoBack()) { + ODKWebView.goBack(); + } else { + super.onBackPressed(); + } + } + } diff --git a/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseActivity.java b/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseActivity.java index 96d21ff7..6612fffd 100644 --- a/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseActivity.java +++ b/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseActivity.java @@ -17,8 +17,11 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; +import android.app.Activity; +import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; diff --git a/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseWebActivity.java b/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseWebActivity.java index ff077683..2c62d8b5 100644 --- a/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseWebActivity.java +++ b/tables_app/src/main/java/org/opendatakit/tables/activities/AbsBaseWebActivity.java @@ -1,5 +1,6 @@ package org.opendatakit.tables.activities; +import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; @@ -83,7 +84,7 @@ public abstract class AbsBaseWebActivity extends AbsTableActivity implements IOd // no need to preserve private PropertyManager mPropertyManager; - public abstract String getInstanceId(); + public abstract String getInstanceId(); /** * Gets the active webkit view diff --git a/tables_app/src/main/java/org/opendatakit/tables/activities/MainActivity.java b/tables_app/src/main/java/org/opendatakit/tables/activities/MainActivity.java index 48ead2da..8ffaf580 100644 --- a/tables_app/src/main/java/org/opendatakit/tables/activities/MainActivity.java +++ b/tables_app/src/main/java/org/opendatakit/tables/activities/MainActivity.java @@ -21,8 +21,10 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager.BackStackEntry; import androidx.fragment.app.FragmentTransaction; +import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu; @@ -265,7 +267,20 @@ private void popBackStack() { if (idxLast < 0) { Intent result = new Intent(); this.setResult(RESULT_OK, result); - finish(); + new AlertDialog.Builder(this) + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle("Closing Application") + .setMessage("Are you sure you want to close this application?") + .setPositiveButton("Yes", new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialog, int which) { + finish(); + } + + }) + .setNegativeButton("No", null) + .show(); } else { BackStackEntry entry = mgr.getBackStackEntryAt(idxLast); swapScreens(ScreenType.valueOf(entry.getName()));