Fix the Wi-Fi detailed settings un-editable issue. am: f914e34d28

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12894947

Change-Id: I60460fb5f945eab4d70e28d47868d611b9c564da
This commit is contained in:
Weng Su
2020-10-23 14:25:53 +00:00
committed by Automerger Merge Worker
4 changed files with 158 additions and 6 deletions

View File

@@ -36,6 +36,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -78,7 +79,8 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
private HandlerThread mWorkerThread;
private WifiDetailPreferenceController2 mWifiDetailPreferenceController2;
private List<WifiDialog2.WifiDialog2Listener> mWifiDialogListeners = new ArrayList<>();
private List<AbstractPreferenceController> mControllers;
@VisibleForTesting
List<AbstractPreferenceController> mControllers;
@Override
public void onDestroy() {
@@ -255,6 +257,11 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
* API call for refreshing the preferences in this fragment.
*/
public void refreshPreferences() {
updatePreferenceStates();
displayPreferenceControllers();
}
protected void displayPreferenceControllers() {
final PreferenceScreen screen = getPreferenceScreen();
for (AbstractPreferenceController controller : mControllers) {
// WifiDetailPreferenceController2 gets the callback WifiEntryCallback#onUpdated,

View File

@@ -69,12 +69,13 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int randomizationLevel = getRandomizationValue();
final boolean isSelectable = mWifiEntry.canSetPrivacy();
preference.setSelectable(isSelectable);
dropDownPreference.setValue(Integer.toString(randomizationLevel));
updateSummary(dropDownPreference, randomizationLevel);
// Makes preference not selectable, when this is a ephemeral network.
if (!mWifiEntry.canSetPrivacy()) {
preference.setSelectable(false);
// If the preference cannot be selectable, display a temporary network in the summary.
if (!isSelectable) {
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
}
}