Skip to content

Commit 57c850d

Browse files
authored
Merge pull request #417 from SUPERCILEX/pass-toggle
Use support library password toggle
2 parents 75ddb2f + 9c6c15a commit 57c850d

20 files changed

+21
-182
lines changed

auth/src/main/java/com/firebase/ui/auth/ui/account_link/WelcomeBackPasswordPrompt.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.firebase.ui.auth.ui.ExtraConstants;
3838
import com.firebase.ui.auth.ui.FlowParameters;
3939
import com.firebase.ui.auth.ui.TaskFailureLogger;
40-
import com.firebase.ui.auth.ui.email.PasswordToggler;
4140
import com.firebase.ui.auth.ui.email.RecoverPasswordActivity;
4241
import com.firebase.ui.auth.util.signincontainer.SaveSmartLock;
4342
import com.google.android.gms.tasks.OnFailureListener;
@@ -58,7 +57,8 @@ public class WelcomeBackPasswordPrompt extends AppCompatBase implements View.OnC
5857
private TextInputLayout mPasswordLayout;
5958
private EditText mPasswordField;
6059
private IdpResponse mIdpResponse;
61-
@Nullable private SaveSmartLock mSaveSmartLock;
60+
@Nullable
61+
private SaveSmartLock mSaveSmartLock;
6262

