Search in sources :

Example 76 with ListPreference

use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.

the class VolumeSteps method updateVolumeStepPrefs.

private void updateVolumeStepPrefs(Preference pref, int steps) {
    if (pref == null || !(pref instanceof ListPreference)) {
        return;
    }
    final ListPreference listPref = (ListPreference) pref;
    listPref.setValue(String.valueOf(steps));
    listPref.setSummary(listPref.getEntry());
}
Also used : ListPreference(android.support.v7.preference.ListPreference)

Example 77 with ListPreference

use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.

the class NetworkTraffic method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.network_traffic);
    loadResources();
    PreferenceScreen prefScreen = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mNetTrafficState = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_STATE);
    mNetTrafficUnit = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_UNIT);
    mNetTrafficPeriod = (ListPreference) prefScreen.findPreference(NETWORK_TRAFFIC_PERIOD);
    mNetTrafficAutohideThreshold = (SeekBarPreference) prefScreen.findPreference(NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD);
    // TrafficStats will return UNSUPPORTED if the device does not support it.
    if (TrafficStats.getTotalTxBytes() != TrafficStats.UNSUPPORTED && TrafficStats.getTotalRxBytes() != TrafficStats.UNSUPPORTED) {
        mNetTrafficVal = Settings.System.getInt(resolver, Settings.System.NETWORK_TRAFFIC_STATE, 0);
        int intIndex = mNetTrafficVal & (MASK_UP + MASK_DOWN);
        intIndex = mNetTrafficState.findIndexOfValue(String.valueOf(intIndex));
        mNetTrafficState.setValueIndex(intIndex >= 0 ? intIndex : 0);
        mNetTrafficState.setSummary(mNetTrafficState.getEntry());
        mNetTrafficState.setOnPreferenceChangeListener(this);
        mNetTrafficUnit.setValueIndex(getBit(mNetTrafficVal, MASK_UNIT) ? 1 : 0);
        mNetTrafficUnit.setSummary(mNetTrafficUnit.getEntry());
        mNetTrafficUnit.setOnPreferenceChangeListener(this);
        int period = (mNetTrafficVal & MASK_PERIOD) >>> 16;
        int periodIndex = mNetTrafficPeriod.findIndexOfValue(String.valueOf(period));
        mNetTrafficPeriod.setValueIndex(periodIndex >= 0 ? periodIndex : 1);
        mNetTrafficPeriod.setSummary(mNetTrafficPeriod.getEntry());
        mNetTrafficPeriod.setOnPreferenceChangeListener(this);
        int netTrafficAutohideThreshold = Settings.System.getInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD, 10);
        mNetTrafficAutohideThreshold.setValue(netTrafficAutohideThreshold / 1);
        mNetTrafficAutohideThreshold.setOnPreferenceChangeListener(this);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 78 with ListPreference

use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.

the class StatusbarBatterySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.statusbar_battery_settings);
    PreferenceScreen prefScreen = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mBatteryStyle = (ListPreference) findPreference(STATUSBAR_BATTERY_STYLE);
    mBatteryStyleValue = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_STYLE, 0);
    mBatteryStyle.setValue(Integer.toString(mBatteryStyleValue));
    mBatteryStyle.setSummary(mBatteryStyle.getEntry());
    mBatteryStyle.setOnPreferenceChangeListener(this);
    mChargingColor = (ColorSelectPreference) prefScreen.findPreference(STATUSBAR_CHARGING_COLOR);
    int chargingColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_CHARGING_COLOR, 0xFFFFFFFF);
    mChargingColor.setColor(chargingColor);
    String hexColor = String.format("#%08X", chargingColor);
    mChargingColor.setSummary(hexColor);
    mChargingColor.setOnPreferenceChangeListener(this);
    mPercentInside = findPreference(STATUSBAR_BATTERY_PERCENT_INSIDE);
    mBatteryPercent = (ListPreference) findPreference(STATUSBAR_BATTERY_PERCENT);
    final int systemShowPercent = Settings.System.getInt(resolver, Settings.System.SHOW_BATTERY_PERCENT, 0);
    int showPercent = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_PERCENT, systemShowPercent);
    int forceShowPercent = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_FORCE_PERCENT, 0);
    int batteryPercentValue = 0;
    if (showPercent == 1) {
        batteryPercentValue = 1;
    } else if (forceShowPercent == 1) {
        batteryPercentValue = 2;
    }
    mBatteryPercent.setValue(Integer.toString(batteryPercentValue));
    mBatteryPercent.setSummary(mBatteryPercent.getEntry());
    mBatteryPercent.setOnPreferenceChangeListener(this);
    mShowBolt = findPreference(STATUSBAR_BATTERY_SHOW_BOLT);
