Merge "[Sound panel] Update Ui layout to match with mertial next" into sc-v2-dev

This commit is contained in:
Shaowei Shen
2021-10-13 12:01:47 +00:00
committed by Android (Google) Code Review
12 changed files with 116 additions and 123 deletions

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<stroke
android:color="?androidprv:attr/colorAccentPrimaryVariant"
android:width="1dp"/>
<corners android:radius="24dp"/>
<padding
android:left="16dp"
android:right="16dp"
android:top="8dp"
android:bottom="8dp" />
<solid android:color="@android:color/transparent" />
</shape>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<stroke
android:color="@android:color/transparent"
android:width="1dp"/>
<corners android:radius="20dp"/>
<padding
android:left="16dp"
android:right="16dp"
android:top="8dp"
android:bottom="8dp" />
<solid android:color="?androidprv:attr/colorAccentPrimary" />
</shape>

View File

@@ -86,7 +86,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_panel_title_margin" android:layout_marginTop="@dimen/settings_panel_title_margin"
android:layout_marginBottom="@dimen/settings_panel_title_margin" android:layout_marginBottom="@dimen/settings_panel_title_margin_bottom"
android:gravity="center" android:gravity="center"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp" android:textSize="24sp"
@@ -102,31 +102,23 @@
android:visibility="gone" android:visibility="gone"
style="@style/TrimmedHorizontalProgressBar"/> style="@style/TrimmedHorizontalProgressBar"/>
<include
android:id="@+id/header_divider"
layout="@layout/horizontal_divider"/>
<!-- Note: There is a landscape version of panel_slice_list which supports scrolling. --> <!-- Note: There is a landscape version of panel_slice_list which supports scrolling. -->
<include layout="@layout/panel_slice_list"/> <include layout="@layout/panel_slice_list"/>
<include
android:id="@+id/footer_divider"
layout="@layout/horizontal_divider"
android:visibility="gone"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="8dp" android:layout_marginTop="16dp"
android:paddingBottom="8dp"> android:layout_marginHorizontal="24dp"
android:layout_marginBottom="18dp">
<Button <Button
android:id="@+id/see_more" android:id="@+id/see_more"
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored" style="@style/PanelOptionRoundedOutlinedButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="36dp"
android:layout_marginStart="12dp" android:minWidth="0dp"
android:text="@string/see_more"/> android:text="@string/see_more"/>
<Space <Space
@@ -136,10 +128,10 @@
<Button <Button
android:id="@+id/done" android:id="@+id/done"
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored" style="@style/PanelOptionRoundedSolidButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="36dp"
android:layout_marginEnd="12dp" android:minWidth="0dp"
android:text="@string/done"/> android:text="@string/done"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@@ -25,6 +25,6 @@
style="@style/Widget.SliceView.Panel" style="@style/Widget.SliceView.Panel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="8dp" android:paddingVertical="@dimen/panel_slice_vertical_padding"
android:paddingEnd="8dp"/> android:paddingHorizontal="@dimen/panel_slice_Horizontal_padding"/>
</LinearLayout> </LinearLayout>

View File

@@ -26,6 +26,6 @@
style="@style/Widget.SliceView.Panel.Slider" style="@style/Widget.SliceView.Panel.Slider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="0dp" android:paddingVertical="@dimen/panel_slice_vertical_padding"
android:paddingEnd="0dp"/> android:paddingHorizontal="@dimen/panel_slice_Horizontal_padding"/>
</LinearLayout> </LinearLayout>

View File

@@ -426,8 +426,13 @@
<!-- Settings panel related dimensions --> <!-- Settings panel related dimensions -->
<dimen name="settings_panel_corner_radius">28dp</dimen> <dimen name="settings_panel_corner_radius">28dp</dimen>
<dimen name="settings_panel_title_margin">24dp</dimen> <dimen name="settings_panel_title_margin">24dp</dimen>
<dimen name="settings_panel_title_margin_bottom">16dp</dimen>
<dimen name="settings_panel_width">@dimen/match_parent</dimen> <dimen name="settings_panel_width">@dimen/match_parent</dimen>
<!-- Panel slices dimensions -->
<dimen name="panel_slice_vertical_padding">8dp</dimen>
<dimen name="panel_slice_Horizontal_padding">24dp</dimen>
<!-- Text padding for EmptyTextSettings --> <!-- Text padding for EmptyTextSettings -->
<dimen name="empty_text_padding">24dp</dimen> <dimen name="empty_text_padding">24dp</dimen>

View File

@@ -12885,7 +12885,7 @@
<string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string> <string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
<!-- See more items in contextual homepage [CHAR LIMIT=30]--> <!-- See more items in contextual homepage [CHAR LIMIT=30]-->
<string name="see_more">See more</string> <string name="see_more">Settings</string>
<!-- See less items in contextual homepage [CHAR LIMIT=30]--> <!-- See less items in contextual homepage [CHAR LIMIT=30]-->
<string name="see_less">See less</string> <string name="see_less">See less</string>

View File

@@ -585,15 +585,16 @@
</style> </style>
<style name="SliceRow.Slider"> <style name="SliceRow.Slider">
<!-- Padding between content and the start icon is 0dp --> <!-- Padding between content and the start icon is 5dp -->
<item name="contentStartPadding">0dp</item> <item name="contentStartPadding">5dp</item>
<item name="contentEndPadding">36dp</item> <item name="contentEndPadding">0dp</item>
<!-- 0dp start padding for the end item --> <!-- 0dp start padding for the end item -->
<item name="endItemStartPadding">0dp</item> <item name="endItemStartPadding">0dp</item>
<!-- 8dp end padding for the end item --> <!-- 8dp end padding for the end item -->
<item name="endItemEndPadding">8dp</item> <item name="endItemEndPadding">8dp</item>
<item name="titleSize">20sp</item>
<!-- Align text with slider --> <!-- Align text with slider -->
<item name="titleStartPadding">11dp</item> <item name="titleStartPadding">11dp</item>
<item name="subContentStartPadding">11dp</item> <item name="subContentStartPadding">11dp</item>
@@ -624,6 +625,15 @@
<item name="android:paddingEnd">8dp</item> <item name="android:paddingEnd">8dp</item>
</style> </style>
<style name="PanelOptionRoundedOutlinedButton" parent="@android:style/Widget.Material.Button">
<item name="android:background">@drawable/volume_dialog_button_background_outline</item>
</style>
<style name="PanelOptionRoundedSolidButton" parent="@android:style/Widget.Material.Button">
<item name="android:textColor">@android:color/system_neutral1_900</item>
<item name="android:background">@drawable/volume_dialog_button_background_solid</item>
</style>
<style name="SetupWizardPartnerResource"> <style name="SetupWizardPartnerResource">
<!-- Disable to use partner overlay theme for outside setupwizard flow. --> <!-- Disable to use partner overlay theme for outside setupwizard flow. -->
<item name="sucUsePartnerResource">@bool/config_suc_use_partner_resource</item> <item name="sucUsePartnerResource">@bool/config_suc_use_partner_resource</item>

View File

@@ -100,10 +100,8 @@ public class PanelFragment extends Fragment {
private TextView mHeaderTitle; private TextView mHeaderTitle;
private TextView mHeaderSubtitle; private TextView mHeaderSubtitle;
private int mMaxHeight; private int mMaxHeight;
private View mFooterDivider;
private boolean mPanelCreating; private boolean mPanelCreating;
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private View mHeaderDivider;
private final Map<Uri, LiveData<Slice>> mSliceLiveData = new LinkedHashMap<>(); private final Map<Uri, LiveData<Slice>> mSliceLiveData = new LinkedHashMap<>();
@@ -210,9 +208,7 @@ public class PanelFragment extends Fragment {
mHeaderLayout = mLayoutView.findViewById(R.id.header_layout); mHeaderLayout = mLayoutView.findViewById(R.id.header_layout);
mHeaderTitle = mLayoutView.findViewById(R.id.header_title); mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle); mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
mProgressBar = mLayoutView.findViewById(R.id.progress_bar); mProgressBar = mLayoutView.findViewById(R.id.progress_bar);
mHeaderDivider = mLayoutView.findViewById(R.id.header_divider);
// Make the panel layout gone here, to avoid janky animation when updating from old panel. // Make the panel layout gone here, to avoid janky animation when updating from old panel.
// We will make it visible once the panel is ready to load. // We will make it visible once the panel is ready to load.
@@ -257,8 +253,6 @@ public class PanelFragment extends Fragment {
enableTitle(title); enableTitle(title);
} }
mFooterDivider.setVisibility(View.GONE);
mSeeMoreButton.setOnClickListener(getSeeMoreListener()); mSeeMoreButton.setOnClickListener(getSeeMoreListener());
mDoneButton.setOnClickListener(getCloseListener()); mDoneButton.setOnClickListener(getCloseListener());
@@ -324,10 +318,8 @@ public class PanelFragment extends Fragment {
private void updateProgressBar() { private void updateProgressBar() {
if (mPanel.isProgressBarVisible()) { if (mPanel.isProgressBarVisible()) {
mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);
mHeaderDivider.setVisibility(View.GONE);
} else { } else {
mProgressBar.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE);
mHeaderDivider.setVisibility(View.VISIBLE);
} }
} }

View File

@@ -16,7 +16,8 @@
package com.android.settings.panel; package com.android.settings.panel;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI; import static android.app.slice.Slice.HINT_ERROR;
import static android.app.slice.SliceItem.FORMAT_SLICE;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
@@ -31,6 +32,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.slice.Slice; import androidx.slice.Slice;
import androidx.slice.SliceItem;
import androidx.slice.widget.SliceView; import androidx.slice.widget.SliceView;
import com.android.settings.R; import com.android.settings.R;
@@ -113,8 +115,6 @@ public class PanelSlicesAdapter
public class SliceRowViewHolder extends RecyclerView.ViewHolder public class SliceRowViewHolder extends RecyclerView.ViewHolder
implements DividerItemDecoration.DividedViewHolder { implements DividerItemDecoration.DividedViewHolder {
private boolean mDividerAllowedAbove = true;
@VisibleForTesting @VisibleForTesting
final SliceView sliceView; final SliceView sliceView;
@VisibleForTesting @VisibleForTesting
@@ -137,8 +137,10 @@ public class PanelSlicesAdapter
// Do not show the divider above media devices switcher slice per request // Do not show the divider above media devices switcher slice per request
final Slice slice = sliceLiveData.getValue(); final Slice slice = sliceLiveData.getValue();
if (slice == null || slice.getUri().equals(MEDIA_OUTPUT_INDICATOR_SLICE_URI)) {
mDividerAllowedAbove = false; // Hides slice which reports with error hint or not contain any slice sub-item.
if (slice == null || !isValidSlice(slice)) {
sliceView.setVisibility(View.GONE);
} }
// Log Panel interaction // Log Panel interaction
@@ -156,14 +158,26 @@ public class PanelSlicesAdapter
); );
} }
private boolean isValidSlice(Slice slice) {
if (slice.getHints().contains(HINT_ERROR)) {
return false;
}
for (SliceItem item : slice.getItems()) {
if (item.getFormat().equals(FORMAT_SLICE)) {
return true;
}
}
return false;
}
@Override @Override
public boolean isDividerAllowedAbove() { public boolean isDividerAllowedAbove() {
return mDividerAllowedAbove; return false;
} }
@Override @Override
public boolean isDividerAllowedBelow() { public boolean isDividerAllowedBelow() {
return true; return false;
} }
} }
} }

View File

@@ -17,8 +17,6 @@
package com.android.settings.panel; package com.android.settings.panel;
import static com.android.settings.panel.PanelContent.VIEW_TYPE_SLIDER;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
@@ -212,38 +210,6 @@ public class PanelFragmentTest {
assertThat(titleView.getVisibility()).isEqualTo(View.VISIBLE); assertThat(titleView.getVisibility()).isEqualTo(View.VISIBLE);
} }
@Test
public void sliderPanelType_notDisplayFooterDivider() {
mFakePanelContent.setViewType(VIEW_TYPE_SLIDER);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
activityController.setup();
final PanelFragment panelFragment = (PanelFragment)
Objects.requireNonNull(activityController
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
// Check visibility
assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void defaultPanelType_notDisplayFooterDivider() {
mFakePanelContent.setViewType(0 /* viewType */);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
activityController.setup();
final PanelFragment panelFragment = (PanelFragment)
Objects.requireNonNull(activityController
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
final View footerDivider = panelFragment.mLayoutView.findViewById(R.id.footer_divider);
// Check visibility
assertThat(footerDivider.getVisibility()).isEqualTo(View.GONE);
}
@Test @Test
public void onHeaderChanged_updateHeader_verifyTitle() { public void onHeaderChanged_updateHeader_verifyTitle() {
mFakePanelContent.setIcon(IconCompat.createWithResource(mContext, R.drawable.ic_android)); mFakePanelContent.setIcon(IconCompat.createWithResource(mContext, R.drawable.ic_android));

View File

@@ -19,7 +19,6 @@ 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.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_INDICATOR_SLICE_URI; import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -124,53 +123,6 @@ public class PanelSlicesAdapterTest {
assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES); assertThat(adapter.getData().size()).isEqualTo(MAX_NUM_OF_SLICES);
} }
@Test
public void mediaOutputIndicatorSlice_shouldNotAllowDividerAbove() {
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, 0 /* view type*/);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedAbove()).isFalse();
}
@Test
public void sliderPanelType_shouldAllowDividerBelow() {
addTestLiveData(VOLUME_MEDIA_URI);
mFakePanelContent.setViewType(PanelContent.VIEW_TYPE_SLIDER);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder =
adapter.onCreateViewHolder(view, PanelContent.VIEW_TYPE_SLIDER);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
}
@Test
public void defaultPanelType_shouldAllowDividerBelow() {
addTestLiveData(VOLUME_MEDIA_URI);
mFakePanelContent.setViewType(0 /* viewType */);
final PanelSlicesAdapter adapter =
new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
final int position = 0;
final ViewGroup view = new FrameLayout(mContext);
final SliceRowViewHolder viewHolder = adapter.onCreateViewHolder(view, 0/* viewType */);
adapter.onBindViewHolder(viewHolder, position);
assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
}
@Test @Test
public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() { public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() {
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI); addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);