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]);
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations