Skip to content

Commit 2f95e75

Browse files
Aaron MandleGerrit Code Review
authored andcommitted
Merge "Terms of service URL and minor UI polish pt.3"
2 parents 61c5985 + 1b09adf commit 2f95e75

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed

auth/src/main/java/com/firebase/ui/auth/AuthFlowFactory.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ public static Intent createIntent(
4545
@NonNull String appName,
4646
@NonNull String apiaryKey,
4747
@NonNull String applicationId,
48+
String termsOfServiceUrl,
4849
int theme,
4950
@Nullable List<String> providers) {
5051
ArrayList<IDPProviderParcel> providerParcels = new ArrayList<>();
5152
if (providers == null || providers.size() == 0) {
5253
return CredentialsInitActivity.createIntent(
53-
context,appName, providerParcels, apiaryKey, applicationId, theme);
54+
context,
55+
appName,
56+
providerParcels,
57+
apiaryKey,
58+
applicationId,
59+
termsOfServiceUrl,
60+
theme
61+
);
5462
}
5563

5664
for (String provider : providers) {
@@ -63,6 +71,13 @@ public static Intent createIntent(
6371
}
6472
}
6573
return CredentialsInitActivity.createIntent(
66-
context,appName, providerParcels, apiaryKey, applicationId, theme);
74+
context,
75+
appName,
76+
providerParcels,
77+
apiaryKey,
78+
applicationId,
79+
termsOfServiceUrl,
80+
theme
81+
);
6782
}
6883
}

