aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-08-31 14:52:57 +0200
committerChristian Schneppe <christian@pix-art.de>2019-08-31 14:52:57 +0200
commit8b63dbb26d5f5d81ad631c6cb8629cb5637df0ea (patch)
tree12616e01c88ed7ebce05839c97cc9362058e1f20 /src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
parent94143682ffd20c41ebc607228716fc184d558a16 (diff)
do password empty check in dialog not in restore backup service
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
index ffcbbb0bb..3b7744088 100644
--- a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.ui;
import android.content.ComponentName;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.databinding.DataBindingUtil;
@@ -153,23 +154,32 @@ public class ImportBackupActivity extends XmppActivity implements ServiceConnect
finish();
}
});
- builder.setPositiveButton(R.string.restore, (dialog, which) -> {
- final String password = enterPasswordBinding.accountPassword.getEditableText().toString();
- final Uri uri = backupFile.getUri();
- Intent intent = new Intent(this, ImportBackupService.class);
- intent.setAction(Intent.ACTION_SEND);
- intent.putExtra("password", password);
- if ("file".equals(uri.getScheme())) {
- intent.putExtra("file", uri.getPath());
- } else {
- intent.setData(uri);
- intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- }
- setLoadingState(true);
- ContextCompat.startForegroundService(this, intent);
- });
+ builder.setPositiveButton(R.string.restore, null);
builder.setCancelable(false);
- builder.create().show();
+ final AlertDialog dialog = builder.create();
+ dialog.setOnShowListener((d) -> {
+ dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
+ final String password = enterPasswordBinding.accountPassword.getEditableText().toString();
+ if (password.isEmpty()) {
+ enterPasswordBinding.accountPasswordLayout.setError(getString(R.string.please_enter_password));
+ return;
+ }
+ final Uri uri = backupFile.getUri();
+ Intent intent = new Intent(this, ImportBackupService.class);
+ intent.setAction(Intent.ACTION_SEND);
+ intent.putExtra("password", password);
+ if ("file".equals(uri.getScheme())) {
+ intent.putExtra("file", uri.getPath());
+ } else {
+ intent.setData(uri);
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ }
+ setLoadingState(true);
+ ContextCompat.startForegroundService(this, intent);
+ d.dismiss();
+ });
+ });
+ dialog.show();
}
private void setLoadingState(final boolean loadingState) {