Double list in Bluetooth Settings

Paired devices are listed first (from cache), followed by unpaired ones.
A scan is only started on user request or when there is no paired device
(should it be when there is no paired *connected* device?).

Wrench icon only displayed for paired devices.

Wrench click listener no longer uses mDeviceSettings which is unreliable
with ListView view recycling.

Fixed blinking ProgressCategory when the category was first in the list.

Change-Id: Ie749883426c12bd354da64733bd04b00304bc1f5
This commit is contained in:
Gilles Debunne
2011-06-28 14:01:50 -07:00
parent d1a22ec0a2
commit 4346cda76c
7 changed files with 115 additions and 84 deletions

View File

@@ -62,7 +62,7 @@ public abstract class DeviceListPreferenceFragment extends
mFilter = BluetoothDeviceFilter.ALL_FILTER;
}
DeviceListPreferenceFragment(BluetoothDeviceFilter.Filter filter) {
final void setFilter(BluetoothDeviceFilter.Filter filter) {
mFilter = filter;
}
@@ -84,14 +84,10 @@ public abstract class DeviceListPreferenceFragment extends
addPreferencesForActivity();
mDeviceListGroup = (PreferenceCategory) findPreference(KEY_BT_DEVICE_LIST);
if (mDeviceListGroup == null) {
// If null, device preferences are added directly to the root of the preference screen
mDeviceListGroup = getPreferenceScreen();
mDeviceListGroup.setOrderingAsAdded(false);
}
if (mDeviceListGroup == null) {
Log.e(TAG, "Could not find device list preference object!");
}
}
void setDeviceListGroup(PreferenceGroup preferenceGroup) {
mDeviceListGroup = preferenceGroup;
}
/** Add preferences from the subclass. */
@@ -121,7 +117,7 @@ public abstract class DeviceListPreferenceFragment extends
mDeviceListGroup.removeAll();
}
void addDevices() {
void addCachedDevices() {
Collection<CachedBluetoothDevice> cachedDevices =
mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
for (CachedBluetoothDevice cachedDevice : cachedDevices) {
@@ -159,7 +155,7 @@ public abstract class DeviceListPreferenceFragment extends
return;
}
// No update while list shows state message
// Prevent updates while the list shows one of the state messages
if (mLocalAdapter.getBluetoothState() != BluetoothAdapter.STATE_ON) return;
if (mFilter.matches(cachedDevice.getDevice())) {
@@ -199,7 +195,6 @@ public abstract class DeviceListPreferenceFragment extends
if (mDeviceListGroup instanceof ProgressCategory) {
((ProgressCategory) mDeviceListGroup).setProgress(start);
}
// else TODO Add a spinner at the end of the list to show in progress state
}
public void onBluetoothStateChanged(int bluetoothState) {