diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index 5df6d9f0a3..5885596048 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -27,8 +27,10 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.os.PowerManager; +import android.view.MenuItem; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.Lifecycle; @@ -260,6 +262,18 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc super.onBackPressed(); } + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + protected boolean backHandled() { for (IBackPressedListener listener : backPressedListeners) if (listener.onBackPressed()) diff --git a/app/src/main/java/eu/faircode/email/ActivityBilling.java b/app/src/main/java/eu/faircode/email/ActivityBilling.java index 16c07cef69..4a9016982d 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBilling.java +++ b/app/src/main/java/eu/faircode/email/ActivityBilling.java @@ -148,18 +148,6 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis super.onDestroy(); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) - onBackPressed(); - return true; - default: - return false; - } - } - @NonNull static String getSkuPro() { if (BuildConfig.DEBUG) diff --git a/app/src/main/java/eu/faircode/email/ActivityCompose.java b/app/src/main/java/eu/faircode/email/ActivityCompose.java index f9314f5f5a..56bc7384eb 100644 --- a/app/src/main/java/eu/faircode/email/ActivityCompose.java +++ b/app/src/main/java/eu/faircode/email/ActivityCompose.java @@ -198,16 +198,4 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB finishAndRemoveTask(); } } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) - onBackPressed(); - return true; - default: - return false; - } - } } diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 221dce5e0d..a284326378 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -347,12 +347,6 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac if (drawerToggle.onOptionsItemSelected(item)) return true; - switch (item.getItemId()) { - case android.R.id.home: - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) - getSupportFragmentManager().popBackStack(); - return true; - } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index e89dfb2197..b23afd5a7e 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -582,14 +582,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB if (drawerToggle.onOptionsItemSelected(item)) return true; - switch (item.getItemId()) { - case android.R.id.home: - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) - getSupportFragmentManager().popBackStack(); - return true; - default: - return false; - } + return super.onOptionsItemSelected(item); } private void checkFirst() { diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 8dc3c1286e..1c754b3ede 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -939,10 +939,6 @@ public class FragmentCompose extends FragmentBase { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) - onExit(); - return true; case R.id.menu_encrypt: onMenuEncrypt(); return true;