diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-11-26 03:21:16 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-11-26 03:21:16 +0000 |
commit | d1f960f8891b8786f6fccb9ce5e7a2749e328f55 (patch) | |
tree | 9fe911dc4b1ffbf06751dc24f3ede4f79599d1bc | |
parent | e82a803759141643ea02e2e888e0a3f42507f191 (diff) | |
parent | da45aaa7e67ffa6213c1b5e6e638b4b10ef258fe (diff) | |
download | setupdesign-d1f960f8891b8786f6fccb9ce5e7a2749e328f55.tar.gz |
Import updated Android Setupdesign Library 412158963 am: da45aaa7e6
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupdesign/+/16339912
Change-Id: Ia79140ce5fcc1ebd61aba700681ef8a83c2a1fcd
19 files changed, 195 insertions, 49 deletions
diff --git a/main/res/anim-ldrtl-v31/sud_interpolator.xml b/main/res/anim-ldrtl-v31/sud_interpolator.xml new file mode 100644 index 0000000..bec77f0 --- /dev/null +++ b/main/res/anim-ldrtl-v31/sud_interpolator.xml @@ -0,0 +1,19 @@ +<?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. +--> + +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:pathData="M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1" /> diff --git a/main/res/anim-ldrtl-v31/sud_slide_back_in.xml b/main/res/anim-ldrtl-v31/sud_slide_back_in.xml new file mode 100644 index 0000000..006d9b4 --- /dev/null +++ b/main/res/anim-ldrtl-v31/sud_slide_back_in.xml @@ -0,0 +1,22 @@ +<?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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:duration="@integer/sudTransitionDuration" + android:fromXDelta="100%" + android:toXDelta="0%" + android:interpolator="@anim/sud_interpolator" /> diff --git a/main/res/anim-ldrtl-v31/sud_slide_back_out.xml b/main/res/anim-ldrtl-v31/sud_slide_back_out.xml new file mode 100644 index 0000000..341bbad --- /dev/null +++ b/main/res/anim-ldrtl-v31/sud_slide_back_out.xml @@ -0,0 +1,22 @@ +<?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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:duration="@integer/sudTransitionDuration" + android:fromXDelta="0%" + android:toXDelta="-100%" + android:interpolator="@anim/sud_interpolator" /> diff --git a/main/res/anim-ldrtl-v31/sud_slide_next_in.xml b/main/res/anim-ldrtl-v31/sud_slide_next_in.xml new file mode 100644 index 0000000..77d4cd5 --- /dev/null +++ b/main/res/anim-ldrtl-v31/sud_slide_next_in.xml @@ -0,0 +1,22 @@ +<?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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:duration="@integer/sudTransitionDuration" + android:fromXDelta="-100%" + android:toXDelta="0%" + android:interpolator="@anim/sud_interpolator" /> diff --git a/main/res/anim-ldrtl-v31/sud_slide_next_out.xml b/main/res/anim-ldrtl-v31/sud_slide_next_out.xml new file mode 100644 index 0000000..8ae16d4 --- /dev/null +++ b/main/res/anim-ldrtl-v31/sud_slide_next_out.xml @@ -0,0 +1,22 @@ +<?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. +--> + +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:duration="@integer/sudTransitionDuration" + android:fromXDelta="0%" + android:toXDelta="100%" + android:interpolator="@anim/sud_interpolator" /> diff --git a/main/res/layout-land-v31/sud_glif_blank_template_content.xml b/main/res/layout-land-v31/sud_glif_blank_template_content.xml index dd4d52d..fd7cbd2 100644 --- a/main/res/layout-land-v31/sud_glif_blank_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_blank_template_content.xml @@ -47,6 +47,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="@dimen/sud_glif_land_content_area_weight" + android:focusedByDefault="true" android:orientation="vertical"> <FrameLayout diff --git a/main/res/layout-land-v31/sud_glif_list_template_content.xml b/main/res/layout-land-v31/sud_glif_list_template_content.xml index 478ac5f..f7a353b 100644 --- a/main/res/layout-land-v31/sud_glif_list_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_list_template_content.xml @@ -58,6 +58,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="@dimen/sud_glif_land_content_area_weight" + android:focusedByDefault="true" android:orientation="vertical"> <com.google.android.setupdesign.view.StickyHeaderListView diff --git a/main/res/layout-land-v31/sud_glif_preference_template_content.xml b/main/res/layout-land-v31/sud_glif_preference_template_content.xml index c03d2fe..fcb9ff6 100644 --- a/main/res/layout-land-v31/sud_glif_preference_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_preference_template_content.xml @@ -58,6 +58,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="@dimen/sud_glif_land_content_area_weight" + android:focusedByDefault="true" android:orientation="vertical"> <FrameLayout diff --git a/main/res/layout-land-v31/sud_glif_recycler_template_content.xml b/main/res/layout-land-v31/sud_glif_recycler_template_content.xml index 4840caf..4bd56ea 100644 --- a/main/res/layout-land-v31/sud_glif_recycler_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_recycler_template_content.xml @@ -59,6 +59,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="@dimen/sud_glif_land_content_area_weight" + android:focusedByDefault="true" android:orientation="vertical"> <com.google.android.setupdesign.view.HeaderRecyclerView diff --git a/main/res/layout-land-v31/sud_glif_template_content.xml b/main/res/layout-land-v31/sud_glif_template_content.xml index d1b6b92..1e8f9a0 100644 --- a/main/res/layout-land-v31/sud_glif_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_template_content.xml @@ -58,6 +58,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="@dimen/sud_glif_land_content_area_weight" + android:focusedByDefault="true" android:orientation="vertical"> <com.google.android.setupdesign.view.BottomScrollView @@ -65,7 +66,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" - android:scrollIndicators="?attr/sudScrollIndicators"> + android:scrollIndicators="?attr/sudScrollIndicators" + android:importantForAccessibility="no"> <LinearLayout android:layout_width="match_parent" diff --git a/main/res/values/attrs.xml b/main/res/values/attrs.xml index 48003a0..3f167ac 100644 --- a/main/res/values/attrs.xml +++ b/main/res/values/attrs.xml @@ -187,6 +187,7 @@ <attr name="android:summary" /> <attr name="android:title" /> <attr name="android:visible" /> + <attr name="android:contentDescription" /> <attr name="sudIconTint" /> <attr name="sudIconGravity" /> </declare-styleable> diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index 7c0065d..c6dea59 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -701,6 +701,8 @@ <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/sudFontSecondary</item> <item name="android:textAlignment" tools:targetApi="jelly_bean_mr1">gravity</item> <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="android:textDirection" tools:targetApi="jelly_bean_mr1">locale</item> + <item name="android:accessibilityHeading" tools:targetApi="p">true</item> </style> <style name="SudGlifDescription" parent="SudDescription.Glif"> @@ -712,6 +714,7 @@ <item name="android:layout_marginEnd">?attr/sudMarginEnd</item> <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/sudFontSecondary</item> <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="android:textDirection" tools:targetApi="jelly_bean_mr1">locale</item> </style> <style name="SudGlifHeaderContainer"> diff --git a/main/src/com/google/android/setupdesign/DividerItemDecoration.java b/main/src/com/google/android/setupdesign/DividerItemDecoration.java index df86b23..dabe36f 100644 --- a/main/src/com/google/android/setupdesign/DividerItemDecoration.java +++ b/main/src/com/google/android/setupdesign/DividerItemDecoration.java @@ -21,10 +21,10 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import androidx.core.view.ViewCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import androidx.annotation.IntDef; +import androidx.core.view.ViewCompat; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index dcfc595..034509d 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -206,56 +206,66 @@ public class GlifLayout extends PartnerCustomizationLayout { View headerView = this.findManagedViewById(R.id.sud_landscape_header_area); if (headerView != null) { - if (PartnerConfigHelper.get(getContext()) - .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END)) { - int layoutMarginEnd = + int layoutMarginEnd; + if (shouldApplyPartnerResource() + && PartnerConfigHelper.get(getContext()) + .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END)) { + layoutMarginEnd = (int) PartnerConfigHelper.get(getContext()) .getDimension(getContext(), PartnerConfig.CONFIG_LAYOUT_MARGIN_END); - - int paddingEnd = (horizontalSpacing / 2) - layoutMarginEnd; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - headerView.setPadding( - headerView.getPaddingStart(), - headerView.getPaddingTop(), - paddingEnd, - headerView.getPaddingBottom()); - } else { - headerView.setPadding( - headerView.getPaddingLeft(), - headerView.getPaddingTop(), - paddingEnd, - headerView.getPaddingBottom()); - } + } else { + TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.sudMarginEnd}); + layoutMarginEnd = a.getDimensionPixelSize(0, 0); + a.recycle(); + } + int paddingEnd = (horizontalSpacing / 2) - layoutMarginEnd; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + headerView.setPadding( + headerView.getPaddingStart(), + headerView.getPaddingTop(), + paddingEnd, + headerView.getPaddingBottom()); + } else { + headerView.setPadding( + headerView.getPaddingLeft(), + headerView.getPaddingTop(), + paddingEnd, + headerView.getPaddingBottom()); } } View contentView = this.findManagedViewById(R.id.sud_landscape_content_area); if (contentView != null) { - if (PartnerConfigHelper.get(getContext()) - .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) { - int layoutMarginStart = + int layoutMarginStart; + if (shouldApplyPartnerResource() + && PartnerConfigHelper.get(getContext()) + .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) { + layoutMarginStart = (int) PartnerConfigHelper.get(getContext()) .getDimension(getContext(), PartnerConfig.CONFIG_LAYOUT_MARGIN_START); - - int paddingStart = 0; - if (headerView != null) { - paddingStart = (horizontalSpacing / 2) - layoutMarginStart; - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - contentView.setPadding( - paddingStart, - contentView.getPaddingTop(), - contentView.getPaddingEnd(), - contentView.getPaddingBottom()); - } else { - contentView.setPadding( - paddingStart, - contentView.getPaddingTop(), - contentView.getPaddingRight(), - contentView.getPaddingBottom()); - } + } else { + TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.sudMarginStart}); + layoutMarginStart = a.getDimensionPixelSize(0, 0); + a.recycle(); + } + int paddingStart = 0; + if (headerView != null) { + paddingStart = (horizontalSpacing / 2) - layoutMarginStart; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + contentView.setPadding( + paddingStart, + contentView.getPaddingTop(), + contentView.getPaddingEnd(), + contentView.getPaddingBottom()); + } else { + contentView.setPadding( + paddingStart, + contentView.getPaddingTop(), + contentView.getPaddingRight(), + contentView.getPaddingBottom()); } } } diff --git a/main/src/com/google/android/setupdesign/accessibility/LinkAccessibilityHelper.java b/main/src/com/google/android/setupdesign/accessibility/LinkAccessibilityHelper.java index 1a55b25..237cd83 100644 --- a/main/src/com/google/android/setupdesign/accessibility/LinkAccessibilityHelper.java +++ b/main/src/com/google/android/setupdesign/accessibility/LinkAccessibilityHelper.java @@ -19,9 +19,6 @@ package com.google.android.setupdesign.accessibility; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; -import androidx.core.view.AccessibilityDelegateCompat; -import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; -import androidx.core.view.accessibility.AccessibilityNodeProviderCompat; import android.text.Layout; import android.text.Spanned; import android.text.style.ClickableSpan; @@ -33,6 +30,9 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; +import androidx.core.view.AccessibilityDelegateCompat; +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; +import androidx.core.view.accessibility.AccessibilityNodeProviderCompat; import androidx.customview.widget.ExploreByTouchHelper; import java.util.List; diff --git a/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java b/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java index 29eaf23..c934612 100644 --- a/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java +++ b/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java @@ -24,16 +24,16 @@ import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; -import androidx.core.view.AccessibilityDelegateCompat; -import androidx.core.view.ViewCompat; -import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; -import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.TextView; +import androidx.core.view.AccessibilityDelegateCompat; +import androidx.core.view.ViewCompat; +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; +import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat; import com.google.android.setupdesign.R; import com.google.android.setupdesign.util.LayoutStyler; import com.google.android.setupdesign.view.CheckableLinearLayout; diff --git a/main/src/com/google/android/setupdesign/items/Item.java b/main/src/com/google/android/setupdesign/items/Item.java index 3947c62..ff2e3ce 100644 --- a/main/src/com/google/android/setupdesign/items/Item.java +++ b/main/src/com/google/android/setupdesign/items/Item.java @@ -44,6 +44,7 @@ public class Item extends AbstractItem { private int layoutRes; @Nullable private CharSequence summary; @Nullable private CharSequence title; + @Nullable private CharSequence contentDescription; private boolean visible = true; @ColorInt private int iconTint = Color.TRANSPARENT; private int iconGravity = Gravity.CENTER_VERTICAL; @@ -60,6 +61,7 @@ public class Item extends AbstractItem { icon = a.getDrawable(R.styleable.SudItem_android_icon); title = a.getText(R.styleable.SudItem_android_title); summary = a.getText(R.styleable.SudItem_android_summary); + contentDescription = a.getText(R.styleable.SudItem_android_contentDescription); layoutRes = a.getResourceId(R.styleable.SudItem_android_layout, getDefaultLayoutResource()); visible = a.getBoolean(R.styleable.SudItem_android_visible, true); iconTint = a.getColor(R.styleable.SudItem_sudIconTint, Color.TRANSPARENT); @@ -143,6 +145,16 @@ public class Item extends AbstractItem { return title; } + @Nullable + public CharSequence getContentDescription() { + return contentDescription; + } + + public void setContentDescription(@Nullable CharSequence contentDescription) { + this.contentDescription = contentDescription; + notifyItemChanged(); + } + public void setVisible(boolean visible) { if (this.visible == visible) { return; @@ -178,6 +190,8 @@ public class Item extends AbstractItem { summaryView.setVisibility(View.GONE); } + view.setContentDescription(getContentDescription()); + final View iconContainer = view.findViewById(R.id.sud_items_icon_container); final Drawable icon = getIcon(); if (icon != null) { diff --git a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java index fb69a8d..c4e8f56 100644 --- a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java +++ b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java @@ -269,6 +269,11 @@ public class RecyclerMixin implements Mixin { return dividerInsetEnd; } + /** Remove the divider inset from this RecyclerView. */ + public void removeDividerInset() { + recyclerView.removeItemDecoration(dividerDecoration); + } + private void updateDivider() { boolean shouldUpdate = true; if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) { diff --git a/main/src/com/google/android/setupdesign/view/RichTextView.java b/main/src/com/google/android/setupdesign/view/RichTextView.java index b86082e..182981f 100644 --- a/main/src/com/google/android/setupdesign/view/RichTextView.java +++ b/main/src/com/google/android/setupdesign/view/RichTextView.java @@ -23,7 +23,6 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; -import androidx.core.view.ViewCompat; import androidx.appcompat.widget.AppCompatTextView; import android.text.Annotation; import android.text.SpannableString; @@ -36,6 +35,7 @@ import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import androidx.annotation.VisibleForTesting; +import androidx.core.view.ViewCompat; import com.google.android.setupdesign.accessibility.LinkAccessibilityHelper; import com.google.android.setupdesign.span.LinkSpan; import com.google.android.setupdesign.span.LinkSpan.OnLinkClickListener; |