Search in sources :

Example 36 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSnoopLogPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    final ListPreference listPreference = (ListPreference) preference;
    final String currentValue = SystemProperties.get(BLUETOOTH_BTSNOOP_LOG_MODE_PROPERTY);
    int index = getDefaultModeIndex();
    for (int i = 0; i < mListValues.length; i++) {
        if (TextUtils.equals(currentValue, mListValues[i])) {
            index = i;
            break;
        }
    }
    listPreference.setValue(mListValues[index]);
    listPreference.setSummary(mListEntries[index]);
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 37 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GameDriverAppPreferenceController method createListPreference.

@VisibleForTesting
protected ListPreference createListPreference(Context context, String packageName, String appName) {
    final ListPreference listPreference = new ListPreference(context);
    listPreference.setKey(packageName);
    listPreference.setTitle(appName);
    listPreference.setDialogTitle(mPreferenceTitle);
    listPreference.setEntries(mEntryList);
    listPreference.setEntryValues(mEntryList);
    // from Settings.Global.GAME_DRIVER(_PRERELEASE)?_OPT_(IN|OUT)_APPS
    if (mDevOptOutApps.contains(packageName)) {
        listPreference.setValue(mPreferenceSystem);
        listPreference.setSummary(mPreferenceSystem);
    } else if (mDevPrereleaseOptInApps.contains(packageName)) {
        listPreference.setValue(mPreferencePrereleaseDriver);
        listPreference.setSummary(mPreferencePrereleaseDriver);
    } else if (mDevOptInApps.contains(packageName)) {
        listPreference.setValue(mPreferenceGameDriver);
        listPreference.setSummary(mPreferenceGameDriver);
    } else {
        listPreference.setValue(mPreferenceDefault);
        listPreference.setSummary(mPreferenceDefault);
    }
    listPreference.setOnPreferenceChangeListener(this);
    return listPreference;
}
Also used : ListPreference(androidx.preference.ListPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 38 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GameDriverEnableForAllAppsPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    final ListPreference listPref = (ListPreference) preference;
    listPref.setVisible(isAvailable());
    final int currentChoice = Settings.Global.getInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
    if (currentChoice == GAME_DRIVER_ALL_APPS) {
        listPref.setValue(mPreferenceGameDriver);
        listPref.setSummary(mPreferenceGameDriver);
    } else if (currentChoice == GAME_DRIVER_PRERELEASE_ALL_APPS) {
        listPref.setValue(mPreferencePrereleaseDriver);
        listPref.setSummary(mPreferencePrereleaseDriver);
    } else {
        listPref.setValue(mPreferenceDefault);
        listPref.setSummary(mPreferenceDefault);
    }
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 39 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GameDriverEnableForAllAppsPreferenceController method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    final ListPreference listPref = (ListPreference) preference;
    final String value = newValue.toString();
    final int currentChoice = Settings.Global.getInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
    final int userChoice;
    if (value.equals(mPreferenceGameDriver)) {
        userChoice = GAME_DRIVER_ALL_APPS;
    } else if (value.equals(mPreferencePrereleaseDriver)) {
        userChoice = GAME_DRIVER_PRERELEASE_ALL_APPS;
    } else {
        userChoice = GAME_DRIVER_DEFAULT;
    }
    listPref.setValue(value);
    listPref.setSummary(value);
    if (userChoice != currentChoice) {
        Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, userChoice);
    }
    return true;
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 40 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InactiveApps method init.

private void init() {
    PreferenceGroup screen = getPreferenceScreen();
    screen.removeAll();
    screen.setOrderingAsAdded(false);
    final Context context = getActivity();
    final PackageManager pm = context.getPackageManager();
    final UsageStatsManager usm = context.getSystemService(UsageStatsManager.class);
    Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
    launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> apps = pm.queryIntentActivities(launcherIntent, 0);
    for (ResolveInfo app : apps) {
        String packageName = app.activityInfo.applicationInfo.packageName;
        ListPreference p = new ListPreference(getPrefContext());
        p.setTitle(app.loadLabel(pm));
        p.setIcon(app.loadIcon(pm));
        p.setKey(packageName);
        p.setEntries(SETTABLE_BUCKETS_NAMES);
        p.setEntryValues(SETTABLE_BUCKETS_VALUES);
        updateSummary(p);
        p.setOnPreferenceChangeListener(this);
        screen.addPreference(p);
    }
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) UsageStatsManager(android.app.usage.UsageStatsManager) PreferenceGroup(androidx.preference.PreferenceGroup) Intent(android.content.Intent) ListPreference(androidx.preference.ListPreference)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4