Inline slider with header

Add a header to the slider slices to allow for a second line of text.
This is important to add more context to slices outside of settings.

Fixes: 80157462
Test: robotests
Merged-In: Ida90c9377afb19de320dfce54175f51eee088cfe
Change-Id: I1a1be345e84cbd9f300440e6431d4b331d051dac
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index feb7042..43216f8 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -282,6 +282,7 @@
         final PendingIntent actionIntent = getSliderAction(context, sliceData);
         final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
         final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
+        final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
         @ColorInt final int color = Utils.getColorAccent(context);
         final SliceAction primaryAction = new SliceAction(contentIntent, icon,
                 sliceData.getTitle());
@@ -289,12 +290,14 @@
 
         return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
                 .setAccentColor(color)
-                .addInputRange(builder -> builder
+                .setHeader(builder -> builder
                         .setTitle(sliceData.getTitle())
+                        .setSubtitle(subtitleText)
+                        .setPrimaryAction(primaryAction))
+                .addInputRange(builder -> builder
                         .setMax(sliderController.getMaxSteps())
                         .setValue(sliderController.getSliderPosition())
-                        .setInputAction(actionIntent)
-                        .setPrimaryAction(primaryAction))
+                        .setInputAction(actionIntent))
                 .setKeywords(keywords)
                 .build();
     }
diff --git a/tests/robotests/src/com/android/settings/testutils/SliceTester.java b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
index f617aa9..870adae 100644
--- a/tests/robotests/src/com/android/settings/testutils/SliceTester.java
+++ b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
@@ -150,14 +150,17 @@
         final int color = colorItem.getInt();
         assertThat(color).isEqualTo(Utils.getColorAccent(context));
 
-        final IconCompat expectedToggleIcon = IconCompat.createWithResource(context,
+        final SliceAction primaryAction = metadata.getPrimaryAction();
+
+        final IconCompat expectedIcon = IconCompat.createWithResource(context,
                 sliceData.getIconResource());
+        assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
 
         final long sliceTTL = metadata.getExpiry();
         assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
 
         // Check primary intent
-        final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
+        final PendingIntent primaryPendingIntent = primaryAction.getAction();
         assertThat(primaryPendingIntent).isEqualTo(
                 SliceBuilderUtils.getContentPendingIntent(context, sliceData));