Search in sources :

Example 86 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project platform_packages_apps_Galaxy by Cosmic-OS.

the class ButtonSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.button_settings);
    // volume key cursor control
    mVolumeKeyCursorControl = (ListPreference) findPreference(VOLUME_KEY_CURSOR_CONTROL);
    if (mVolumeKeyCursorControl != null) {
        mVolumeKeyCursorControl.setOnPreferenceChangeListener(this);
        int volumeRockerCursorControl = Settings.System.getInt(getContentResolver(), Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
        mVolumeKeyCursorControl.setValue(Integer.toString(volumeRockerCursorControl));
        mVolumeKeyCursorControl.setSummary(mVolumeKeyCursorControl.getEntry());
    }
    final Resources res = getResources();
    final ContentResolver resolver = getActivity().getContentResolver();
    final PreferenceScreen prefScreen = getPreferenceScreen();
    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);
        final boolean variableBrightness = getResources().getBoolean(com.android.internal.R.bool.config_deviceHasVariableButtonBrightness);
        mBacklightTimeout = (ListPreference) findPreference(KEY_BACKLIGHT_TIMEOUT);
        mButtonBrightness = (CustomSeekBarPreference) findPreference(KEY_BUTTON_BRIGHTNESS);
        mButtonBrightness_sw = (SwitchPreference) findPreference(KEY_BUTTON_BRIGHTNESS_SW);
        if (mBacklightTimeout != null) {
            mBacklightTimeout.setOnPreferenceChangeListener(this);
            int BacklightTimeout = Settings.System.getInt(getContentResolver(), Settings.System.BUTTON_BACKLIGHT_TIMEOUT, 5000);
            mBacklightTimeout.setValue(Integer.toString(BacklightTimeout));
            mBacklightTimeout.setSummary(mBacklightTimeout.getEntry());
        }
        if (variableBrightness) {
            hwkeyCat.removePreference(mButtonBrightness_sw);
            if (mButtonBrightness != null) {
                int ButtonBrightness = Settings.System.getInt(getContentResolver(), Settings.System.BUTTON_BRIGHTNESS, 255);
                mButtonBrightness.setValue(ButtonBrightness / 1);
                mButtonBrightness.setOnPreferenceChangeListener(this);
            }
        } else {
            hwkeyCat.removePreference(mButtonBrightness);
            if (mButtonBrightness_sw != null) {
                mButtonBrightness_sw.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.BUTTON_BRIGHTNESS, 1) == 1));
                mButtonBrightness_sw.setOnPreferenceChangeListener(this);
            }
        }
    } else {
        prefScreen.removePreference(hwkeyCat);
    }
    // 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;
    // load categories and init/remove preferences based on device
    // configuration
    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);
    // back key
    if (!hasBackKey) {
        prefScreen.removePreference(backCategory);
    }
    // home key
    if (!hasHomeKey) {
        prefScreen.removePreference(homeCategory);
    }
    // App switch key (recents)
    if (!hasAppSwitchKey) {
        prefScreen.removePreference(appSwitchCategory);
    }
    // menu key
    if (!hasMenuKey) {
        prefScreen.removePreference(menuCategory);
    }
    // search/assist key
    if (!hasAssistKey) {
        prefScreen.removePreference(assistCategory);
    }
    // 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 87 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project platform_packages_apps_Galaxy by Cosmic-OS.

