Search in sources :

Example 81 with PreferenceScreen

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

the class ButtonSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_button_settings);
    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);
    final boolean needsNavbar = DUActionUtils.hasNavbarByDefault(getActivity());
    final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HWKEY);
    if (needsNavbar) {
        prefScreen.removePreference(hwkeyCat);
    }
    // load categories and init/remove preferences based on device
    // configuration
    final boolean hasPowerKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER);
    // Double press power to launch camera.
    mCameraDoubleTapPowerGesture = (SwitchPreference) findPreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
    final boolean hasCameraKey = (deviceKeys & KEY_MASK_CAMERA) != 0;
    final boolean showCameraWake = (deviceWakeKeys & KEY_MASK_CAMERA) != 0;
    final boolean showVolumeWake = (deviceWakeKeys & KEY_MASK_VOLUME) != 0;
    final PreferenceCategory cameraCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_CAMERA);
    final PreferenceCategory powerCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_POWER);
    final PreferenceCategory volumeCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_VOLUME);
    if (hasCameraKey) {
        mCameraWakeScreen = (SwitchPreference) findPreference(CMSettings.System.CAMERA_WAKE_SCREEN);
        mCameraSleepOnRelease = (SwitchPreference) findPreference(CMSettings.System.CAMERA_SLEEP_ON_RELEASE);
        mCameraLaunch = (SwitchPreference) findPreference(CMSettings.System.CAMERA_LAUNCH);
        if (!showCameraWake) {
            prefScreen.removePreference(mCameraWakeScreen);
        }
        // Only show 'Camera sleep on release' if the device has a focus key
        if (res.getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) {
            prefScreen.removePreference(mCameraSleepOnRelease);
        }
    } else {
        prefScreen.removePreference(cameraCategory);
    }
    if (DeviceUtils.hasVolumeRocker(getActivity())) {
        if (!showVolumeWake) {
            volumeCategory.removePreference(findPreference(CMSettings.System.VOLUME_WAKE_SCREEN));
        }
        if (!TelephonyUtils.isVoiceCapable(getActivity())) {
            volumeCategory.removePreference(findPreference(CMSettings.System.VOLUME_ANSWER_CALL));
        }
        int cursorControlAction = Settings.System.getInt(resolver, Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
        mVolumeKeyCursorControl = initActionList(KEY_VOLUME_KEY_CURSOR_CONTROL, cursorControlAction);
        int swapVolumeKeys = CMSettings.System.getInt(getContentResolver(), CMSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0);
        mSwapVolumeButtons = (SwitchPreference) prefScreen.findPreference(KEY_SWAP_VOLUME_BUTTONS);
        if (mSwapVolumeButtons != null) {
            mSwapVolumeButtons.setChecked(swapVolumeKeys > 0);
        }
    } else {
        prefScreen.removePreference(volumeCategory);
    }
    final ButtonBacklightBrightness backlight = (ButtonBacklightBrightness) findPreference(KEY_BUTTON_BACKLIGHT);
    if (backlight != null) {
        if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported() || needsNavbar) {
            prefScreen.removePreference(backlight);
        }
    }
    // Power button ends calls.
    mPowerEndCall = (SwitchPreference) findPreference(KEY_POWER_END_CALL);
    if (hasPowerKey) {
        if (!TelephonyUtils.isVoiceCapable(getActivity())) {
            powerCategory.removePreference(mPowerEndCall);
            mPowerEndCall = null;
        }
        if (mCameraDoubleTapPowerGesture != null && isCameraDoubleTapPowerGestureAvailable(getResources())) {
            // Update double tap power to launch camera if available.
            mCameraDoubleTapPowerGesture.setOnPreferenceChangeListener(this);
            int cameraDoubleTapPowerDisabled = Settings.Secure.getInt(getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
            mCameraDoubleTapPowerGesture.setChecked(cameraDoubleTapPowerDisabled == 0);
        } else {
            powerCategory.removePreference(mCameraDoubleTapPowerGesture);
            mCameraDoubleTapPowerGesture = null;
        }
    } else {
        prefScreen.removePreference(powerCategory);
    }
    if (mCameraWakeScreen != null) {
        if (mCameraSleepOnRelease != null && !getResources().getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) {
            mCameraSleepOnRelease.setDependency(CMSettings.System.CAMERA_WAKE_SCREEN);
        }
    }
    mVolumeWakeScreen = (SwitchPreference) findPreference(CMSettings.System.VOLUME_WAKE_SCREEN);
    mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
    //volume rocker music control
    mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
    if (mVolumeWakeScreen != null) {
        if (mVolumeMusicControls != null) {
            mVolumeMusicControls.setDependency(CMSettings.System.VOLUME_WAKE_SCREEN);
            mVolumeWakeScreen.setDisableDependentsState(true);
        }
    }
    mDt2lCameraVibrateConfig = (SeekBarPreference) findPreference(DT2L_CAMERA_VIBRATE_CONFIG);
    int dt2lCameraVibrateConfig = Settings.System.getInt(resolver, Settings.System.DT2L_CAMERA_VIBRATE_CONFIG, 1);
    mDt2lCameraVibrateConfig.setValue(dt2lCameraVibrateConfig / 1);
    mDt2lCameraVibrateConfig.setOnPreferenceChangeListener(this);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Resources(android.content.res.Resources) ContentResolver(android.content.ContentResolver)

Example 82 with PreferenceScreen

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

the class PremiumSmsAccess method updatePrefs.

private void updatePrefs(ArrayList<AppEntry> apps) {
    if (apps == null)
        return;
    setEmptyText(R.string.premium_sms_none);
    setLoading(false, true);
    final PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getPrefContext());
    screen.setOrderingAsAdded(true);
    for (int i = 0; i < apps.size(); i++) {
        final PremiumSmsPreference smsPreference = new PremiumSmsPreference(apps.get(i), getPrefContext());
        smsPreference.setOnPreferenceChangeListener(this);
        screen.addPreference(smsPreference);
    }
    if (apps.size() != 0) {
        DividerPreference summary = new DividerPreference(getPrefContext());
        summary.setSelectable(false);
        summary.setSummary(R.string.premium_sms_warning);
        summary.setDividerAllowedAbove(true);
        screen.addPreference(summary);
    }
    setPreferenceScreen(screen);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) DividerPreference(com.android.settings.DividerPreference)

