Verified Commit c90a7261 authored by Torsten Grote's avatar Torsten Grote
Browse files

Do not create two accounts when pressing enter for account creation

Fixes #1367
parent 049cf3ad
......@@ -22,6 +22,7 @@ import javax.annotation.Nullable;
import static android.content.Context.INPUT_METHOD_SERVICE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
@MethodsNotNullByDefault
......@@ -78,6 +79,7 @@ public class PasswordFragment extends SetupFragment {
// the controller is not yet available in onCreateView()
if (!setupController.needToShowDozeFragment()) {
nextButton.setText(R.string.create_account_button);
passwordConfirmation.setImeOptions(IME_ACTION_DONE);
}
}
......
package org.briarproject.briar.android.login;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
......@@ -10,13 +11,18 @@ import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.briar.R;
import org.briarproject.briar.android.fragment.BaseFragment;
import javax.inject.Inject;
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
import static android.view.inputmethod.EditorInfo.IME_ACTION_NEXT;
import static org.briarproject.briar.android.util.UiUtils.enterPressed;
import static org.briarproject.briar.android.util.UiUtils.showOnboardingDialog;
@NotNullByDefault
abstract class SetupFragment extends BaseFragment implements TextWatcher,
OnEditorActionListener, OnClickListener {
......@@ -55,9 +61,13 @@ abstract class SetupFragment extends BaseFragment implements TextWatcher,
@Override
public boolean onEditorAction(TextView textView, int actionId,
KeyEvent keyEvent) {
onClick(textView);
return true;
@Nullable KeyEvent keyEvent) {
if (actionId == IME_ACTION_NEXT || actionId == IME_ACTION_DONE ||
enterPressed(actionId, keyEvent)) {
onClick(textView);
return true;
}
return false;
}
@Override
......
......@@ -11,6 +11,7 @@ import android.os.PowerManager;
import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
......@@ -27,6 +28,7 @@ import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
......@@ -39,8 +41,6 @@ import org.briarproject.briar.R;
import org.briarproject.briar.android.view.ArticleMovementMethod;
import org.briarproject.briar.android.widget.LinkDialogFragment;
import javax.annotation.Nullable;
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.Context.POWER_SERVICE;
import static android.content.Intent.CATEGORY_DEFAULT;
......@@ -60,6 +60,10 @@ import static android.text.format.DateUtils.FORMAT_ABBREV_TIME;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
import static android.view.KeyEvent.ACTION_DOWN;
import static android.view.KeyEvent.ACTION_UP;
import static android.view.KeyEvent.KEYCODE_ENTER;
import static android.view.inputmethod.EditorInfo.IME_NULL;
import static org.briarproject.briar.BuildConfig.APPLICATION_ID;
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
......@@ -288,4 +292,12 @@ public class UiUtils {
.handleException(new UserFeedback(), false));
}
public static boolean enterPressed(int actionId,
@Nullable KeyEvent keyEvent) {
return actionId == IME_NULL &&
keyEvent != null &&
keyEvent.getAction() == ACTION_DOWN &&
keyEvent.getKeyCode() == KEYCODE_ENTER;
}
}
......@@ -71,6 +71,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/confirm_password"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment