use of com.amaze.filemanager.ui.colors.UserColorPreferences in project AmazeFileManager by TeamAmaze.
the class ColorPickerDialog method onDialogClosed.
@Override
public void onDialogClosed(boolean positiveResult) {
// When the user selects "OK", persist the new value
if (positiveResult) {
sharedPrefs.edit().putInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, selectedIndex).apply();
if (selectedIndex != CUSTOM_INDEX && selectedIndex != RANDOM_INDEX) {
AppConfig.getInstance().getUtilsProvider().getColorPreference().saveColorPreferences(sharedPrefs, new UserColorPreferences(getColor(selectedIndex, 0), getColor(selectedIndex, 1), getColor(selectedIndex, 2), getColor(selectedIndex, 3)));
}
listener.onAcceptedConfig();
} else {
selectedIndex = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_COLOR_CONFIG, NO_DATA);
}
}
use of com.amaze.filemanager.ui.colors.UserColorPreferences 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);
}
}
use of com.amaze.filemanager.ui.colors.UserColorPreferences in project AmazeFileManager by TeamAmaze.
the class TabFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = (ViewGroup) inflater.inflate(R.layout.tabfragment, container, false);
fragmentManager = getActivity().getSupportFragmentManager();
dragPlaceholder = rootView.findViewById(R.id.drag_placeholder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
indicator = getActivity().findViewById(R.id.indicator);
} else {
circleDrawable1 = getActivity().findViewById(R.id.tab_indicator1);
circleDrawable2 = getActivity().findViewById(R.id.tab_indicator2);
}
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
savepaths = sharedPrefs.getBoolean("savepaths", true);
mViewPager = rootView.findViewById(R.id.pager);
if (getArguments() != null) {
path = getArguments().getString("path");
}
mainActivity = ((MainActivity) getActivity());
mainActivity.supportInvalidateOptionsMenu();
mViewPager.addOnPageChangeListener(this);
mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
if (savedInstanceState == null) {
int lastOpenTab = sharedPrefs.getInt(PreferencesConstants.PREFERENCE_CURRENT_TAB, PreferenceUtils.DEFAULT_CURRENT_TAB);
MainActivity.currentTab = lastOpenTab;
refactorDrawerStorages(true);
mViewPager.setAdapter(mSectionsPagerAdapter);
try {
mViewPager.setCurrentItem(lastOpenTab, true);
if (circleDrawable1 != null && circleDrawable2 != null) {
updateIndicator(mViewPager.getCurrentItem());
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
fragments.clear();
try {
if (fragmentManager == null) {
fragmentManager = getActivity().getSupportFragmentManager();
}
fragments.add(0, fragmentManager.getFragment(savedInstanceState, "tab" + 0));
fragments.add(1, fragmentManager.getFragment(savedInstanceState, "tab" + 1));
} catch (Exception e) {
e.printStackTrace();
}
mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
mViewPager.setAdapter(mSectionsPagerAdapter);
int pos1 = savedInstanceState.getInt(KEY_POSITION, 0);
MainActivity.currentTab = pos1;
mViewPager.setCurrentItem(pos1);
mSectionsPagerAdapter.notifyDataSetChanged();
}
if (indicator != null)
indicator.setViewPager(mViewPager);
UserColorPreferences userColorPreferences = mainActivity.getCurrentColorPreference();
// color of viewpager when current tab is 0
startColor = userColorPreferences.getPrimaryFirstTab();
// color of viewpager when current tab is 1
endColor = userColorPreferences.getPrimarySecondTab();
return rootView;
}
use of com.amaze.filemanager.ui.colors.UserColorPreferences in project AmazeFileManager by TeamAmaze.
the class ColorPickerDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.show();
Resources res = requireContext().getResources();
int accentColor = ((UserColorPreferences) requireArguments().getParcelable(ARG_COLOR_PREF)).getAccent();
// Button views
((TextView) dialog.findViewById(res.getIdentifier("button1", "id", "android"))).setTextColor(accentColor);
((TextView) dialog.findViewById(res.getIdentifier("button2", "id", "android"))).setTextColor(accentColor);
return dialog;
}
Aggregations