mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 06:22:49 +00:00
Improve auto lock and make it more customizable
This patch makes the auto lock option more customizable. Users can now choose a combination of the following: Locking Aegis when - The back button is pressed - The app is minimized - The device is locked <img src="https://alexbakker.me/u/rlj4y2u8pk.png" width="300">
This commit is contained in:
parent
7d38bc9b71
commit
d875cb6baa
28 changed files with 146 additions and 88 deletions
|
@ -6,7 +6,6 @@ import android.os.Bundle;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.beemdevelopment.aegis.AegisApplication;
|
||||
|
@ -20,9 +19,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
|
||||
public abstract class AegisActivity extends AppCompatActivity implements AegisApplication.LockListener {
|
||||
private boolean _resumed;
|
||||
private AegisApplication _app;
|
||||
private Theme _configuredTheme;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -39,6 +36,7 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,24 +56,9 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
_resumed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
_resumed = false;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void onLocked() {
|
||||
if (isOrphan()) {
|
||||
setResult(RESULT_CANCELED, null);
|
||||
finish();
|
||||
}
|
||||
public void onLocked(boolean userInitiated) {
|
||||
setResult(RESULT_CANCELED, null);
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
|
||||
protected AegisApplication getApp() {
|
||||
|
@ -139,13 +122,6 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether this Activity has been resumed. (i.e. onResume was called)
|
||||
*/
|
||||
protected boolean isOpen() {
|
||||
return _resumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether this Activity instance has become an orphan. This can happen if
|
||||
* the vault was locked by an external trigger while the Activity was still open.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue