Skip to content

Commit d1a92a2

Browse files
authored
Fix landscape NASCAR layout (#1460)
1 parent 63b0757 commit d1a92a2

File tree

7 files changed

+81
-66
lines changed

7 files changed

+81
-66
lines changed

app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@ public class AuthUiActivity extends AppCompatActivity {
8181
@BindView(R.id.google_logo) RadioButton mGoogleLogo;
8282
@BindView(R.id.no_logo) RadioButton mNoLogo;
8383

84-
@BindView(R.id.google_tos) RadioButton mUseGoogleTos;
85-
@BindView(R.id.firebase_tos) RadioButton mUseFirebaseTos;
86-
87-
@BindView(R.id.google_privacy) RadioButton mUseGooglePrivacyPolicy;
88-
@BindView(R.id.firebase_privacy) RadioButton mUseFirebasePrivacyPolicy;
84+
@BindView(R.id.google_tos_privacy) RadioButton mUseGoogleTosPp;
85+
@BindView(R.id.firebase_tos_privacy) RadioButton mUseFirebaseTosPp;
8986

9087
@BindView(R.id.google_scopes_header) TextView mGoogleScopesHeader;
9188
@BindView(R.id.google_scope_drive_file) CheckBox mGoogleScopeDriveFile;
@@ -180,17 +177,20 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
180177

181178
@OnClick(R.id.sign_in)
182179
public void signIn() {
183-
startActivityForResult(
184-
AuthUI.getInstance().createSignInIntentBuilder()
185-
.setTheme(getSelectedTheme())
186-
.setLogo(getSelectedLogo())
187-
.setAvailableProviders(getSelectedProviders())
188-
.setTosAndPrivacyPolicyUrls(getSelectedTosUrl(),
189-
getSelectedPrivacyPolicyUrl())
190-
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
191-
mEnableHintSelector.isChecked())
192-
.build(),
193-
RC_SIGN_IN);
180+
AuthUI.SignInIntentBuilder builder = AuthUI.getInstance().createSignInIntentBuilder()
181+
.setTheme(getSelectedTheme())
182+
.setLogo(getSelectedLogo())
183+
.setAvailableProviders(getSelectedProviders())
184+
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
185+
mEnableHintSelector.isChecked());
186+
187+
if (getSelectedTosUrl() != null && getSelectedPrivacyPolicyUrl() != null) {
188+
builder.setTosAndPrivacyPolicyUrls(
189+
getSelectedTosUrl(),
190+
getSelectedPrivacyPolicyUrl());
191+
}
192+
193+
startActivityForResult(builder.build(), RC_SIGN_IN);
194194
}
195195

196196
@OnClick(R.id.sign_in_silent)
@@ -328,20 +328,30 @@ private List<IdpConfig> getSelectedProviders() {
328328
return selectedProviders;
329329
}
330330

