b/1770342 Bluetooth: Show the pair and connect when the user long touches a device without any supported profiles.
This commit is contained in:
@@ -700,26 +700,26 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
|
|||||||
|
|
||||||
menu.setHeaderTitle(getName());
|
menu.setHeaderTitle(getName());
|
||||||
|
|
||||||
if (isConnected) {
|
if (bondState == BluetoothDevice.BOND_NOT_BONDED) { // Not paired and not connected
|
||||||
menu.add(0, CONTEXT_ITEM_DISCONNECT, 0, R.string.bluetooth_device_context_disconnect);
|
menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_pair_connect);
|
||||||
} else if (hasProfiles) {
|
} else { // Paired
|
||||||
// For connection action, show either "Connect" or "Pair & connect"
|
if (isConnected) { // Paired and connected
|
||||||
int connectString = (bondState == BluetoothDevice.BOND_NOT_BONDED)
|
menu.add(0, CONTEXT_ITEM_DISCONNECT, 0,
|
||||||
? R.string.bluetooth_device_context_pair_connect
|
R.string.bluetooth_device_context_disconnect);
|
||||||
: R.string.bluetooth_device_context_connect;
|
menu.add(0, CONTEXT_ITEM_UNPAIR, 0,
|
||||||
menu.add(0, CONTEXT_ITEM_CONNECT, 0, connectString);
|
R.string.bluetooth_device_context_disconnect_unpair);
|
||||||
}
|
} else { // Paired but not connected
|
||||||
|
if (hasProfiles) {
|
||||||
if (bondState == BluetoothDevice.BOND_BONDED) {
|
menu.add(0, CONTEXT_ITEM_CONNECT, 0, R.string.bluetooth_device_context_connect);
|
||||||
// For unpair action, show either "Unpair" or "Disconnect & unpair"
|
}
|
||||||
int unpairString = isConnected
|
menu.add(0, CONTEXT_ITEM_UNPAIR, 0, R.string.bluetooth_device_context_unpair);
|
||||||
? 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
|
// Show the connection options item
|
||||||
menu.add(0, CONTEXT_ITEM_CONNECT_ADVANCED, 0,
|
if (hasProfiles) {
|
||||||
R.string.bluetooth_device_context_connect_advanced);
|
menu.add(0, CONTEXT_ITEM_CONNECT_ADVANCED, 0,
|
||||||
|
R.string.bluetooth_device_context_connect_advanced);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user