Search in sources :

Example 51 with PreferenceScreen

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

the class HighlightablePreferenceGroupAdapterTest method adjustInitialExpandedChildCount_hasHightlightKey_shouldExpandAllChildren.

@Test
public void adjustInitialExpandedChildCount_hasHightlightKey_shouldExpandAllChildren() {
    final Bundle args = new Bundle();
    when(mFragment.getArguments()).thenReturn(args);
    args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, "testkey");
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    when(mFragment.getPreferenceScreen()).thenReturn(screen);
    HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
    verify(screen).setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) Test(org.junit.Test)

Example 52 with PreferenceScreen

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

the class WifiTetherSecurityPreferenceControllerTest method setUp.

@Before
public void setUp() {
    final Context context = spy(ApplicationProvider.getApplicationContext());
    mConfig = new SoftApConfiguration.Builder().setSsid("test_1234").setPassphrase(null, SoftApConfiguration.SECURITY_TYPE_OPEN).build();
    when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
    mController = new WifiTetherSecurityPreferenceController(context, mListener);
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    final PreferenceManager preferenceManager = new PreferenceManager(context);
    final PreferenceScreen screen = preferenceManager.createPreferenceScreen(context);
    mPreference = new ListPreference(context);
    mPreference.setKey(PREF_KEY);
    screen.addPreference(mPreference);
    mController.displayPreference(screen);
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 53 with PreferenceScreen

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

the class WifiCallingSettingsForSub method updateButtonWfcMode.

private void updateButtonWfcMode(boolean wfcEnabled, int wfcMode, int wfcRoamingMode) {
    mButtonWfcMode.setSummary(getWfcModeSummary(wfcMode));
    mButtonWfcMode.setEnabled(wfcEnabled && mEditableWfcMode);
    // mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value.
    mButtonWfcRoamingMode.setEnabled(wfcEnabled && mEditableWfcRoamingMode);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    boolean updateAddressEnabled = (getCarrierActivityIntent() != null);
    if (wfcEnabled) {
        if (mEditableWfcMode) {
            preferenceScreen.addPreference(mButtonWfcMode);
        } else {
            // Don't show WFC (home) preference if it's not editable.
            preferenceScreen.removePreference(mButtonWfcMode);
        }
        if (mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming) {
            preferenceScreen.addPreference(mButtonWfcRoamingMode);
        } else {
            // Don't show WFC roaming preference if it's not editable.
            preferenceScreen.removePreference(mButtonWfcRoamingMode);
        }
        if (updateAddressEnabled) {
            preferenceScreen.addPreference(mUpdateAddress);
        } else {
            preferenceScreen.removePreference(mUpdateAddress);
        }
    } else {
        preferenceScreen.removePreference(mButtonWfcMode);
        preferenceScreen.removePreference(mButtonWfcRoamingMode);
        preferenceScreen.removePreference(mUpdateAddress);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen)

Example 54 with PreferenceScreen

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

the class WifiP2pSettings method onResume.

@Override
public void onResume() {
    super.onResume();
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION);
    mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    getActivity().registerReceiver(mReceiver, mIntentFilter);
    if (mWifiP2pManager != null) {
        mWifiP2pManager.requestPeers(mChannel, WifiP2pSettings.this);
        mWifiP2pManager.requestDeviceInfo(mChannel, WifiP2pSettings.this);
        mIsIgnoreInitConnectionInfoCallback = false;
        mWifiP2pManager.requestNetworkInfo(mChannel, networkInfo -> {
            mWifiP2pManager.requestConnectionInfo(mChannel, wifip2pinfo -> {
                if (!mIsIgnoreInitConnectionInfoCallback) {
                    if (networkInfo.isConnected()) {
                        if (DBG) {
                            Log.d(TAG, "Connected");
                        }
                    } else if (!mLastGroupFormed) {
                        // Find peers when p2p doesn't connected.
                        startSearch();
                    }
                    mLastGroupFormed = wifip2pinfo.groupFormed;
                }
            });
        });
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen)

Example 55 with PreferenceScreen

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

the class StorageItemPreferenceControllerTest method displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed.

@Test
public void displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed() {
    final StorageItemPreference audio = new StorageItemPreference(mContext);
    final StorageItemPreference image = new StorageItemPreference(mContext);
    final StorageItemPreference games = new StorageItemPreference(mContext);
    final StorageItemPreference apps = new StorageItemPreference(mContext);
    final StorageItemPreference system = new StorageItemPreference(mContext);
    final StorageItemPreference files = new StorageItemPreference(mContext);
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(true);
    mController.displayPreference(screen);
    verify(screen, times(0)).removePreference(files);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8