Import updated Android SetupCompat Library 385050340

Copied from google3/third_party/java_src/android_libs/setupcompat

Bug: 192619979
Test: mm

Included changes:
  - 385050340 [Tablet] Add partner configs for the start margin of butt...
  - 383799896 Refine Suggestion extra flag for notifying an activity th...
  - 383751271 [Tablet] Add partner configs to set both buttons on the r...

PiperOrigin-RevId: 385050340
Change-Id: Ie146223aa7078f0c78c95e867335e5d1919b3b08
diff --git a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
index 5f8bf67..fad5cbf 100644
--- a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
+++ b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
@@ -26,6 +26,7 @@
   private final PartnerConfig buttonDisableBackgroundConfig;
   private final PartnerConfig buttonIconConfig;
   private final PartnerConfig buttonTextColorConfig;
+  private final PartnerConfig buttonMarginStartConfig;
   private final PartnerConfig buttonTextSizeConfig;
   private final PartnerConfig buttonMinHeightConfig;
   private final PartnerConfig buttonTextTypeFaceConfig;
@@ -41,6 +42,7 @@
       PartnerConfig buttonDisableBackgroundConfig,
       PartnerConfig buttonIconConfig,
       PartnerConfig buttonTextColorConfig,
+      PartnerConfig buttonMarginStartConfig,
       PartnerConfig buttonTextSizeConfig,
       PartnerConfig buttonMinHeightConfig,
       PartnerConfig buttonTextTypeFaceConfig,
@@ -50,6 +52,7 @@
     this.partnerTheme = partnerTheme;
 
     this.buttonTextColorConfig = buttonTextColorConfig;
+    this.buttonMarginStartConfig = buttonMarginStartConfig;
     this.buttonTextSizeConfig = buttonTextSizeConfig;
     this.buttonMinHeightConfig = buttonMinHeightConfig;
     this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig;
@@ -86,6 +89,10 @@
     return buttonTextColorConfig;
   }
 
+  public PartnerConfig getButtonMarginStartConfig() {
+    return buttonMarginStartConfig;
+  }
+
   public PartnerConfig getButtonMinHeightConfig() {
     return buttonMinHeightConfig;
   }
@@ -118,6 +125,7 @@
     private PartnerConfig buttonDisableBackgroundConfig = null;
     private PartnerConfig buttonIconConfig = null;
     private PartnerConfig buttonTextColorConfig = null;
+    private PartnerConfig buttonMarginStartConfig = null;
     private PartnerConfig buttonTextSizeConfig = null;
     private PartnerConfig buttonMinHeight = null;
     private PartnerConfig buttonTextTypeFaceConfig = null;
@@ -154,6 +162,11 @@
       return this;
     }
 
+    public Builder setMarginStartConfig(PartnerConfig buttonMarginStartConfig) {
+      this.buttonMarginStartConfig = buttonMarginStartConfig;
+      return this;
+    }
+
     public Builder setTextColorConfig(PartnerConfig buttonTextColorConfig) {
       this.buttonTextColorConfig = buttonTextColorConfig;
       return this;
@@ -202,6 +215,7 @@
           buttonDisableBackgroundConfig,
           buttonIconConfig,
           buttonTextColorConfig,
+          buttonMarginStartConfig,
           buttonTextSizeConfig,
           buttonMinHeight,
           buttonTextTypeFaceConfig,
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index b75d972..a4c8df6 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -29,6 +29,7 @@
 import android.os.PersistableBundle;
 import android.util.AttributeSet;
 import android.view.ContextThemeWrapper;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewStub;
@@ -71,7 +72,7 @@
   @VisibleForTesting final boolean applyDynamicColor;
   @VisibleForTesting final boolean useFullDynamicColor;
 
-  private LinearLayout buttonContainer;
+  @VisibleForTesting LinearLayout buttonContainer;
   private FooterButton primaryButton;
   private FooterButton secondaryButton;
   @IdRes private int primaryButtonId;
@@ -214,8 +215,21 @@
     }
   }
 
