Search in sources :

Example 1 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 2 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 3 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)

Example 4 with PreferenceScreen

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

the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage.

@Test
public void displayPreference_hideFilePreferenceWhenNoEmulatedInternalStorage() {
    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(null);
    mController.displayPreference(screen);
    verify(screen).removePreference(files);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 5 with PreferenceScreen

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

the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable.

@Test
public void displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable() {
    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(false);
    mController.displayPreference(screen);
    verify(screen).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)229 Preference (androidx.preference.Preference)76 Test (org.junit.Test)60 PreferenceManager (androidx.preference.PreferenceManager)36 Context (android.content.Context)34 ContentResolver (android.content.ContentResolver)20 Bundle (android.os.Bundle)20 PreferenceCategory (androidx.preference.PreferenceCategory)20 ArrayList (java.util.ArrayList)20 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 SwitchPreference (androidx.preference.SwitchPreference)16 ListPreference (androidx.preference.ListPreference)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 PackageManager (android.content.pm.PackageManager)12 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