331+
@Nullable
331332
private String getSelectedTosUrl() {
332-
if (mUseGoogleTos.isChecked()) {
333+
if (mUseGoogleTosPp.isChecked()) {
333334
return GOOGLE_TOS_URL;
334335
}
335336

336-
return FIREBASE_TOS_URL;
337+
if (mUseFirebaseTosPp.isChecked()) {
338+
return FIREBASE_TOS_URL;
339+
}
340+
341+
return null;
337342
}
338343

344+
@Nullable
339345
private String getSelectedPrivacyPolicyUrl() {
340-
if (mUseGooglePrivacyPolicy.isChecked()) {
346+
if (mUseGoogleTosPp.isChecked()) {
341347
return GOOGLE_PRIVACY_POLICY_URL;
342348
}
343349

344-
return FIREBASE_PRIVACY_POLICY_URL;
350+
if (mUseFirebaseTosPp.isChecked()) {
351+
return FIREBASE_PRIVACY_POLICY_URL;
352+
}
353+
354+
return null;
345355
}
346356

347357
private void setGoogleScopesEnabled(boolean enabled) {

app/src/main/res/layout/auth_ui_layout.xml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,53 +182,30 @@
182182
android:layout_height="wrap_content"
183183
android:layout_marginTop="16dp"
184184
android:layout_marginBottom="8dp"
185-
android:text="@string/tos_header" />
185+
android:text="@string/tos_pp_header" />
186186

187187
<RadioGroup
188188
android:layout_width="wrap_content"
189189
android:layout_height="wrap_content"
190190
android:orientation="vertical">
191191

192192
<RadioButton
193-
android:id="@+id/google_tos"
193+
android:id="@+id/google_tos_privacy"
194194
android:layout_width="wrap_content"
195195
android:layout_height="wrap_content"
196196
android:checked="true"
197-
android:text="@string/tos_google" />
197+
android:text="@string/tos_pp_google" />
198198

199199
<RadioButton
200-
android:id="@+id/firebase_tos"
200+
android:id="@+id/firebase_tos_privacy"
201201
android:layout_width="wrap_content"
202202
android:layout_height="wrap_content"
203-
android:text="@string/tos_firebase" />
204-
205-
</RadioGroup>
206-
207-
<TextView
208-
style="@style/Base.TextAppearance.AppCompat.Subhead"
209-
android:layout_width="wrap_content"
210-
android:layout_height="wrap_content"
211-
android:layout_marginTop="16dp"
212-
android:layout_marginBottom="8dp"
213-
android:text="@string/pp_header" />
214-
215-
<RadioGroup
216-
android:layout_width="wrap_content"
217-
android:layout_height="wrap_content"
218-
android:orientation="vertical">
219-
220-
<RadioButton
221-
android:id="@+id/google_privacy"
222-
android:layout_width="wrap_content"
223-
android:layout_height="wrap_content"
224-
android:checked="true"
225-
android:text="@string/pp_google" />
203+
android:text="@string/tos_pp_firebase" />
226204

227205
<RadioButton
228-
android:id="@+id/firebase_privacy"
229206
android:layout_width="wrap_content"
230207
android:layout_height="wrap_content"
231-
android:text="@string/pp_firebase" />
208+
android:text="@string/tos_pp_none" />
232209

233210
</RadioGroup>
234211

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@
4040
<string name="logo_google">Google</string>
4141
<string name="logo_none">None</string>
4242

43-
<string name="tos_header">Terms of Service URL</string>
44-
<string name="tos_google">Google</string>
45-
<string name="tos_firebase">Firebase</string>
46-
47-
<string name="pp_header">Privacy Policy URL</string>
48-
<string name="pp_google">Google</string>
49-
<string name="pp_firebase">Firebase</string>
43+
<string name="tos_pp_header">Terms of Service and Privacy Policy</string>
44+
<string name="tos_pp_google">Google</string>
45+
<string name="tos_pp_firebase">Firebase</string>
46+
<string name="tos_pp_none">None</string>
5047

5148
<string name="google_scopes_header">Example extra Google scopes</string>
5249
<string name="google_scope_drive_file">Drive File</string>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ protected void onFailure(@NonNull Exception e) {
132132
PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(this,
133133
getFlowParams(),
134134
termsText);
135+
136+
// No ToS or PP provided, so we should hide the view entirely
137+
if (!getFlowParams().isPrivacyPolicyUrlProvided() &&
138+
!getFlowParams().isTermsOfServiceUrlProvided()) {
139+
termsText.setVisibility(View.GONE);
140+
}
135141
}
136142

137143
private void populateIdpList(List<IdpConfig> providerConfigs,

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@
1515
app:layout_constraintTop_toTopOf="parent"
1616
tools:visibility="visible" />
1717

18+
<!-- TODO remove lint ignore once the bug is fixed:
19+
https://issuetracker.google.com/issues/38281866-->
1820
<ImageView
1921
android:id="@+id/logo"
2022
style="@style/FirebaseUI.AuthMethodPicker.Logo"
23+
android:layout_marginTop="@dimen/fui_field_padding_vert"
24+
android:layout_marginBottom="@dimen/fui_field_padding_vert"
2125
app:layout_constraintStart_toStartOf="parent"
2226
app:layout_constraintEnd_toStartOf="@+id/container"
2327
app:layout_constraintTop_toTopOf="parent"
2428
app:layout_constraintBottom_toTopOf="@+id/main_tos_and_pp"
25-
tools:ignore="ContentDescription" /> <!-- TODO remove once the bug is fixed: https://issuetracker.google.com/issues/38281866-->
29+
app:layout_constraintVertical_weight="2"
30+
tools:background="#bfbfbf"
31+
tools:ignore="ContentDescription"
32+
tools:layout_height="100dp"
33+
tools:layout_width="100dp" />
2634

2735
<TextView
2836
android:id="@+id/main_tos_and_pp"
@@ -31,20 +39,23 @@
3139
android:layout_height="0dp"
3240
android:layout_marginLeft="@dimen/fui_wrapper_padding_horiz"
3341
android:layout_marginRight="@dimen/fui_wrapper_padding_horiz"
34-
android:layout_marginTop="@dimen/fui_field_padding_vert"
3542
android:layout_marginBottom="@dimen/fui_field_padding_vert"
3643
android:gravity="center"
3744
android:textColor="?android:attr/textColorTertiary"
3845
android:textIsSelectable="false"
3946
app:layout_constraintStart_toStartOf="parent"
4047
app:layout_constraintEnd_toStartOf="@+id/container"
4148
app:layout_constraintTop_toBottomOf="@+id/logo"
42-
app:layout_constraintBottom_toBottomOf="parent" />
49+
app:layout_constraintBottom_toBottomOf="parent"
50+
app:layout_constraintVertical_weight="1"
51+
tools:text="By continuing you are indicating that you accept our Terms of Service and Privacy Policy" />
4352

4453
<ScrollView
4554
android:id="@+id/container"
4655
android:layout_width="wrap_content"
47-
android:layout_height="wrap_content"
56+
android:layout_height="0dp"
57+
android:layout_marginTop="@dimen/fui_field_padding_vert"
58+
android:layout_marginBottom="@dimen/fui_field_padding_vert"
4859
app:layout_constraintStart_toStartOf="parent"
4960
app:layout_constraintEnd_toEndOf="parent"
5061
app:layout_constraintTop_toTopOf="parent"
@@ -53,7 +64,9 @@
5364

5465
<LinearLayout
5566
android:id="@+id/btn_holder"
56-
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder" />
67+
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder"
68+
tools:background="#bfbfbf"
69+
tools:layout_height="250dp" />
5770

5871
</ScrollView>
5972

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
app:layout_constraintTop_toTopOf="parent"
1515
tools:visibility="visible" />
1616

17+
<!-- TODO remove lint ignore once the bug is fixed:
18+
https://issuetracker.google.com/issues/38281866-->
1719
<ImageView
1820
android:id="@+id/logo"
1921
style="@style/FirebaseUI.AuthMethodPicker.Logo"
@@ -24,12 +26,16 @@
2426
app:layout_constraintTop_toTopOf="parent"
2527
app:layout_constraintBottom_toTopOf="@+id/container"
2628
app:layout_constraintVertical_weight="1"
27-
tools:ignore="ContentDescription" /> <!-- TODO remove once the bug is fixed: https://issuetracker.google.com/issues/38281866-->
29+
tools:background="#bfbfbf"
30+
tools:ignore="ContentDescription"
31+
tools:layout_height="100dp"
32+
tools:layout_width="100dp" />
2833

2934
<ScrollView
3035
android:id="@+id/container"
3136
android:layout_width="wrap_content"
3237
android:layout_height="0dp"
38+
android:layout_marginBottom="@dimen/fui_field_padding_vert"
3339
android:fillViewport="true"
3440
app:layout_constraintStart_toStartOf="parent"
3541
app:layout_constraintEnd_toEndOf="parent"
@@ -40,7 +46,9 @@
4046
<LinearLayout
4147
android:id="@+id/btn_holder"
4248
style="@style/FirebaseUI.AuthMethodPicker.ButtonHolder"
43-
android:gravity="bottom" />
49+
android:gravity="bottom"
50+
tools:background="#bfbfbf"
51+
tools:layout_height="250dp" />
4452

4553
</ScrollView>
4654

@@ -49,12 +57,16 @@
4957
style="@style/FirebaseUI.Text.BodyText"
5058
android:layout_width="wrap_content"
5159
android:layout_height="wrap_content"
52-
android:layout_marginTop="@dimen/fui_field_padding_vert"
60+
android:paddingStart="8dp"
61+
android:paddingEnd="8dp"
5362
android:layout_marginBottom="@dimen/fui_field_padding_vert"
5463
android:gravity="center"
5564
android:textColor="?android:textColorTertiary"
5665
android:textIsSelectable="true"
66+
app:layout_constraintStart_toStartOf="parent"
67+
app:layout_constraintEnd_toEndOf="parent"
5768
app:layout_constraintTop_toBottomOf="@+id/container"
58-
app:layout_constraintBottom_toBottomOf="parent" />
69+
app:layout_constraintBottom_toBottomOf="parent"
70+
tools:text="By continuing you are indicating that you accept our Terms of Service and Privacy Policy" />
5971

6072
</android.support.constraint.ConstraintLayout>

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Config {
1111
}
1212

1313
object Plugins {
14-
const val android = "com.android.tools.build:gradle:3.2.0-rc03"
14+
const val android = "com.android.tools.build:gradle:3.2.0"
1515
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1616
const val google = "com.google.gms:google-services:4.0.2"
1717

0 commit comments

Comments
 (0)