Search in sources :

Example 1 with CircularColorsView

use of com.amaze.filemanager.ui.views.CircularColorsView in project AmazeFileManager by TeamAmaze.

the class ColorPickerDialog method onBindDialogView.

@Override
public void onBindDialogView(View view) {
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
    int accentColor = ((UserColorPreferences) requireArguments().getParcelable(ARG_COLOR_PREF)).getAccent();
    if (selectedIndex == NO_DATA) {
        // if instance was restored the value is already set
        boolean isUsingDefault = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, NO_DATA) == NO_DATA && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_SKIN, R.color.primary_indigo) == R.color.primary_indigo && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_SKIN_TWO, R.color.primary_indigo) == R.color.primary_indigo && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_ACCENT, R.color.primary_pink) == R.color.primary_pink && sharedPrefs.getInt(PreferencesConstants.PREFERENCE_ICON_SKIN, R.color.primary_pink) == R.color.primary_pink;
        if (isUsingDefault) {
            sharedPrefs.edit().putInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, DEFAULT).apply();
        }
        if (sharedPrefs.getBoolean("random_checkbox", false)) {
            sharedPrefs.edit().putInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, RANDOM_INDEX).apply();
        }
        sharedPrefs.edit().remove("random_checkbox").apply();
        selectedIndex = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, CUSTOM_INDEX);
    }
    LinearLayout container = view.findViewById(R.id.container);
    for (int i = 0; i < COLORS.length; i++) {
        View child = inflateItem(container, i, accentColor);
        if (selectedIndex == i) {
            selectedItem = child;
            select(selectedItem, true);
        }
        ((TextView) child.findViewById(R.id.text)).setText(COLORS[i].first);
        CircularColorsView colorsView = child.findViewById(R.id.circularColorsView);
        colorsView.setColors(getColor(i, 0), getColor(i, 1), getColor(i, 2), getColor(i, 3));
        AppTheme appTheme = AppTheme.getTheme(requireArguments().getInt(ARG_APP_THEME));
        if (appTheme.getMaterialDialogTheme() == Theme.LIGHT)
            colorsView.setDividerColor(Color.WHITE);
        else
            colorsView.setDividerColor(Color.BLACK);
        container.addView(child);
    }
    /*CUSTOM*/
    {
        View child = inflateItem(container, CUSTOM_INDEX, accentColor);
        if (selectedIndex == CUSTOM_INDEX) {
            selectedItem = child;
            select(selectedItem, true);
        }
        ((TextView) child.findViewById(R.id.text)).setText(R.string.custom);
        child.findViewById(R.id.circularColorsView).setVisibility(View.INVISIBLE);
        container.addView(child);
    }
    /*RANDOM*/
    {
        View child = inflateItem(container, RANDOM_INDEX, accentColor);
        if (selectedIndex == RANDOM_INDEX) {
            selectedItem = child;
            select(selectedItem, true);
        }
        ((TextView) child.findViewById(R.id.text)).setText(R.string.random);
        child.findViewById(R.id.circularColorsView).setVisibility(View.INVISIBLE);
        container.addView(child);
    }
}
Also used : CircularColorsView(com.amaze.filemanager.ui.views.CircularColorsView) UserColorPreferences(com.amaze.filemanager.ui.colors.UserColorPreferences) TextView(android.widget.TextView) View(android.view.View) CircularColorsView(com.amaze.filemanager.ui.views.CircularColorsView) TextView(android.widget.TextView) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) LinearLayout(android.widget.LinearLayout)

Example 2 with CircularColorsView

use of com.amaze.filemanager.ui.views.CircularColorsView in project AmazeFileManager by TeamAmaze.

the class SelectedColorsPreference method onBindView.

@SuppressLint("WrongConstant")
@Override
protected void onBindView(View view) {
    // Keep this before things that need changing what's on screen
    super.onBindView(view);
    CircularColorsView colorsView = view.findViewById(R.id.colorsection);
    colorsView.setColors(colors[0], colors[1], colors[2], colors[3]);
    colorsView.setDividerColor(backgroundColor);
    colorsView.setVisibility(visibility);
}
Also used : CircularColorsView(com.amaze.filemanager.ui.views.CircularColorsView) SuppressLint(android.annotation.SuppressLint)

Aggregations

CircularColorsView (com.amaze.filemanager.ui.views.CircularColorsView)2 SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 UserColorPreferences (com.amaze.filemanager.ui.colors.UserColorPreferences)1 AppTheme (com.amaze.filemanager.ui.theme.AppTheme)1