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