mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Fix for another NPE which should never happen but apparently does.
This commit is contained in:
parent
b4e48f9dba
commit
faa3d2276e
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2011 Whisper Systems
|
* Copyright (C) 2011 Whisper Systems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -10,27 +10,28 @@
|
|||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity for changing a user's local encryption passphrase.
|
* Activity for changing a user's local encryption passphrase.
|
||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -44,12 +45,12 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.change_passphrase_activity);
|
setContentView(R.layout.change_passphrase_activity);
|
||||||
|
|
||||||
initializeResources();
|
initializeResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeResources() {
|
private void initializeResources() {
|
||||||
this.originalPassphrase = (EditText) findViewById(R.id.old_passphrase);
|
this.originalPassphrase = (EditText) findViewById(R.id.old_passphrase);
|
||||||
this.newPassphrase = (EditText) findViewById(R.id.new_passphrase);
|
this.newPassphrase = (EditText) findViewById(R.id.new_passphrase);
|
||||||
@ -57,16 +58,20 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
|
|
||||||
this.okButton = (Button) findViewById(R.id.ok_button);
|
this.okButton = (Button) findViewById(R.id.ok_button);
|
||||||
this.cancelButton = (Button) findViewById(R.id.cancel_button);
|
this.cancelButton = (Button) findViewById(R.id.cancel_button);
|
||||||
|
|
||||||
this.okButton.setOnClickListener(new OkButtonClickListener());
|
this.okButton.setOnClickListener(new OkButtonClickListener());
|
||||||
this.cancelButton.setOnClickListener(new CancelButtonClickListener());
|
this.cancelButton.setOnClickListener(new CancelButtonClickListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyAndSavePassphrases() {
|
private void verifyAndSavePassphrases() {
|
||||||
String original = this.originalPassphrase.getText().toString();
|
Editable originalText = this.originalPassphrase.getText();
|
||||||
String passphrase = this.newPassphrase.getText().toString();
|
Editable newText = this.newPassphrase.getText();
|
||||||
String passphraseRepeat = this.repeatPassphrase.getText().toString();
|
Editable repeatText = this.repeatPassphrase.getText();
|
||||||
|
|
||||||
|
String original = (originalText == null ? "" : originalText.toString());
|
||||||
|
String passphrase = (newText == null ? "" : newText.toString());
|
||||||
|
String passphraseRepeat = (repeatText == null ? "" : repeatText.toString());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!passphrase.equals(passphraseRepeat)) {
|
if (!passphrase.equals(passphraseRepeat)) {
|
||||||
Toast.makeText(getApplicationContext(), "Passphrases Don't Match!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Passphrases Don't Match!", Toast.LENGTH_SHORT).show();
|
||||||
@ -77,7 +82,7 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
MemoryCleaner.clean(original);
|
MemoryCleaner.clean(original);
|
||||||
MemoryCleaner.clean(passphrase);
|
MemoryCleaner.clean(passphrase);
|
||||||
MemoryCleaner.clean(passphraseRepeat);
|
MemoryCleaner.clean(passphraseRepeat);
|
||||||
|
|
||||||
setMasterSecret(masterSecret);
|
setMasterSecret(masterSecret);
|
||||||
}
|
}
|
||||||
} catch (InvalidPassphraseException e) {
|
} catch (InvalidPassphraseException e) {
|
||||||
@ -87,11 +92,11 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class CancelButtonClickListener implements OnClickListener {
|
private class CancelButtonClickListener implements OnClickListener {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OkButtonClickListener implements OnClickListener {
|
private class OkButtonClickListener implements OnClickListener {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
verifyAndSavePassphrases();
|
verifyAndSavePassphrases();
|
||||||
@ -103,7 +108,7 @@ public class PassphraseChangeActivity extends PassphraseActivity {
|
|||||||
this.originalPassphrase = null;
|
this.originalPassphrase = null;
|
||||||
this.newPassphrase = null;
|
this.newPassphrase = null;
|
||||||
this.repeatPassphrase = null;
|
this.repeatPassphrase = null;
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user