Skip to content

Commit 33b47d7

Browse files
authored
Make auth_method_picker layout work in landscape (#562)
1 parent 11280c7 commit 33b47d7

File tree

7 files changed

+87
-25
lines changed

7 files changed

+87
-25
lines changed

auth/src/main/java/com/firebase/ui/auth/ui/idp/AuthMethodPickerActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ protected void onCreate(Bundle savedInstanceState) {
8080
populateIdpList(mActivityHelper.getFlowParams().providerInfo);
8181

8282
int logoId = mActivityHelper.getFlowParams().logoId;
83-
ImageView logo = (ImageView) findViewById(R.id.logo);
8483
if (logoId == AuthUI.NO_LOGO) {
85-
logo.setVisibility(View.GONE);
84+
findViewById(R.id.logo_layout).setVisibility(View.GONE);
8685
} else {
86+
ImageView logo = (ImageView) findViewById(R.id.logo);
8787
logo.setImageResource(logoId);
8888
}
8989
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:baselineAligned="false"
7+
android:clipChildren="false"
8+
android:clipToPadding="false"
9+
android:gravity="center|bottom"
10+
android:orientation="horizontal">
11+
12+
<include
13+
layout="@layout/include_auth_method_picker_logo"
14+
android:layout_width="0dp"
15+
android:layout_height="match_parent"
16+
android:layout_weight="1.0" />
17+
18+
<FrameLayout
19+
android:layout_width="0dp"
20+
android:layout_height="match_parent"
21+
android:layout_weight="1.0">
22+
23+
24+
<LinearLayout
25+
android:id="@+id/btn_holder"
26+
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder"
27+
android:layout_height="wrap_content"
28+
android:layout_gravity="center"
29+
android:paddingTop="@dimen/auth_method_button_marginBottom">
30+
31+
<Button
32+
android:id="@+id/email_provider"
33+
style="@style/FirebaseUI.Button.AccountChooser.EmailButton"
34+
android:text="@string/sign_in_with_email"
35+
android:visibility="gone"
36+
tools:visibility="visible" />
37+
38+
</LinearLayout>
39+
40+
</FrameLayout>
41+
42+
</LinearLayout>

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
android:layout_width="match_parent"
54
android:layout_height="match_parent"
5+
xmlns:tools="http://schemas.android.com/tools"
66
android:clipChildren="false"
77
android:clipToPadding="false"
88
android:gravity="center|bottom"
99
android:orientation="vertical">
1010

11-
<LinearLayout
12-
android:layout_width="match_parent"
13-
android:layout_height="match_parent"
14-
android:layout_weight="1.0"
15-
android:gravity="center">
16-
17-
<ImageView
18-
android:id="@+id/logo"
19-
style="@style/FirebaseUI.AuthMethodPicker.Logo"
20-
android:contentDescription="@string/accessibility_logo"/>
21-
22-
</LinearLayout>
11+
<include layout="@layout/include_auth_method_picker_logo" />
2312

2413
<LinearLayout
2514
android:id="@+id/btn_holder"
26-
android:layout_weight="0"
27-
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder">
15+
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder.Portrait"
16+
android:layout_height="wrap_content">
2817

2918
<Button
3019
android:id="@+id/email_provider"
3120
style="@style/FirebaseUI.Button.AccountChooser.EmailButton"
32-
android:text="@string/sign_in_with_email"/>
21+
android:text="@string/sign_in_with_email"
22+
android:visibility="gone"
23+
tools:visibility="visible"/>
3324

3425
</LinearLayout>
3526

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/logo_layout"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:layout_weight="1.0"
7+
android:gravity="center">
8+
9+
<ImageView
10+
android:id="@+id/logo"
11+
style="@style/FirebaseUI.AuthMethodPicker.Logo"
12+
android:contentDescription="@string/accessibility_logo" />
13+
14+
</LinearLayout>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<dimen name="auth_method_button_width">228dp</dimen>
4+
<dimen name="auth_method_button_marginBottom">24dp</dimen>
5+
<dimen name="auth_method_button_drawablePadding">20dp</dimen>
6+
</resources>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<dimen name="auth_method_button_width">208dp</dimen>
4+
<dimen name="auth_method_button_marginBottom">8dp</dimen>
5+
<dimen name="auth_method_button_drawablePadding">12dp</dimen>
6+
</resources>

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,30 +184,33 @@
184184
</style>
185185

186186
<style name="FirebaseUI.AuthMethodPicker.ButtonHolder">
187+
<item name="android:layout_width">@dimen/auth_method_button_width</item>
187188
<item name="android:orientation">vertical</item>
188-
<item name="android:paddingBottom">56dp</item>
189189
<item name="android:clipToPadding">false</item>
190-
<item name="android:layout_width">220dp</item>
191-
<item name="android:layout_height">wrap_content</item>
190+
<item name="android:paddingLeft">4dp</item>
191+
<item name="android:paddingRight">4dp</item>
192+
</style>
193+
194+
<style name="FirebaseUI.AuthMethodPicker.ButtonHolder.Portrait" parent="FirebaseUI.AuthMethodPicker.ButtonHolder">
195+
<item name="android:paddingBottom">56dp</item>
192196
</style>
193197

194198
<style name="FirebaseUI.Button.AccountChooser">
195199
<item name="android:layout_width">match_parent</item>
196200
<item name="android:layout_height">wrap_content</item>
197201
<item name="android:textAllCaps">false</item>
198-
<item name="android:drawablePadding">20dp</item>
202+
<item name="android:drawablePadding">@dimen/auth_method_button_drawablePadding</item>
199203
<item name="android:textStyle">bold</item>
200204
<item name="android:paddingLeft">12dp</item>
201205
<item name="android:paddingRight">12dp</item>
202-
<item name="android:layout_marginBottom">24dp</item>
206+
<item name="android:layout_marginBottom">@dimen/auth_method_button_marginBottom</item>
203207
<item name="android:layout_gravity">left</item>
204208
<item name="android:gravity">left|center_vertical</item>
205209
<item name="android:typeface">normal</item>
206210
</style>
207211

208212
<style name="FirebaseUI.Button.AccountChooser.EmailButton">
209213
<item name="android:drawableLeft">@drawable/ic_mail_white_24dp</item>
210-
<item name="android:visibility">gone</item>
211214
<item name="android:background">@drawable/idp_button_background_email</item>
212215
<item name="android:textColor">#ffffff</item>
213216
</style>

0 commit comments

Comments
 (0)