// updateEnablement();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 79 with ListPreference

use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.

the class OmniJawsSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.omnijaws_settings);
    final PreferenceScreen prefScreen = getPreferenceScreen();
    mWeatherCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_WEATHER);
    if (mWeatherCategory != null && !isOmniJawsServiceInstalled()) {
        prefScreen.removePreference(mWeatherCategory);
    } else {
        String settingHeaderPackage = Settings.System.getString(getContentResolver(), Settings.System.OMNIJAWS_WEATHER_ICON_PACK);
        if (settingHeaderPackage == null) {
            settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX;
        }
        mWeatherIconPack = (ListPreference) findPreference(WEATHER_ICON_PACK);
        List<String> entries = new ArrayList<String>();
        List<String> values = new ArrayList<String>();
        getAvailableWeatherIconPacks(entries, values);
        mWeatherIconPack.setEntries(entries.toArray(new String[entries.size()]));
        mWeatherIconPack.setEntryValues(values.toArray(new String[values.size()]));
        int valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage);
        if (valueIndex == -1) {
            // no longer found
            settingHeaderPackage = DEFAULT_WEATHER_ICON_PACKAGE + "." + DEFAULT_WEATHER_ICON_PREFIX;
            Settings.System.putString(getContentResolver(), Settings.System.OMNIJAWS_WEATHER_ICON_PACK, settingHeaderPackage);
            valueIndex = mWeatherIconPack.findIndexOfValue(settingHeaderPackage);
        }
        mWeatherIconPack.setValueIndex(valueIndex >= 0 ? valueIndex : 0);
        mWeatherIconPack.setSummary(mWeatherIconPack.getEntry());
        mWeatherIconPack.setOnPreferenceChangeListener(this);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList)

Example 80 with ListPreference

use of android.support.v7.preference.ListPreference in project android_packages_apps_OmniGears by omnirom.

the class BarsSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.bars_settings);
    PreferenceScreen prefScreen = getPreferenceScreen();
    mQuickPulldown = (ListPreference) findPreference(QUICK_PULLDOWN);
    mQuickPulldown.setOnPreferenceChangeListener(this);
    int quickPulldownValue = Settings.System.getInt(getContentResolver(), Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 0);
    mQuickPulldown.setValue(String.valueOf(quickPulldownValue));
    updatePulldownSummary(quickPulldownValue);
    // TrafficStats will return UNSUPPORTED if the device does not support it.
    if (TrafficStats.getTotalTxBytes() == TrafficStats.UNSUPPORTED || TrafficStats.getTotalRxBytes() == TrafficStats.UNSUPPORTED) {
        prefScreen.removePreference(findPreference(NETWORK_TRAFFIC_ROOT));
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Aggregations

ListPreference (android.support.v7.preference.ListPreference)115 Preference (android.support.v7.preference.Preference)51 PreferenceScreen (android.support.v7.preference.PreferenceScreen)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 ContentResolver (android.content.ContentResolver)24 PreferenceCategory (android.support.v7.preference.PreferenceCategory)20 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)17 Intent (android.content.Intent)12 Resources (android.content.res.Resources)12 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)12 PackageInfo (android.content.pm.PackageInfo)11 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)11 RestrictionEntry (android.content.RestrictionEntry)10 OverlayInfo (android.content.om.OverlayInfo)10 ApplicationInfo (android.content.pm.ApplicationInfo)10 SmallTest (android.support.test.filters.SmallTest)10 HashSet (java.util.HashSet)10 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)10 IBinder (android.os.IBinder)7