Skip to content

Commit 7395e6d

Browse files
SUPERCILEXsamtstern
authored andcommitted
Rewrite layouts (#1016)
1 parent 0f79011 commit 7395e6d

25 files changed

+267
-259
lines changed

auth/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
<activity
3030
android:name=".ui.email.RegisterEmailActivity"
3131
android:label="@string/fui_sign_in_default"
32-
android:exported="false" />
32+
android:exported="false"
33+
android:windowSoftInputMode="adjustResize" />
3334

3435
<activity
3536
android:name=".ui.phone.PhoneVerificationActivity"
3637
android:label="@string/fui_sign_in_with_phone_number"
3738
android:exported="false"
38-
android:windowSoftInputMode="stateAlwaysVisible" />
39+
android:windowSoftInputMode="adjustResize|stateAlwaysVisible" />
3940

4041
<activity
4142
android:name=".ui.accountlink.WelcomeBackIdpPrompt"
@@ -45,7 +46,8 @@
4546
<activity
4647
android:name=".ui.accountlink.WelcomeBackPasswordPrompt"
4748
android:label="@string/fui_title_welcome_back_password_prompt"
48-
android:exported="false" />
49+
android:exported="false"
50+
android:windowSoftInputMode="adjustResize" />
4951

5052
<activity
5153
android:name=".ui.idp.AuthMethodPickerActivity"

auth/src/main/java/com/firebase/ui/auth/ui/phone/VerifyPhoneNumberFragment.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.support.annotation.NonNull;
2323
import android.support.annotation.Nullable;
2424
import android.support.annotation.RestrictTo;
25+
import android.support.design.widget.TextInputLayout;
2526
import android.support.v4.app.FragmentActivity;
2627
import android.text.TextUtils;
2728
import android.util.Log;
@@ -59,8 +60,8 @@ public class VerifyPhoneNumberFragment extends FragmentBase implements View.OnCl
5960
private Context mAppContext;
6061

6162
private CountryListSpinner mCountryListSpinner;
63+
private TextInputLayout mPhoneInputLayout;
6264
private EditText mPhoneEditText;
63-
private TextView mErrorEditText;
6465
private Button mSendCodeButton;
6566
private PhoneVerificationActivity mVerifier;
6667
private TextView mSmsTermsText;
@@ -91,8 +92,8 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
9192
View v = inflater.inflate(R.layout.fui_phone_layout, container, false);
9293

9394
mCountryListSpinner = v.findViewById(R.id.country_list);
95+
mPhoneInputLayout = v.findViewById(R.id.phone_layout);
9496
mPhoneEditText = v.findViewById(R.id.phone_number);
95-
mErrorEditText = v.findViewById(R.id.phone_number_error);
9697
mSendCodeButton = v.findViewById(R.id.send_code);
9798
mSmsTermsText = v.findViewById(R.id.send_sms_tos);
9899

@@ -195,7 +196,7 @@ public void onClick(View v) {
195196
private void onNext() {
196197
String phoneNumber = getPseudoValidPhoneNumber();
197198
if (phoneNumber == null) {
198-
mErrorEditText.setText(R.string.fui_invalid_phone_number);
199+
mPhoneInputLayout.setError(getString(R.string.fui_invalid_phone_number));
199200
} else {
200201
mVerifier.verifyPhoneNumber(phoneNumber, false);
201202
}
@@ -218,7 +219,7 @@ private void setupCountrySpinner() {
218219
mCountryListSpinner.setOnClickListener(new View.OnClickListener() {
219220
@Override
220221
public void onClick(View v) {
221-
mErrorEditText.setText("");
222+
mPhoneInputLayout.setError(null);
222223
}
223224
});
224225
}
@@ -276,6 +277,6 @@ private void setCountryCode(PhoneNumber phoneNumber) {
276277
}
277278

278279
void showError(String e) {
279-
mErrorEditText.setText(e);
280+
mPhoneInputLayout.setError(e);
280281
}
281282
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.firebase.ui.auth.util.ui;
2+
3+
import android.content.Context;
4+
import android.support.design.widget.TextInputLayout;
5+
import android.util.AttributeSet;
6+
import android.widget.EditText;
7+
8+
public class BaselineTextInputLayout extends TextInputLayout {
9+
public BaselineTextInputLayout(Context context) {
10+
super(context);
11+
}
12+
13+
public BaselineTextInputLayout(Context context, AttributeSet attrs) {
14+
super(context, attrs);
15+
}
16+
17+
public BaselineTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
18+
super(context, attrs, defStyleAttr);
19+
}
20+
21+
@Override
22+
public int getBaseline() {
23+
EditText text = getEditText();
24+
return text == null ? super.getBaseline() : text.getPaddingTop() + text.getBaseline();
25+
}
26+
}

auth/src/main/java/com/firebase/ui/auth/ui/idp/SupportVectorDrawablesButton.java renamed to auth/src/main/java/com/firebase/ui/auth/util/ui/SupportVectorDrawablesButton.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package com.firebase.ui.auth.ui.idp;
1+
package com.firebase.ui.auth.util.ui;
22

33
import android.content.Context;
44
import android.content.res.TypedArray;
55
import android.graphics.drawable.Drawable;
66
import android.os.Build;
7+
import android.support.v4.widget.TextViewCompat;
78
import android.support.v7.content.res.AppCompatResources;
89
import android.support.v7.widget.AppCompatButton;
910
import android.util.AttributeSet;
@@ -84,13 +85,8 @@ private void initSupportVectorDrawablesAttrs(AttributeSet attrs) {
8485
}
8586
}
8687

87-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
88-
setCompoundDrawablesRelativeWithIntrinsicBounds(
89-
drawableStart, drawableTop, drawableEnd, drawableBottom);
90-
} else {
91-
setCompoundDrawablesWithIntrinsicBounds(
92-
drawableStart, drawableTop, drawableEnd, drawableBottom);
93-
}
88+
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
89+
this, drawableStart, drawableTop, drawableEnd, drawableBottom);
9490

