Merge "[Wi-Fi HotSpot] Improve Wi-Fi hotspot settings entries visibility problem"
This commit is contained in:
@@ -90,7 +90,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
mBandIndex = validateSelection(Integer.parseInt((String) newValue));
|
||||
Log.d(TAG, "Band preference changed, updating band index to " + mBandIndex);
|
||||
preference.setSummary(getConfigSummary());
|
||||
mListener.onTetherConfigUpdated();
|
||||
mListener.onTetherConfigUpdated(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class WifiTetherBasePreferenceController extends AbstractPrefere
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
public interface OnTetherConfigUpdateListener {
|
||||
void onTetherConfigUpdated();
|
||||
void onTetherConfigUpdated(AbstractPreferenceController context);
|
||||
}
|
||||
|
||||
protected final WifiManager mWifiManager;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mPassword = (String) newValue;
|
||||
updatePasswordDisplay((EditTextPreference) mPreference);
|
||||
mListener.onTetherConfigUpdated();
|
||||
mListener.onTetherConfigUpdated(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class WifiTetherSSIDPreferenceController extends WifiTetherBasePreference
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mSSID = (String) newValue;
|
||||
updateSsidDisplay((EditTextPreference) preference);
|
||||
mListener.onTetherConfigUpdated();
|
||||
mListener.onTetherConfigUpdated(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WifiTetherSecurityPreferenceController extends WifiTetherBasePrefer
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mSecurityValue = Integer.parseInt((String) newValue);
|
||||
preference.setSummary(getSummaryForSecurityType(mSecurityValue));
|
||||
mListener.onTetherConfigUpdated();
|
||||
mListener.onTetherConfigUpdated(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,8 @@ import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
@@ -42,7 +41,6 @@ import com.android.settings.widget.SwitchBarController;
|
||||
import com.android.settingslib.TetherUtil;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -54,6 +52,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
private static final String TAG = "WifiTetherSettings";
|
||||
private static final IntentFilter TETHER_STATE_CHANGE_FILTER;
|
||||
private static final String KEY_WIFI_TETHER_SCREEN = "wifi_tether_settings_screen";
|
||||
private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2;
|
||||
private static final int EXPANDED_CHILD_COUNT_DEFAULT = 3;
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_WIFI_TETHER_NETWORK_NAME = "wifi_tether_network_name";
|
||||
@VisibleForTesting
|
||||
@@ -185,7 +186,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTetherConfigUpdated() {
|
||||
public void onTetherConfigUpdated(AbstractPreferenceController context) {
|
||||
final WifiConfiguration config = buildNewConfig();
|
||||
mPasswordPreferenceController.updateVisibility(config.getAuthType());
|
||||
|
||||
@@ -201,6 +202,10 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
mSwitchBarController.stopTether();
|
||||
}
|
||||
mWifiManager.setWifiApConfiguration(config);
|
||||
|
||||
if (context instanceof WifiTetherSecurityPreferenceController) {
|
||||
reConfigInitialExpandedChildCount();
|
||||
}
|
||||
}
|
||||
|
||||
private WifiConfiguration buildNewConfig() {
|
||||
@@ -285,4 +290,23 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void reConfigInitialExpandedChildCount() {
|
||||
final PreferenceGroup screen = getPreferenceScreen();
|
||||
if (mSecurityPreferenceController.getSecurityType() == WifiConfiguration.KeyMgmt.NONE) {
|
||||
screen.setInitialExpandedChildrenCount(EXPANDED_CHILD_COUNT_WITH_SECURITY_NON);
|
||||
return;
|
||||
}
|
||||
screen.setInitialExpandedChildrenCount(EXPANDED_CHILD_COUNT_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialExpandedChildCount() {
|
||||
if (mSecurityPreferenceController == null) {
|
||||
return EXPANDED_CHILD_COUNT_DEFAULT;
|
||||
}
|
||||
|
||||
return (mSecurityPreferenceController.getSecurityType() == WifiConfiguration.KeyMgmt.NONE) ?
|
||||
EXPANDED_CHILD_COUNT_WITH_SECURITY_NON : EXPANDED_CHILD_COUNT_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user