Merge "Hide "Pair new device" from connected device slice"
This commit is contained in:
@@ -37,7 +37,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
|
||||
import com.android.settings.bluetooth.BluetoothPairingDetail;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
@@ -127,11 +126,6 @@ public class BluetoothDevicesSlice implements CustomSliceable {
|
||||
listBuilder.addRow(rows.get(i));
|
||||
}
|
||||
|
||||
// Add "Pair new device" if need.
|
||||
if (rows.size() < DEFAULT_EXPANDED_ROW_COUNT) {
|
||||
listBuilder.addRow(getPairNewDeviceRowBuilder());
|
||||
}
|
||||
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
@@ -268,26 +262,4 @@ public class BluetoothDevicesSlice implements CustomSliceable {
|
||||
return mContext.getResources().getQuantityString(R.plurals.show_bluetooth_devices,
|
||||
deviceCount, deviceCount);
|
||||
}
|
||||
|
||||
private ListBuilder.RowBuilder getPairNewDeviceRowBuilder() {
|
||||
final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title);
|
||||
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add);
|
||||
final SliceAction sliceAction = SliceAction.createDeeplink(
|
||||
getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title);
|
||||
|
||||
return new ListBuilder.RowBuilder()
|
||||
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
|
||||
.setTitle(title)
|
||||
.setPrimaryAction(sliceAction);
|
||||
}
|
||||
|
||||
private PendingIntent getPairNewDeviceIntent() {
|
||||
final Intent intent = new SubSettingLauncher(mContext)
|
||||
.setDestination(BluetoothPairingDetail.class.getName())
|
||||
.setTitleRes(R.string.bluetooth_pairing_page_title)
|
||||
.setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING)
|
||||
.toIntent();
|
||||
|
||||
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.slice.Slice;
|
||||
@@ -122,18 +121,6 @@ public class BluetoothDevicesSliceTest {
|
||||
SliceTester.assertAnySliceItemContainsTitle(sliceItems, BLUETOOTH_MOCK_TITLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_hasBluetoothDevices_shouldHavePairNewDevice() {
|
||||
mockBluetoothDeviceList(1);
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
|
||||
final Slice slice = mBluetoothDevicesSlice.getSlice();
|
||||
|
||||
final List<SliceItem> sliceItems = slice.getItems();
|
||||
SliceTester.assertAnySliceItemContainsTitle(sliceItems,
|
||||
mContext.getString(R.string.bluetooth_pairing_pref_title));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
@@ -145,17 +132,6 @@ public class BluetoothDevicesSliceTest {
|
||||
mContext.getString(R.string.no_bluetooth_devices));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_noBluetoothDevices_shouldNotHavePairNewDevice() {
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
|
||||
final Slice slice = mBluetoothDevicesSlice.getSlice();
|
||||
|
||||
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
|
||||
assertThat(hasTitle(metadata,
|
||||
mContext.getString(R.string.bluetooth_pairing_pref_title))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows() {
|
||||
mockBluetoothDeviceList(BluetoothDevicesSlice.DEFAULT_EXPANDED_ROW_COUNT + 1);
|
||||
@@ -204,9 +180,4 @@ public class BluetoothDevicesSliceTest {
|
||||
mBluetoothDeviceList.add(mCachedBluetoothDevice);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasTitle(SliceMetadata metadata, String title) {
|
||||
final CharSequence sliceTitle = metadata.getTitle();
|
||||
return TextUtils.equals(sliceTitle, title);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user