Example 83 with PreferenceScreen

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

the class AppCircleBar method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ContentResolver resolver = getActivity().getContentResolver();
    Resources res = getResources();
    addPreferencesFromResource(R.xml.app_circlebar);
    PreferenceScreen prefSet = getPreferenceScreen();
    mIncludedAppCircleBar = (AppMultiSelectListPreference) prefSet.findPreference(PREF_INCLUDE_APP_CIRCLE_BAR_KEY);
    Set<String> includedApps = getIncludedApps();
    if (includedApps != null)
        mIncludedAppCircleBar.setValues(includedApps);
    mIncludedAppCircleBar.setOnPreferenceChangeListener(this);
    mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
    mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_WIDTH, 40));
    mTriggerWidthPref.setOnPreferenceChangeListener(this);
    mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP);
    mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_TOP, 0));
    mTriggerTopPref.setOnPreferenceChangeListener(this);
    mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
    mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_HEIGHT, 100));
    mTriggerBottomPref.setOnPreferenceChangeListener(this);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Resources(android.content.res.Resources) ContentResolver(android.content.ContentResolver)

Example 84 with PreferenceScreen

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

the class WifiCallingSettings method updateButtonWfcMode.

private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode, int wfcRoamingMode) {
    mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
    mButtonWfcMode.setEnabled(wfcEnabled && mEditableWfcMode);
    // mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value.
    mButtonWfcRoamingMode.setEnabled(wfcEnabled && mEditableWfcRoamingMode);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    boolean updateAddressEnabled = (getCarrierActivityIntent(context) != null);
    if (wfcEnabled) {
        if (mEditableWfcMode) {
            preferenceScreen.addPreference(mButtonWfcMode);
        } else {
            // Don't show WFC (home) preference if it's not editable.
            preferenceScreen.removePreference(mButtonWfcMode);
        }
        if (mEditableWfcRoamingMode) {
            preferenceScreen.addPreference(mButtonWfcRoamingMode);
        } else {
            // Don't show WFC roaming preference if it's not editable.
            preferenceScreen.removePreference(mButtonWfcRoamingMode);
        }
        if (updateAddressEnabled) {
            preferenceScreen.addPreference(mUpdateAddress);
        } else {
            preferenceScreen.removePreference(mUpdateAddress);
        }
    } else {
        preferenceScreen.removePreference(mButtonWfcMode);
        preferenceScreen.removePreference(mButtonWfcRoamingMode);
        preferenceScreen.removePreference(mUpdateAddress);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 85 with PreferenceScreen

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

the class SpellCheckersSettings method updatePreferenceScreen.

private void updatePreferenceScreen() {
    mCurrentSci = mTsm.getCurrentSpellChecker();
    final boolean isSpellCheckerEnabled = mTsm.isSpellCheckerEnabled();
    mSwitchBar.setChecked(isSpellCheckerEnabled);
    final SpellCheckerSubtype currentScs;
    if (mCurrentSci != null) {
        currentScs = mTsm.getCurrentSpellCheckerSubtype(false);
    } else {
        currentScs = null;
    }
    mSpellCheckerLanaguagePref.setSummary(getSpellCheckerSubtypeLabel(mCurrentSci, currentScs));
    final PreferenceScreen screen = getPreferenceScreen();
    final int count = screen.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        final Preference preference = screen.getPreference(index);
        preference.setEnabled(isSpellCheckerEnabled);
        if (preference instanceof SpellCheckerPreference) {
            final SpellCheckerPreference pref = (SpellCheckerPreference) preference;
            pref.setSelected(mCurrentSci);
        }
    }
    mSpellCheckerLanaguagePref.setEnabled(isSpellCheckerEnabled && mCurrentSci != null);
}
Also used : SpellCheckerSubtype(android.view.textservice.SpellCheckerSubtype) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)115 Preference (android.support.v7.preference.Preference)42 ContentResolver (android.content.ContentResolver)35 SwitchPreference (android.support.v14.preference.SwitchPreference)21 Context (android.content.Context)19 Resources (android.content.res.Resources)16 PreferenceCategory (android.support.v7.preference.PreferenceCategory)14 Intent (android.content.Intent)12 ArrayList (java.util.ArrayList)9 ListPreference (android.support.v7.preference.ListPreference)8 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)7 PackageManager (android.content.pm.PackageManager)6 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)6 PreferenceManager (android.support.v7.preference.PreferenceManager)6 Activity (android.app.Activity)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 InputMethodInfo (android.view.inputmethod.InputMethodInfo)4 ComponentName (android.content.ComponentName)3