diff --git a/res/layout/custom_preference_list_fragment.xml b/res/layout/custom_preference_list_fragment.xml index f0bf010b185..4803639cae0 100644 --- a/res/layout/custom_preference_list_fragment.xml +++ b/res/layout/custom_preference_list_fragment.xml @@ -1,20 +1,17 @@ - @@ -26,14 +23,20 @@ + + diff --git a/res/layout/list_content_with_empty_view.xml b/res/layout/list_content_with_empty_view.xml deleted file mode 100644 index 1d4dcdcfcbd..00000000000 --- a/res/layout/list_content_with_empty_view.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - diff --git a/res/values/strings.xml b/res/values/strings.xml index 364ae3ea7eb..79ff275162f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -281,7 +281,7 @@ "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?" - "Turning on Bluetooth\u2026" + "Turning Bluetooth on\u2026" Auto connect @@ -969,7 +969,7 @@ Advanced Bluetooth - Turn on bluetooth to see available devices + To see devices, turn Bluetooth on. @@ -1075,7 +1075,7 @@ Set up & manage wireless access points - Turning on Wi-Fi\u2026 + Turning Wi-Fi on\u2026 Turning off Wi-Fi\u2026 @@ -1115,7 +1115,7 @@ Modify network - Turn on wifi to see available networks + To see available networks, turn Wi-Fi on. diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java index 22112d7b28c..ea89a1bc47f 100644 --- a/src/com/android/settings/UserDictionarySettings.java +++ b/src/com/android/settings/UserDictionarySettings.java @@ -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; } diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index cd3730904e7..6a5641f69a7 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -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 diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 3fd1bef8f19..74400d4a25c 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -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 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 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; }