|
23 | 23 | import android.support.annotation.StyleRes; |
24 | 24 | import android.support.design.widget.Snackbar; |
25 | 25 | import android.support.v7.app.AppCompatActivity; |
| 26 | +import android.support.v7.app.AppCompatDelegate; |
26 | 27 | import android.view.View; |
27 | 28 | import android.widget.Button; |
28 | 29 | import android.widget.CheckBox; |
@@ -193,6 +194,10 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { |
193 | 194 | if (isGoogleMisconfigured() || isFacebookMisconfigured() || isTwitterMisconfigured()) { |
194 | 195 | showSnackbar(R.string.configuration_required); |
195 | 196 | } |
| 197 | + |
| 198 | + if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) { |
| 199 | + mUseDarkTheme.setChecked(true); |
| 200 | + } |
196 | 201 | } |
197 | 202 |
|
198 | 203 | @OnClick(R.id.sign_in) |
@@ -281,22 +286,26 @@ private void setFacebookScopesEnabled(boolean enabled) { |
281 | 286 | mFacebookScopePhotos.setEnabled(enabled); |
282 | 287 | } |
283 | 288 |
|
| 289 | + @OnClick({R.id.default_theme, R.id.purple_theme, R.id.green_theme, R.id.dark_theme}) |
| 290 | + public void toggleDarkTheme() { |
| 291 | + int mode = mUseDarkTheme.isChecked() ? |
| 292 | + AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_AUTO; |
| 293 | + AppCompatDelegate.setDefaultNightMode(mode); |
| 294 | + getDelegate().setLocalNightMode(mode); |
| 295 | + } |
| 296 | + |
284 | 297 | @MainThread |
285 | 298 | @StyleRes |
286 | 299 | private int getSelectedTheme() { |
287 | | - if (mUseDefaultTheme.isChecked()) { |
288 | | - return AuthUI.getDefaultTheme(); |
| 300 | + if (mUseGreenTheme.isChecked()) { |
| 301 | + return R.style.GreenTheme; |
289 | 302 | } |
290 | 303 |
|
291 | 304 | if (mUsePurpleTheme.isChecked()) { |
292 | 305 | return R.style.PurpleTheme; |
293 | 306 | } |
294 | 307 |
|
295 | | - if (mUseDarkTheme.isChecked()) { |
296 | | - return R.style.DarkTheme; |
297 | | - } |
298 | | - |
299 | | - return R.style.GreenTheme; |
| 308 | + return AuthUI.getDefaultTheme(); |
300 | 309 | } |
301 | 310 |
|
302 | 311 | @MainThread |
|
0 commit comments