From 75bc10e1aa8087ac8c0565c9620c62717042700b Mon Sep 17 00:00:00 2001 From: Joshua Soberg Date: Thu, 4 Feb 2021 20:17:23 -0500 Subject: [PATCH] #635 - Make sure the AuthenticateActivity isn't destroyed on screen off --- .../Activities/AuthenticateActivity.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java index 4de8be91..19afcf01 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java @@ -212,13 +212,6 @@ public class AuthenticateActivity extends BaseActivity unlockProgress.setVisibility(isTaskRunning ? View.VISIBLE : View.GONE); } - @Override - protected void onDestroy() { - super.onDestroy(); - ProcessLifecycleOwner.get().getLifecycle() - .removeObserver(observer); - } - @Override public void onClick(View view) { Editable text = passwordInput.getText(); @@ -271,6 +264,12 @@ public class AuthenticateActivity extends BaseActivity finish(); } + @Override + public void onBackPressed() { + finishWithResult(false, null); + super.onBackPressed(); + } + @Override protected void onPause() { super.onPause(); @@ -282,9 +281,15 @@ public class AuthenticateActivity extends BaseActivity } @Override - public void onBackPressed() { - finishWithResult(false, null); - super.onBackPressed(); + protected void onDestroy() { + ProcessLifecycleOwner.get().getLifecycle() + .removeObserver(observer); + super.onDestroy(); + } + + @Override + protected boolean shouldDestroyOnScreenOff() { + return false; } /** Retained instance fragment to hold a running {@link AuthenticationTask} between configuration changes.*/