use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class DashboardFragment method updatePreferenceStatesInParallel.
/**
* Use parallel method to update state of each preference managed by PreferenceController.
*/
@VisibleForTesting
// the thumb sliding of the toggle button.
void updatePreferenceStatesInParallel() {
final PreferenceScreen screen = getPreferenceScreen();
final Collection<List<AbstractPreferenceController>> controllerLists = mPreferenceControllers.values();
final List<ControllerFutureTask> taskList = new ArrayList<>();
for (List<AbstractPreferenceController> controllerList : controllerLists) {
for (AbstractPreferenceController controller : controllerList) {
final ControllerFutureTask task = new ControllerFutureTask(new ControllerTask(controller, screen, mMetricsFeatureProvider, getMetricsCategory()), null);
taskList.add(task);
ThreadUtils.postOnBackgroundThread(task);
}
}
for (ControllerFutureTask task : taskList) {
try {
task.get();
} catch (InterruptedException | ExecutionException e) {
Log.w(TAG, task.getController().getPreferenceKey() + " " + e.getMessage());
}
}
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class PublicVolumeSettings method update.
public void update() {
if (!isVolumeValid()) {
getActivity().finish();
return;
}
getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
final Context context = getActivity();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
if (mVolume.isMountedReadable()) {
addPreference(mSummary);
final File file = mVolume.getPath();
final long totalBytes = file.getTotalSpace();
final long freeBytes = file.getFreeSpace();
final long usedBytes = totalBytes - freeBytes;
final Formatter.BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large), result.value, result.units));
mSummary.setSummary(getString(R.string.storage_volume_used, Formatter.formatFileSize(context, totalBytes)));
mSummary.setPercent(usedBytes, totalBytes);
}
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
addPreference(mMount);
}
if (!mVolume.isMountedReadable()) {
mUnmount.setVisibility(View.GONE);
}
addPreference(mFormatPublic);
if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
addPreference(mFormatPrivate);
}
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class MagnificationSettingsFragmentTest method setup.
@Before
public void setup() {
mContext.setTheme(R.style.Theme_AppCompat);
mFragment = spy(new MagnificationSettingsFragment());
mScreen = new PreferenceScreen(mContext, null);
doReturn(mContext).when(mFragment).getContext();
doReturn(mScreen).when(mFragment).getPreferenceScreen();
doReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS)).when(mFragment).getChildFragmentManager();
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
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();
final 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 android_packages_apps_Settings by omnirom.
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.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (mWifiP2pManager != null && initChannel()) {
// Register receiver after make sure channel exist
getActivity().registerReceiver(mReceiver, mIntentFilter);
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;
}
});
});
}
}
Aggregations