parent
3139fe0170
commit
fa262bbceb
4 changed files with 34 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue