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