Add an option to automatically lock the app

This adds an option to automatically lock the app when:
* The back button is pressed
* The device is locked

It's the first step towards implementing #7
This commit is contained in:
Alexander Bakker 2019-04-07 18:18:50 +02:00
parent 6d93b78f9a
commit 18fd88a441
5 changed files with 45 additions and 2 deletions

View file

@ -363,6 +363,15 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
updateLockIcon();
}
@Override
public void onBackPressed() {
if (_app.isAutoLockEnabled()) {
lockDatabase();
}
super.onBackPressed();
}
private BottomSheetDialog createBottomSheet(final DatabaseEntry entry) {
BottomSheetDialog dialog = new BottomSheetDialog(this);
dialog.setContentView(R.layout.bottom_sheet_edit_entry);
@ -428,6 +437,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
return true;
case R.id.action_lock:
lockDatabase();
startAuthActivity();
return true;
default:
if (item.getGroupId() == R.id.action_filter_group) {
@ -475,7 +485,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_entryListView.clearEntries();
_db.lock();
_loaded = false;
startAuthActivity();
}
}