Search in sources :

Example 1 with ColorPickerFragment

use of net.margaritov.preference.colorpicker.fragment.ColorPickerFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ColorPickerPreference method showFragment.

private void showFragment(Bundle state) {
    SettingsActivity sa = null;
    if (getContext() instanceof ContextThemeWrapper) {
        if (((ContextThemeWrapper) getContext()).getBaseContext() instanceof SettingsActivity) {
            sa = (SettingsActivity) ((ContextThemeWrapper) getContext()).getBaseContext();
        }
    }
    if (sa == null) {
        return;
    }
    Bundle arguments;
    if (state != null) {
        arguments = new Bundle(state);
    } else {
        SharedPreferences prefs = sa.getSharedPreferences("color_picker_fragment", Activity.MODE_PRIVATE);
        boolean showHelpScreen = prefs.getBoolean("show_help_screen", true);
        arguments = new Bundle();
        arguments.putInt("new_color", mValue);
        arguments.putInt("old_color", mValue);
        arguments.putBoolean("help_screen_visible", showHelpScreen);
    }
    arguments.putInt("initial_color", mValue);
    arguments.putInt("reset_color_1", mResetColor1);
    arguments.putInt("reset_color_2", mResetColor2);
    arguments.putCharSequence("reset_color_1_title", mResetColor1Title);
    arguments.putCharSequence("reset_color_2_title", mResetColor2Title);
    arguments.putBoolean("alpha_slider_visible", mAlphaSliderVisible);
    mPickerFragment = new ColorPickerFragment();
    mPickerFragment.setArguments(arguments);
    mPickerFragment.setOnColorChangedListener(this);
    FragmentTransaction transaction = sa.getFragmentManager().beginTransaction();
    transaction.replace(R.id.main_content, mPickerFragment);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.addToBackStack(":settings:prefs");
    transaction.setBreadCrumbTitle(R.string.color_picker_fragment_title);
    transaction.commitAllowingStateLoss();
}
Also used : FragmentTransaction(android.app.FragmentTransaction) ContextThemeWrapper(android.view.ContextThemeWrapper) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) ColorPickerFragment(net.margaritov.preference.colorpicker.fragment.ColorPickerFragment) SettingsActivity(com.android.settings.SettingsActivity)

Aggregations

FragmentTransaction (android.app.FragmentTransaction)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 SettingsActivity (com.android.settings.SettingsActivity)1 ColorPickerFragment (net.margaritov.preference.colorpicker.fragment.ColorPickerFragment)1