|
|
|
@ -20,6 +20,7 @@ import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.InputType;
|
|
|
|
|
import android.text.SpannableString;
|
|
|
|
|
import android.text.Spanned;
|
|
|
|
|
import android.text.style.RelativeSizeSpan;
|
|
|
|
@ -36,6 +37,7 @@ import android.widget.ImageButton;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
|
|
|
|
import org.thoughtcrime.securesms.util.DynamicIntroTheme;
|
|
|
|
@ -52,7 +54,10 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
|
|
|
|
private DynamicIntroTheme dynamicTheme = new DynamicIntroTheme();
|
|
|
|
|
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
|
|
|
|
|
|
|
|
private EditText passphraseText;
|
|
|
|
|
private EditText passphraseText;
|
|
|
|
|
private ImageButton showButton;
|
|
|
|
|
private ImageButton hideButton;
|
|
|
|
|
private AnimatingToggle visibilityToggle;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -116,18 +121,36 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setPassphraseVisibility(boolean visibility) {
|
|
|
|
|
int cursorPosition = passphraseText.getSelectionStart();
|
|
|
|
|
if (visibility) {
|
|
|
|
|
passphraseText.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
|
|
|
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
|
|
|
|
} else {
|
|
|
|
|
passphraseText.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
|
|
|
InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
|
|
|
|
}
|
|
|
|
|
passphraseText.setSelection(cursorPosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeResources() {
|
|
|
|
|
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
|
|
getSupportActionBar().setCustomView(R.layout.centered_app_title);
|
|
|
|
|
|
|
|
|
|
ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
|
|
|
|
|
passphraseText = (EditText) findViewById(R.id.passphrase_edit);
|
|
|
|
|
|
|
|
|
|
showButton = (ImageButton) findViewById(R.id.passphrase_visibility);
|
|
|
|
|
hideButton = (ImageButton) findViewById(R.id.passphrase_visibility_off);
|
|
|
|
|
visibilityToggle = (AnimatingToggle) findViewById(R.id.button_toggle);
|
|
|
|
|
passphraseText = (EditText) findViewById(R.id.passphrase_edit);
|
|
|
|
|
SpannableString hint = new SpannableString(" " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
|
|
|
|
|
hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
|
|
|
|
hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
|
|
|
|
|
|
|
|
|
passphraseText.setHint(hint);
|
|
|
|
|
okButton.setOnClickListener(new OkButtonClickListener());
|
|
|
|
|
showButton.setOnClickListener(new ShowButtonOnClickListener());
|
|
|
|
|
hideButton.setOnClickListener(new HideButtonOnClickListener());
|
|
|
|
|
passphraseText.setOnEditorActionListener(new PassphraseActionListener());
|
|
|
|
|
passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
|
|
|
|
|
EditorInfo.IME_ACTION_DONE);
|
|
|
|
@ -159,6 +182,22 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ShowButtonOnClickListener implements OnClickListener {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
visibilityToggle.display(hideButton);
|
|
|
|
|
setPassphraseVisibility(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class HideButtonOnClickListener implements OnClickListener {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
visibilityToggle.display(showButton);
|
|
|
|
|
setPassphraseVisibility(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void cleanup() {
|
|
|
|
|
this.passphraseText.setText("");
|
|
|
|
|