9591
attributeArray.recycle();
9692
}

auth/src/main/res/layout-land/fui_auth_method_picker_layout.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<ImageView
1313
android:id="@+id/logo"
1414
style="@style/FirebaseUI.AuthMethodPicker.Logo"
15-
app:layout_constraintLeft_toLeftOf="parent"
16-
app:layout_constraintRight_toLeftOf="@id/container"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintEnd_toStartOf="@id/container"
1717
app:layout_constraintTop_toTopOf="parent"
1818
app:layout_constraintBottom_toBottomOf="parent"
1919
tools:ignore="ContentDescription" /> <!-- TODO remove once the bug is fixed: https://issuetracker.google.com/issues/38281866-->
@@ -22,8 +22,8 @@
2222
android:id="@+id/container"
2323
android:layout_width="wrap_content"
2424
android:layout_height="wrap_content"
25-
app:layout_constraintLeft_toLeftOf="parent"
26-
app:layout_constraintRight_toRightOf="parent"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintEnd_toEndOf="parent"
2727
app:layout_constraintTop_toTopOf="parent"
2828
app:layout_constraintBottom_toBottomOf="parent"
2929
app:layout_constraintHorizontal_bias="0.9">
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout
2+
<FrameLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:id="@+id/fragment_register_email"
46
android:layout_width="match_parent"
57
android:layout_height="match_parent"
6-
android:orientation="vertical">
7-
8-
<FrameLayout
9-
android:id="@+id/fragment_register_email"
10-
android:layout_width="match_parent"
11-
android:layout_height="wrap_content" />
12-
13-
</LinearLayout>
8+
tools:ignore="MergeRootFrame" />

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
<ImageView
1313
android:id="@+id/logo"
1414
style="@style/FirebaseUI.AuthMethodPicker.Logo"
15-
app:layout_constraintLeft_toLeftOf="parent"
16-
app:layout_constraintRight_toRightOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintEnd_toEndOf="parent"
1717
app:layout_constraintTop_toTopOf="parent"
18-
app:layout_constraintBottom_toTopOf="@+id/container"
18+
app:layout_constraintBottom_toTopOf="@id/container"
1919
tools:ignore="ContentDescription" /> <!-- TODO remove once the bug is fixed: https://issuetracker.google.com/issues/38281866-->
2020

2121
<ScrollView
2222
android:id="@+id/container"
2323
android:layout_width="wrap_content"
2424
android:layout_height="wrap_content"
25-
app:layout_constraintLeft_toLeftOf="parent"
26-
app:layout_constraintRight_toRightOf="parent"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintEnd_toEndOf="parent"
2727
app:layout_constraintTop_toTopOf="parent"
2828
app:layout_constraintBottom_toBottomOf="parent"
2929
app:layout_constraintVertical_bias="0.9">
Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
2+
<ScrollView
33
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
45
xmlns:tools="http://schemas.android.com/tools"
5-
style="@style/FirebaseUI.WrapperStyle"
66
android:layout_width="match_parent"
7-
android:layout_height="wrap_content">
7+
android:layout_height="match_parent">
88

9-
<android.support.design.widget.TextInputLayout
10-
android:id="@+id/email_layout"
11-
style="@style/FirebaseUI.TextInputLayout.EmailField"
12-
android:layout_width="match_parent"
9+
<LinearLayout
10+
style="@style/FirebaseUI.WrapperStyle"
1311
android:layout_height="wrap_content"
14-
android:paddingTop="16dp"
15-
android:transitionGroup="true"
16-
android:transitionName="email_field"
17-
tools:ignore="UnusedAttribute">
12+
android:orientation="vertical">
1813

19-
<android.support.design.widget.TextInputEditText
20-
android:id="@+id/email"
21-
style="@style/FirebaseUI.TextInputEditText.EmailField" />
14+
<android.support.design.widget.TextInputLayout
15+
android:id="@+id/email_layout"
16+
style="@style/FirebaseUI.TextInputLayout.EmailField"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:layout_marginTop="@dimen/fui_field_padding_vert"
20+
android:transitionGroup="true"
21+
android:transitionName="email_field"
22+
app:errorEnabled="true"
23+
tools:ignore="UnusedAttribute">
2224

23-
</android.support.design.widget.TextInputLayout>
25+
<android.support.design.widget.TextInputEditText
26+
android:id="@+id/email"
27+
style="@style/FirebaseUI.TextInputEditText.EmailField" />
2428

25-
<Button
26-
android:id="@+id/button_next"
27-
style="@style/FirebaseUI.Button"
28-
android:layout_alignParentEnd="true"
29-
android:layout_alignParentRight="true"
30-
android:layout_below="@id/email_layout"
31-
android:text="@string/fui_next_default" />
29+
</android.support.design.widget.TextInputLayout>
3230

33-
</RelativeLayout>
31+
<Button
32+
android:id="@+id/button_next"
33+
style="@style/FirebaseUI.Button"
34+
android:text="@string/fui_next_default" />
35+
36+
</LinearLayout>
37+
38+
</ScrollView>

0 commit comments

Comments
 (0)