Update preferenceSlice layout rule for new volume panel design

-show icon at left side of Slice if the mapping preference contains icon
-align MediaOutputIndicatorSlice layout with other volume slice

Bug: 148821795
Test: make -j42 RunSettingsRoboTests
Change-Id: I5b0cf7f32f355503942cb62ccf36f77ceeb1b30d
This commit is contained in:
timhypeng
2020-02-04 10:19:33 +08:00
committed by tim peng
parent b7f5bf4682
commit da96aeb33d
2 changed files with 22 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import android.app.PendingIntent;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Log;
@@ -77,18 +78,24 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
final SliceAction primarySliceAction = SliceAction.createDeeplink(
primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
// To set an empty icon to indent the row
final ListBuilder listBuilder = new ListBuilder(mContext,
MEDIA_OUTPUT_INDICATOR_SLICE_URI,
ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new ListBuilder.RowBuilder()
.setTitle(title)
.setTitleItem(createEmptyIcon(), ListBuilder.ICON_IMAGE)
.setSubtitle(findActiveDeviceName())
.setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
private IconCompat createEmptyIcon() {
final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
return IconCompat.createWithBitmap(bitmap);
}
private Intent getMediaOutputSliceIntent() {
final Intent intent = new Intent()
.setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)

View File

@@ -286,7 +286,7 @@ public class SliceBuilderUtils {
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
@ColorInt int color = Utils.getColorAccentDefaultColor(context);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
final SliceAction primaryAction = SliceAction.createDeeplink(contentIntent, icon,
ListBuilder.ICON_IMAGE, sliceData.getTitle());
@@ -299,17 +299,22 @@ public class SliceBuilderUtils {
if (cur > sliderController.getMax()) {
cur = sliderController.getMax();
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color)
.addInputRange(new InputRangeBuilder()
final InputRangeBuilder inputRangeBuilder = new InputRangeBuilder()
.setTitle(sliceData.getTitle())
.setSubtitle(subtitleText)
.setPrimaryAction(primaryAction)
.setMax(sliderController.getMax())
.setMin(sliderController.getMin())
.setValue(cur)
.setInputAction(actionIntent))
.setInputAction(actionIntent);
if (sliceData.getIconResource() != 0) {
inputRangeBuilder.setTitleItem(icon, ListBuilder.ICON_IMAGE);
color = CustomSliceable.COLOR_NOT_TINTED;
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color)
.addInputRange(inputRangeBuilder)
.setKeywords(keywords)
.build();
}