the class PulseSettings method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.equals(mRenderMode)) {
        int mode = Integer.valueOf((String) newValue);
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_RENDER_STYLE_URI, mode, UserHandle.USER_CURRENT);
        PreferenceCategory fadingBarsCat = (PreferenceCategory) findPreference("pulse_fading_bars_category");
        fadingBarsCat.setEnabled(mode == RENDER_STYLE_FADING_BARS);
        PreferenceCategory solidBarsCat = (PreferenceCategory) findPreference("pulse_2");
        solidBarsCat.setEnabled(mode == RENDER_STYLE_SOLID_LINES);
        return true;
    } else if (preference.equals(mShowPulse)) {
        boolean enabled = ((Boolean) newValue).booleanValue();
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_ENABLED, enabled ? 1 : 0, UserHandle.USER_CURRENT);
        return true;
    } else if (preference.equals(mPulseColor)) {
        int color = ((Integer) newValue).intValue();
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_COLOR, color, UserHandle.USER_CURRENT);
        return true;
    } else if (preference.equals(mLavaLampEnabled)) {
        boolean enabled = ((Boolean) newValue).booleanValue();
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_LAVALAMP_ENABLED, enabled ? 1 : 0, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mCustomDimen) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_DIMEN, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mCustomDiv) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_DIV, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mFilled) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_FILLED_BLOCK_SIZE, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mEmpty) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_EMPTY_BLOCK_SIZE, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mFudge) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_FUDGE_FACTOR, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mSolidFudge) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_FUDGE_FACTOR, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mSolidSpeed) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_LAVALAMP_SOLID_SPEED, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mFadingSpeed) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_LAVALAMP_SPEED, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mSolidCount) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_UNITS_COUNT, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mSolidOpacity) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_UNITS_OPACITY, val, UserHandle.USER_CURRENT);
        return true;
    } else if (preference == mNavButtonsOpacity) {
        int val = (Integer) newValue;
        Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_BUTTONS_OPACITY, val, UserHandle.USER_CURRENT);
        return true;
    }
    return false;
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory)

Example 88 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project platform_packages_apps_Galaxy by Cosmic-OS.

the class BatteryLightSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.battery_light_settings);
    PreferenceScreen prefSet = getPreferenceScreen();
    mColorCategory = (PreferenceCategory) findPreference("battery_light_cat");
    mLowBatteryBlinking = (SystemSettingSwitchPreference) prefSet.findPreference("battery_light_low_blinking");
    if (getResources().getBoolean(com.android.internal.R.bool.config_ledCanPulse)) {
        mLowBatteryBlinking.setChecked(Settings.System.getIntForUser(getContentResolver(), Settings.System.BATTERY_LIGHT_LOW_BLINKING, 0, UserHandle.USER_CURRENT) == 1);
        mLowBatteryBlinking.setOnPreferenceChangeListener(this);
    } else {
        prefSet.removePreference(mLowBatteryBlinking);
    }
    if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
        int color = Settings.System.getIntForUser(getContentResolver(), Settings.System.BATTERY_LIGHT_LOW_COLOR, 0xFFFF0000, UserHandle.USER_CURRENT);
        mLowColor = (ColorPickerPreference) findPreference("battery_light_low_color");
        mLowColor.setAlphaSliderEnabled(true);
        mLowColor.setNewPreviewColor(color);
        mLowColor.setOnPreferenceChangeListener(this);
        color = Settings.System.getIntForUser(getContentResolver(), Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, 0xFFFFFF00, UserHandle.USER_CURRENT);
        mMediumColor = (ColorPickerPreference) findPreference("battery_light_medium_color");
        mMediumColor.setAlphaSliderEnabled(true);
        mMediumColor.setNewPreviewColor(color);
        mMediumColor.setOnPreferenceChangeListener(this);
        color = Settings.System.getIntForUser(getContentResolver(), Settings.System.BATTERY_LIGHT_FULL_COLOR, 0xFFFFFF00, UserHandle.USER_CURRENT);
        mFullColor = (ColorPickerPreference) findPreference("battery_light_full_color");
        mFullColor.setAlphaSliderEnabled(true);
        mFullColor.setNewPreviewColor(color);
        mFullColor.setOnPreferenceChangeListener(this);
        color = Settings.System.getIntForUser(getContentResolver(), Settings.System.BATTERY_LIGHT_REALLYFULL_COLOR, 0xFF00FF00, UserHandle.USER_CURRENT);
        mReallyFullColor = (ColorPickerPreference) findPreference("battery_light_reallyfull_color");
        mReallyFullColor.setAlphaSliderEnabled(true);
        mReallyFullColor.setNewPreviewColor(color);
        mReallyFullColor.setOnPreferenceChangeListener(this);
    } else {
        prefSet.removePreference(mColorCategory);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 89 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project platform_packages_apps_Settings by BlissRoms.

the class ManageDomainUrls method onRebuildComplete.

@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
    if (getContext() == null) {
        return;
    }
    final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
    if (disableWebActions) {
        mDomainAppList = getPreferenceScreen();
    } else {
        final PreferenceGroup preferenceScreen = getPreferenceScreen();
        if (preferenceScreen.getPreferenceCount() == 0) {
            // add preferences
            final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
            webActionCategory.setTitle(R.string.web_action_section_title);
            preferenceScreen.addPreference(webActionCategory);
            // toggle to enable / disable Web Actions [aka Instant Apps]
            mWebAction = new SwitchPreference(getPrefContext());
            mWebAction.setTitle(R.string.web_action_enable_title);
            mWebAction.setSummary(R.string.web_action_enable_summary);
            mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTANT_APPS_ENABLED, 1) != 0);
            mWebAction.setOnPreferenceChangeListener(this);
            webActionCategory.addPreference(mWebAction);
            // Determine whether we should show the instant apps account chooser setting
            ComponentName instantAppSettingsComponent = getActivity().getPackageManager().getInstantAppResolverSettingsComponent();
            Intent instantAppSettingsIntent = null;
            if (instantAppSettingsComponent != null) {
                instantAppSettingsIntent = new Intent().setComponent(instantAppSettingsComponent);
            }
            if (instantAppSettingsIntent != null) {
                final Intent launchIntent = instantAppSettingsIntent;
                // TODO: Make this button actually launch the account chooser.
                mInstantAppAccountPreference = new Preference(getPrefContext());
                mInstantAppAccountPreference.setTitle(R.string.instant_apps_settings);
                mInstantAppAccountPreference.setOnPreferenceClickListener(pref -> {
                    startActivity(launchIntent);
                    return true;
                });
                webActionCategory.addPreference(mInstantAppAccountPreference);
            }
            // list to manage link handling per app
            mDomainAppList = new PreferenceCategory(getPrefContext());
            mDomainAppList.setTitle(R.string.domain_url_section_title);
            preferenceScreen.addPreference(mDomainAppList);
        }
    }
    rebuildAppList(mDomainAppList, apps);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) SwitchPreference(android.support.v14.preference.SwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) PreferenceGroup(android.support.v7.preference.PreferenceGroup) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 90 with PreferenceCategory

