[WifiSettings] Add progress bar when scanning

Add a progress bar when the Wi-Fi screen is in a transient state,
like enabling, disabling Wi-Fi and scanning for network. This change
sets the progress bar as a pinned header at the top of the activity.

The pinned header container needs to be match parent so that the
progress bar can occupy the full width of the screen. If the header
view doesn't want to fill the width, then the header view *inside*
the container should be wrap_content.

Added an overloaded setPinnedHeader method that takes a layout
resource ID, and returns the view to the caller. This way the
inflater can set the parent property so that layout params will not
be ignored.

Bug: 17389577
Change-Id: I18d0eb7c72ad31d1c4b35a54789016c32c81fb93
This commit is contained in:
Maurice Lam
2015-04-21 23:01:11 -07:00
parent bc95630994
commit 28c3f6bb71
10 changed files with 145 additions and 9 deletions

View File

@@ -56,6 +56,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.widget.Toast;
@@ -127,6 +128,7 @@ public class WifiSettings extends RestrictedSettingsFragment
private WriteWifiConfigToNfcDialog mWifiToNfcDialog;
private TextView mEmptyView;
private ProgressBar mProgressHeader;
// this boolean extra specifies whether to disable the Next button when not connected. Used by
// account creation outside of setup wizard.
@@ -152,6 +154,15 @@ public class WifiSettings extends RestrictedSettingsFragment
super(DISALLOW_CONFIG_WIFI);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final Activity activity = getActivity();
if (activity != null) {
mProgressHeader = (ProgressBar) setPinnedHeaderView(R.layout.wifi_progress_header);
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -711,7 +722,9 @@ public class WifiSettings extends RestrictedSettingsFragment
}
protected void setProgressBarVisible(boolean visible) {
// TODO: show a progress bar when scan is in progress.
if (mProgressHeader != null) {
mProgressHeader.setVisibility(visible ? View.VISIBLE : View.GONE);
}
}
@Override