Merge "[Sound panel] Update Ui layout to match with mertial next" into sc-v2-dev
This commit is contained in:
31
res/drawable/volume_dialog_button_background_outline.xml
Normal file
31
res/drawable/volume_dialog_button_background_outline.xml
Normal 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>
|
31
res/drawable/volume_dialog_button_background_solid.xml
Normal file
31
res/drawable/volume_dialog_button_background_solid.xml
Normal 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>
|
@@ -86,7 +86,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="24sp"
|
||||
@@ -102,31 +102,23 @@
|
||||
android:visibility="gone"
|
||||
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. -->
|
||||
<include layout="@layout/panel_slice_list"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/footer_divider"
|
||||
layout="@layout/horizontal_divider"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginBottom="18dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/see_more"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||
style="@style/PanelOptionRoundedOutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_height="36dp"
|
||||
android:minWidth="0dp"
|
||||
android:text="@string/see_more"/>
|
||||
|
||||
<Space
|
||||
@@ -136,10 +128,10 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/done"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
|
||||
style="@style/PanelOptionRoundedSolidButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_height="36dp"
|
||||
android:minWidth="0dp"
|
||||
android:text="@string/done"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
@@ -25,6 +25,6 @@
|
||||
style="@style/Widget.SliceView.Panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"/>
|
||||
android:paddingVertical="@dimen/panel_slice_vertical_padding"
|
||||
android:paddingHorizontal="@dimen/panel_slice_Horizontal_padding"/>
|
||||
</LinearLayout>
|
@@ -26,6 +26,6 @@
|
||||
style="@style/Widget.SliceView.Panel.Slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"/>
|
||||
android:paddingVertical="@dimen/panel_slice_vertical_padding"
|
||||
android:paddingHorizontal="@dimen/panel_slice_Horizontal_padding"/>
|
||||
</LinearLayout>
|
@@ -426,8 +426,13 @@
|
||||
<!-- Settings panel related dimensions -->
|
||||
<dimen name="settings_panel_corner_radius">28dp</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>
|
||||
|
||||
<!-- Panel slices dimensions -->
|
||||
<dimen name="panel_slice_vertical_padding">8dp</dimen>
|
||||
<dimen name="panel_slice_Horizontal_padding">24dp</dimen>
|
||||
|
||||
<!-- Text padding for EmptyTextSettings -->
|
||||
<dimen name="empty_text_padding">24dp</dimen>
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
<!-- 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]-->
|
||||
<string name="see_less">See less</string>
|
||||
|
||||
|
@@ -585,15 +585,16 @@
|
||||
</style>
|
||||
|
||||
<style name="SliceRow.Slider">
|
||||
<!-- Padding between content and the start icon is 0dp -->
|
||||
<item name="contentStartPadding">0dp</item>
|
||||
<item name="contentEndPadding">36dp</item>
|
||||
<!-- Padding between content and the start icon is 5dp -->
|
||||
<item name="contentStartPadding">5dp</item>
|
||||
<item name="contentEndPadding">0dp</item>
|
||||
|
||||
<!-- 0dp start padding for the end item -->
|
||||
<item name="endItemStartPadding">0dp</item>
|
||||
<!-- 8dp end padding for the end item -->
|
||||
<item name="endItemEndPadding">8dp</item>
|
||||
|
||||
<item name="titleSize">20sp</item>
|
||||
<!-- Align text with slider -->
|
||||
<item name="titleStartPadding">11dp</item>
|
||||
<item name="subContentStartPadding">11dp</item>
|
||||
@@ -624,6 +625,15 @@
|
||||
<item name="android:paddingEnd">8dp</item>
|
||||
</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">
|
||||
<!-- Disable to use partner overlay theme for outside setupwizard flow. -->
|
||||
<item name="sucUsePartnerResource">@bool/config_suc_use_partner_resource</item>
|
||||
|
@@ -100,10 +100,8 @@ public class PanelFragment extends Fragment {
|
||||
private TextView mHeaderTitle;
|
||||
private TextView mHeaderSubtitle;
|
||||
private int mMaxHeight;
|
||||
private View mFooterDivider;
|
||||
private boolean mPanelCreating;
|
||||
private ProgressBar mProgressBar;
|
||||
private View mHeaderDivider;
|
||||
|
||||
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);
|
||||
mHeaderTitle = mLayoutView.findViewById(R.id.header_title);
|
||||
mHeaderSubtitle = mLayoutView.findViewById(R.id.header_subtitle);
|
||||
mFooterDivider = mLayoutView.findViewById(R.id.footer_divider);
|
||||
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.
|
||||
// We will make it visible once the panel is ready to load.
|
||||
@@ -257,8 +253,6 @@ public class PanelFragment extends Fragment {
|
||||
enableTitle(title);
|
||||
}
|
||||
|
||||
mFooterDivider.setVisibility(View.GONE);
|
||||
|
||||
mSeeMoreButton.setOnClickListener(getSeeMoreListener());
|
||||
mDoneButton.setOnClickListener(getCloseListener());
|
||||
|
||||
@@ -324,10 +318,8 @@ public class PanelFragment extends Fragment {
|
||||
private void updateProgressBar() {
|
||||
if (mPanel.isProgressBarVisible()) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mHeaderDivider.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
mHeaderDivider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,8 @@
|
||||
|
||||
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.content.Context;
|
||||
@@ -31,6 +32,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceItem;
|
||||
import androidx.slice.widget.SliceView;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -113,8 +115,6 @@ public class PanelSlicesAdapter
|
||||
public class SliceRowViewHolder extends RecyclerView.ViewHolder
|
||||
implements DividerItemDecoration.DividedViewHolder {
|
||||
|
||||
private boolean mDividerAllowedAbove = true;
|
||||
|
||||
@VisibleForTesting
|
||||
final SliceView sliceView;
|
||||
@VisibleForTesting
|
||||
@@ -137,8 +137,10 @@ public class PanelSlicesAdapter
|
||||
|
||||
// Do not show the divider above media devices switcher slice per request
|
||||
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
|
||||
@@ -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
|
||||
public boolean isDividerAllowedAbove() {
|
||||
return mDividerAllowedAbove;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDividerAllowedBelow() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@
|
||||
|
||||
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 org.mockito.ArgumentMatchers.any;
|
||||
@@ -212,38 +210,6 @@ public class PanelFragmentTest {
|
||||
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
|
||||
public void onHeaderChanged_updateHeader_verifyTitle() {
|
||||
mFakePanelContent.setIcon(IconCompat.createWithResource(mContext, R.drawable.ic_android));
|
||||
|
@@ -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.PanelSlicesAdapter.MAX_NUM_OF_SLICES;
|
||||
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;
|
||||
|
||||
@@ -124,53 +123,6 @@ public class PanelSlicesAdapterTest {
|
||||
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
|
||||
public void mediaOutputIndicatorSlice_notSliderPanel_noSliderLayout() {
|
||||
addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
|
||||
|
Reference in New Issue
Block a user