Import updated Android Setupdesign Library 412158963

Copied from google3/third_party/java_src/android_libs/setupdesign

Test: mm

Included changes:
  - 412158963 Hide item divider in google service when system property ...
  - 412135443 Migrate compat classes to androidx
  - 411941072 [SetupDesing] To add android:importantForAccessibility="n...
  - 411938410 Support Item class config contentDescription for accessib...
  - 411691396 Add the attribute accessibilityHeading in header title
  - 411539431 [SetupDesing] Fix the keypad default focus issue in lands...
  - 411518305 [Stencil] Adds BC transition for RTL style on S.
  - 410938656 [Stencil] Makes HeaderMixin and DescriptionMixin supports...
  - 410189919 Fix sample app truncated in sw800 when partner config off

PiperOrigin-RevId: 412158963

Bug: 207099076

Change-Id: I094efbeaceada9a3a5b94018cf8e8ed8909d8e30
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.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 @@
 
     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 @@
 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.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.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 @@
   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 @@
     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 @@
     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 @@
       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 @@
     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.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.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;