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 a219f0a6..0c1a975b 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 @@ -32,6 +32,9 @@ import com.google.android.material.textfield.TextInputLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; +import androidx.lifecycle.DefaultLifecycleObserver; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.ProcessLifecycleOwner; import android.text.Editable; import android.text.InputType; @@ -106,6 +109,9 @@ public class AuthenticateActivity extends BaseActivity } }); + ProcessLifecycleOwner.get().getLifecycle() + .addObserver(new ProcessLifecycleObserver()); + getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } @@ -195,6 +201,15 @@ public class AuthenticateActivity extends BaseActivity unlockProgress.setVisibility(isTaskRunning ? View.VISIBLE : View.GONE); } + private class ProcessLifecycleObserver implements DefaultLifecycleObserver { + @Override + public void onStop(LifecycleOwner owner) { + if (settings.getRelockOnBackground()) { + cancelBackgroundTask(); + } + } + } + @Override public void onClick(View view) { Editable text = passwordInput.getText();