Scroll to top when user connects to a network.

We now track when the user initiates a connection request, and upon
connection will scroll to the connected network.

Bug: 34093572
Test: Open wifi picker. Connect to a new or different network. The picker
should scroll to the top of list

Change-Id: I7bed31b0dd4f40333f76f8389612f7fd55f2620e
This commit is contained in:
Sundeep Ghuman
2017-08-16 17:03:07 -07:00
parent 858ea46a3a
commit 055079ba38

View File

@@ -176,6 +176,12 @@ public class WifiSettings extends RestrictedSettingsFragment
// For Search
private static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
/**
* Tracks whether the user initiated a connection via clicking in order to autoscroll to the
* network once connected.
*/
private boolean mClickedConnect;
/* End of "used in Wifi Setup context" */
public WifiSettings() {
@@ -894,6 +900,10 @@ public class WifiSettings extends RestrictedSettingsFragment
mConnectedAccessPointPreferenceCategory.addPreference(pref);
mConnectedAccessPointPreferenceCategory.setVisible(true);
if (mClickedConnect) {
mClickedConnect = false;
scrollToPreference(mConnectedAccessPointPreferenceCategory);
}
}
/** Removes all preferences and hide the {@link #mConnectedAccessPointPreferenceCategory}. */
@@ -1039,7 +1049,7 @@ public class WifiSettings extends RestrictedSettingsFragment
mMetricsFeatureProvider.action(getActivity(), MetricsEvent.ACTION_WIFI_CONNECT,
isSavedNetwork);
mWifiManager.connect(config, mConnectListener);
scrollToPreference(mConnectedAccessPointPreferenceCategory);
mClickedConnect = true;
}
protected void connect(final int networkId, boolean isSavedNetwork) {