import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.ProgressBar;
import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
private WifiDialog mDialog;
private WriteWifiConfigToNfcDialog mWifiToNfcDialog;
- private ProgressBar mProgressHeader;
+ private View mProgressHeader;
// this boolean extra specifies whether to disable the Next button when not connected. Used by
// account creation outside of setup wizard.
super.onViewCreated(view, savedInstanceState);
final Activity activity = getActivity();
if (activity != null) {
- mProgressHeader = (ProgressBar) setPinnedHeaderView(R.layout.wifi_progress_header);
+ mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+ .findViewById(R.id.progress_bar_animation);
setProgressBarVisible(false);
}
}
// loaded (ODR).
setAnimationAllowed(false);
+ addPreferences();
+
+ mIsRestricted = isUiRestricted();
+
+ mBgThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
+ mBgThread.start();
+ }
+
+ private void addPreferences() {
addPreferencesFromResource(R.xml.wifi_settings);
mConnectedAccessPointPreferenceCategory =
mStatusMessagePreference = new LinkablePreference(prefContext);
mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
-
- mIsRestricted = isUiRestricted();
-
- mBgThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
- mBgThread.start();
}
@Override
mWifiTracker.startTracking();
if (mIsRestricted) {
- if (!isUiRestrictedByOnlyAdmin()) {
- getEmptyTextView().setText(R.string.wifi_empty_list_user_restricted);
- }
- getPreferenceScreen().removeAll();
+ restrictUi();
return;
}
onWifiStateChanged(mWifiManager.getWifiState());
}
+ private void restrictUi() {
+ if (!isUiRestrictedByOnlyAdmin()) {
+ getEmptyTextView().setText(R.string.wifi_empty_list_user_restricted);
+ }
+ getPreferenceScreen().removeAll();
+ }
+
/**
* Only update the AP list if there are not any APs currently shown.
*
public void onResume() {
final Activity activity = getActivity();
super.onResume();
+
+ // Because RestrictedSettingsFragment's onResume potentially requests authorization,
+ // which changes the restriction state, recalculate it.
+ final boolean alreadyImmutablyRestricted = mIsRestricted;
+ mIsRestricted = isUiRestricted();
+ if (!alreadyImmutablyRestricted && mIsRestricted) {
+ restrictUi();
+ }
+
if (mWifiEnabler != null) {
mWifiEnabler.resume(activity);
}
}
@Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ final boolean formerlyRestricted = mIsRestricted;
+ mIsRestricted = isUiRestricted();
+ if (formerlyRestricted && !mIsRestricted
+ && getPreferenceScreen().getPreferenceCount() == 0) {
+ // De-restrict the ui
+ addPreferences();
+ }
+ }
+
+ @Override
public int getMetricsCategory() {
return MetricsEvent.WIFI;
}
case MENU_ID_WPS_PBC:
showDialog(WPS_PBC_DIALOG_ID);
return true;
- /*
- case MENU_ID_P2P:
- if (getActivity() instanceof SettingsActivity) {
- ((SettingsActivity) getActivity()).startPreferencePanel(
- WifiP2pSettings.class.getCanonicalName(),
- null,
- R.string.wifi_p2p_settings_title, null,
- this, 0);
- } else {
- startFragment(this, WifiP2pSettings.class.getCanonicalName(),
- R.string.wifi_p2p_settings_title, -1, null);
- }
- return true;
- */
case MENU_ID_WPS_PIN:
showDialog(WPS_PIN_DIALOG_ID);
return true;
protected void setProgressBarVisible(boolean visible) {
if (mProgressHeader != null) {
- mProgressHeader.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
+ mProgressHeader.setVisibility(visible ? View.VISIBLE : View.GONE);
}
}