Improve settings theme color

- Closes #863
This commit is contained in:
Mauricio Colli 2018-01-27 02:41:11 -02:00
parent 3139fe0170
commit fa262bbceb
No known key found for this signature in database
GPG Key ID: F200BFD6F29DDD85
4 changed files with 34 additions and 1 deletions

View File

@ -43,7 +43,8 @@ public class SettingsActivity extends AppCompatActivity implements BasePreferenc
@Override
protected void onCreate(Bundle savedInstanceBundle) {
ThemeHelper.setTheme(this);
setTheme(ThemeHelper.getSettingsThemeStyle(this));
super.onCreate(savedInstanceBundle);
setContentView(R.layout.settings_layout);

View File

@ -49,6 +49,21 @@ public class ThemeHelper {
return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme);
}
@StyleRes
public static int getSettingsThemeStyle(Context context) {
String lightTheme = context.getResources().getString(R.string.light_theme_key);
String darkTheme = context.getResources().getString(R.string.dark_theme_key);
String blackTheme = context.getResources().getString(R.string.black_theme_key);
String selectedTheme = getSelectedTheme(context);
if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme;
else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme;
else if (selectedTheme.equals(darkTheme)) return R.style.DarkSettingsTheme;
// Fallback
else return R.style.DarkSettingsTheme;
}
/**
* Get a resource id from a resource styled according to the the context's theme.
*/

View File

@ -6,6 +6,7 @@
<color name="light_youtube_primary_color">#e53935</color>
<color name="light_youtube_dark_color">#d32f2f</color>
<color name="light_youtube_accent_color">#000000</color>
<color name="light_settings_accent_color">#e53935</color>
<color name="light_separator_color">#32000000</color>
<color name="light_ripple_color">#48868686</color>
<color name="light_selected_color">#2a868686</color>
@ -20,6 +21,7 @@
<color name="dark_youtube_primary_color">#CD322E</color>
<color name="dark_youtube_dark_color">#BC211D</color>
<color name="dark_youtube_accent_color">#FFFFFF</color>
<color name="dark_settings_accent_color">#ff5252</color>
<color name="dark_separator_color">#0affffff</color>
<color name="dark_ripple_color">#48ffffff</color>
<color name="dark_selected_color">#2affffff</color>
@ -31,6 +33,7 @@
<!-- Black Theme -->
<color name="black_background_color">#000</color>
<color name="black_settings_accent_color">@color/dark_settings_accent_color</color>
<color name="black_separator_color">#1effffff</color>
<color name="black_contrast_background_color">#23454545</color>

View File

@ -90,6 +90,20 @@
<item name="contrast_background_color">@color/black_contrast_background_color</item>
</style>
<!-- Settings -->
<style name="LightSettingsTheme" parent="LightTheme">
<item name="colorAccent">@color/light_settings_accent_color</item>
</style>
<style name="DarkSettingsTheme" parent="DarkTheme">
<item name="colorAccent">@color/dark_settings_accent_color</item>
</style>
<style name="BlackSettingsTheme" parent="BlackTheme">
<item name="colorAccent">@color/black_settings_accent_color</item>
</style>
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/black</item>