use of me.ccrama.redditslide.Activities.Slide in project Slide by ccrama.
the class SettingsThemeFragment method Bind.
public void Bind() {
final RelativeLayout colorTintModeLayout = (RelativeLayout) context.findViewById(R.id.settings_theme_colorTintMode);
final TextView currentTintTextView = (TextView) context.findViewById(R.id.settings_theme_tint_current);
final SwitchCompat tintEverywhereSwitch = (SwitchCompat) context.findViewById(R.id.settings_theme_tint_everywhere);
final SwitchCompat colorNavbarSwitch = (SwitchCompat) context.findViewById(R.id.settings_theme_colorNavbar);
final SwitchCompat colorIconSwitch = (SwitchCompat) context.findViewById(R.id.settings_theme_colorAppIcon);
back = new ColorPreferences(context).getFontStyle().getThemeType();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// * App Theme */
setupSettingsThemePrimary();
setupSettingsThemeAccent();
setupSettingsThemeBase();
setupSettingsThemeNight();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// * Tinting */
colorTintModeLayout.setOnClickListener(v -> {
final PopupMenu popup = new PopupMenu(context, v);
popup.getMenuInflater().inflate(R.menu.color_tinting_mode_settings, popup.getMenu());
popup.setOnMenuItemClickListener(item -> {
switch(item.getItemId()) {
case R.id.none:
setTintingMode(false, false);
break;
case R.id.background:
setTintingMode(true, false);
break;
case R.id.name:
setTintingMode(true, true);
break;
}
currentTintTextView.setText(SettingValues.colorBack ? SettingValues.colorSubName ? context.getString(R.string.subreddit_name_tint) : context.getString(R.string.card_background_tint) : context.getString(R.string.misc_none));
boolean enabled = !currentTintTextView.getText().equals(context.getString(R.string.misc_none));
tintEverywhereSwitch.setEnabled(enabled);
tintEverywhereSwitch.setChecked(SettingValues.colorEverywhere);
tintEverywhereSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingValues.colorEverywhere = isChecked;
editSharedBooleanPreference(SettingValues.PREF_COLOR_EVERYWHERE, isChecked);
});
return true;
});
popup.show();
});
// Color tinting mode
currentTintTextView.setText(SettingValues.colorBack ? SettingValues.colorSubName ? context.getString(R.string.subreddit_name_tint) : context.getString(R.string.card_background_tint) : context.getString(R.string.misc_none));
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boolean enabled = !currentTintTextView.getText().equals(context.getString(R.string.misc_none));
tintEverywhereSwitch.setEnabled(enabled);
tintEverywhereSwitch.setChecked(SettingValues.colorEverywhere);
tintEverywhereSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingValues.colorEverywhere = isChecked;
editSharedBooleanPreference(SettingValues.PREF_COLOR_EVERYWHERE, isChecked);
});
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
colorNavbarSwitch.setChecked(SettingValues.colorNavBar);
colorNavbarSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingsThemeFragment.changed = true;
SettingValues.colorNavBar = isChecked;
editSharedBooleanPreference(SettingValues.PREF_COLOR_NAV_BAR, isChecked);
context.themeSystemBars("");
if (!isChecked) {
context.getWindow().setNavigationBarColor(Color.TRANSPARENT);
}
});
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
colorIconSwitch.setChecked(SettingValues.colorIcon);
colorIconSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingValues.colorIcon = isChecked;
editSharedBooleanPreference(SettingValues.PREF_COLOR_ICON, isChecked);
if (isChecked) {
setComponentState(Slide.class.getPackage().getName() + ".Slide", PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
setComponentState(ColorPreferences.getIconName(context, Reddit.colors.getInt("DEFAULTCOLOR", 0)), PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
} else {
setComponentState(ColorPreferences.getIconName(context, Reddit.colors.getInt("DEFAULTCOLOR", 0)), PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
setComponentState(Slide.class.getPackage().getName() + ".Slide", PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
});
}
Aggregations