Changed text and appearance when Wifi/Bluetooth is off

A TextView is used as an empty view, centered on screen with the message.

Change-Id: I33825775d6b2ed212e5839cfac84d055b9336667
This commit is contained in:
Gilles Debunne
2011-06-30 12:00:28 -07:00
parent 945e383833
commit 18e9992a5e
6 changed files with 69 additions and 80 deletions

View File

@@ -1,20 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Based on preference_list_fragment.xml in framework -->
@@ -26,14 +23,20 @@
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingTop="0dip"
android:paddingBottom="0dip"
android:paddingLeft="0dip"
android:paddingRight="0dip"
android:paddingBottom="@*android:dimen/preference_fragment_padding_bottom"
android:paddingLeft="@*android:dimen/preference_fragment_padding_side"
android:paddingRight="@*android:dimen/preference_fragment_padding_side"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:scrollbarAlwaysDrawVerticalTrack="true" />
<TextView android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dip"
android:gravity="center"
android:visibility="gone" />
</LinearLayout>

View File

@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
/>
<TextView android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dip"
android:gravity="center"
android:visibility="gone" />
</FrameLayout>

View File

@@ -281,7 +281,7 @@
<string name="bluetooth_ask_enablement_and_lasting_discovery" product="default">"An application on your phone is requesting permission to turn on Bluetooth and to make your phone discoverable by other devices. Do you want to do this?"</string>
<!-- Strings for msg to display to user while bluetooth is turning on -->
<string name="bluetooth_turning_on">"Turning on Bluetooth\u2026"</string>
<string name="bluetooth_turning_on">"Turning Bluetooth on\u2026"</string>
<!-- Strings for device profile auto connect setting -->
<string name="bluetooth_auto_connect">Auto connect</string>
@@ -969,7 +969,7 @@
<!-- Bluetooth Advanced settings. Used as a label under the shortcut icon that goes to Bluetooth advanced settings. [CHAR LIMIT=20]-->
<string name="bluetooth_advanced_settings_label">Advanced Bluetooth</string>
<!-- Bluetooth settings. Text displayed when Bluetooth is off and device list is empty [CHAR LIMIT=50]-->
<string name="bluetooth_empty_list_bluetooth_off">Turn on bluetooth to see available devices</string>
<string name="bluetooth_empty_list_bluetooth_off">To see devices, turn Bluetooth on.</string>
<!-- Bluetooth settings. The title of the screen to pick which profiles to connect to on the device. For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. -->
@@ -1075,7 +1075,7 @@
<!-- Summary text of the Wi-fi settings screen -->
<string name="wifi_settings_summary">Set up &amp; manage wireless access points</string>
<!-- Summary text when turning Wi-Fi or bluetooth on -->
<string name="wifi_starting">Turning on Wi-Fi\u2026</string>
<string name="wifi_starting">Turning Wi-Fi on\u2026</string>
<!-- Summary text when turning Wi-Fi or bluetooth off -->
<string name="wifi_stopping">Turning off Wi-Fi\u2026</string>
<!-- Summary text when Wi-Fi or bluetooth has error -->
@@ -1115,7 +1115,7 @@
<!-- Menu option to modify a Wi-Fi network configuration -->
<string name="wifi_menu_modify">Modify network</string>
<!-- Wi-Fi settings. text displayed when WiFi is off and network list is empty [CHAR LIMIT=50]-->
<string name="wifi_empty_list_wifi_off">Turn on wifi to see available networks</string>
<string name="wifi_empty_list_wifi_off">To see available networks, turn Wi-Fi on.</string>
<!-- Dialog for Access Points --> <skip />
<!-- Label for network setup [CHAR LIMIT=50] -->

View File

@@ -46,7 +46,6 @@ import android.widget.TextView;
import com.android.settings.SettingsPreferenceFragment.SettingsDialogFragment;
import java.util.Arrays;
import java.util.Locale;
public class UserDictionarySettings extends ListFragment implements DialogCreatable {
@@ -100,7 +99,7 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.list_content_with_empty_view, container, false);
mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
return mView;
}

