Snap for 7821078 from e7f8a872a5 to sc-v2-release

Change-Id: If09588496663dd400342a1da315ac66864ba6443
This commit is contained in:
Android Build Coastguard Worker
2021-10-13 23:09:18 +00:00
14 changed files with 167 additions and 124 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

@@ -0,0 +1,47 @@
<?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.
-->
<!-- Layout used by BatterySaverScheduleSeekBarController for the seekbar widget. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="6dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:layout_marginStart="18dp"
android:singleLine="true"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<com.android.settings.widget.DefaultIndicatorSeekBar
android:id="@*android:id/seekbar"
style="@android:style/Widget.Material.SeekBar.Discrete"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="9dp" />
</LinearLayout>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

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>
<!-- 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>
@@ -13434,6 +13434,9 @@
<string name="default_active_sim_sms">SMS</string>
<!-- Provider Model: summary of default mobile data. [CHAR LIMIT=50] -->
<string name="default_active_sim_mobile_data">mobile data</string>
<!-- Provider Model: Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi
scanning is on. To mark a link to bring the user to "scanning settings" screen. [CHAR LIMIT=NONE]-->
<string name="wifi_scan_notify_message">To improve device experience, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location-based features and services. You can change this in Wi\u2011Fi scanning settings. <annotation id="link">Change</annotation></string>
<!-- Summary text separator for preferences including a short description
(eg. "Connected / 5G"). [CHAR LIMIT=50] -->

View File

@@ -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>

View File

@@ -55,7 +55,7 @@ public class BatterySaverScheduleSeekBarController implements
public BatterySaverScheduleSeekBarController(Context context) {
mContext = context;
mSeekBarPreference = new SeekBarPreference(context);
mSeekBarPreference.setLayoutResource(R.layout.preference_widget_seekbar_settings);
mSeekBarPreference.setLayoutResource(R.layout.battery_saver_schedule_percentage_seekbar);
mSeekBarPreference.setIconSpaceReserved(false);
mSeekBarPreference.setOnPreferenceChangeListener(this);
mSeekBarPreference.setContinuousUpdates(true);

View File

@@ -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);
}
}

View File

@@ -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;
}
}
}

View File

@@ -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));

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.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);