Skip to content

Use support library password toggle #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.firebase.ui.auth.ui.ExtraConstants;
import com.firebase.ui.auth.ui.FlowParameters;
import com.firebase.ui.auth.ui.TaskFailureLogger;
import com.firebase.ui.auth.ui.email.PasswordToggler;
import com.firebase.ui.auth.ui.email.RecoverPasswordActivity;
import com.firebase.ui.auth.util.signincontainer.SaveSmartLock;
import com.google.android.gms.tasks.OnFailureListener;
Expand All @@ -58,7 +57,8 @@ public class WelcomeBackPasswordPrompt extends AppCompatBase implements View.OnC
private TextInputLayout mPasswordLayout;
private EditText mPasswordField;
private IdpResponse mIdpResponse;
@Nullable private SaveSmartLock mSaveSmartLock;
@Nullable
private SaveSmartLock mSaveSmartLock;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -76,15 +76,16 @@ protected void onCreate(Bundle savedInstanceState) {
bodyText = String.format(bodyText, mEmail);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
int emailStart = bodyText.indexOf(mEmail);
spannableStringBuilder.setSpan(BOLD, emailStart, emailStart + mEmail.length(), Spannable
.SPAN_INCLUSIVE_INCLUSIVE);
spannableStringBuilder.setSpan(BOLD,
emailStart,
emailStart + mEmail.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);

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

// Click listeners
findViewById(R.id.button_done).setOnClickListener(this);
findViewById(R.id.toggle_visibility).setOnClickListener(new PasswordToggler(mPasswordField));
findViewById(R.id.trouble_signing_in).setOnClickListener(this);
}