View File

@@ -20,17 +20,21 @@ import android.app.ActionBar;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import android.widget.TextView;
import com.android.settings.ProgressCategory;
import com.android.settings.R;
@@ -50,6 +54,24 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
private PreferenceGroup mFoundDevicesCategory;
private boolean mFoundDevicesCategoryIsPresent;
private View mView;
private TextView mEmptyView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
return mView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mEmptyView = (TextView) mView.findViewById(R.id.empty);
getListView().setEmptyView(mEmptyView);
}
@Override
void addPreferencesForActivity() {
addPreferencesFromResource(R.xml.bluetooth_settings);
@@ -205,11 +227,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
setDeviceListGroup(preferenceScreen);
removeAllDevices();
// TODO: from xml, add top padding. Same as in wifi
Preference emptyListPreference = new Preference(getActivity());
emptyListPreference.setTitle(messageId);
preferenceScreen.addPreference(emptyListPreference);
mEmptyView.setText(messageId);
}
@Override

View File

@@ -56,6 +56,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.android.internal.util.AsyncChannel;
@@ -106,6 +107,9 @@ public class WifiSettings extends SettingsPreferenceFragment
private WifiDialog mDialog;
private View mView;
private TextView mEmptyView;
/* Used in Wifi Setup context */
// this boolean extra specifies whether to disable the Next button when not connected
@@ -149,11 +153,8 @@ public class WifiSettings extends SettingsPreferenceFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (mInXlSetupWizard) {
return inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
} else {
return super.onCreateView(inflater, container, savedInstanceState);
}
mView = inflater.inflate(R.layout.custom_preference_list_fragment, container, false);
return mView;
}
@Override
@@ -209,6 +210,9 @@ public class WifiSettings extends SettingsPreferenceFragment
mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
}
mEmptyView = (TextView) mView.findViewById(R.id.empty);
getListView().setEmptyView(mEmptyView);
registerForContextMenu(getListView());
setHasOptionsMenu(true);
@@ -398,12 +402,11 @@ public class WifiSettings extends SettingsPreferenceFragment
* the strength of network and the security for it.
*/
private void updateAccessPoints() {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
final int wifiState = mWifiManager.getWifiState();
switch (wifiState) {
case WifiManager.WIFI_STATE_ENABLED:
getPreferenceScreen().removeAll();
// AccessPoints are automatically sorted with TreeSet.
final Collection<AccessPoint> accessPoints = constructAccessPoints();
if (mInXlSetupWizard) {
@@ -416,6 +419,10 @@ public class WifiSettings extends SettingsPreferenceFragment
}
break;
case WifiManager.WIFI_STATE_ENABLING:
getPreferenceScreen().removeAll();
break;
case WifiManager.WIFI_STATE_DISABLING:
addMessagePreference(R.string.wifi_stopping);
break;
@@ -427,9 +434,8 @@ public class WifiSettings extends SettingsPreferenceFragment
}
private void addMessagePreference(int messageId) {
Preference emptyListPreference = new Preference(getActivity());
emptyListPreference.setTitle(messageId);
getPreferenceScreen().addPreference(emptyListPreference);
if (mEmptyView != null) mEmptyView.setText(messageId);
getPreferenceScreen().removeAll();
}
private Collection<AccessPoint> constructAccessPoints() {
@@ -550,15 +556,13 @@ public class WifiSettings extends SettingsPreferenceFragment
switch (state) {
case WifiManager.WIFI_STATE_ENABLED:
mScanner.resume();
return; // not break, to avoid pause
return; // not break, to avoid the call to pause() below
case WifiManager.WIFI_STATE_ENABLING:
getPreferenceScreen().removeAll();
addMessagePreference(R.string.wifi_starting);
break;
case WifiManager.WIFI_STATE_DISABLED:
getPreferenceScreen().removeAll();
addMessagePreference(R.string.wifi_empty_list_wifi_off);
break;
}