+  private boolean isFooterButtonAlignedEnd(Context context) {
+    if (PartnerConfigHelper.get(context)
+        .isPartnerConfigAvailable(PartnerConfig.CONFIG_FOOTER_BUTTON_ALIGNED_END)) {
+      return PartnerConfigHelper.get(context)
+          .getBoolean(context, PartnerConfig.CONFIG_FOOTER_BUTTON_ALIGNED_END, false);
+    } else {
+      return false;
+    }
+  }
+
   private View addSpace() {
     LinearLayout buttonContainer = ensureFooterInflated();
+    if (isFooterButtonAlignedEnd(buttonContainer.getContext())) {
+      return null;
+    }
     View space = new View(buttonContainer.getContext());
     space.setLayoutParams(new LayoutParams(0, 0, 1.0f));
     space.setVisibility(View.INVISIBLE);
@@ -257,6 +271,9 @@
         footerBarPaddingTop,
         buttonContainer.getPaddingRight(),
         footerBarPaddingBottom);
+    if (isFooterButtonAlignedEnd(buttonContainer.getContext())) {
+      buttonContainer.setGravity(Gravity.END);
+    }
   }
 
   /**
@@ -343,6 +360,7 @@
             .setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
             .setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
             .setTextColorConfig(PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR)
+            .setMarginStartConfig(PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_MARGIN_START)
             .setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
             .setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
             .setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
@@ -417,6 +435,7 @@
                 usePrimaryStyle
                     ? PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR
                     : PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR)
+            .setMarginStartConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_MARGIN_START)
             .setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
             .setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
             .setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
diff --git a/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java b/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java
index ef45b5c..cc445a6 100644
--- a/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java
+++ b/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java
@@ -32,6 +32,7 @@
 import android.os.Build.VERSION_CODES;
 import android.util.StateSet;
 import android.util.TypedValue;
+import android.view.ViewGroup;
 import android.widget.Button;
 import androidx.annotation.ColorInt;
 import androidx.annotation.VisibleForTesting;
@@ -58,6 +59,7 @@
             .setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
             .setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
             .setTextColorConfig(PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR)
+            .setMarginStartConfig(PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_MARGIN_START)
             .setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
             .setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
             .setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
@@ -92,6 +94,7 @@
             .setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
             .setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
             .setTextColorConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR)
+            .setMarginStartConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_MARGIN_START)
             .setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
             .setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
             .setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
@@ -133,6 +136,8 @@
         applyDynamicColor,
         footerButtonPartnerConfig.getButtonTextColorConfig(),
         footerButtonPartnerConfig.getButtonRippleColorAlphaConfig());
+    FooterButtonStyleUtils.updateButtonMarginStartWithPartnerConfig(
+        context, button, footerButtonPartnerConfig.getButtonMarginStartConfig());
     FooterButtonStyleUtils.updateButtonTextSizeWithPartnerConfig(
         context, button, footerButtonPartnerConfig.getButtonTextSizeConfig());
     FooterButtonStyleUtils.updateButtonMinHeightWithPartnerConfig(
@@ -276,6 +281,19 @@
     }
   }
 
+  static void updateButtonMarginStartWithPartnerConfig(
+      Context context, Button button, PartnerConfig buttonMarginStartConfig) {
+    ViewGroup.LayoutParams lp = button.getLayoutParams();
+    boolean partnerConfigAvailable =
+        PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonMarginStartConfig);
+    if (partnerConfigAvailable && lp instanceof ViewGroup.MarginLayoutParams) {
+      final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
+      int startMargin =
+          (int) PartnerConfigHelper.get(context).getDimension(context, buttonMarginStartConfig);
+      mlp.setMargins(startMargin, mlp.topMargin, mlp.rightMargin, mlp.bottomMargin);
+    }
+  }
+
   static void updateButtonTextSizeWithPartnerConfig(
       Context context, Button button, PartnerConfig buttonTextSizeConfig) {
     float size = PartnerConfigHelper.get(context).getDimension(context, buttonTextSizeConfig);
diff --git a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
index 79976bc..84bd68b 100644
--- a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
+++ b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
@@ -65,6 +65,9 @@
    */
   public static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
 
+  /** Extra for notifying an activity that was called from suggested action activity. */
+  public static final String EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW = "isSuwSuggestedActionFlow";
+
   public static final String EXTRA_THEME = "theme";
   public static final String EXTRA_USE_IMMERSIVE_MODE = "useImmersiveMode";
 
@@ -122,7 +125,8 @@
             EXTRA_IS_DEFERRED_SETUP,
             EXTRA_IS_PRE_DEFERRED_SETUP,
             EXTRA_IS_PORTAL_SETUP,
