Support skipping password creation at setup
This commit is contained in:
parent
a4a3b4a453
commit
04b2c3772a
3 changed files with 56 additions and 26 deletions
|
@ -49,15 +49,29 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<Button android:id="@+id/ok_button"
|
||||
android:text="@string/create_passphrase_activity__continue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_marginTop="20dip"
|
||||
android:layout_marginBottom="20dip"/>
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dip"
|
||||
android:layout_marginBottom="20dip"
|
||||
android:layout_gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button android:id="@+id/skip_button"
|
||||
android:text="Skip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="5dip"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<Button android:id="@+id/ok_button"
|
||||
android:text="Create"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/progress_layout"
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.widget.LinearLayout;
|
|||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
|
@ -45,6 +46,7 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||
private EditText passphraseEdit;
|
||||
private EditText passphraseRepeatEdit;
|
||||
private Button okButton;
|
||||
private Button skipButton;
|
||||
|
||||
public PassphraseCreateActivity() { }
|
||||
|
||||
|
@ -63,6 +65,7 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||
this.passphraseEdit = (EditText) findViewById(R.id.passphrase_edit);
|
||||
this.passphraseRepeatEdit = (EditText) findViewById(R.id.passphrase_edit_repeat);
|
||||
this.okButton = (Button) findViewById(R.id.ok_button);
|
||||
this.skipButton = (Button) findViewById(R.id.skip_button);
|
||||
|
||||
this.okButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -70,6 +73,13 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||
verifyAndSavePassphrases();
|
||||
}
|
||||
});
|
||||
|
||||
this.skipButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
disablePassphrase();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void verifyAndSavePassphrases() {
|
||||
|
@ -93,6 +103,12 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||
new SecretGenerator().execute(passphrase);
|
||||
}
|
||||
|
||||
private void disablePassphrase() {
|
||||
TextSecurePreferences.setPasswordDisabled(this, true);
|
||||
new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
||||
|
||||
}
|
||||
|
||||
private class SecretGenerator extends AsyncTask<String, Void, Void> {
|
||||
private MasterSecret masterSecret;
|
||||
|
||||
|
|
|
@ -66,22 +66,22 @@ public class MemoryCleaner {
|
|||
}
|
||||
|
||||
public static void clean(String string) {
|
||||
if (string == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
Field charArrayField = String.class.getDeclaredField("value");
|
||||
charArrayField.setAccessible(true);
|
||||
|
||||
char[] internalBuffer = (char[])charArrayField.get(string);
|
||||
|
||||
Arrays.fill(internalBuffer, 'A');
|
||||
} catch (NoSuchFieldException nsfe) {
|
||||
Log.w("MemoryCleaner", nsfe);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.w("MemoryCleaner", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.w("MemoryCleaner", e);
|
||||
}
|
||||
// if (string == null)
|
||||
// return;
|
||||
//
|
||||
// try {
|
||||
// Field charArrayField = String.class.getDeclaredField("value");
|
||||
// charArrayField.setAccessible(true);
|
||||
//
|
||||
// char[] internalBuffer = (char[])charArrayField.get(string);
|
||||
//
|
||||
// Arrays.fill(internalBuffer, 'A');
|
||||
// } catch (NoSuchFieldException nsfe) {
|
||||
// Log.w("MemoryCleaner", nsfe);
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// Log.w("MemoryCleaner", e);
|
||||
// } catch (IllegalAccessException e) {
|
||||
// Log.w("MemoryCleaner", e);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue