Search in sources :

Example 21 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class OmniSwitch method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.omniswitch);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mOmniSwitchSettings = (Preference) prefSet.findPreference(OMNISWITCH_START_SETTINGS);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 22 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PixelAnimDurationSettings method refreshSettings.

public void refreshSettings() {
    PreferenceScreen prefs = getPreferenceScreen();
    if (prefs != null) {
        prefs.removeAll();
    }
    addPreferencesFromResource(R.xml.pixel_anim_duration);
    mContext = getActivity().getApplicationContext();
    mContentRes = getActivity().getContentResolver();
    final Resources res = getResources();
    int defaultValue;
    mPixelx = (SeekBarPreference) findPreference(PIXEL_X);
    int xanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_X, 133, UserHandle.USER_CURRENT);
    mPixelx.setValue(xanim / 1);
    mPixelx.setOnPreferenceChangeListener(this);
    mPixely = (SeekBarPreference) findPreference(PIXEL_Y);
    int yanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_Y, 255, UserHandle.USER_CURRENT);
    mPixely.setValue(yanim / 1);
    mPixely.setOnPreferenceChangeListener(this);
    mCollapse = (SeekBarPreference) findPreference(PIXEL_COLLAPSE);
    int xcol = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_RY, 83, UserHandle.USER_CURRENT);
    mCollapse.setValue(xcol / 1);
    mCollapse.setOnPreferenceChangeListener(this);
    mBg = (SeekBarPreference) findPreference(PIXEL_BG);
    int bg = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_BG, 100, UserHandle.USER_CURRENT);
    mBg.setValue(yanim / 1);
    mBg.setOnPreferenceChangeListener(this);
    mRetract = (SeekBarPreference) findPreference(PIXEL_RETRACT);
    int ret = Settings.System.getIntForUser(getContentResolver(), Settings.System.RETRACT_ANIMATION_DURATION, 300, UserHandle.USER_CURRENT);
    mRetract.setValue(ret / 1);
    mRetract.setOnPreferenceChangeListener(this);
    mDiamond = (SeekBarPreference) findPreference(PIXEL_DIAMOND);
    int diam = Settings.System.getIntForUser(getContentResolver(), Settings.System.DIAMOND_ANIMATION_DURATION, 200, UserHandle.USER_CURRENT);
    mDiamond.setValue(diam / 1);
    mDiamond.setOnPreferenceChangeListener(this);
    mDots = (SeekBarPreference) findPreference(PIXEL_DOTS);
    int dots = Settings.System.getIntForUser(getContentResolver(), Settings.System.DOTS_RESIZE_DURATION, 200, UserHandle.USER_CURRENT);
    mDots.setValue(dots / 1);
    mDots.setOnPreferenceChangeListener(this);
    mHome = (SeekBarPreference) findPreference(PIXEL_HOME);
    int home = Settings.System.getIntForUser(getContentResolver(), Settings.System.HOME_RESIZE_DURATION, 255, UserHandle.USER_CURRENT);
    mHome.setValue(home / 1);
    mHome.setOnPreferenceChangeListener(this);
    mColorCat = (PreferenceCategory) findPreference(COLOR_CAT);
    mTopColor = (ColorPickerPreference) findPreference(TOP_COLOR);
    mTopColor.setOnPreferenceChangeListener(this);
    int top = Settings.System.getInt(mContentRes, Settings.System.DOT_TOP_COLOR, Color.RED);
    String topHexColor = String.format("#%08x", (0x00ffffff & top));
    mTopColor.setSummary(topHexColor);
    mTopColor.setNewPreviewColor(top);
    mBottomColor = (ColorPickerPreference) findPreference(BOTTOM_COLOR);
    mBottomColor.setOnPreferenceChangeListener(this);
    int bottom = Settings.System.getInt(mContentRes, Settings.System.DOT_BOTTOM_COLOR, Color.YELLOW);
    String bottomHexColor = String.format("#%08x", (0x00ffffff & bottom));
    mBottomColor.setSummary(bottomHexColor);
    mBottomColor.setNewPreviewColor(bottom);
    mRightColor = (ColorPickerPreference) findPreference(RIGHT_COLOR);
    mRightColor.setOnPreferenceChangeListener(this);
    int right = Settings.System.getInt(mContentRes, Settings.System.DOT_RIGHT_COLOR, Color.GREEN);
    String rightHexColor = String.format("#%08x", (0x00ffffff & right));
    mRightColor.setSummary(rightHexColor);
    mRightColor.setNewPreviewColor(right);
    mLeftColor = (ColorPickerPreference) findPreference(LEFT_COLOR);
    mLeftColor.setOnPreferenceChangeListener(this);
    int left = Settings.System.getInt(mContentRes, Settings.System.DOT_LEFT_COLOR, Color.RED);
    String leftHexColor = String.format("#%08x", (0x00ffffff & left));
    mLeftColor.setSummary(leftHexColor);
    mLeftColor.setNewPreviewColor(left);
    mColorStyle = (ListPreference) findPreference(COLOR_STYLE);
    int style = Settings.System.getIntForUser(mContentRes, Settings.System.DOT_COLOR_SWITCH, 0, UserHandle.USER_CURRENT);
    mColorStyle.setValue(String.valueOf(style));
    mColorStyle.setSummary(mColorStyle.getEntry());
    mColorStyle.setOnPreferenceChangeListener(this);
    UpdateSettings(style);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Resources(android.content.res.Resources)

Example 23 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HWSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_hw_keys);
    final ContentResolver resolver = getContentResolver();
    final PreferenceScreen prefScreen = getPreferenceScreen();
    final Resources res = getResources();
    final int deviceWakeKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareWakeKeys);
    // bits for hardware keys present on device
    final int deviceKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareKeys);
    // read bits for present hardware keys
    final boolean hasHomeKey = (deviceKeys & KEY_MASK_HOME) != 0;
    final boolean hasBackKey = (deviceKeys & KEY_MASK_BACK) != 0;
    final boolean hasMenuKey = (deviceKeys & KEY_MASK_MENU) != 0;
    final boolean hasAssistKey = (deviceKeys & KEY_MASK_ASSIST) != 0;
    final boolean hasAppSwitchKey = (deviceKeys & KEY_MASK_APP_SWITCH) != 0;
    final boolean hasCameraKey = (deviceKeys & KEY_MASK_CAMERA) != 0;
    final boolean showHomeWake = (deviceWakeKeys & KEY_MASK_HOME) != 0;
    final boolean showBackWake = (deviceWakeKeys & KEY_MASK_BACK) != 0;
    final boolean showMenuWake = (deviceWakeKeys & KEY_MASK_MENU) != 0;
    final boolean showAssistWake = (deviceWakeKeys & KEY_MASK_ASSIST) != 0;
    final boolean showAppSwitchWake = (deviceWakeKeys & KEY_MASK_APP_SWITCH) != 0;
    final boolean needsNavbar = DUActionUtils.hasNavbarByDefault(getActivity());
    final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HWKEY);
    int keysDisabled = 0;
    if (!needsNavbar) {
        mHwKeyDisable = (SwitchPreference) findPreference(HWKEY_DISABLE);
        keysDisabled = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.HARDWARE_KEYS_DISABLE, 0, UserHandle.USER_CURRENT);
        mHwKeyDisable.setChecked(keysDisabled != 0);
        mHwKeyDisable.setOnPreferenceChangeListener(this);
    } else {
        prefScreen.removePreference(hwkeyCat);
    }
    // load categories and init/remove preferences based on device
    // configuration
    final boolean hasPowerKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER);
    final PreferenceCategory backCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_BACK);
    final PreferenceCategory homeCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HOME);
    final PreferenceCategory menuCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_MENU);
    final PreferenceCategory assistCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_ASSIST);
    final PreferenceCategory appSwitchCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_APPSWITCH);
    // Power button ends calls.
    mPowerEndCall = (SwitchPreference) findPreference(KEY_POWER_END_CALL);
    // Home button answers calls.
    mHomeAnswerCall = (SwitchPreference) findPreference(KEY_HOME_ANSWER_CALL);
    if (hasBackKey) {
        if (!showBackWake) {
            backCategory.removePreference(findPreference(CMSettings.System.BACK_WAKE_SCREEN));
        }
    } else {
        prefScreen.removePreference(backCategory);
    }
    if (hasHomeKey) {
        if (!showHomeWake) {
            homeCategory.removePreference(findPreference(CMSettings.System.HOME_WAKE_SCREEN));
        }
        if (!TelephonyUtils.isVoiceCapable(getActivity())) {
            homeCategory.removePreference(mHomeAnswerCall);
            mHomeAnswerCall = null;
        }
    } else {
        prefScreen.removePreference(homeCategory);
    }
    // App switch key (recents)
    if (!hasAppSwitchKey) {
        prefScreen.removePreference(appSwitchCategory);
    }
    if (hasMenuKey) {
        if (!showMenuWake) {
            menuCategory.removePreference(findPreference(CMSettings.System.MENU_WAKE_SCREEN));
        }
    } else {
        prefScreen.removePreference(menuCategory);
    }
    if (hasAssistKey) {
        if (!showAssistWake) {
            assistCategory.removePreference(findPreference(CMSettings.System.ASSIST_WAKE_SCREEN));
        }
    } else {
        prefScreen.removePreference(assistCategory);
    }
    final ButtonBacklightBrightness backlight = (ButtonBacklightBrightness) findPreference(KEY_BUTTON_BACKLIGHT);
    if (backlight != null) {
        if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported() || needsNavbar) {
            prefScreen.removePreference(backlight);
        }
    }
    // let super know we can load ActionPreferences
    onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.HWKEYS));
    // load preferences first
    setActionPreferencesEnabled(keysDisabled == 0);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Resources(android.content.res.Resources) ContentResolver(android.content.ContentResolver)

Example 24 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HWSettings method updateDisableNavkeysCategories.

private void updateDisableNavkeysCategories() {
    final PreferenceScreen prefScreen = getPreferenceScreen();
    boolean enabled = Settings.Secure.getInt(getActivity().getContentResolver(), Settings.Secure.HARDWARE_KEYS_DISABLE, 0) == 1;
    final ButtonBacklightBrightness backlight = (ButtonBacklightBrightness) prefScreen.findPreference(KEY_BUTTON_BACKLIGHT);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    final int defaultBrightness = getContext().getResources().getInteger(com.android.internal.R.integer.config_buttonBrightnessSettingDefault);
    int keysDisabled = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.HARDWARE_KEYS_DISABLE, 0, UserHandle.USER_CURRENT);
    /* Save/restore button timeouts to disable them in softkey mode */
    if (keysDisabled == 1) {
        CMSettings.Secure.putInt(getContext().getContentResolver(), CMSettings.Secure.BUTTON_BRIGHTNESS, 0);
    } else {
        int oldBright = prefs.getInt(ButtonBacklightBrightness.KEY_BUTTON_BACKLIGHT, defaultBrightness);
        CMSettings.Secure.putInt(getContext().getContentResolver(), CMSettings.Secure.BUTTON_BRIGHTNESS, oldBright);
    }
    /* Toggle backlight control depending on navbar state, force it to
           off if enabling */
    if (backlight != null) {
        backlight.setEnabled(!enabled);
        backlight.updateSummary();
    }
    if (mHomeAnswerCall != null) {
        mHomeAnswerCall.setEnabled(!enabled);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) SharedPreferences(android.content.SharedPreferences)

Example 25 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PieControl method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.pa_pie_control);
    PreferenceScreen prefSet = getPreferenceScreen();
    Context context = getActivity();
    mResolver = context.getContentResolver();
    mPieSize = (ListPreference) prefSet.findPreference(PA_PIE_SIZE);
    float pieSize = Settings.System.getFloat(mResolver, Settings.System.PA_PIE_SIZE, 1.0f);
    mPieSize.setValue(String.valueOf(pieSize));
    mPieSize.setOnPreferenceChangeListener(this);
    mPieGravity = (ListPreference) prefSet.findPreference(PA_PIE_GRAVITY);
    int pieGravity = Settings.System.getInt(mResolver, Settings.System.PA_PIE_GRAVITY, 2);
    mPieGravity.setValue(String.valueOf(pieGravity));
    mPieGravity.setOnPreferenceChangeListener(this);
    mPieMode = (ListPreference) prefSet.findPreference(PA_PIE_MODE);
    int pieMode = Settings.System.getInt(mResolver, Settings.System.PA_PIE_MODE, 2);
    mPieMode.setValue(String.valueOf(pieMode));
    mPieMode.setOnPreferenceChangeListener(this);
    mPieGap = (ListPreference) prefSet.findPreference(PA_PIE_GAP);
    int pieGap = Settings.System.getInt(mResolver, Settings.System.PA_PIE_GAP, 2);
    mPieGap.setValue(String.valueOf(pieGap));
    mPieGap.setOnPreferenceChangeListener(this);
    mPieAngle = (ListPreference) prefSet.findPreference(PA_PIE_ANGLE);
    int pieAngle = Settings.System.getInt(mResolver, Settings.System.PA_PIE_ANGLE, 12);
    mPieAngle.setValue(String.valueOf(pieAngle));
    mPieAngle.setOnPreferenceChangeListener(this);
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)640 Preference (android.support.v7.preference.Preference)458 Context (android.content.Context)127 Test (org.junit.Test)126 SwitchPreference (android.support.v14.preference.SwitchPreference)96 PreferenceCategory (android.support.v7.preference.PreferenceCategory)82 Intent (android.content.Intent)63 PreferenceGroup (android.support.v7.preference.PreferenceGroup)58 VisibleForTesting (android.support.annotation.VisibleForTesting)55 PreferenceManager (android.support.v7.preference.PreferenceManager)54 ContentResolver (android.content.ContentResolver)53 PackageManager (android.content.pm.PackageManager)51 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)48 Bundle (android.os.Bundle)46 ArrayList (java.util.ArrayList)46 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)44 ListPreference (android.support.v7.preference.ListPreference)41 ComponentName (android.content.ComponentName)31 Resources (android.content.res.Resources)30 VolumeInfo (android.os.storage.VolumeInfo)30