mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Add support for predictive back gesture
This commit is contained in:
parent
c6888b11df
commit
ad77bd687f
15 changed files with 395 additions and 212 deletions
|
@ -19,6 +19,7 @@ import android.widget.PopupWindow;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.biometric.BiometricPrompt;
|
||||
|
@ -76,6 +77,8 @@ public class AuthActivity extends AegisActivity {
|
|||
Button decryptButton = findViewById(R.id.button_decrypt);
|
||||
TextView biometricsButton = findViewById(R.id.button_biometrics);
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new BackPressHandler());
|
||||
|
||||
_textPassword.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||
decryptButton.performClick();
|
||||
|
@ -102,7 +105,9 @@ public class AuthActivity extends AegisActivity {
|
|||
}
|
||||
|
||||
if (_vaultManager.getVaultFileError() != null) {
|
||||
Dialogs.showErrorDialog(this, R.string.vault_load_error, _vaultManager.getVaultFileError(), (dialog, which) -> onBackPressed());
|
||||
Dialogs.showErrorDialog(this, R.string.vault_load_error, _vaultManager.getVaultFileError(), (dialog, which) -> {
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -179,11 +184,6 @@ public class AuthActivity extends AegisActivity {
|
|||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finishAffinity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -301,6 +301,19 @@ public class AuthActivity extends AegisActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private class BackPressHandler extends OnBackPressedCallback {
|
||||
public BackPressHandler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
// This breaks predictive back gestures, but it doesn't make sense
|
||||
// to go back to MainActivity when cancelling auth
|
||||
finishAffinity();
|
||||
}
|
||||
}
|
||||
|
||||
private class PasswordDerivationListener implements PasswordSlotDecryptTask.Callback {
|
||||
@Override
|
||||
public void onTaskFinished(PasswordSlotDecryptTask.Result result) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue