Merge "[WifiSetup] Show progress bar when scanning" into mnc-dev
This commit is contained in:
@@ -33,7 +33,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkInfo.State;
|
import android.net.NetworkInfo.State;
|
||||||
@@ -623,13 +622,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
final Collection<AccessPoint> accessPoints =
|
final Collection<AccessPoint> accessPoints =
|
||||||
mWifiTracker.getAccessPoints();
|
mWifiTracker.getAccessPoints();
|
||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
if (accessPoints.size() == 0) {
|
|
||||||
addMessagePreference(R.string.wifi_empty_list_wifi_on);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
boolean hasAvailableAccessPoints = false;
|
||||||
for (AccessPoint accessPoint : accessPoints) {
|
for (AccessPoint accessPoint : accessPoints) {
|
||||||
// Ignore access points that are out of range.
|
// Ignore access points that are out of range.
|
||||||
if (accessPoint.getLevel() != -1) {
|
if (accessPoint.getLevel() != -1) {
|
||||||
|
hasAvailableAccessPoints = true;
|
||||||
AccessPointPreference preference = new AccessPointPreference(accessPoint,
|
AccessPointPreference preference = new AccessPointPreference(accessPoint,
|
||||||
getActivity());
|
getActivity());
|
||||||
|
|
||||||
@@ -637,18 +635,27 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
accessPoint.setListener(this);
|
accessPoint.setListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasAvailableAccessPoints) {
|
||||||
|
setProgressBarVisible(true);
|
||||||
|
addMessagePreference(R.string.wifi_empty_list_wifi_on);
|
||||||
|
} else {
|
||||||
|
setProgressBarVisible(false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiManager.WIFI_STATE_ENABLING:
|
case WifiManager.WIFI_STATE_ENABLING:
|
||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
|
setProgressBarVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiManager.WIFI_STATE_DISABLING:
|
case WifiManager.WIFI_STATE_DISABLING:
|
||||||
addMessagePreference(R.string.wifi_stopping);
|
addMessagePreference(R.string.wifi_stopping);
|
||||||
|
setProgressBarVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiManager.WIFI_STATE_DISABLED:
|
case WifiManager.WIFI_STATE_DISABLED:
|
||||||
setOffMessage();
|
setOffMessage();
|
||||||
|
setProgressBarVisible(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Update "Saved Networks" menu option.
|
// Update "Saved Networks" menu option.
|
||||||
@@ -703,6 +710,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setProgressBarVisible(boolean visible) {
|
||||||
|
// TODO: show a progress bar when scan is in progress.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWifiStateChanged(int state) {
|
public void onWifiStateChanged(int state) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
@@ -713,10 +724,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case WifiManager.WIFI_STATE_ENABLING:
|
case WifiManager.WIFI_STATE_ENABLING:
|
||||||
addMessagePreference(R.string.wifi_starting);
|
addMessagePreference(R.string.wifi_starting);
|
||||||
|
setProgressBarVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WifiManager.WIFI_STATE_DISABLED:
|
case WifiManager.WIFI_STATE_DISABLED:
|
||||||
setOffMessage();
|
setOffMessage();
|
||||||
|
setProgressBarVisible(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
|
|
||||||
private static final String TAG = "WifiSettingsForSetupWizard";
|
private static final String TAG = "WifiSettingsForSetupWizard";
|
||||||
|
|
||||||
|
private SetupWizardListLayout mLayout;
|
||||||
private View mAddOtherNetworkItem;
|
private View mAddOtherNetworkItem;
|
||||||
private TextView mEmptyFooter;
|
private TextView mEmptyFooter;
|
||||||
private boolean mListLastEmpty = false;
|
private boolean mListLastEmpty = false;
|
||||||
@@ -50,9 +51,9 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
final SetupWizardListLayout layout = (SetupWizardListLayout) inflater.inflate(
|
mLayout = (SetupWizardListLayout)
|
||||||
R.layout.setup_wifi_layout, container, false);
|
inflater.inflate(R.layout.setup_wifi_layout, container, false);
|
||||||
final ListView list = layout.getListView();
|
final ListView list = mLayout.getListView();
|
||||||
|
|
||||||
mAddOtherNetworkItem = inflater.inflate(R.layout.setup_wifi_add_network, list, false);
|
mAddOtherNetworkItem = inflater.inflate(R.layout.setup_wifi_add_network, list, false);
|
||||||
list.addFooterView(mAddOtherNetworkItem, null, true);
|
list.addFooterView(mAddOtherNetworkItem, null, true);
|
||||||
@@ -65,13 +66,13 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final NavigationBar navigationBar = layout.getNavigationBar();
|
final NavigationBar navigationBar = mLayout.getNavigationBar();
|
||||||
if (navigationBar != null) {
|
if (navigationBar != null) {
|
||||||
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
||||||
activity.onNavigationBarCreated(navigationBar);
|
activity.onNavigationBarCreated(navigationBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
return layout;
|
return mLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,4 +147,15 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
|||||||
mListLastEmpty = isEmpty;
|
mListLastEmpty = isEmpty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setProgressBarVisible(boolean visible) {
|
||||||
|
if (mLayout != null) {
|
||||||
|
if (visible) {
|
||||||
|
mLayout.showProgressBar();
|
||||||
|
} else {
|
||||||
|
mLayout.hideProgressBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user