mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 06:39:54 +01:00
Show strength meter when password entry has focus.
Also fixed some IME action issues on Android 2.3.
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
android:hint="@string/password_hint"
|
android:hint="@string/password_hint"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:lines="1"
|
|
||||||
android:maxLines="1" />
|
android:maxLines="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/choose_nickname"
|
android:text="@string/choose_nickname"
|
||||||
android:textSize="18sp"/>
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/nickname_entry_wrapper"
|
android:id="@+id/nickname_entry_wrapper"
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/choose_password"
|
android:text="@string/choose_password"
|
||||||
android:textSize="18sp"/>
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/password_entry_wrapper"
|
android:id="@+id/password_entry_wrapper"
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/confirm_password"
|
android:text="@string/confirm_password"
|
||||||
android:textSize="18sp"/>
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/password_confirm_wrapper"
|
android:id="@+id/password_confirm_wrapper"
|
||||||
@@ -77,6 +77,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
android:maxLines="1"/>
|
android:maxLines="1"/>
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/create_account"
|
android:id="@+id/create_account"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:text="@string/create_account_button"/>
|
android:text="@string/create_account_button"/>
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import static android.content.Intent.ACTION_MAIN;
|
|||||||
import static android.content.Intent.CATEGORY_HOME;
|
import static android.content.Intent.CATEGORY_HOME;
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
|
|
||||||
|
|
||||||
public class PasswordActivity extends BaseActivity {
|
public class PasswordActivity extends BaseActivity {
|
||||||
|
|
||||||
@@ -63,11 +62,11 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
password = (EditText) findViewById(R.id.edit_password);
|
password = (EditText) findViewById(R.id.edit_password);
|
||||||
password.setOnEditorActionListener(new OnEditorActionListener() {
|
password.setOnEditorActionListener(new OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId,
|
||||||
if (actionId == IME_ACTION_DONE) {
|
KeyEvent event) {
|
||||||
validatePassword(encrypted, password.getText());
|
hideSoftKeyboard();
|
||||||
}
|
validatePassword(encrypted, password.getText());
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import android.text.TextWatcher;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@@ -43,14 +42,13 @@ import static android.view.View.GONE;
|
|||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
|
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
|
|
||||||
public class SetupActivity extends BaseActivity implements OnClickListener,
|
public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||||
OnEditorActionListener {
|
OnEditorActionListener {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(SetupActivity.class.getName());
|
Logger.getLogger(SetupActivity.class.getName());
|
||||||
@@ -82,11 +80,13 @@ OnEditorActionListener {
|
|||||||
|
|
||||||
TextWatcher tw = new TextWatcher() {
|
TextWatcher tw = new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
|
int after) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before,
|
||||||
|
int count) {
|
||||||
enableOrDisableContinueButton();
|
enableOrDisableContinueButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ OnEditorActionListener {
|
|||||||
|
|
||||||
private void enableOrDisableContinueButton() {
|
private void enableOrDisableContinueButton() {
|
||||||
if (progress == null) return; // Not created yet
|
if (progress == null) return; // Not created yet
|
||||||
if (passwordEntry.getText().length() > 0)
|
if (passwordEntry.getText().length() > 0 && passwordEntry.hasFocus())
|
||||||
strengthMeter.setVisibility(VISIBLE);
|
strengthMeter.setVisibility(VISIBLE);
|
||||||
else strengthMeter.setVisibility(INVISIBLE);
|
else strengthMeter.setVisibility(INVISIBLE);
|
||||||
String nickname = nicknameEntry.getText().toString();
|
String nickname = nicknameEntry.getText().toString();
|
||||||
@@ -114,11 +114,14 @@ OnEditorActionListener {
|
|||||||
boolean passwordsMatch = firstPassword.equals(secondPassword);
|
boolean passwordsMatch = firstPassword.equals(secondPassword);
|
||||||
float strength = strengthEstimator.estimateStrength(firstPassword);
|
float strength = strengthEstimator.estimateStrength(firstPassword);
|
||||||
strengthMeter.setStrength(strength);
|
strengthMeter.setStrength(strength);
|
||||||
AndroidUtils.setError(nicknameEntryWrapper, getString(R.string.name_too_long),
|
AndroidUtils.setError(nicknameEntryWrapper,
|
||||||
|
getString(R.string.name_too_long),
|
||||||
nicknameLength > MAX_AUTHOR_NAME_LENGTH);
|
nicknameLength > MAX_AUTHOR_NAME_LENGTH);
|
||||||
AndroidUtils.setError(passwordEntryWrapper, getString(R.string.password_too_weak),
|
AndroidUtils.setError(passwordEntryWrapper,
|
||||||
|
getString(R.string.password_too_weak),
|
||||||
firstPassword.length() > 0 && strength < WEAK);
|
firstPassword.length() > 0 && strength < WEAK);
|
||||||
AndroidUtils.setError(passwordConfirmationWrapper, getString(R.string.passwords_do_not_match),
|
AndroidUtils.setError(passwordConfirmationWrapper,
|
||||||
|
getString(R.string.passwords_do_not_match),
|
||||||
secondPassword.length() > 0 && !passwordsMatch);
|
secondPassword.length() > 0 && !passwordsMatch);
|
||||||
createAccountButton.setEnabled(nicknameLength > 0
|
createAccountButton.setEnabled(nicknameLength > 0
|
||||||
&& nicknameLength <= MAX_AUTHOR_NAME_LENGTH
|
&& nicknameLength <= MAX_AUTHOR_NAME_LENGTH
|
||||||
@@ -126,9 +129,7 @@ OnEditorActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
// Hide the soft keyboard
|
hideSoftKeyboard();
|
||||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
|
||||||
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user