use of com.faltenreich.diaguard.shared.view.theme.Theme in project Diaguard by Faltenreich.
the class PreferenceStore method getTheme.
public Theme getTheme() {
Theme themeDefault = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P ? Theme.SYSTEM : Theme.LIGHT;
String themeKey = sharedPreferences.getString(getKey(R.string.preference_theme), null);
if (themeKey != null) {
Theme theme = Theme.fromKey(themeKey);
return theme != null ? theme : themeDefault;
} else {
setTheme(themeDefault);
return themeDefault;
}
}
use of com.faltenreich.diaguard.shared.view.theme.Theme in project Diaguard by Faltenreich.
the class PreferenceFragment method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (!isAdded()) {
return;
}
if (key.equals(getString(R.string.preference_unit_bloodsugar))) {
Events.post(new UnitChangedEvent(Category.BLOODSUGAR));
} else if (key.equals(getString(R.string.preference_unit_meal))) {
Events.post(new UnitChangedEvent(Category.MEAL));
} else if (key.equals(getString(R.string.preference_unit_meal_factor))) {
Events.post(new MealFactorUnitChangedEvent());
} else if (key.equals(getString(R.string.preference_unit_hba1c))) {
Events.post(new UnitChangedEvent(Category.HBA1C));
} else if (key.equals(getString(R.string.preference_unit_weight))) {
Events.post(new UnitChangedEvent(Category.WEIGHT));
} else if (key.equals(getString(R.string.preference_timeline_show_dots)) || key.equals(getString(R.string.preference_timeline_show_lines))) {
Events.post(new TimelinePreferenceChangedEvent());
} else if (key.equals(getString(R.string.preference_theme))) {
Theme theme = PreferenceStore.getInstance().getTheme();
ThemeUtils.setDefaultNightMode(theme);
ThemeUtils.setUiMode(getActivity(), theme);
} else if (key.equals(getString(R.string.preference_decimal_places))) {
int decimalPlaces = PreferenceStore.getInstance().getDecimalPlaces();
PreferenceCache.getInstance().setDecimalPlaces(decimalPlaces);
}
}
use of com.faltenreich.diaguard.shared.view.theme.Theme in project Diaguard by Faltenreich.
the class DiaguardApplication method init.
private void init() {
context = getApplicationContext();
JodaTimeAndroid.init(this);
PreferenceStore.getInstance().init(this);
Database.getInstance().init(this);
new Import(this).importDataIfNeeded();
PreferenceStore.getInstance().migrate();
Migrator.getInstance().start();
NotificationUtils.setupNotifications(this);
Theme theme = PreferenceStore.getInstance().getTheme();
ThemeUtils.setDefaultNightMode(theme);
ThemeUtils.setUiMode(this, theme);
ImageLoader.getInstance().init(this);
}
Aggregations