auth/src/main/java/com/firebase/ui/auth/choreographer/ControllerConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ControllerConstants {
2525
public static final String EXTRA_APPLICATION_ID = "extra_application_id";
2626
public static final String EXTRA_APIARY_KEY = "extra_apiary_key";
2727
public static final String EXTRA_SUCCESS = "success_extra";
28+
public static final String EXTRA_TERMS_OF_SERVICE_URL = "extra_tos_url";
2829
public static final String EXTRA_ID_TOKEN = "extra_id_token";
2930
public static final String EXTRA_RESTORE_PASSWORD_FLAG = "extra_restore_password_flag";
3031
public static final String EXTRA_HINT_INTENT = "hintIntent";

auth/src/main/java/com/firebase/ui/auth/ui/BaseActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ public abstract class BaseActivity extends android.support.v7.app.AppCompatActiv
3838

3939
protected int mId;
4040
protected String mAppName;
41+
protected String mTermsOfServiceUrl;
4142
protected AtomicBoolean isPendingFinishing = new AtomicBoolean(false);
4243

4344
@Override
4445
protected void onCreate(Bundle savedInstanceState) {
4546
super.onCreate(savedInstanceState);
4647
Intent previousIntent = getIntent();
4748
mAppName = getIntent().getStringExtra(ControllerConstants.EXTRA_APP_NAME);
49+
mTermsOfServiceUrl = getIntent().getStringExtra(ControllerConstants.EXTRA_TERMS_OF_SERVICE_URL);
4850
mId = previousIntent.getIntExtra(EXTRA_ID, Controller.DEFAULT_INIT_FLOW_ID);
4951
mController = setUpController();
5052
}
@@ -113,13 +115,21 @@ protected void doAction(Action action) {
113115
} else if (action.getNextId() == Controller.START_NEW_FLOW_ID) {
114116
Intent newFlowIntent = action.getNextIntent();
115117
newFlowIntent.putExtra(ControllerConstants.EXTRA_APP_NAME, mAppName);
118+
newFlowIntent.putExtra(
119+
ControllerConstants.EXTRA_TERMS_OF_SERVICE_URL,
120+
mTermsOfServiceUrl
121+
);
116122
this.startActivityForResult(newFlowIntent, NEXT_FLOW);
117123
return;
118124
}
119125
if (action.hasNextAction()) {
120126
this.startActivity(action.getNextIntent()
121127
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
122128
.putExtra(ControllerConstants.EXTRA_APP_NAME, mAppName)
129+
.putExtra(
130+
ControllerConstants.EXTRA_TERMS_OF_SERVICE_URL,
131+
mTermsOfServiceUrl
132+
)
123133
.putExtra(EXTRA_ID, action.getNextId()));
124134
} else {
125135
this.setResult(action.getFinishResultCode(), action.getFinishData());

auth/src/main/java/com/firebase/ui/auth/ui/credentials/CredentialsInitActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ public void onCreate(Bundle savedInstance) {
5656

5757
public static Intent createIntent(
5858
Context context, String appName, ArrayList<IDPProviderParcel> parcels, String
59-
apiaryKey, String applicationId, int theme) {
59+
apiaryKey, String applicationId, String termsOfServiceUrl, int theme) {
6060
return new Intent()
6161
.setClass(context, CredentialsInitActivity.class)
6262
.putExtra(EXTRA_ID, CredentialsController.ID_INIT)
6363
.putExtra(ControllerConstants.EXTRA_APP_NAME, appName)
6464
.putExtra(ControllerConstants.EXTRA_APIARY_KEY, apiaryKey)
6565
.putExtra(ControllerConstants.EXTRA_APPLICATION_ID, applicationId)
66+
.putExtra(ControllerConstants.EXTRA_TERMS_OF_SERVICE_URL, termsOfServiceUrl)
6667
.putParcelableArrayListExtra(ControllerConstants.EXTRA_PROVIDERS, parcels)
6768
.putExtra(ControllerConstants.EXTRA_THEME, theme);
6869
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.firebase.ui.auth.ui.email;
1616

1717
import android.content.Intent;
18+
import android.net.Uri;
1819
import android.os.Bundle;
1920
import android.support.design.widget.TextInputLayout;
2021
import android.support.v4.content.ContextCompat;
@@ -94,6 +95,9 @@ protected void onCreate(Bundle savedInstanceState) {
9495
}
9596

9697
private void setUpTermsOfService() {
98+
if (mTermsOfServiceUrl == null) {
99+
return;
100+
}
97101
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ContextCompat.getColor
98102
(getApplicationContext(), R.color.linkColor));
99103

@@ -104,6 +108,14 @@ private void setUpTermsOfService() {
104108
spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0);
105109
TextView agreementText = (TextView) findViewById(R.id.create_account_text);
106110
agreementText.setText(spannableStringBuilder);
111+
agreementText.setOnClickListener(new View.OnClickListener() {
112+
@Override
113+
public void onClick(View view) {
114+
Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse
115+
(mTermsOfServiceUrl));
116+
startActivity(intent);
117+
}
118+
});
107119
}
108120

109121
@Override

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@
8383
android:id="@+id/create_account_text"
8484
android:layout_height="wrap_content"
8585
android:layout_width="match_parent"
86-
android:paddingTop="336dp"
86+
android:layout_marginTop="336dp"
8787
style="@style/FirebaseUI.Text.BodyText"
88-
android:text="@string/create_account_preamble"
8988
/>
9089

9190

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
android:id="@+id/password_layout"
2222
xmlns:app="http://schemas.android.com/apk/res-auto"
2323
style="@style/FirebaseUI.Text.TextInputLayout"
24-
android:paddingTop="136dp"
24+
android:paddingTop="16dp"
2525
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
2626
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
2727
android:layout_width="match_parent"
@@ -37,7 +37,7 @@
3737
<ImageView
3838
style="@style/FirebaseUI.ImageView.VisibilityToggle"
3939
android:id="@+id/toggle_visibility"
40-
android:paddingTop="154dp"
40+
android:paddingTop="34dp"
4141
android:layout_alignEnd="@id/password_layout"
4242
android:layout_alignRight="@id/password_layout">
4343
</ImageView>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<color name="colorPrimaryDark">#2F3E9E</color>
55
<color name="colorAccent">#3E50B4</color>
66
<color name="headingColor">#212121</color>
7-
<color name="bodyTextColor">#757575</color>
7+
<color name="bodyTextColor">#c0000000</color>
88
<color name="errorColor">#DD2C00</color>
99
<color name="linkColor">#4285F4</color>
1010
<color name="buttonColor">@color/colorPrimary</color>

0 commit comments

Comments
 (0)