Persist new value in ChangeCredentialsTask

Try to avoids problems when the calling activity is killed
This commit is contained in:
Jakob Nixdorf 2021-03-25 20:22:59 +01:00
parent d95dac1784
commit 2bec1e8224
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
3 changed files with 6 additions and 2 deletions

View file

@ -191,8 +191,7 @@ public class SettingsActivity extends BaseActivity
if (fragment.useAndroidSync != null)
fragment.useAndroidSync.setEnabled(true);
}
} else if(key.equals(getString(R.string.settings_key_enable_android_backup_service)))
{
} else if(key.equals(getString(R.string.settings_key_enable_android_backup_service))) {
Log.d(SettingsActivity.class.getSimpleName(), "onSharedPreferenceChanged called modifying settings_key_enable_android_backup_service service is now: " +
(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled"));

View file

@ -204,6 +204,7 @@ public class CredentialsPreference extends DialogPreference
}
}
assert passwordInput.getText() != null; // The save button should only be accessible when a password has been entered (and confirmed)
ChangeCredentialsTask task = new ChangeCredentialsTask(context, encryptionType, oldEncryptionKey, value, passwordInput.getText().toString());
task.setCallback(this::handleTaskResult);

View file

@ -59,6 +59,10 @@ public class ChangeCredentialsTask extends UiBasedBackgroundTask<ChangeCredentia
return new Result(false, null, null);
}
// We already persist the new value here so if something happens to the calling preference
// everything is already finalized
settings.setAuthMethod(newAuthMethod);
return new Result(true, newEncryptionKey, encryptionType);
}