Add preferences in new connected device page
1. Add device preference 2. connection preference This cl add click action for Add device preference. Action for connection preference will be added in future cl. Bug: 69333961 Test: Screenshot | RunSettingsRoboTests Change-Id: Ifb1afc8371ee45165ea22a7a195a774ba04fdeea
This commit is contained in:
@@ -398,6 +398,12 @@
|
||||
<string name="connected_device_connected_title">Currently connected</string>
|
||||
<!-- Title for connected device group [CHAR LIMIT=none]-->
|
||||
<string name="connected_device_saved_title">Saved devices</string>
|
||||
<!-- Title for preference to add a device [CHAR LIMIT=none]-->
|
||||
<string name="connected_device_add_device_title">Add device</string>
|
||||
<!-- Summary for preference to add a device [CHAR LIMIT=none]-->
|
||||
<string name="connected_device_add_device_summary">Bluetooth will turn on to enable pairing</string>
|
||||
<!-- Title for other connection preferences [CHAR LIMIT=none]-->
|
||||
<string name="connected_device_connections_title">Connection preferences</string>
|
||||
|
||||
<!-- Date & time settings screen title -->
|
||||
<string name="date_and_time">Date & time</string>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="connected_devices_screen"
|
||||
android:title="@string/connected_devices_dashboard_title">
|
||||
|
||||
@@ -26,4 +27,17 @@
|
||||
<PreferenceCategory
|
||||
android:key="saved_device_list"
|
||||
android:title="@string/connected_device_saved_title"/>
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
|
||||
android:key="add_bt_devices"
|
||||
android:title="@string/connected_device_add_device_title"
|
||||
android:icon="@drawable/ic_menu_add"
|
||||
android:summary="@string/connected_device_add_device_summary"
|
||||
settings:allowDividerAbove="true"/>
|
||||
|
||||
<Preference
|
||||
android:key="connection_preferences"
|
||||
android:title="@string/connected_device_connections_title"
|
||||
settings:allowDividerAbove="true"/>
|
||||
</PreferenceScreen>
|
||||
|
@@ -73,10 +73,20 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
updateContent(mLocalAdapter.getBluetoothState());
|
||||
updateBluetooth();
|
||||
mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateBluetooth() {
|
||||
if (mLocalAdapter.isEnabled()) {
|
||||
updateContent(mLocalAdapter.getBluetoothState());
|
||||
} else {
|
||||
// Turn on bluetooth if it is disabled
|
||||
mLocalAdapter.enable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
@@ -64,8 +64,8 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
|
||||
controllers.add(new ConnectedDeviceGroupController(this, lifecycle));
|
||||
controllers.add(new SavedDeviceGroupController(this, lifecycle));
|
||||
return controllers;
|
||||
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.verify;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserManager;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -55,8 +54,6 @@ import org.robolectric.annotation.Config;
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class BluetoothPairingDetailTest {
|
||||
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private Resources mResource;
|
||||
@Mock
|
||||
@@ -133,6 +130,25 @@ public class BluetoothPairingDetailTest {
|
||||
verify(mFragment).finish();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBluetooth_bluetoothOff_turnOnBluetooth() {
|
||||
doReturn(false).when(mLocalAdapter).isEnabled();
|
||||
|
||||
mFragment.updateBluetooth();
|
||||
|
||||
verify(mLocalAdapter).enable();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateBluetooth_bluetoothOn_updateState() {
|
||||
doReturn(true).when(mLocalAdapter).isEnabled();
|
||||
doNothing().when(mFragment).updateContent(anyInt());
|
||||
|
||||
mFragment.updateBluetooth();
|
||||
|
||||
verify(mFragment).updateContent(anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnScanningStateChanged_restartScanAfterInitialScanning() {
|
||||
mFragment.mAvailableDevicesCategory = mAvailableDevicesCategory;
|
||||
@@ -181,6 +197,4 @@ public class BluetoothPairingDetailTest {
|
||||
verify(mAvailableDevicesCategory, times(1)).removeAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user