-            EXTRA_IS_SETUP_FLOW)) {
+            EXTRA_IS_SETUP_FLOW,
+            EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW)) {
       dstIntent.putExtra(key, srcIntent.getBooleanExtra(key, false));
     }
 
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
index 280ab81..305db70 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
@@ -108,6 +108,10 @@
   CONFIG_FOOTER_BUTTON_MIN_HEIGHT(
       PartnerConfigKey.KEY_FOOTER_BUTTON_MIN_HEIGHT, ResourceType.DIMENSION),
 
+  // Make the footer buttons all aligned the end
+  CONFIG_FOOTER_BUTTON_ALIGNED_END(
+      PartnerConfigKey.KEY_FOOTER_BUTTON_ALIGNED_END, ResourceType.BOOL),
+
   // Disabled background alpha of the footer buttons
   CONFIG_FOOTER_BUTTON_DISABLED_ALPHA(
       PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_ALPHA, ResourceType.FRACTION),
@@ -124,6 +128,10 @@
   CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR(
       PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_TEXT_COLOR, ResourceType.COLOR),
 
+  // Margin start of the primary footer button
+  CONFIG_FOOTER_PRIMARY_BUTTON_MARGIN_START(
+      PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_MARGIN_START, ResourceType.DIMENSION),
+
   // Background color of the secondary footer button
   CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR(
       PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_BG_COLOR, ResourceType.COLOR),
@@ -132,6 +140,10 @@
   CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR(
       PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_TEXT_COLOR, ResourceType.COLOR),
 
+  // Margin start of the secondary footer button
+  CONFIG_FOOTER_SECONDARY_BUTTON_MARGIN_START(
+      PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_MARGIN_START, ResourceType.DIMENSION),
+
   // Background color of layout
   CONFIG_LAYOUT_BACKGROUND_COLOR(PartnerConfigKey.KEY_LAYOUT_BACKGROUND_COLOR, ResourceType.COLOR),
 
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
index c7444a5..211a271 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
@@ -47,12 +47,15 @@
   PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_SIZE,
   PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_STYLE,
   PartnerConfigKey.KEY_FOOTER_BUTTON_MIN_HEIGHT,
+  PartnerConfigKey.KEY_FOOTER_BUTTON_ALIGNED_END,
   PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_ALPHA,
   PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_BG_COLOR,
   PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_BG_COLOR,
   PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_TEXT_COLOR,
+  PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_MARGIN_START,
   PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_BG_COLOR,
   PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_TEXT_COLOR,
+  PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_MARGIN_START,
   PartnerConfigKey.KEY_LAYOUT_BACKGROUND_COLOR,
   PartnerConfigKey.KEY_LAYOUT_MARGIN_START,
   PartnerConfigKey.KEY_LAYOUT_MARGIN_END,
@@ -204,6 +207,9 @@
   // The min height of the footer buttons
   String KEY_FOOTER_BUTTON_MIN_HEIGHT = "setup_compat_footer_button_min_height";
 
+  // Make the footer buttons all aligned the end
+  String KEY_FOOTER_BUTTON_ALIGNED_END = "setup_compat_footer_button_aligned_end";
+
   // Disabled background alpha of the footer buttons
   String KEY_FOOTER_BUTTON_DISABLED_ALPHA = "setup_compat_footer_button_disabled_alpha";
 
@@ -216,12 +222,19 @@
   // Text color of the primary footer button
   String KEY_FOOTER_PRIMARY_BUTTON_TEXT_COLOR = "setup_compat_footer_primary_button_text_color";
 
+  // Margin start of the primary footer button
+  String KEY_FOOTER_PRIMARY_BUTTON_MARGIN_START = "setup_compat_footer_primary_button_margin_start";
+
   // Background color of the secondary footer button
   String KEY_FOOTER_SECONDARY_BUTTON_BG_COLOR = "setup_compat_footer_secondary_button_bg_color";
 
   // Text color of the secondary footer button
   String KEY_FOOTER_SECONDARY_BUTTON_TEXT_COLOR = "setup_compat_footer_secondary_button_text_color";
 
+  // Margin start of the secondary footer button
+  String KEY_FOOTER_SECONDARY_BUTTON_MARGIN_START =
+      "setup_compat_footer_secondary_button_margin_start";
+
   // Background color of layout
   String KEY_LAYOUT_BACKGROUND_COLOR = "setup_design_layout_bg_color";