Search in sources :

Example 66 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class AutofillLoggingLevelPreferenceController method updateOptions.

private void updateOptions() {
    if (mPreference == null) {
        // TODO: there should be a hook on AbstractPreferenceController where we could
        // unregister mObserver and avoid this check
        Log.v(TAG, "ignoring Settings update because UI is gone");
        return;
    }
    final int level = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AUTOFILL_LOGGING_LEVEL, AutofillManager.DEFAULT_LOGGING_LEVEL);
    final int index;
    if (level == AutofillManager.FLAG_ADD_CLIENT_DEBUG) {
        index = 1;
    } else if (level == AutofillManager.FLAG_ADD_CLIENT_VERBOSE) {
        index = 2;
    } else {
        index = 0;
    }
    final ListPreference listPreference = (ListPreference) mPreference;
    listPreference.setValue(mListValues[index]);
    listPreference.setSummary(mListSummaries[index]);
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 67 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class GraphicsDriverEnableForAllAppsPreferenceController 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.UPDATABLE_DRIVER_ALL_APPS, UPDATABLE_DRIVER_DEFAULT);
    if (currentChoice == UPDATABLE_DRIVER_PRODUCTION_ALL_APPS) {
        listPref.setValue(mPreferenceProductionDriver);
        listPref.setSummary(mPreferenceProductionDriver);
    } else if (currentChoice == UPDATABLE_DRIVER_PRERELEASE_ALL_APPS) {
        listPref.setValue(mPreferencePrereleaseDriver);
        listPref.setSummary(mPreferencePrereleaseDriver);
    } else {
        listPref.setValue(mPreferenceDefault);
        listPref.setSummary(mPreferenceDefault);
    }
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 68 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class ProfileGpuRenderingPreferenceController method updateTrackFrameTimeOptions.

private void updateTrackFrameTimeOptions() {
    final String value = SystemProperties.get(ThreadedRenderer.PROFILE_PROPERTY, "");
    // default
    int index = 0;
    for (int i = 0; i < mListValues.length; i++) {
        if (TextUtils.equals(value, mListValues[i])) {
            index = i;
            break;
        }
    }
    final ListPreference listPreference = (ListPreference) mPreference;
    listPreference.setValue(mListValues[index]);
    listPreference.setSummary(mListSummaries[index]);
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 69 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

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 String settingsPackage = context.getPackageName();
    final boolean allowRestrictedBucket = Settings.Global.getInt(getContentResolver(), Settings.Global.ENABLE_RESTRICTED_BUCKET, Settings.Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1;
    final CharSequence[] bucketNames = allowRestrictedBucket ? FULL_SETTABLE_BUCKETS_NAMES : REDUCED_SETTABLE_BUCKETS_NAMES;
    final CharSequence[] bucketValues = allowRestrictedBucket ? FULL_SETTABLE_BUCKETS_VALUES : REDUCED_SETTABLE_BUCKETS_VALUES;
    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(bucketNames);
        p.setEntryValues(bucketValues);
        updateSummary(p);
        // Don't allow Settings to change its own standby bucket.
        if (TextUtils.equals(packageName, settingsPackage)) {
            p.setEnabled(false);
        }
        p.setOnPreferenceChangeListener(this);
        screen.addPreference(p);
    }
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) PreferenceGroup(androidx.preference.PreferenceGroup) Intent(android.content.Intent) ListPreference(androidx.preference.ListPreference)

Example 70 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class HandsFreeProfileOutputPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mAudioManager = mContext.getSystemService(AudioManager.class);
    mShadowAudioManager = ShadowAudioManager.getShadow();
    ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
    mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
    when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
    when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
    when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
    when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
    when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
    when(mBluetoothDevice.isConnected()).thenReturn(true);
    mSecondBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
    when(mSecondBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_2);
    when(mSecondBluetoothDevice.isConnected()).thenReturn(true);
    mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
    when(mLeftBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_1);
    when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
    mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_4));
    when(mRightBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_2);
    when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
    mController = new HandsFreeProfileOutputPreferenceController(mContext, TEST_KEY);
    mScreen = spy(new PreferenceScreen(mContext, null));
    mPreference = new ListPreference(mContext);
    mProfileConnectedDevices = new ArrayList<>();
    mHearingAidActiveDevices = new ArrayList<>(2);
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    when(mScreen.getContext()).thenReturn(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mScreen.addPreference(mPreference);
    mController.displayPreference(mScreen);
    mController.setCallback(mAudioSwitchPreferenceCallback);
}
Also used : AudioManager(android.media.AudioManager) ShadowAudioManager(com.android.settings.testutils.shadow.ShadowAudioManager) PreferenceScreen(androidx.preference.PreferenceScreen) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) BluetoothManager(android.bluetooth.BluetoothManager) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

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