Output switcher panel requires large title icon for Slice slider style
-Add "VIEW_TYPE_SLIDER_LARGE_ICON" to be a new panel type which would enlarge its title icon -Set "VIEW_TYPE_SLIDER_LARGE_ICON" to MediaOutputPanel and MediaOutputGroupPanel -Extend slider style and add customized icon size -Add test cases Bug: 157208551 Test: make -j42 RunSettingsRoboTests Change-Id: I9b4de4aa552e8b26e766411f7eff93ea1a2d1910
This commit is contained in:
31
res/layout/panel_slice_slider_row_large_icon.xml
Normal file
31
res/layout/panel_slice_slider_row_large_icon.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2020 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/slice_slider_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.slice.widget.SliceView
|
||||||
|
android:id="@+id/slice_view"
|
||||||
|
style="@style/Widget.SliceView.Panel.Slider.LargeIcon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="0dp"/>
|
||||||
|
</LinearLayout>
|
@@ -533,6 +533,10 @@
|
|||||||
<item name="rowStyle">@style/SliceRow.Slider</item>
|
<item name="rowStyle">@style/SliceRow.Slider</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Widget.SliceView.Panel.Slider.LargeIcon">
|
||||||
|
<item name="rowStyle">@style/SliceRow.Slider.LargeIcon</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="SliceRow">
|
<style name="SliceRow">
|
||||||
<!-- 2dp start padding for the start icon -->
|
<!-- 2dp start padding for the start icon -->
|
||||||
<item name="titleItemStartPadding">2dp</item>
|
<item name="titleItemStartPadding">2dp</item>
|
||||||
@@ -576,6 +580,11 @@
|
|||||||
<item name="subContentStartPadding">11dp</item>
|
<item name="subContentStartPadding">11dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="SliceRow.Slider.LargeIcon">
|
||||||
|
<!-- Layout is 48dp and actual icon size is 48-(iconSize/2) -->
|
||||||
|
<item name="iconSize">12dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
|
<style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
|
||||||
<item name="android:layout_margin">16dp</item>
|
<item name="android:layout_margin">16dp</item>
|
||||||
<item name="android:paddingStart">8dp</item>
|
<item name="android:paddingStart">8dp</item>
|
||||||
|
@@ -159,6 +159,6 @@ public class MediaOutputGroupPanel implements PanelContent, LocalMediaManager.De
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewType() {
|
public int getViewType() {
|
||||||
return PanelContent.VIEW_TYPE_SLIDER;
|
return PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -246,7 +246,7 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewType() {
|
public int getViewType() {
|
||||||
return PanelContent.VIEW_TYPE_SLIDER;
|
return PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MediaController.Callback mCb = new MediaController.Callback() {
|
private final MediaController.Callback mCb = new MediaController.Callback() {
|
||||||
|
@@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
public interface PanelContent extends Instrumentable {
|
public interface PanelContent extends Instrumentable {
|
||||||
|
|
||||||
int VIEW_TYPE_SLIDER = 1;
|
int VIEW_TYPE_SLIDER = 1;
|
||||||
|
int VIEW_TYPE_SLIDER_LARGE_ICON = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a icon for the title of the Panel.
|
* @return a icon for the title of the Panel.
|
||||||
|
@@ -75,6 +75,8 @@ public class PanelSlicesAdapter
|
|||||||
View view;
|
View view;
|
||||||
if (viewType == PanelContent.VIEW_TYPE_SLIDER) {
|
if (viewType == PanelContent.VIEW_TYPE_SLIDER) {
|
||||||
view = inflater.inflate(R.layout.panel_slice_slider_row, viewGroup, false);
|
view = inflater.inflate(R.layout.panel_slice_slider_row, viewGroup, false);
|
||||||
|
} else if (viewType == PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON) {
|
||||||
|
view = inflater.inflate(R.layout.panel_slice_slider_row_large_icon, viewGroup, false);
|
||||||
} else {
|
} else {
|
||||||
view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
|
view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
|
||||||
}
|
}
|
||||||
|
@@ -72,4 +72,9 @@ public class MediaOutputGroupPanelTest {
|
|||||||
public void getSeeMoreIntent_isNull() {
|
public void getSeeMoreIntent_isNull() {
|
||||||
assertThat(mPanel.getSeeMoreIntent()).isNull();
|
assertThat(mPanel.getSeeMoreIntent()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getViewType_checkType() {
|
||||||
|
assertThat(mPanel.getViewType()).isEqualTo(PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -312,4 +312,9 @@ public class MediaOutputPanelTest {
|
|||||||
|
|
||||||
verify(mCallback).forceClose();
|
verify(mCallback).forceClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getViewType_checkType() {
|
||||||
|
assertThat(mPanel.getViewType()).isEqualTo(PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.panel;
|
package com.android.settings.panel;
|
||||||
|
|
||||||
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER;
|
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER;
|
||||||
|
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER_LARGE_ICON;
|
||||||
import static com.android.settings.panel.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
|
import static com.android.settings.panel.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
|
||||||
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_GROUP_SLICE_URI;
|
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_GROUP_SLICE_URI;
|
||||||
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
|
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
|
||||||
@@ -206,6 +207,19 @@ public class PanelSlicesAdapterTest {
|
|||||||
assertThat(intArgumentCaptor.getValue()).isEqualTo(R.layout.panel_slice_slider_row);
|
assertThat(intArgumentCaptor.getValue()).isEqualTo(R.layout.panel_slice_slider_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreateViewHolder_viewTypeSliderLargeIcon_verifyLayout() {
|
||||||
|
final PanelSlicesAdapter adapter = new PanelSlicesAdapter(mPanelFragment, mData, 0);
|
||||||
|
final ViewGroup view = new FrameLayout(mContext);
|
||||||
|
final ArgumentCaptor<Integer> intArgumentCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||||
|
|
||||||
|
adapter.onCreateViewHolder(view, VIEW_TYPE_SLIDER_LARGE_ICON);
|
||||||
|
|
||||||
|
verify(sLayoutInflater).inflate(intArgumentCaptor.capture(), eq(view), eq(false));
|
||||||
|
assertThat(intArgumentCaptor.getValue()).isEqualTo(
|
||||||
|
R.layout.panel_slice_slider_row_large_icon);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onCreateViewHolder_viewTypeDefault_verifyLayout() {
|
public void onCreateViewHolder_viewTypeDefault_verifyLayout() {
|
||||||
final PanelSlicesAdapter adapter =
|
final PanelSlicesAdapter adapter =
|
||||||
|
@@ -70,4 +70,9 @@ public class VolumePanelTest {
|
|||||||
public void getSeeMoreIntent_notNull() {
|
public void getSeeMoreIntent_notNull() {
|
||||||
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
|
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getViewType_checkType() {
|
||||||
|
assertThat(mPanel.getViewType()).isEqualTo(PanelContent.VIEW_TYPE_SLIDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user