use of me.ccrama.redditslide.databinding.ChoosemainBinding in project Slide by ccrama.
the class SettingsThemeFragment method setupSettingsThemePrimary.
private void setupSettingsThemePrimary() {
final LinearLayout mainTheme = (LinearLayout) context.findViewById(R.id.settings_theme_main);
mainTheme.setOnClickListener(v -> {
final ChoosemainBinding choosemainBinding = ChoosemainBinding.inflate(context.getLayoutInflater());
final TextView title = choosemainBinding.title;
title.setBackgroundColor(Palette.getDefaultColor());
final LineColorPicker colorPicker = choosemainBinding.picker;
final LineColorPicker colorPicker2 = choosemainBinding.picker2;
colorPicker.setColors(ColorPreferences.getBaseColors(context));
int currentColor = Palette.getDefaultColor();
for (int i : colorPicker.getColors()) {
for (int i2 : ColorPreferences.getColors(context.getBaseContext(), i)) {
if (i2 == currentColor) {
colorPicker.setSelectedColor(i);
colorPicker2.setColors(ColorPreferences.getColors(context.getBaseContext(), i));
colorPicker2.setSelectedColor(i2);
break;
}
}
}
colorPicker.setOnColorChangedListener(c -> {
SettingsThemeFragment.changed = true;
colorPicker2.setColors(ColorPreferences.getColors(context.getBaseContext(), c));
colorPicker2.setSelectedColor(c);
});
colorPicker2.setOnColorChangedListener(i -> {
SettingsThemeFragment.changed = true;
title.setBackgroundColor(colorPicker2.getColor());
final Toolbar toolbar = (Toolbar) context.findViewById(R.id.toolbar);
if (toolbar != null)
toolbar.setBackgroundColor(colorPicker2.getColor());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = context.getWindow();
window.setStatusBarColor(Palette.getDarkerColor(colorPicker2.getColor()));
}
context.setRecentBar(context.getString(R.string.title_theme_settings), colorPicker2.getColor());
});
choosemainBinding.ok.setOnClickListener(v1 -> {
if (SettingValues.colorIcon) {
setComponentState(ColorPreferences.getIconName(context, Reddit.colors.getInt("DEFAULTCOLOR", 0)), PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
setComponentState(ColorPreferences.getIconName(context, colorPicker2.getColor()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
Reddit.colors.edit().putInt("DEFAULTCOLOR", colorPicker2.getColor()).apply();
context.restartActivity();
});
new AlertDialog.Builder(context).setView(choosemainBinding.getRoot()).show();
});
}
Aggregations