use of android.support.v7.preference.PreferenceCategory in project platform_packages_apps_Settings by BlissRoms.

the class InstalledAppDetails method addAppInstallerInfoPref.

private void addAppInstallerInfoPref(PreferenceScreen screen) {
    String installerPackageName = AppStoreUtil.getInstallerPackageName(getContext(), mPackageName);
    final CharSequence installerLabel = Utils.getApplicationLabel(getContext(), installerPackageName);
    if (installerLabel == null) {
        return;
    }
    final int detailsStringId = AppUtils.isInstant(mPackageInfo.applicationInfo) ? R.string.instant_app_details_summary : R.string.app_install_details_summary;
    PreferenceCategory category = new PreferenceCategory(getPrefContext());
    category.setTitle(R.string.app_install_details_group_title);
    screen.addPreference(category);
    Preference pref = new Preference(getPrefContext());
    pref.setTitle(R.string.app_install_details_title);
    pref.setKey("app_info_store");
    pref.setSummary(getString(detailsStringId, installerLabel));
    Intent intent = AppStoreUtil.getAppStoreLink(getContext(), installerPackageName, mPackageName);
    if (intent != null) {
        pref.setIntent(intent);
    } else {
        pref.setEnabled(false);
    }
    category.addPreference(pref);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent)

Aggregations

PreferenceCategory (android.support.v7.preference.PreferenceCategory)166 Preference (android.support.v7.preference.Preference)105 PreferenceScreen (android.support.v7.preference.PreferenceScreen)75 Intent (android.content.Intent)35 Context (android.content.Context)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)27 ArrayList (java.util.ArrayList)24 ComponentName (android.content.ComponentName)22 ListPreference (android.support.v7.preference.ListPreference)18 Bundle (android.os.Bundle)16 PreferenceGroup (android.support.v7.preference.PreferenceGroup)14 DimmableIconPreference (com.android.settings.DimmableIconPreference)14 ContentResolver (android.content.ContentResolver)13 LayoutPreference (com.android.settings.applications.LayoutPreference)13 PreferenceManager (android.support.v7.preference.PreferenceManager)12 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)12 FooterPreference (com.android.settingslib.widget.FooterPreference)12 Test (org.junit.Test)12 Activity (android.app.Activity)9