[WifiSetup] Progress when wifi scanning
Use a custom empty view to show the status while wifi is scanning or off. Cannot use android.R.id.empty because in phone portrait layout the illustration is the listview header, which will be hidden if the list is empty and we use ListView.setEmptyView. Bug: 17183006 Change-Id: Ie8598303f4e61f87e078008fb7a03918ba92c9ef
This commit is contained in:
@@ -321,8 +321,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
prepareWifiAssistantCard();
|
||||
|
||||
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
||||
getListView().setEmptyView(mEmptyView);
|
||||
mEmptyView = initEmptyView();
|
||||
registerForContextMenu(getListView());
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@@ -773,6 +772,12 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
protected TextView initEmptyView() {
|
||||
TextView emptyView = (TextView) getActivity().findViewById(android.R.id.empty);
|
||||
getListView().setEmptyView(emptyView);
|
||||
return emptyView;
|
||||
}
|
||||
|
||||
private void setOffMessage() {
|
||||
if (mEmptyView != null) {
|
||||
mEmptyView.setCompoundDrawablesWithIntrinsicBounds(0,
|
||||
|
@@ -18,18 +18,19 @@ package com.android.settings.wifi;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.DataSetObserver;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.AbsListView.LayoutParams;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.PopupMenu.OnMenuItemClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -47,6 +48,11 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
||||
// show a text regarding data charges when wifi connection is required during setup wizard
|
||||
protected static final String EXTRA_SHOW_WIFI_REQUIRED_INFO = "wifi_show_wifi_required_info";
|
||||
|
||||
private View mAddOtherNetworkItem;
|
||||
private ListAdapter mAdapter;
|
||||
private TextView mEmptyFooter;
|
||||
private boolean mListLastEmpty = false;
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -60,9 +66,9 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
||||
list.addHeaderView(header, null, false);
|
||||
}
|
||||
|
||||
final View other = inflater.inflate(R.layout.setup_wifi_add_network, list, false);
|
||||
list.addFooterView(other, null, true);
|
||||
other.setOnClickListener(new OnClickListener() {
|
||||
mAddOtherNetworkItem = inflater.inflate(R.layout.setup_wifi_add_network, list, false);
|
||||
list.addFooterView(mAddOtherNetworkItem, null, true);
|
||||
mAddOtherNetworkItem.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mWifiManager.isWifiEnabled()) {
|
||||
@@ -92,6 +98,15 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
||||
if (hasNextButton()) {
|
||||
getNextButton().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mAdapter = getPreferenceScreen().getRootAdapter();
|
||||
mAdapter.registerDataSetObserver(new DataSetObserver() {
|
||||
@Override
|
||||
public void onChanged() {
|
||||
super.onChanged();
|
||||
updateFooter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,4 +148,30 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
||||
activity.networkSelected();
|
||||
super.connect(networkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextView initEmptyView() {
|
||||
mEmptyFooter = new TextView(getActivity());
|
||||
mEmptyFooter.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.MATCH_PARENT));
|
||||
mEmptyFooter.setGravity(Gravity.CENTER);
|
||||
mEmptyFooter.setCompoundDrawablesWithIntrinsicBounds(0,
|
||||
R.drawable.ic_wifi_emptystate, 0,0);
|
||||
return mEmptyFooter;
|
||||
}
|
||||
|
||||
protected void updateFooter() {
|
||||
final boolean isEmpty = mAdapter.isEmpty();
|
||||
if (isEmpty != mListLastEmpty) {
|
||||
final ListView list = getListView();
|
||||
if (isEmpty) {
|
||||
list.removeFooterView(mAddOtherNetworkItem);
|
||||
list.addFooterView(mEmptyFooter, null, false);
|
||||
} else {
|
||||
list.removeFooterView(mEmptyFooter);
|
||||
list.addFooterView(mAddOtherNetworkItem, null, true);
|
||||
}
|
||||
mListLastEmpty = isEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user