|
16 | 16 |
|
17 | 17 | import android.content.Context;
|
18 | 18 | import android.content.Intent;
|
| 19 | +import android.os.Build; |
19 | 20 | import android.os.Bundle;
|
20 | 21 | import android.util.Log;
|
21 | 22 | import android.view.View;
|
@@ -108,6 +109,7 @@ public class AuthUiActivity extends AppCompatActivity {
|
108 | 109 | @BindView(R.id.hint_selector_enabled) CheckBox mEnableHintSelector;
|
109 | 110 | @BindView(R.id.allow_new_email_accounts) CheckBox mAllowNewEmailAccounts;
|
110 | 111 | @BindView(R.id.require_name) CheckBox mRequireName;
|
| 112 | + @BindView(R.id.use_auth_emulator) CheckBox mUseEmulator; |
111 | 113 |
|
112 | 114 | @NonNull
|
113 | 115 | public static Intent createIntent(@NonNull Context context) {
|
@@ -188,6 +190,17 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
188 | 190 | }
|
189 | 191 | });
|
190 | 192 |
|
| 193 | + // useEmulator can't be reversed until the FirebaseApp is cleared, so we make this |
| 194 | + // checkbox "sticky" until the app is restarted |
| 195 | + mUseEmulator.setOnCheckedChangeListener(new OnCheckedChangeListener() { |
| 196 | + @Override |
| 197 | + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| 198 | + if (isChecked) { |
| 199 | + mUseEmulator.setEnabled(false); |
| 200 | + } |
| 201 | + } |
| 202 | + }); |
| 203 | + |
191 | 204 | if (ConfigurationUtils.isGoogleMisconfigured(this)
|
192 | 205 | || ConfigurationUtils.isFacebookMisconfigured(this)) {
|
193 | 206 | showSnackbar(R.string.configuration_required);
|
@@ -231,9 +244,19 @@ public void signInWithEmailLink(@Nullable String link) {
|
231 | 244 | startActivityForResult(buildSignInIntent(link), RC_SIGN_IN);
|
232 | 245 | }
|
233 | 246 |
|
| 247 | + @NonNull |
| 248 | + public AuthUI getAuthUI() { |
| 249 | + AuthUI authUI = AuthUI.getInstance(); |
| 250 | + if (mUseEmulator.isChecked()) { |
| 251 | + authUI.useEmulator("10.0.2.2", 9099); |
| 252 | + } |
| 253 | + |
| 254 | + return authUI; |
| 255 | + } |
| 256 | + |
234 | 257 | @NonNull
|
235 | 258 | public Intent buildSignInIntent(@Nullable String link) {
|
236 |
| - AuthUI.SignInIntentBuilder builder = AuthUI.getInstance().createSignInIntentBuilder() |
| 259 | + AuthUI.SignInIntentBuilder builder = getAuthUI().createSignInIntentBuilder() |
237 | 260 | .setTheme(getSelectedTheme())
|
238 | 261 | .setLogo(getSelectedLogo())
|
239 | 262 | .setAvailableProviders(getSelectedProviders())
|
@@ -273,7 +296,7 @@ public Intent buildSignInIntent(@Nullable String link) {
|
273 | 296 |
|
274 | 297 | @OnClick(R.id.sign_in_silent)
|
275 | 298 | public void silentSignIn() {
|
276 |
| - AuthUI.getInstance().silentSignIn(this, getSelectedProviders()) |
| 299 | + getAuthUI().silentSignIn(this, getSelectedProviders()) |
277 | 300 | .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
278 | 301 | @Override
|
279 | 302 | public void onComplete(@NonNull Task<AuthResult> task) {
|
@@ -348,8 +371,10 @@ private void startSignedInActivity(@Nullable IdpResponse response) {
|
348 | 371 | public void toggleDarkTheme() {
|
349 | 372 | int mode = mDarkTheme.isChecked() ?
|
350 | 373 | AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
|
351 |
| - AppCompatDelegate.setDefaultNightMode(mode); |
352 |
| - getDelegate().setLocalNightMode(mode); |
| 374 | + if (Build.VERSION.SDK_INT >= 17) { |
| 375 | + AppCompatDelegate.setDefaultNightMode(mode); |
| 376 | + getDelegate().setLocalNightMode(mode); |
| 377 | + } |
353 | 378 | }
|
354 | 379 |
|
355 | 380 | @StyleRes
|
|
0 commit comments