summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2022-05-11 16:08:43 +0800
committerpastychang <pastychang@google.com>2022-05-23 15:14:23 +0800
commit3c778d5d37d2ef344d1207726f5d3ab49fe803cb (patch)
treee94f2f0f46cd6d06fc62643eaf5c64bbb8a7cea7
parent0d3126a738d4ab2dae348b589d686c6c257c22eb (diff)
downloadsetupcompat-3c778d5d37d2ef344d1207726f5d3ab49fe803cb.tar.gz
Import updated Android SetupCompat Library 447928644android13-dev
Copied from google3/third_party/java_src/android_libs/setupcompat Test: mm Included changes: - 447928644 Set wrap content back if not a evenly weighting button. - 447370250 1.Modify targetSdk = 33 for SetupWizard and SearchSelector PiperOrigin-RevId: 447928644 Change-Id: I84ad65b397ac38f30f2a4a8ad8ba384fbb50abdb
-rw-r--r--main/java/com/google/android/setupcompat/template/FooterBarMixin.java29
-rw-r--r--main/java/com/google/android/setupcompat/util/BuildCompatUtils.java4
2 files changed, 26 insertions, 7 deletions
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 4d78955..4d2a0c9 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -33,6 +33,7 @@ import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.Button;
import android.widget.LinearLayout;
@@ -536,13 +537,12 @@ public class FooterBarMixin implements Mixin {
buttonContainer.addView(tempPrimaryButton);
}
- if (isEvenlyWeightedButtons) {
- setEvenlyWeightedButtons(tempPrimaryButton, tempSecondaryButton);
- }
+ setEvenlyWeightedButtons(tempPrimaryButton, tempSecondaryButton, isEvenlyWeightedButtons);
}
- private void setEvenlyWeightedButtons(Button primaryButton, Button secondaryButton) {
- if (primaryButton != null && secondaryButton != null) {
+ private void setEvenlyWeightedButtons(
+ Button primaryButton, Button secondaryButton, boolean isEvenlyWeighted) {
+ if (primaryButton != null && secondaryButton != null && isEvenlyWeighted) {
primaryButton.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int primaryButtonMeasuredWidth = primaryButton.getMeasuredWidth();
secondaryButton.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
@@ -552,6 +552,25 @@ public class FooterBarMixin implements Mixin {
primaryButton.getLayoutParams().width = maxButtonMeasureWidth;
secondaryButton.getLayoutParams().width = maxButtonMeasureWidth;
+ } else {
+ if (primaryButton != null) {
+ LinearLayout.LayoutParams primaryLayoutParams =
+ (LinearLayout.LayoutParams) primaryButton.getLayoutParams();
+ if (null != primaryLayoutParams) {
+ primaryLayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
+ primaryLayoutParams.weight = 0;
+ primaryButton.setLayoutParams(primaryLayoutParams);
+ }
+ }
+ if (secondaryButton != null) {
+ LinearLayout.LayoutParams secondaryLayoutParams =
+ (LinearLayout.LayoutParams) secondaryButton.getLayoutParams();
+ if (null != secondaryLayoutParams) {
+ secondaryLayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
+ secondaryLayoutParams.weight = 0;
+ secondaryButton.setLayoutParams(secondaryLayoutParams);
+ }
+ }
}
}
diff --git a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
index 8fa862f..3c4e2a2 100644
--- a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
+++ b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
@@ -72,8 +72,8 @@ public final class BuildCompatUtils {
* @return Whether the current OS version is higher or equal to T.
*/
public static boolean isAtLeastT() {
- if (!isAtLeastS()) {
- return false;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ return true;
}
return (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 33)
|| (Build.VERSION.CODENAME.length() == 1