Numerous minor updates for Bluetooth Settings
+ Remove top "this device" item from the list + Upon opening Bluetooth settings, cue a search for available, pair-ready devices + Upon opening Bluetooth settings, make the phone/tablet visible to other devices + Keep phone/tablet visible as long Bluetooth settings is open and screen is on + Filter this list so that only pair-ready devices are displayed + Add non-interactive text “<Device name> is now visible to nearby devices” at the bottom of the available devices list Overflow menu: - Remove “visibility timeout” + Replace “Search for devices” with “Refresh” Bug: 15716927 Change-Id: I7c5225784af9bfb48dde511e05503ddc59be2b2b
This commit is contained in:
@@ -265,6 +265,8 @@
|
|||||||
<!-- Bluetooth settings. Message for disconnecting from all profiles of a bluetooth device. [CHAR LIMIT=NONE] -->
|
<!-- Bluetooth settings. Message for disconnecting from all profiles of a bluetooth device. [CHAR LIMIT=NONE] -->
|
||||||
<string name="bluetooth_disconnect_all_profiles">This will end your connection with:<br><b><xliff:g id="device_name">%1$s</xliff:g></b></string>
|
<string name="bluetooth_disconnect_all_profiles">This will end your connection with:<br><b><xliff:g id="device_name">%1$s</xliff:g></b></string>
|
||||||
|
|
||||||
|
<!-- Bluetooth Visibility message. This message informs the user that their device is now visible to other bluetooth devices. [CHAR LIMIT=50] -->
|
||||||
|
<string name="bluetooth_is_visible_message"><xliff:g id="device_name">%1$s</xliff:g> is now visible to nearby devices.</string>
|
||||||
<!-- Bluetooth broadcasting settings, option to enable/disable broadcasting -->
|
<!-- Bluetooth broadcasting settings, option to enable/disable broadcasting -->
|
||||||
<string name="bluetooth_broadcasting">Broadcasting</string>
|
<string name="bluetooth_broadcasting">Broadcasting</string>
|
||||||
<!-- Bluetooth settings. Dialog title to disable a single profile of a device. [CHAR LIMIT=40] -->
|
<!-- Bluetooth settings. Dialog title to disable a single profile of a device. [CHAR LIMIT=40] -->
|
||||||
@@ -1103,7 +1105,7 @@
|
|||||||
<!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
|
<!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
|
||||||
<string name="bluetooth_preference_scan_title">Scan for devices</string>
|
<string name="bluetooth_preference_scan_title">Scan for devices</string>
|
||||||
<!-- Bluetooth settings: The title of the action button that initiates a search for nearby devices [CHAR LIMIT=20] -->
|
<!-- Bluetooth settings: The title of the action button that initiates a search for nearby devices [CHAR LIMIT=20] -->
|
||||||
<string name="bluetooth_search_for_devices">Search for devices</string>
|
<string name="bluetooth_search_for_devices">Refresh</string>
|
||||||
<!-- Bluetooth settings: The title of the action button while a search for nearby devices is in progress [CHAR LIMIT=20] -->
|
<!-- Bluetooth settings: The title of the action button while a search for nearby devices is in progress [CHAR LIMIT=20] -->
|
||||||
<string name="bluetooth_searching_for_devices">Searching\u2026</string>
|
<string name="bluetooth_searching_for_devices">Searching\u2026</string>
|
||||||
<!-- Bluetooth settings: The sub heading for device settings. [CHAR LIMIT=30] -->
|
<!-- Bluetooth settings: The sub heading for device settings. [CHAR LIMIT=30] -->
|
||||||
|
@@ -57,16 +57,14 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
|
|
||||||
private static final int MENU_ID_SCAN = Menu.FIRST;
|
private static final int MENU_ID_SCAN = Menu.FIRST;
|
||||||
private static final int MENU_ID_RENAME_DEVICE = Menu.FIRST + 1;
|
private static final int MENU_ID_RENAME_DEVICE = Menu.FIRST + 1;
|
||||||
private static final int MENU_ID_VISIBILITY_TIMEOUT = Menu.FIRST + 2;
|
private static final int MENU_ID_SHOW_RECEIVED = Menu.FIRST + 2;
|
||||||
private static final int MENU_ID_SHOW_RECEIVED = Menu.FIRST + 3;
|
private static final int MENU_ID_MESSAGE_ACCESS = Menu.FIRST + 3;
|
||||||
private static final int MENU_ID_MESSAGE_ACCESS = Menu.FIRST + 4;
|
|
||||||
|
|
||||||
/* Private intent to show the list of received files */
|
/* Private intent to show the list of received files */
|
||||||
private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
|
private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES =
|
||||||
"android.btopp.intent.action.OPEN_RECEIVED_FILES";
|
"android.btopp.intent.action.OPEN_RECEIVED_FILES";
|
||||||
|
|
||||||
private BluetoothEnabler mBluetoothEnabler;
|
private BluetoothEnabler mBluetoothEnabler;
|
||||||
private BluetoothDiscoverableEnabler mDiscoverableEnabler;
|
|
||||||
|
|
||||||
private PreferenceGroup mPairedDevicesCategory;
|
private PreferenceGroup mPairedDevicesCategory;
|
||||||
private PreferenceGroup mAvailableDevicesCategory;
|
private PreferenceGroup mAvailableDevicesCategory;
|
||||||
@@ -142,13 +140,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
}
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (mDiscoverableEnabler != null) {
|
|
||||||
mDiscoverableEnabler.resume(getActivity());
|
|
||||||
}
|
|
||||||
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
||||||
if (mLocalAdapter != null) {
|
if (mLocalAdapter != null) {
|
||||||
updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted);
|
updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the device visible to other devices.
|
||||||
|
mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,9 +156,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
mBluetoothEnabler.pause();
|
mBluetoothEnabler.pause();
|
||||||
}
|
}
|
||||||
getActivity().unregisterReceiver(mReceiver);
|
getActivity().unregisterReceiver(mReceiver);
|
||||||
if (mDiscoverableEnabler != null) {
|
|
||||||
mDiscoverableEnabler.pause();
|
// Make the device only visible to connected devices.
|
||||||
}
|
mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -179,9 +177,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
menu.add(Menu.NONE, MENU_ID_RENAME_DEVICE, 0, R.string.bluetooth_rename_device)
|
menu.add(Menu.NONE, MENU_ID_RENAME_DEVICE, 0, R.string.bluetooth_rename_device)
|
||||||
.setEnabled(bluetoothIsEnabled)
|
.setEnabled(bluetoothIsEnabled)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
menu.add(Menu.NONE, MENU_ID_VISIBILITY_TIMEOUT, 0, R.string.bluetooth_visibility_timeout)
|
|
||||||
.setEnabled(bluetoothIsEnabled)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
menu.add(Menu.NONE, MENU_ID_SHOW_RECEIVED, 0, R.string.bluetooth_show_received_files)
|
menu.add(Menu.NONE, MENU_ID_SHOW_RECEIVED, 0, R.string.bluetooth_show_received_files)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
// Message Access API is still not finished, once completed we undo this check.
|
// Message Access API is still not finished, once completed we undo this check.
|
||||||
@@ -207,11 +202,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
getFragmentManager(), "rename device");
|
getFragmentManager(), "rename device");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MENU_ID_VISIBILITY_TIMEOUT:
|
|
||||||
new BluetoothVisibilityTimeoutFragment().show(
|
|
||||||
getFragmentManager(), "visibility timeout");
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case MENU_ID_SHOW_RECEIVED:
|
case MENU_ID_SHOW_RECEIVED:
|
||||||
Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
|
Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
|
||||||
getActivity().sendBroadcast(intent);
|
getActivity().sendBroadcast(intent);
|
||||||
@@ -262,30 +252,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
preferenceScreen.setOrderingAsAdded(true);
|
preferenceScreen.setOrderingAsAdded(true);
|
||||||
mDevicePreferenceMap.clear();
|
mDevicePreferenceMap.clear();
|
||||||
|
|
||||||
// This device
|
|
||||||
if (mMyDevicePreference == null) {
|
|
||||||
mMyDevicePreference = new Preference(getActivity());
|
|
||||||
}
|
|
||||||
mMyDevicePreference.setTitle(mLocalAdapter.getName());
|
|
||||||
if (getResources().getBoolean(com.android.internal.R.bool.config_voice_capable)) {
|
|
||||||
mMyDevicePreference.setIcon(R.drawable.ic_bt_cellphone); // for phones
|
|
||||||
} else {
|
|
||||||
mMyDevicePreference.setIcon(R.drawable.ic_bt_laptop); // for tablets, etc.
|
|
||||||
}
|
|
||||||
mMyDevicePreference.setPersistent(false);
|
|
||||||
mMyDevicePreference.setEnabled(true);
|
|
||||||
preferenceScreen.addPreference(mMyDevicePreference);
|
|
||||||
|
|
||||||
if (!isRestrictedAndNotPinProtected()) {
|
|
||||||
if (mDiscoverableEnabler == null) {
|
|
||||||
mDiscoverableEnabler = new BluetoothDiscoverableEnabler(mLocalAdapter,
|
|
||||||
mMyDevicePreference);
|
|
||||||
mDiscoverableEnabler.resume(getActivity());
|
|
||||||
LocalBluetoothManager.getInstance(getActivity()).setDiscoverableEnabler(
|
|
||||||
mDiscoverableEnabler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Paired devices category
|
// Paired devices category
|
||||||
if (mPairedDevicesCategory == null) {
|
if (mPairedDevicesCategory == null) {
|
||||||
mPairedDevicesCategory = new PreferenceCategory(getActivity());
|
mPairedDevicesCategory = new PreferenceCategory(getActivity());
|
||||||
@@ -297,13 +263,10 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
BluetoothDeviceFilter.BONDED_DEVICE_FILTER);
|
BluetoothDeviceFilter.BONDED_DEVICE_FILTER);
|
||||||
int numberOfPairedDevices = mPairedDevicesCategory.getPreferenceCount();
|
int numberOfPairedDevices = mPairedDevicesCategory.getPreferenceCount();
|
||||||
|
|
||||||
if (mDiscoverableEnabler != null) {
|
|
||||||
mDiscoverableEnabler.setNumberOfPairedDevices(numberOfPairedDevices);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Available devices category
|
// Available devices category
|
||||||
if (mAvailableDevicesCategory == null) {
|
if (mAvailableDevicesCategory == null) {
|
||||||
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity());
|
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity());
|
||||||
|
mAvailableDevicesCategory.setSelectable(false);
|
||||||
} else {
|
} else {
|
||||||
mAvailableDevicesCategory.removeAll();
|
mAvailableDevicesCategory.removeAll();
|
||||||
}
|
}
|
||||||
@@ -331,6 +294,16 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mMyDevicePreference == null) {
|
||||||
|
mMyDevicePreference = new Preference(getActivity());
|
||||||
|
}
|
||||||
|
mMyDevicePreference.setSummary(getResources().getString(
|
||||||
|
R.string.bluetooth_is_visible_message, mLocalAdapter.getName()));
|
||||||
|
mMyDevicePreference.setSelectable(false);
|
||||||
|
mMyDevicePreference.setEnabled(false);
|
||||||
|
preferenceScreen.addPreference(mMyDevicePreference);
|
||||||
|
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
return; // not break
|
return; // not break
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user