summaryrefslogtreecommitdiff
path: root/main/java/com/google/android/setupcompat
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2019-04-02 13:42:22 +0800
committerNicole Huang <nicolehuang@google.com>2019-04-03 11:16:01 +0800
commit5b6b1b301b6261397427cb510c5d02b3e10345de (patch)
tree5182a36fdfab3d6956db7d3613bf9ca3b951283c /main/java/com/google/android/setupcompat
parentde9b52a147ec3aeb290d01d0eda1867aa3103acd (diff)
downloadsetupcompat-5b6b1b301b6261397427cb510c5d02b3e10345de.tar.gz
Import updated Android SetupCompat Library 241465949
Copied from google3/third_party/java_src/android_libs/setupcompat Test: mm Included changes: - 241465949 Fix lint error for setupcompat library. - 241273207 Add null checking for isAnySetupWizard PiperOrigin-RevId: 241465949 Change-Id: I21857f3cd7733ede34ab37cec7293c6b35e9d903
Diffstat (limited to 'main/java/com/google/android/setupcompat')
-rw-r--r--main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java2
-rw-r--r--main/java/com/google/android/setupcompat/internal/BuildCompat.java2
-rw-r--r--main/java/com/google/android/setupcompat/template/FooterBarMixin.java28
-rw-r--r--main/java/com/google/android/setupcompat/template/FooterButton.java5
-rw-r--r--main/java/com/google/android/setupcompat/util/SystemBarHelper.java14
-rw-r--r--main/java/com/google/android/setupcompat/util/WizardManagerHelper.java14
6 files changed, 32 insertions, 33 deletions
diff --git a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
index 0e85268..f144242 100644
--- a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
+++ b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
@@ -155,7 +155,7 @@ public class PartnerCustomizationLayout extends TemplateLayout {
attrs, R.styleable.SucPartnerCustomizationLayout, defStyleAttr, 0);
if (!a.hasValue(R.styleable.SucPartnerCustomizationLayout_sucUsePartnerResource)) {
- // TODO(b/128961334): Enable Log.WTF after other client already set sucUsePartnerResource.
+ // TODO: Enable Log.WTF after other client already set sucUsePartnerResource.
Log.e(TAG, "Attribute sucUsePartnerResource not found in " + activity.getComponentName());
}
diff --git a/main/java/com/google/android/setupcompat/internal/BuildCompat.java b/main/java/com/google/android/setupcompat/internal/BuildCompat.java
index 54c0911..7aeb85d 100644
--- a/main/java/com/google/android/setupcompat/internal/BuildCompat.java
+++ b/main/java/com/google/android/setupcompat/internal/BuildCompat.java
@@ -8,7 +8,7 @@ public final class BuildCompat {
private BuildCompat() {}
- // TODO(b/127925696): remove the code for pre-release version of Android Q
+ // TODO: remove the code for pre-release version of Android Q
public static boolean isAtLeastQ() {
return (VERSION.SDK_INT > VERSION_CODES.P)
|| (VERSION.CODENAME.length() == 1
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 005471d..c9c76b0 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -52,6 +52,8 @@ import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import com.google.android.setupcompat.PartnerCustomizationLayout;
import com.google.android.setupcompat.R;
+import com.google.android.setupcompat.internal.BuildCompat;
+import com.google.android.setupcompat.internal.Preconditions;
import com.google.android.setupcompat.internal.TemplateLayout;
import com.google.android.setupcompat.logging.internal.FooterBarMixinMetrics;
import com.google.android.setupcompat.partnerconfig.PartnerConfig;
@@ -231,7 +233,7 @@ public class FooterBarMixin implements Mixin {
if (footerButton.getTheme() == 0 || applyPartnerResources) {
footerButton.setTheme(R.style.SucPartnerCustomizationButton_Primary);
}
- // TODO(b/120055778): Make sure customize attributes in theme can be applied during setup flow.
+ // TODO: Make sure customize attributes in theme can be applied during setup flow.
// If sets background color to full transparent, the button changes to colored borderless ink
// button style.
if (applyPartnerResources
@@ -254,7 +256,7 @@ public class FooterBarMixin implements Mixin {
if (footerBarPrimaryBackgroundColor != 0) {
updateButtonBackground(button, footerBarPrimaryBackgroundColor);
} else {
- // TODO(b/122509325): get button background color from activity theme
+ // TODO: get button background color from activity theme
}
}
@@ -292,7 +294,7 @@ public class FooterBarMixin implements Mixin {
int color =
PartnerConfigHelper.get(context)
.getColor(context, PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR);
- // TODO(b/120055778): Make sure customize attributes in theme can be applied during setup flow.
+ // TODO: Make sure customize attributes in theme can be applied during setup flow.
// If doesn't set background color to full transparent or white, the button changes to colored
// bordered ink button style.
if (applyPartnerResources && (color != Color.TRANSPARENT && color != Color.WHITE)) {
@@ -311,7 +313,7 @@ public class FooterBarMixin implements Mixin {
if (footerBarSecondaryBackgroundColor != 0) {
updateButtonBackground(button, footerBarSecondaryBackgroundColor);
} else {
- // TODO(b/122509325): get button background color from activity theme
+ // TODO: get button background color from activity theme
}
}
@@ -426,7 +428,8 @@ public class FooterBarMixin implements Mixin {
return button;
}
- // TODO(b/120055778): Make sure customize attributes in theme can be applied during setup flow.
+ // TODO: Make sure customize attributes in theme can be applied during setup flow.
+ @TargetApi(VERSION_CODES.Q)
private void updateButtonAttrsWithPartnerConfig(
Button button, boolean isPrimaryButton, @ButtonType int buttonType) {
updateButtonTextColorWithPartnerConfig(button, isPrimaryButton);
@@ -483,7 +486,10 @@ public class FooterBarMixin implements Mixin {
}
}
+ @TargetApi(VERSION_CODES.Q)
private void updateButtonBackgroundWithPartnerConfig(Button button, boolean isPrimaryButton) {
+ Preconditions.checkArgument(
+ BuildCompat.isAtLeastQ(), "Update button background only support on sdk Q or higher");
@ColorInt int color;
int[] DISABLED_STATE_SET = {-android.R.attr.state_enabled};
int[] ENABLED_STATE_SET = {};
@@ -509,9 +515,9 @@ public class FooterBarMixin implements Mixin {
new int[] {convertRgbToArgb(color, alpha), color});
// b/129482013: When a LayerDrawable is mutated, a new clone of its children drawables are
- // created, but without copying the state from the parent drawable. So even though the parent
- // is getting the correct drawable state from the view, the children won't get those states
- // until a state change happens.
+ // created, but without copying the state from the parent drawable. So even though the
+ // parent is getting the correct drawable state from the view, the children won't get those
+ // states until a state change happens.
// As a workaround, we mutate the drawable and forcibly set the state to empty, and then
// refresh the state so the children will have the updated states.
button.getBackground().mutate().setState(new int[0]);
@@ -590,7 +596,7 @@ public class FooterBarMixin implements Mixin {
}
if (icon != null) {
- // TODO(b/120488979): restrict the icons to a reasonable size
+ // TODO: restrict the icons to a reasonable size
int h = icon.getIntrinsicHeight();
int w = icon.getIntrinsicWidth();
icon.setBounds(0, 0, w, h);
@@ -612,7 +618,6 @@ public class FooterBarMixin implements Mixin {
private static PartnerConfig getDrawablePartnerConfig(@ButtonType int buttonType) {
PartnerConfig result;
- // LINT.IfChange
switch (buttonType) {
case ButtonType.ADD_ANOTHER:
result = PartnerConfig.CONFIG_FOOTER_BUTTON_ICON_ADD_ANOTHER;
@@ -643,9 +648,6 @@ public class FooterBarMixin implements Mixin {
result = null;
break;
}
- // LINT.ThenChange(
- // //depot/google3/third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/template/FooterButton.java,
- // //depot/google3/third_party/java_src/android_libs/setupcompat/main/res/values/attrs.xml)
return result;
}
diff --git a/main/java/com/google/android/setupcompat/template/FooterButton.java b/main/java/com/google/android/setupcompat/template/FooterButton.java
index 35ea02c..457a116 100644
--- a/main/java/com/google/android/setupcompat/template/FooterButton.java
+++ b/main/java/com/google/android/setupcompat/template/FooterButton.java
@@ -212,7 +212,6 @@ public final class FooterButton implements OnClickListener {
this.theme = theme;
}
- // LINT.IfChange
/** Maximum valid value of ButtonType */
private static final int MAX_BUTTON_TYPE = 8;
@@ -266,7 +265,6 @@ public final class FooterButton implements OnClickListener {
}
private String getButtonTypeName() {
- // LINT.IfChange
switch (buttonType) {
case ButtonType.ADD_ANOTHER:
return "ADD_ANOTHER";
@@ -288,9 +286,6 @@ public final class FooterButton implements OnClickListener {
default:
return "OTHER";
}
- // LINT.ThenChange(
- // //depot/google3/third_party/java_src/android_libs/setupcompat/main/java/com/google/android/setupcompat/template/FooterBarMixin.java,
- // //depot/google3/third_party/java_src/android_libs/setupcompat/main/res/values/attrs.xml)
}
/**
diff --git a/main/java/com/google/android/setupcompat/util/SystemBarHelper.java b/main/java/com/google/android/setupcompat/util/SystemBarHelper.java
index 60d5283..f336617 100644
--- a/main/java/com/google/android/setupcompat/util/SystemBarHelper.java
+++ b/main/java/com/google/android/setupcompat/util/SystemBarHelper.java
@@ -214,14 +214,12 @@ public final class SystemBarHelper {
*/
@RequiresPermission("android.permission.STATUS_BAR")
public static void setBackButtonVisible(final Window window, final boolean visible) {
- if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
- if (visible) {
- SystemBarHelper.removeVisibilityFlag(window, STATUS_BAR_DISABLE_BACK);
- SystemBarHelper.removeImmersiveFlagsFromDecorView(window, STATUS_BAR_DISABLE_BACK);
- } else {
- SystemBarHelper.addVisibilityFlag(window, STATUS_BAR_DISABLE_BACK);
- SystemBarHelper.addImmersiveFlagsToDecorView(window, STATUS_BAR_DISABLE_BACK);
- }
+ if (visible) {
+ SystemBarHelper.removeVisibilityFlag(window, STATUS_BAR_DISABLE_BACK);
+ SystemBarHelper.removeImmersiveFlagsFromDecorView(window, STATUS_BAR_DISABLE_BACK);
+ } else {
+ SystemBarHelper.addVisibilityFlag(window, STATUS_BAR_DISABLE_BACK);
+ SystemBarHelper.addImmersiveFlagsToDecorView(window, STATUS_BAR_DISABLE_BACK);
}
}
diff --git a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
index d071dbf..61cd760 100644
--- a/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
+++ b/main/java/com/google/android/setupcompat/util/WizardManagerHelper.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.provider.Settings;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.setupcompat.internal.BuildCompat;
import java.util.Arrays;
@@ -196,14 +197,17 @@ public class WizardManagerHelper {
* @param originalIntent The original intent that was used to start the step, usually via {@link
* Activity#getIntent()}.
*/
- public static boolean isAnySetupWizard(Intent originalIntent) {
+ public static boolean isAnySetupWizard(@Nullable Intent originalIntent) {
+ if (originalIntent == null) {
+ return false;
+ }
+
if (BuildCompat.isAtLeastQ()) {
return originalIntent.getBooleanExtra(EXTRA_IS_SETUP_FLOW, false);
} else {
- return originalIntent != null
- && (isSetupWizardIntent(originalIntent)
- || isPreDeferredSetupWizard(originalIntent)
- || isDeferredSetupWizard(originalIntent));
+ return isSetupWizardIntent(originalIntent)
+ || isPreDeferredSetupWizard(originalIntent)
+ || isDeferredSetupWizard(originalIntent);
}
}
}