b/1770342 Bluetooth: Show the pair and connect when the user long touches a device without any supported profiles.

This commit is contained in:
Michael Chan
2009-08-12 15:38:01 -07:00
parent ce6ec9fb34
commit fdfb90f9e8

View File

@@ -700,28 +700,28 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
menu.setHeaderTitle(getName());
if (isConnected) {
menu.add(0, CONTEXT_ITEM_DISCONNECT, 0, R.string.bluetooth_device_context_disconnect);
} else if (hasProfiles) {
// For connection action, show either "Connect" or "Pair & connect"
int connectString = (bondState == BluetoothDevice.BOND_NOT_BONDED)
? R.string.bluetooth_device_context_pair_connect
: R.string.bluetooth_device_context_connect;
menu.add(0, CONTEXT_ITEM_CONNECT, 0, connectString);
if (bondState == BluetoothDevice.BOND_NOT_BONDED) { // Not paired and not connected
menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_pair_connect);
} else { // Paired
if (isConnected) { // Paired and connected
menu.add(0, CONTEXT_ITEM_DISCONNECT, 0,
R.string.bluetooth_device_context_disconnect);
menu.add(0, CONTEXT_ITEM_UNPAIR, 0,
R.string.bluetooth_device_context_disconnect_unpair);
} else { // Paired but not connected
if (hasProfiles) {
menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_connect);
}
menu.add(0, CONTEXT_ITEM_UNPAIR, 0, R.string.bluetooth_device_context_unpair);
}
if (bondState == BluetoothDevice.BOND_BONDED) {
// For unpair action, show either "Unpair" or "Disconnect & unpair"
int unpairString = isConnected
? R.string.bluetooth_device_context_disconnect_unpair
: R.string.bluetooth_device_context_unpair;
menu.add(0, CONTEXT_ITEM_UNPAIR, 0, unpairString);
// Show the connection options item
if (hasProfiles) {
menu.add(0, CONTEXT_ITEM_CONNECT_ADVANCED, 0,
R.string.bluetooth_device_context_connect_advanced);
}
}
}
/**
* Called when a context menu item is clicked.