| 498 | } |
| 499 | |
| 500 | public static void setTheme(Context context) { |
| 501 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 502 | boolean dark = prefs.getBoolean("dark_theme", false); |
| 503 | String theme = prefs.getString("theme", "teal"); |
| 504 | if (theme.equals("teal")) |
| 505 | context.setTheme(dark ? R.style.AppThemeTealDark : R.style.AppThemeTeal); |
| 506 | else if (theme.equals("blue")) |
| 507 | context.setTheme(dark ? R.style.AppThemeBlueDark : R.style.AppThemeBlue); |
| 508 | else if (theme.equals("purple")) |
| 509 | context.setTheme(dark ? R.style.AppThemePurpleDark : R.style.AppThemePurple); |
| 510 | else if (theme.equals("amber")) |
| 511 | context.setTheme(dark ? R.style.AppThemeAmberDark : R.style.AppThemeAmber); |
| 512 | else if (theme.equals("orange")) |
| 513 | context.setTheme(dark ? R.style.AppThemeOrangeDark : R.style.AppThemeOrange); |
| 514 | else if (theme.equals("green")) |
| 515 | context.setTheme(dark ? R.style.AppThemeGreenDark : R.style.AppThemeGreen); |
| 516 | |
| 517 | if (context instanceof Activity && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) |
| 518 | setTaskColor(context); |
| 519 | } |
| 520 | |
| 521 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 522 | private static void setTaskColor(Context context) { |