#635 - Use a lifecycle observer to cancel an active task when going to the background if set to do so
This commit is contained in:
parent
97e7f51fe9
commit
38a5ca656c
1 changed files with 15 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue