[Provider Model] Add progress bar to internet panel
- Show progress bar when Wi-Fi scanning - Show "Searching for networks..." sub-title when Wi-Fi scanning - Remove "Wi-Fi" from searching networks string Bug: 178774497 Test: manual test atest -c InternetConnectivityPanelTest make RunSettingsRoboTests ROBOTEST_FILTER=PanelFragmentTest Change-Id: Ic05b939bef3b106845fe90db41eb09f0e15756f4
This commit is contained in:
@@ -65,6 +65,8 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
private static final String TAG = "InternetConnectivityPanel";
|
||||
private static final int SUBTITLE_TEXT_NONE = -1;
|
||||
private static final int SUBTITLE_TEXT_WIFI_IS_TURNED_ON = R.string.wifi_is_turned_on_subtitle;
|
||||
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
||||
R.string.wifi_empty_list_wifi_on;
|
||||
private static final int SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE =
|
||||
R.string.non_carrier_network_unavailable;
|
||||
private static final int SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE =
|
||||
@@ -80,9 +82,14 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
if (TextUtils.equals(intent.getAction(), WifiManager.NETWORK_STATE_CHANGED_ACTION)
|
||||
|| TextUtils.equals(intent.getAction(),
|
||||
WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
||||
|
||||
if (TextUtils.equals(intent.getAction(), WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
||||
showProgressBar();
|
||||
updatePanelTitle();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.equals(intent.getAction(), WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
||||
updatePanelTitle();
|
||||
}
|
||||
}
|
||||
@@ -102,6 +109,12 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
private DataConnectivityListener mConnectivityListener;
|
||||
private int mDefaultDataSubid = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
// Wi-Fi scanning progress bar
|
||||
protected boolean mIsProgressBarVisible;
|
||||
protected final Runnable mHideProgressBarRunnable = () -> {
|
||||
setProgressBarVisible(false);
|
||||
};
|
||||
|
||||
private InternetConnectivityPanel(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mIsProviderModelEnabled = Utils.isProviderModelEnabled(mContext);
|
||||
@@ -137,6 +150,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
mTelephonyManager.registerTelephonyCallback(
|
||||
new HandlerExecutor(new Handler(Looper.getMainLooper())), mTelephonyCallback);
|
||||
mContext.registerReceiver(mWifiStateReceiver, mWifiStateFilter);
|
||||
showProgressBar();
|
||||
updatePanelTitle();
|
||||
}
|
||||
|
||||
@@ -151,6 +165,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
mConnectivityListener.stop();
|
||||
mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
|
||||
mContext.unregisterReceiver(mWifiStateReceiver);
|
||||
mContext.getMainThreadHandler().removeCallbacks(mHideProgressBarRunnable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,6 +230,11 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
mContext.startActivity(getSeeMoreIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProgressBarVisible() {
|
||||
return mIsProgressBarVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
|
||||
@@ -302,6 +322,11 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
||||
if (wifiList != null && wifiList.size() != 0) {
|
||||
if (mIsProgressBarVisible) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: Searching for networks...
|
||||
mSubtitle = SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -334,6 +359,33 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
mSubtitle = SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE;
|
||||
}
|
||||
|
||||
protected void showProgressBar() {
|
||||
if (mWifiManager == null || !mInternetUpdater.isWifiEnabled()) {
|
||||
setProgressBarVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setProgressBarVisible(true);
|
||||
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
|
||||
if (wifiScanResults != null && wifiScanResults.size() > 0) {
|
||||
mContext.getMainThreadHandler().postDelayed(mHideProgressBarRunnable,
|
||||
2000 /* delay millis */);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setProgressBarVisible(boolean visible) {
|
||||
if (mIsProgressBarVisible == visible) {
|
||||
return;
|
||||
}
|
||||
mIsProgressBarVisible = visible;
|
||||
|
||||
if (mCallback == null) {
|
||||
return;
|
||||
}
|
||||
mCallback.onProgressBarVisibleChanged();
|
||||
updatePanelTitle();
|
||||
}
|
||||
|
||||
private class NetworkProviderTelephonyCallback extends TelephonyCallback implements
|
||||
TelephonyCallback.DataConnectionStateListener,
|
||||
TelephonyCallback.ServiceStateListener {
|
||||
|
Reference in New Issue
Block a user