6363
@Override
6464
protected void onCreate(Bundle savedInstanceState) {
@@ -76,15 +76,16 @@ protected void onCreate(Bundle savedInstanceState) {
7676
bodyText = String.format(bodyText, mEmail);
7777
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
7878
int emailStart = bodyText.indexOf(mEmail);
79-
spannableStringBuilder.setSpan(BOLD, emailStart, emailStart + mEmail.length(), Spannable
80-
.SPAN_INCLUSIVE_INCLUSIVE);
79+
spannableStringBuilder.setSpan(BOLD,
80+
emailStart,
81+
emailStart + mEmail.length(),
82+
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
8183

8284
TextView bodyTextView = ((TextView) findViewById(R.id.welcome_back_password_body));
8385
bodyTextView.setText(spannableStringBuilder);
8486

8587
// Click listeners
8688
findViewById(R.id.button_done).setOnClickListener(this);
87-
findViewById(R.id.toggle_visibility).setOnClickListener(new PasswordToggler(mPasswordField));
8889
findViewById(R.id.trouble_signing_in).setOnClickListener(this);
8990
}
9091

@@ -131,7 +132,8 @@ public void onSuccess(AuthResult authResult) {
131132
// Sign in with the credential
132133
firebaseAuth.signInWithCredential(authCredential)
133134
.addOnFailureListener(
134-
new TaskFailureLogger(TAG, "Error signing in with credential"))
135+
new TaskFailureLogger(TAG,
136+
"Error signing in with credential"))
135137
.addOnSuccessListener(
136138
new OnSuccessListener<AuthResult>() {
137139
@Override

auth/src/main/java/com/firebase/ui/auth/ui/email/ImageFocusTransparencyChanger.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

auth/src/main/java/com/firebase/ui/auth/ui/email/PasswordToggler.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailActivity.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
import android.support.v4.content.ContextCompat;
2525
import android.text.SpannableStringBuilder;
2626
import android.text.style.ForegroundColorSpan;
27-
import android.util.TypedValue;
2827
import android.view.View;
2928
import android.widget.Button;
3029
import android.widget.EditText;
31-
import android.widget.ImageView;
3230
import android.widget.TextView;
3331

3432
import com.firebase.ui.auth.R;
@@ -75,33 +73,17 @@ protected void onCreate(Bundle savedInstanceState) {
7573

7674
mSaveSmartLock = mActivityHelper.getSaveSmartLockInstance();
7775

78-
String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
7976
mEmailEditText = (EditText) findViewById(R.id.email);
80-
81-
TypedValue visibleIcon = new TypedValue();
82-
TypedValue slightlyVisibleIcon = new TypedValue();
83-
84-
getResources().getValue(R.dimen.visible_icon, visibleIcon, true);
85-
getResources().getValue(R.dimen.slightly_visible_icon, slightlyVisibleIcon, true);
86-
87-
mPasswordEditText = (EditText) findViewById(R.id.password);
88-
ImageView togglePasswordImage = (ImageView) findViewById(R.id.toggle_visibility);
89-
90-
mPasswordEditText.setOnFocusChangeListener(new ImageFocusTransparencyChanger(
91-
togglePasswordImage,
92-
visibleIcon.getFloat(),
93-
slightlyVisibleIcon.getFloat()));
94-
95-
togglePasswordImage.setOnClickListener(new PasswordToggler(mPasswordEditText));
96-
9777
mNameEditText = (EditText) findViewById(R.id.name);
78+
mPasswordEditText = (EditText) findViewById(R.id.password);
9879

99-
mPasswordFieldValidator = new PasswordFieldValidator((TextInputLayout)
100-
findViewById(R.id.password_layout),
80+
mPasswordFieldValidator = new PasswordFieldValidator(
81+
(TextInputLayout) findViewById(R.id.password_layout),
10182
getResources().getInteger(R.integer.min_password_length));
10283
mNameValidator = new RequiredFieldValidator((TextInputLayout) findViewById(R.id.name_layout));
10384
mEmailFieldValidator = new EmailFieldValidator((TextInputLayout) findViewById(R.id.email_layout));
10485

86+
String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
10587
if (email != null) {
10688
mEmailEditText.setText(email);
10789
mEmailEditText.setEnabled(false);

auth/src/main/java/com/firebase/ui/auth/ui/email/SignInActivity.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
import android.support.annotation.NonNull;
2121
import android.support.annotation.Nullable;
2222
import android.support.design.widget.TextInputLayout;
23-
import android.util.TypedValue;
2423
import android.view.View;
2524
import android.widget.Button;
2625
import android.widget.EditText;
27-
import android.widget.ImageView;
2826
import android.widget.TextView;
2927

3028
import com.firebase.ui.auth.R;
@@ -60,34 +58,17 @@ protected void onCreate(Bundle savedInstanceState) {
6058

6159
mSaveSmartLock = mActivityHelper.getSaveSmartLockInstance();
6260

63-
String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
64-
6561
mEmailEditText = (EditText) findViewById(R.id.email);
66-
67-
TypedValue visibleIcon = new TypedValue();
68-
TypedValue slightlyVisibleIcon = new TypedValue();
69-
70-
getResources().getValue(R.dimen.visible_icon, visibleIcon, true);
71-
getResources().getValue(R.dimen.slightly_visible_icon, slightlyVisibleIcon, true);
72-
7362
mPasswordEditText = (EditText) findViewById(R.id.password);
74-
ImageView togglePasswordImage = (ImageView) findViewById(R.id.toggle_visibility);
75-
76-
mPasswordEditText.setOnFocusChangeListener(new ImageFocusTransparencyChanger(
77-
togglePasswordImage,
78-
visibleIcon.getFloat(),
79-
slightlyVisibleIcon.getFloat()));
80-
81-
togglePasswordImage.setOnClickListener(new PasswordToggler(mPasswordEditText));
82-
8363
mEmailValidator = new EmailFieldValidator((TextInputLayout) findViewById(R.id.email_layout));
8464
mPasswordValidator = new RequiredFieldValidator((TextInputLayout) findViewById(R.id.password_layout));
85-
Button signInButton = (Button) findViewById(R.id.button_done);
86-
TextView recoveryButton = (TextView) findViewById(R.id.trouble_signing_in);
8765

66+
String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
8867
if (email != null) {
8968
mEmailEditText.setText(email);
9069
}
70+
Button signInButton = (Button) findViewById(R.id.button_done);
71+
TextView recoveryButton = (TextView) findViewById(R.id.trouble_signing_in);
9172
signInButton.setOnClickListener(this);
9273
recoveryButton.setOnClickListener(this);
9374
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

auth/src/main/res/layout/register_email_layout.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
android:layout_height="wrap_content"
5858
android:paddingTop="224dp"
5959
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
60-
app:hintTextAppearance="@style/FirebaseUI.Text.HintText">
60+
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
61+
app:passwordToggleEnabled="true">
6162

6263
<android.support.design.widget.TextInputEditText
6364
style="@style/FirebaseUI.EditText.PasswordField"
@@ -67,15 +68,6 @@
6768

6869
</android.support.design.widget.TextInputLayout>
6970

70-
<ImageView
71-
style="@style/FirebaseUI.ImageView.VisibilityToggle"
72-
android:id="@+id/toggle_visibility"
73-
android:layout_alignEnd="@id/password_layout"
74-
android:paddingTop="242dp"
75-
android:layout_alignRight="@id/password_layout"
76-
android:contentDescription="@string/accessibility_toggle">
77-
</ImageView>
78-
7971
<TextView
8072
android:id="@+id/create_account_text"
8173
android:layout_height="wrap_content"

auth/src/main/res/layout/sign_in_layout.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,15 @@
3131
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
3232
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
3333
android:layout_width="match_parent"
34-
android:layout_height="wrap_content">
34+
android:layout_height="wrap_content"
35+
app:passwordToggleEnabled="true">
3536

3637
<android.support.design.widget.TextInputEditText
3738
style="@style/FirebaseUI.EditText.PasswordField"
3839
android:id="@+id/password"/>
3940

4041
</android.support.design.widget.TextInputLayout>
4142

42-
<ImageView
43-
style="@style/FirebaseUI.ImageView.VisibilityToggle"
44-
android:id="@+id/toggle_visibility"
45-
android:layout_alignEnd="@id/password_layout"
46-
android:layout_alignRight="@id/password_layout"
47-
android:paddingTop="154dp"
48-
android:contentDescription="@string/accessibility_toggle">
49-
</ImageView>
50-
5143
<LinearLayout
5244
android:layout_height="wrap_content"
5345
android:layout_width="match_parent"

auth/src/main/res/layout/welcome_back_password_prompt_layout.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
2929
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
3030
android:layout_width="match_parent"
31-
android:layout_height="wrap_content">
31+
android:layout_height="wrap_content"
32+
app:passwordToggleEnabled="true">
3233

3334
<android.support.design.widget.TextInputEditText
3435
style="@style/FirebaseUI.EditText.PasswordField"
@@ -37,14 +38,6 @@
3738

3839
</android.support.design.widget.TextInputLayout>
3940

40-
<ImageView
41-
style="@style/FirebaseUI.ImageView.VisibilityToggle"
42-
android:id="@+id/toggle_visibility"
43-
android:paddingTop="34dp"
44-
android:layout_alignEnd="@id/password_layout"
45-
android:layout_alignRight="@id/password_layout"
46-
android:contentDescription="@string/accessibility_toggle"/>
47-
4841
</RelativeLayout>
4942

5043
<LinearLayout

auth/src/main/res/values/styles.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@
143143
<item name="android:inputType">textPassword</item>
144144
</style>
145145

146-
<style name="FirebaseUI.ImageView"/>
147-
148-
<style name="FirebaseUI.ImageView.VisibilityToggle">
149-
<item name="android:layout_marginBottom">12dp</item>
150-
<item name="android:layout_marginRight">4dp</item>
151-
<item name="android:layout_height">wrap_content</item>
152-
<item name="android:layout_width">wrap_content</item>
153-
<item name="android:src">@drawable/ic_visibility_black_24dp</item>
154-
</style>
155-
156146
<style name="FirebaseUI.Text.Link">
157147
<item name="android:textColor">@color/linkColor</item>
158148
</style>

auth/src/main/res/values/values.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<integer name="min_password_length">6</integer>
4-
<item name="visible_icon" type="dimen" format="float">1.0</item>
5-
<item name="slightly_visible_icon" type="dimen" format="float">0.4</item>
64
</resources>

0 commit comments

Comments
 (0)