mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Call changeMasterSecretPassphrase in AsyncTask
Fixes #2768 Closes #2893
This commit is contained in:
parent
857135aab1
commit
58664fcddb
@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -88,7 +91,6 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
original = MasterSecretUtil.UNENCRYPTED_PASSPHRASE;
|
original = MasterSecretUtil.UNENCRYPTED_PASSPHRASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
if (!passphrase.equals(passphraseRepeat)) {
|
if (!passphrase.equals(passphraseRepeat)) {
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
R.string.PassphraseChangeActivity_passphrases_dont_match_exclamation,
|
R.string.PassphraseChangeActivity_passphrases_dont_match_exclamation,
|
||||||
@ -100,15 +102,7 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation,
|
R.string.PassphraseChangeActivity_enter_new_passphrase_exclamation,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
MasterSecret masterSecret = MasterSecretUtil.changeMasterSecretPassphrase(this, original, passphrase);
|
new ChangePassphraseTask(this).execute(original, passphrase);
|
||||||
TextSecurePreferences.setPasswordDisabled(this, false);
|
|
||||||
|
|
||||||
setMasterSecret(masterSecret);
|
|
||||||
}
|
|
||||||
} catch (InvalidPassphraseException e) {
|
|
||||||
Toast.makeText(this, R.string.PassphraseChangeActivity_incorrect_old_passphrase_exclamation,
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
this.originalPassphrase.setText("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +118,46 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ChangePassphraseTask extends AsyncTask<String, Void, MasterSecret> {
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
public ChangePassphraseTask(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
okButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MasterSecret doInBackground(String... params) {
|
||||||
|
try {
|
||||||
|
MasterSecret masterSecret = MasterSecretUtil.changeMasterSecretPassphrase(context, params[0], params[1]);
|
||||||
|
TextSecurePreferences.setPasswordDisabled(context, false);
|
||||||
|
|
||||||
|
return masterSecret;
|
||||||
|
|
||||||
|
} catch (InvalidPassphraseException e) {
|
||||||
|
Log.w(PassphraseChangeActivity.class.getSimpleName(), e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(MasterSecret masterSecret) {
|
||||||
|
okButton.setEnabled(true);
|
||||||
|
|
||||||
|
if (masterSecret != null) {
|
||||||
|
setMasterSecret(masterSecret);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.PassphraseChangeActivity_incorrect_old_passphrase_exclamation,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
originalPassphrase.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup() {
|
protected void cleanup() {
|
||||||
this.originalPassphrase = null;
|
this.originalPassphrase = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user