Expand Down Expand Up @@ -131,7 +132,8 @@ public void onSuccess(AuthResult authResult) {
// Sign in with the credential
firebaseAuth.signInWithCredential(authCredential)
.addOnFailureListener(
new TaskFailureLogger(TAG, "Error signing in with credential"))
new TaskFailureLogger(TAG,
"Error signing in with credential"))
.addOnSuccessListener(
new OnSuccessListener<AuthResult>() {
@Override
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import android.support.v4.content.ContextCompat;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

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

mSaveSmartLock = mActivityHelper.getSaveSmartLockInstance();

String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
mEmailEditText = (EditText) findViewById(R.id.email);

TypedValue visibleIcon = new TypedValue();
TypedValue slightlyVisibleIcon = new TypedValue();

getResources().getValue(R.dimen.visible_icon, visibleIcon, true);
getResources().getValue(R.dimen.slightly_visible_icon, slightlyVisibleIcon, true);

mPasswordEditText = (EditText) findViewById(R.id.password);
ImageView togglePasswordImage = (ImageView) findViewById(R.id.toggle_visibility);

mPasswordEditText.setOnFocusChangeListener(new ImageFocusTransparencyChanger(
togglePasswordImage,
visibleIcon.getFloat(),
slightlyVisibleIcon.getFloat()));

togglePasswordImage.setOnClickListener(new PasswordToggler(mPasswordEditText));

mNameEditText = (EditText) findViewById(R.id.name);
mPasswordEditText = (EditText) findViewById(R.id.password);

mPasswordFieldValidator = new PasswordFieldValidator((TextInputLayout)
findViewById(R.id.password_layout),
mPasswordFieldValidator = new PasswordFieldValidator(
(TextInputLayout) findViewById(R.id.password_layout),
getResources().getInteger(R.integer.min_password_length));
mNameValidator = new RequiredFieldValidator((TextInputLayout) findViewById(R.id.name_layout));
mEmailFieldValidator = new EmailFieldValidator((TextInputLayout) findViewById(R.id.email_layout));

String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
if (email != null) {
mEmailEditText.setText(email);
mEmailEditText.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

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

mSaveSmartLock = mActivityHelper.getSaveSmartLockInstance();

String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);

mEmailEditText = (EditText) findViewById(R.id.email);

TypedValue visibleIcon = new TypedValue();
TypedValue slightlyVisibleIcon = new TypedValue();

getResources().getValue(R.dimen.visible_icon, visibleIcon, true);
getResources().getValue(R.dimen.slightly_visible_icon, slightlyVisibleIcon, true);

mPasswordEditText = (EditText) findViewById(R.id.password);
ImageView togglePasswordImage = (ImageView) findViewById(R.id.toggle_visibility);

mPasswordEditText.setOnFocusChangeListener(new ImageFocusTransparencyChanger(
togglePasswordImage,
visibleIcon.getFloat(),
slightlyVisibleIcon.getFloat()));

togglePasswordImage.setOnClickListener(new PasswordToggler(mPasswordEditText));

mEmailValidator = new EmailFieldValidator((TextInputLayout) findViewById(R.id.email_layout));
mPasswordValidator = new RequiredFieldValidator((TextInputLayout) findViewById(R.id.password_layout));
Button signInButton = (Button) findViewById(R.id.button_done);
TextView recoveryButton = (TextView) findViewById(R.id.trouble_signing_in);

String email = getIntent().getStringExtra(ExtraConstants.EXTRA_EMAIL);
if (email != null) {
mEmailEditText.setText(email);
}
Button signInButton = (Button) findViewById(R.id.button_done);
TextView recoveryButton = (TextView) findViewById(R.id.trouble_signing_in);
signInButton.setOnClickListener(this);
recoveryButton.setOnClickListener(this);
}
Expand Down
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.
12 changes: 2 additions & 10 deletions auth/src/main/res/layout/register_email_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
android:layout_height="wrap_content"
android:paddingTop="224dp"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
app:hintTextAppearance="@style/FirebaseUI.Text.HintText">
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
app:passwordToggleEnabled="true">

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

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

<ImageView
style="@style/FirebaseUI.ImageView.VisibilityToggle"
android:id="@+id/toggle_visibility"
android:layout_alignEnd="@id/password_layout"
android:paddingTop="242dp"
android:layout_alignRight="@id/password_layout"
android:contentDescription="@string/accessibility_toggle">
</ImageView>

<TextView
android:id="@+id/create_account_text"
android:layout_height="wrap_content"
Expand Down
12 changes: 2 additions & 10 deletions auth/src/main/res/layout/sign_in_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,15 @@
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">

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

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

<ImageView
style="@style/FirebaseUI.ImageView.VisibilityToggle"
android:id="@+id/toggle_visibility"
android:layout_alignEnd="@id/password_layout"
android:layout_alignRight="@id/password_layout"
android:paddingTop="154dp"
android:contentDescription="@string/accessibility_toggle">
</ImageView>

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
Expand Down
11 changes: 2 additions & 9 deletions auth/src/main/res/layout/welcome_back_password_prompt_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">

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

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

<ImageView
style="@style/FirebaseUI.ImageView.VisibilityToggle"
android:id="@+id/toggle_visibility"
android:paddingTop="34dp"
android:layout_alignEnd="@id/password_layout"
android:layout_alignRight="@id/password_layout"
android:contentDescription="@string/accessibility_toggle"/>

</RelativeLayout>

<LinearLayout
Expand Down
10 changes: 0 additions & 10 deletions auth/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,6 @@
<item name="android:inputType">textPassword</item>
</style>

<style name="FirebaseUI.ImageView"/>

<style name="FirebaseUI.ImageView.VisibilityToggle">
<item name="android:layout_marginBottom">12dp</item>
<item name="android:layout_marginRight">4dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:src">@drawable/ic_visibility_black_24dp</item>
</style>

<style name="FirebaseUI.Text.Link">
<item name="android:textColor">@color/linkColor</item>
</style>
Expand Down
2 changes: 0 additions & 2 deletions auth/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="min_password_length">6</integer>
<item name="visible_icon" type="dimen" format="float">1.0</item>
<item name="slightly_visible_icon" type="dimen" format="float">0.4</item>
</resources>