Skip to content

Commit 86ff10c

Browse files
Iain McGinnissGerrit Code Review
authored andcommitted
Merge "Move config strings into their own XML file, with basic docs"
2 parents 3cf7647 + e4378ff commit 86ff10c

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
public class AuthUiActivity extends Activity {
4141

42+
private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME";
43+
4244
private static final String GOOGLE_TOS_URL =
4345
"https://www.google.com/policies/terms/";
4446
private static final String FIREBASE_TOS_URL =
@@ -88,6 +90,22 @@ public void onCreate(Bundle savedInstanceState) {
8890

8991
setContentView(R.layout.auth_ui_layout);
9092
ButterKnife.bind(this);
93+
94+
if (!isGoogleConfigured()) {
95+
mUseGoogleProvider.setChecked(false);
96+
mUseGoogleProvider.setEnabled(false);
97+
mUseGoogleProvider.setText(R.string.google_label_missing_config);
98+
}
99+
100+
if (!isFacebookConfigured()) {
101+
mUseFacebookProvider.setChecked(false);
102+
mUseFacebookProvider.setEnabled(false);
103+
mUseFacebookProvider.setText(R.string.facebook_label_missing_config);
104+
}
105+
106+
if (!isGoogleConfigured() || !isFacebookConfigured()) {
107+
showSnackbar(R.string.configuration_required);
108+
}
91109
}
92110

93111
@OnClick(R.id.sign_in)
@@ -170,10 +188,21 @@ private String getSelectedTosUrl() {
170188
return FIREBASE_TOS_URL;
171189
}
172190

191+
@MainThread
192+
private boolean isGoogleConfigured() {
193+
return !UNCHANGED_CONFIG_VALUE.equals(
194+
getResources().getString(R.string.default_web_client_id));
195+
}
196+
197+
@MainThread
198+
private boolean isFacebookConfigured() {
199+
return !UNCHANGED_CONFIG_VALUE.equals(
200+
getResources().getString(R.string.facebook_application_id));
201+
}
202+
173203
@MainThread
174204
private void showSnackbar(@StringRes int errorMessageRes) {
175-
Snackbar.make(mRootView, errorMessageRes, Snackbar.LENGTH_LONG)
176-
.show();
205+
Snackbar.make(mRootView, errorMessageRes, Snackbar.LENGTH_LONG).show();
177206
}
178207

179208
public static Intent createIntent(Context context) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
<!--
3+
The Facebook Application ID associated with this Android application. To
4+
use Facebook accounts with the demo application, register an application
5+
and provide your value here.
6+
-->
7+
<string name="facebook_application_id" translatable="false">CHANGE-ME</string>
8+
</resources>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
<!-- strings for Auth UI demo activities -->
1111
<eat-comment/>
12-
<string name="launch_title">Firebase Auth UI Demo</string>
12+
<string name="launch_title">FirebaseUI Auth Demo</string>
1313
<string name="sign_in">Start</string>
1414
<string name="green_theme">Green Theme</string>
1515
<string name="purple_theme">Purple Theme</string>
1616
<string name="use_theme_header">Use theme:</string>
1717
<string name="auth_providers_header">Use auth providers:</string>
1818
<string name="email_label">Email</string>
1919
<string name="facebook_label">Facebook</string>
20+
<string name="facebook_label_missing_config">Facebook - configuration missing</string>
2021
<string name="google_label">Google</string>
22+
<string name="google_label_missing_config">Google - configuration missing</string>
2123
<string name="google_tos_label">Google TOS</string>
2224
<string name="firebase_tos_label">Firebase TOS</string>
2325
<string name="tos_header">Terms of Service URL:</string>
@@ -33,4 +35,5 @@
3335
<string name="user_profile_header">User profile:</string>
3436
<string name="profile_picture_content_desc">Profile picture</string>
3537
<string name="default_theme">Default theme</string>
38+
<string name="configuration_required">Configuration is required - see README.md</string>
3639
</resources>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<resources>
2+
<!--
3+
The Facebook Application ID associated with this Android application. This
4+
must be overridden by users of FirebaseUI auth in order to support Facebook
5+
accounts in the authentication flow.
6+
7+
See:
8+
https://developers.facebook.com/docs/facebook-login/android
9+
-->
10+
<string name="facebook_application_id" translatable="false">CHANGE-ME</string>
11+
12+
<!--
13+
The Google web client ID associated with this Android application. The
14+
google-services gradle plugin will automatically provide this value.
15+
16+
See:
17+
https://developers.google.com/identity/sign-in/web/devconsole-project
18+
https://developers.google.com/android/guides/google-services-plugin
19+
-->
20+
<string name="default_web_client_id" translatable="false">CHANGE-ME</string>
21+
</resources>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,4 @@
6060
<string name="progress_dialog_sending">Sending…</string>
6161
<string name="progress_dialog_signing_in">Signing in…</string>
6262
<string name="progress_dialog_signing_up">Signing up…</string>
63-
<string name="facebook_application_id">FACEBOOK-APPID</string>
64-
<string name="default_web_client_id">GOOGLE-WEBCLIENT-ID</string>
6563
</resources>

0 commit comments

Comments
 (0)