mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-19 05:31:31 +00:00
parent
9ef14a0f64
commit
bea3c33223
@ -126,7 +126,7 @@
|
|||||||
<activity android:name=".PassphraseCreateActivity"
|
<activity android:name=".PassphraseCreateActivity"
|
||||||
android:label="@string/AndroidManifest__create_passphrase"
|
android:label="@string/AndroidManifest__create_passphrase"
|
||||||
android:windowSoftInputMode="stateUnchanged"
|
android:windowSoftInputMode="stateUnchanged"
|
||||||
android:theme="@style/NoAnimation.Theme.Sherlock.Light.DarkActionBar"
|
android:theme="@style/TextSecure.IntroTheme"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||||
|
|
||||||
|
@ -1,100 +1,38 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:id="@+id/scroll_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:background="@drawable/background_pattern_repeat">
|
android:background="@drawable/background_pattern_repeat">
|
||||||
|
|
||||||
<FrameLayout
|
<RelativeLayout android:id="@+id/prompt_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="wrap_content">
|
||||||
android:gravity="center" >
|
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/create_layout"
|
<ImageView android:id="@+id/watermark"
|
||||||
android:paddingRight="16dip"
|
|
||||||
android:paddingLeft="16dip"
|
|
||||||
android:paddingTop="10dip"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="visible"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView style="@style/Registration.Description"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_marginBottom="16dip"
|
|
||||||
android:layout_marginTop="16dip"
|
|
||||||
android:text="@string/create_passphrase_activity__please_choose_a_passphrase_that_will_be_used_to_locally_encrypt_your_data_this_should_be_a_strong_passphrase"/>
|
|
||||||
|
|
||||||
<TextView style="@style/Registration.Label"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:text="@string/create_passphrase_activity__passphrase" />
|
|
||||||
|
|
||||||
<EditText android:id="@+id/passphrase_edit"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="textPassword"
|
|
||||||
android:layout_marginBottom="10dip"
|
|
||||||
android:singleLine="true"/>
|
|
||||||
|
|
||||||
<TextView style="@style/Registration.Label"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:text="@string/create_passphrase_activity__repeat" />
|
|
||||||
|
|
||||||
<EditText android:id="@+id/passphrase_edit_repeat"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="textPassword"
|
|
||||||
android:singleLine="true"/>
|
|
||||||
|
|
||||||
<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="@string/create_passphrase_activity__skip"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="5dip"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_weight="1"
|
android:layout_marginBottom="20dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
android:src="@drawable/lockscreen_watermark"
|
||||||
|
android:contentDescription="@string/PassphrasePromptActivity_watermark_content_description"
|
||||||
|
android:layout_marginTop="100dp"/>
|
||||||
|
|
||||||
<Button android:id="@+id/ok_button"
|
<RelativeLayout android:layout_width="match_parent"
|
||||||
android:text="@string/create_passphrase_activity__create"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_below="@id/watermark">
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/progress_layout"
|
<ProgressBar android:id="@+id/passphrase_edit"
|
||||||
android:paddingRight="16dip"
|
android:layout_width="75dp"
|
||||||
android:paddingLeft="16dip"
|
android:layout_height="75dp"
|
||||||
android:paddingTop="10dip"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView style="@style/Registration.BigLabel"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_marginBottom="16dip"
|
|
||||||
android:layout_marginTop="16dip"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/create_passphrase_activity__generating_secrets"/>
|
|
||||||
|
|
||||||
<ProgressBar android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:layout_gravity="center"/>
|
android:padding="10dp"
|
||||||
</LinearLayout>
|
android:layout_centerHorizontal="true"/>
|
||||||
</FrameLayout>
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
@ -214,10 +214,6 @@
|
|||||||
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>
|
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>
|
||||||
<string name="PassphraseChangeActivity_incorrect_old_passphrase_exclamation">Incorrect old passphrase!</string>
|
<string name="PassphraseChangeActivity_incorrect_old_passphrase_exclamation">Incorrect old passphrase!</string>
|
||||||
|
|
||||||
<!-- PassphraseCreateActivity -->
|
|
||||||
<string name="PassphraseCreateActivity_passphrases_dont_match">Passphrases don\'t match</string>
|
|
||||||
<string name="PassphraseCreateActivity_you_must_specify_a_password">You must specify a password</string>
|
|
||||||
|
|
||||||
<!-- PassphrasePromptActivity -->
|
<!-- PassphrasePromptActivity -->
|
||||||
<string name="PassphrasePromptActivity_enter_passphrase">Enter passphrase</string>
|
<string name="PassphrasePromptActivity_enter_passphrase">Enter passphrase</string>
|
||||||
<string name="PassphrasePromptActivity_watermark_content_description">TextSecure icon</string>
|
<string name="PassphrasePromptActivity_watermark_content_description">TextSecure icon</string>
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -24,6 +26,8 @@ import android.widget.EditText;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||||
@ -40,14 +44,6 @@ import org.whispersystems.textsecure.util.Util;
|
|||||||
|
|
||||||
public class PassphraseCreateActivity extends PassphraseActivity {
|
public class PassphraseCreateActivity extends PassphraseActivity {
|
||||||
|
|
||||||
private LinearLayout createLayout;
|
|
||||||
private LinearLayout progressLayout;
|
|
||||||
|
|
||||||
private EditText passphraseEdit;
|
|
||||||
private EditText passphraseRepeatEdit;
|
|
||||||
private Button okButton;
|
|
||||||
private Button skipButton;
|
|
||||||
|
|
||||||
public PassphraseCreateActivity() { }
|
public PassphraseCreateActivity() { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -60,53 +56,12 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeResources() {
|
private void initializeResources() {
|
||||||
this.createLayout = (LinearLayout)findViewById(R.id.create_layout);
|
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||||
this.progressLayout = (LinearLayout)findViewById(R.id.progress_layout);
|
getSupportActionBar().setCustomView(R.layout.light_centered_app_title);
|
||||||
this.passphraseEdit = (EditText) findViewById(R.id.passphrase_edit);
|
mitigateAndroidTilingBug();
|
||||||
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
|
|
||||||
public void onClick(View v) {
|
|
||||||
verifyAndSavePassphrases();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.skipButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
disablePassphrase();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyAndSavePassphrases() {
|
|
||||||
if (Util.isEmpty(this.passphraseEdit) || Util.isEmpty(this.passphraseRepeatEdit)) {
|
|
||||||
Toast.makeText(this, R.string.PassphraseCreateActivity_you_must_specify_a_password, Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String passphrase = this.passphraseEdit.getText().toString();
|
|
||||||
String passphraseRepeat = this.passphraseRepeatEdit.getText().toString();
|
|
||||||
|
|
||||||
if (!passphrase.equals(passphraseRepeat)) {
|
|
||||||
Toast.makeText(this, R.string.PassphraseCreateActivity_passphrases_dont_match, Toast.LENGTH_SHORT).show();
|
|
||||||
this.passphraseEdit.setText("");
|
|
||||||
this.passphraseRepeatEdit.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We do this, but the edit boxes are basically impossible to clean up.
|
|
||||||
MemoryCleaner.clean(passphraseRepeat);
|
|
||||||
new SecretGenerator().execute(passphrase);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disablePassphrase() {
|
|
||||||
TextSecurePreferences.setPasswordDisabled(this, true);
|
TextSecurePreferences.setPasswordDisabled(this, true);
|
||||||
new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SecretGenerator extends AsyncTask<String, Void, Void> {
|
private class SecretGenerator extends AsyncTask<String, Void, Void> {
|
||||||
@ -114,8 +69,6 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
createLayout.setVisibility(View.GONE);
|
|
||||||
progressLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,7 +77,6 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||||||
masterSecret = MasterSecretUtil.generateMasterSecret(PassphraseCreateActivity.this,
|
masterSecret = MasterSecretUtil.generateMasterSecret(PassphraseCreateActivity.this,
|
||||||
passphrase);
|
passphrase);
|
||||||
|
|
||||||
// We do this, but the edit boxes are basically impossible to clean up.
|
|
||||||
MemoryCleaner.clean(passphrase);
|
MemoryCleaner.clean(passphrase);
|
||||||
|
|
||||||
MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
|
MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
|
||||||
@ -140,10 +92,17 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mitigateAndroidTilingBug() {
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
|
Drawable actionBarBackground = getResources().getDrawable(R.drawable.background_pattern_repeat);
|
||||||
|
Util.fixBackgroundRepeat(actionBarBackground);
|
||||||
|
getSupportActionBar().setBackgroundDrawable(actionBarBackground);
|
||||||
|
Util.fixBackgroundRepeat(findViewById(R.id.scroll_parent).getBackground());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup() {
|
protected void cleanup() {
|
||||||
this.passphraseEdit = null;
|
|
||||||
this.passphraseRepeatEdit = null;
|
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user