do password empty check in dialog not in restore backup service
This commit is contained in:
parent
cb1feab350
commit
d9f39df9c8
|
@ -93,7 +93,7 @@ public class ImportBackupService extends Service {
|
|||
uri = data;
|
||||
}
|
||||
|
||||
if (password == null || uri == null) {
|
||||
if (password == null || password.isEmpty() || uri == null) {
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
if (running.compareAndSet(false, true)) {
|
||||
|
@ -158,14 +158,6 @@ public class ImportBackupService extends Service {
|
|||
|
||||
private boolean importBackup(Uri uri, String password) {
|
||||
Log.d(Config.LOGTAG, "importing backup from " + uri);
|
||||
if (password == null || password.isEmpty()) {
|
||||
synchronized (mOnBackupProcessedListeners) {
|
||||
for (OnBackupProcessed l : mOnBackupProcessedListeners) {
|
||||
l.onBackupDecryptionFailed();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
SQLiteDatabase db = mDatabaseBackend.getWritableDatabase();
|
||||
final InputStream inputStream;
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.siacs.conversations.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;
|
||||
|
@ -140,8 +141,16 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
|
|||
finish();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.restore, (dialog, which) -> {
|
||||
builder.setPositiveButton(R.string.restore, null);
|
||||
builder.setCancelable(false);
|
||||
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);
|
||||
|
@ -154,9 +163,10 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
|
|||
}
|
||||
setLoadingState(true);
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
d.dismiss();
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
builder.create().show();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void setLoadingState(final boolean loadingState) {
|
||||
|
|
|
@ -874,4 +874,5 @@
|
|||
<string name="open_backup">Open backup</string>
|
||||
<string name="not_a_backup_file">The file you selected is not a Conversations backup file</string>
|
||||
<string name="account_already_setup">This account has already been setup</string>
|
||||
<string name="please_enter_password">Please enter the password for this account</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue