Revert "Import updated Android SetupCompat Library 369420590" am: a29772e750 am: f6e3746d04
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupcompat/+/14282601
Change-Id: I99646f811c2f05d005845652e39f7a70286e75d5
diff --git a/Android.bp b/Android.bp
index 353706d..01e654d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -19,6 +19,52 @@
],
}
+filegroup {
+ name: "Aidls",
+ srcs: [
+ "main/aidl/com/google/android/setupcompat/ISetupCompatService.aidl",
+ ],
+ path: "main/aidl",
+}
+
+filegroup {
+ name: "AidlsPortal",
+ srcs: [
+ "main/aidl/com/google/android/setupcompat/portal/*.aidl",
+ ],
+ path: "main/aidl",
+}
+
+filegroup {
+ name: "Srcs",
+ srcs: [
+ "main/java/com/google/android/setupcompat/*.java",
+ "main/java/com/google/android/setupcompat/internal/*.java",
+ "main/java/com/google/android/setupcompat/logging/*.java",
+ "main/java/com/google/android/setupcompat/logging/internal/*.java",
+ "main/java/com/google/android/setupcompat/template/*.java",
+ "main/java/com/google/android/setupcompat/util/*.java",
+ "main/java/com/google/android/setupcompat/view/*.java",
+ ],
+ path: "main/java",
+}
+
+filegroup {
+ name: "SrcsPartnerConfig",
+ srcs: [
+ "partnerconfig/java/**/*.java",
+ ],
+ path: "partnerconfig/java",
+}
+
+filegroup {
+ name: "SrcsPortal",
+ srcs: [
+ "main/java/com/google/android/setupcompat/portal/*.java",
+ ],
+ path: "main/java",
+}
+
android_library {
name: "setupcompat",
manifest: "AndroidManifest.xml",
@@ -26,9 +72,11 @@
"main/res",
],
srcs: [
- "main/java/**/*.java",
- "partnerconfig/java/**/*.java",
- "main/aidl/**/*.aidl",
+ ":Aidls",
+ ":AidlsPortal",
+ ":Srcs",
+ ":SrcsPartnerConfig",
+ ":SrcsPortal",
],
static_libs: [
"androidx.annotation_annotation",
diff --git a/main/aidl/com/google/android/setupcompat/portal/IPortalProgressCallback.aidl b/main/aidl/com/google/android/setupcompat/portal/IPortalProgressCallback.aidl
new file mode 100644
index 0000000..13303d8
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/IPortalProgressCallback.aidl
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.os.Bundle;
+
+/**
+ * Interface for progress service to update progress to SUW. Clients should
+ * update progress at least once a minute, or set a pending reason to stop
+ * update progress. Without progress update and pending reason. We considering
+ * the progress service is no response will suspend it and unbinde service.
+ */
+interface IPortalProgressCallback {
+ /**
+ * Sets completed amount.
+ */
+ Bundle setProgressCount(int completed, int failed, int total) = 0;
+
+ /**
+ * Sets completed percentage.
+ */
+ Bundle setProgressPercentage(int percentage) = 1;
+
+ /**
+ * Sets the summary shows on portal activity.
+ */
+ Bundle setSummary(String summary) = 2;
+
+ /**
+ * Let SUW knows the progress is pending now, and stop update progress.
+ * @param reasonResId The resource identifier.
+ * @param quantity The number used to get the correct string for the current language's
+ * plural rules
+ * @param formatArgs The format arguments that will be used for substitution.
+ */
+ Bundle setPendingReason(int reasonResId, int quantity, in int[] formatArgs, int reason) = 3;
+
+ /**
+ * Once the progress completed, and service can be destroy. Call this function.
+ * SUW will unbind the service.
+ * @param resId The resource identifier.
+ * @param quantity The number used to get the correct string for the current language's
+ * plural rules
+ * @param formatArgs The format arguments that will be used for substitution.
+ */
+ Bundle setComplete(int resId, int quantity, in int[] formatArgs) = 4;
+
+ /**
+ * Once the progress failed, and not able to finish the progress. Should call
+ * this function. SUW will unbind service after receive setFailure. Client can
+ * registerProgressService again once the service is ready to execute.
+ * @param resId The resource identifier.
+ * @param quantity The number used to get the correct string for the current language's
+ * plural rules
+ * @param formatArgs The format arguments that will be used for substitution.
+ */
+ Bundle setFailure(int resId, int quantity, in int[] formatArgs) = 5;
+}
\ No newline at end of file
diff --git a/main/aidl/com/google/android/setupcompat/portal/IPortalProgressService.aidl b/main/aidl/com/google/android/setupcompat/portal/IPortalProgressService.aidl
new file mode 100644
index 0000000..d741125
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/IPortalProgressService.aidl
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.os.Bundle;
+import com.google.android.setupcompat.portal.IPortalProgressCallback;
+
+/**
+ * Interface of progress service, all servics needs to run during onboarding, and would like
+ * to consolidate notifications with SetupNotificationService, should implement this interface.
+ * So that SetupNotificationService can bind the progress service and run below
+ * SetupNotificationService.
+ */
+interface IPortalProgressService {
+ /**
+ * Called when the Portal notification is started.
+ */
+ oneway void onPortalSessionStart() = 0;
+
+ /**
+ * Provides a non-null callback after service connected.
+ */
+ oneway void onSetCallback(IPortalProgressCallback callback) = 1;
+
+ /**
+ * Called when progress timed out.
+ */
+ oneway void onSuspend() = 2;
+
+ /**
+ * User clicks "User mobile data" on portal activity.
+ * All running progress should agree to use mobile data.
+ */
+ oneway void onAllowMobileData(boolean allowed) = 3;
+
+ /**
+ * Portal service calls to get remaining downloading size(MB) from progress service.
+ */
+ @nullable
+ Bundle onGetRemainingValues() = 4;
+}
\ No newline at end of file
diff --git a/main/aidl/com/google/android/setupcompat/portal/IPortalRegisterResultListener.aidl b/main/aidl/com/google/android/setupcompat/portal/IPortalRegisterResultListener.aidl
new file mode 100644
index 0000000..56d39e5
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/IPortalRegisterResultListener.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+/** Listener to listen the result of registerProgressService */
+interface IPortalRegisterResultListener {
+ void onResult(in Bundle result) = 0;
+}
\ No newline at end of file
diff --git a/main/aidl/com/google/android/setupcompat/portal/ISetupNotificationService.aidl b/main/aidl/com/google/android/setupcompat/portal/ISetupNotificationService.aidl
new file mode 100644
index 0000000..9f9b1d8
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/ISetupNotificationService.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.os.UserHandle;
+import com.google.android.setupcompat.portal.IPortalRegisterResultListener;
+import com.google.android.setupcompat.portal.NotificationComponent;
+import com.google.android.setupcompat.portal.ProgressServiceComponent;
+
+/**
+ * Declares the interface for notification related service methods.
+ */
+interface ISetupNotificationService {
+ /** Register a notification without progress service */
+ boolean registerNotification(in NotificationComponent component) = 0;
+ void unregisterNotification(in NotificationComponent component) = 1;
+
+ /** Register a progress service */
+ void registerProgressService(in ProgressServiceComponent component, in UserHandle userHandle, IPortalRegisterResultListener listener) = 2;
+
+ /** Checks the progress connection still alive or not. */
+ boolean isProgressServiceAlive(in ProgressServiceComponent component, in UserHandle userHandle) = 3;
+
+ /** Checks portal avaailable or not. */
+ boolean isPortalAvailable() = 4;
+}
\ No newline at end of file
diff --git a/main/aidl/com/google/android/setupcompat/portal/NotificationComponent.aidl b/main/aidl/com/google/android/setupcompat/portal/NotificationComponent.aidl
new file mode 100644
index 0000000..5de3f76
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/NotificationComponent.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+parcelable NotificationComponent;
\ No newline at end of file
diff --git a/main/aidl/com/google/android/setupcompat/portal/ProgressServiceComponent.aidl b/main/aidl/com/google/android/setupcompat/portal/ProgressServiceComponent.aidl
new file mode 100644
index 0000000..6a6e120
--- /dev/null
+++ b/main/aidl/com/google/android/setupcompat/portal/ProgressServiceComponent.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+ package com.google.android.setupcompat.portal;
+
+ parcelable ProgressServiceComponent;
\ No newline at end of file
diff --git a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
index 3f3eb9d..466f036 100644
--- a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
+++ b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
@@ -42,6 +42,7 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.StatusBarMixin;
import com.google.android.setupcompat.template.SystemNavBarMixin;
+import com.google.android.setupcompat.util.BuildCompatUtils;
import com.google.android.setupcompat.util.WizardManagerHelper;
/** A templatization layout with consistent style used in Setup Wizard or app itself. */
@@ -56,6 +57,18 @@
*/
private boolean usePartnerResourceAttr;
+ /**
+ * Attribute indicating whether using full dynamic colors or not. This corresponds to the {@code
+ * app:sucFullDynamicColor} XML attribute.
+ */
+ private boolean useFullDynamicColorAttr;
+
+ /**
+ * Attribute indicating whether usage of dynamic is allowed. This corresponds to the existence of
+ * {@code app:sucFullDynamicColor} XML attribute.
+ */
+ private boolean useDynamicColor;
+
private Activity activity;
public PartnerCustomizationLayout(Context context) {
@@ -157,6 +170,10 @@
isSetupFlow
|| a.getBoolean(R.styleable.SucPartnerCustomizationLayout_sucUsePartnerResource, true);
+ useDynamicColor = a.hasValue(R.styleable.SucPartnerCustomizationLayout_sucFullDynamicColor);
+ useFullDynamicColorAttr =
+ a.getBoolean(R.styleable.SucPartnerCustomizationLayout_sucFullDynamicColor, false);
+
a.recycle();
if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -169,7 +186,11 @@
+ " enablePartnerResourceLoading="
+ enablePartnerResourceLoading()
+ " usePartnerResourceAttr="
- + usePartnerResourceAttr);
+ + usePartnerResourceAttr
+ + " useDynamicColor="
+ + useDynamicColor
+ + " useFullDynamicColorAttr="
+ + useFullDynamicColorAttr);
}
}
@@ -253,4 +274,30 @@
}
return true;
}
+
+ /**
+ * Returns {@code true} if the current layout/activity applies dynamic color. Otherwise, returns
+ * {@code false}.
+ */
+ public boolean shouldApplyDynamicColor() {
+ if (!useDynamicColor) {
+ return false;
+ }
+ if (!BuildCompatUtils.isAtLeastS()) {
+ return false;
+ }
+ if (!PartnerConfigHelper.get(getContext()).isAvailable()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns {@code true} if the current layout/activity applies full dynamic color. Otherwise,
+ * returns {@code false}. This method combines the result of {@link #shouldApplyDynamicColor()}
+ * and the value of the {@code app:sucFullDynamicColor}.
+ */
+ public boolean useFullDynamicColor() {
+ return shouldApplyDynamicColor() && useFullDynamicColorAttr;
+ }
}
diff --git a/main/java/com/google/android/setupcompat/portal/NotificationComponent.java b/main/java/com/google/android/setupcompat/portal/NotificationComponent.java
new file mode 100644
index 0000000..a90963b
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/portal/NotificationComponent.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import androidx.annotation.IntDef;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A class that represents how a persistent notification is to be presented to the user using the
+ * {@link com.google.android.setupcompat.portal.ISetupNotificationService}.
+ */
+public class NotificationComponent implements Parcelable {
+
+ @NotificationType private final int notificationType;
+ private Bundle extraBundle = new Bundle();
+
+ private NotificationComponent(@NotificationType int notificationType) {
+ this.notificationType = notificationType;
+ }
+
+ protected NotificationComponent(Parcel in) {
+ this(in.readInt());
+ extraBundle = in.readBundle(Bundle.class.getClassLoader());
+ }
+
+ public int getIntExtra(String key, int defValue) {
+ return extraBundle.getInt(key, defValue);
+ }
+
+ @NotificationType
+ public int getNotificationType() {
+ return notificationType;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(notificationType);
+ dest.writeBundle(extraBundle);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<NotificationComponent> CREATOR =
+ new Creator<NotificationComponent>() {
+ @Override
+ public NotificationComponent createFromParcel(Parcel in) {
+ return new NotificationComponent(in);
+ }
+
+ @Override
+ public NotificationComponent[] newArray(int size) {
+ return new NotificationComponent[size];
+ }
+ };
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ NotificationType.INITIAL_ONGOING,
+ NotificationType.PREDEFERRED,
+ NotificationType.PREDEFERRED_PREPARING,
+ NotificationType.DEFERRED,
+ NotificationType.DEFERRED_ONGOING,
+ NotificationType.PORTAL
+ })
+ public @interface NotificationType {
+ int UNKNOWN = 0;
+ int INITIAL_ONGOING = 1;
+ int PREDEFERRED = 2;
+ int PREDEFERRED_PREPARING = 3;
+ int DEFERRED = 4;
+ int DEFERRED_ONGOING = 5;
+ int PORTAL = 6;
+ int MAX = 7;
+ }
+
+ public static class Builder {
+
+ private final NotificationComponent component;
+
+ public Builder(@NotificationType int notificationType) {
+ component = new NotificationComponent(notificationType);
+ }
+
+ public Builder putIntExtra(String key, int value) {
+ component.extraBundle.putInt(key, value);
+ return this;
+ }
+
+ public NotificationComponent build() {
+ return component;
+ }
+ }
+}
diff --git a/main/java/com/google/android/setupcompat/portal/PortalConstants.java b/main/java/com/google/android/setupcompat/portal/PortalConstants.java
new file mode 100644
index 0000000..52d8700
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/portal/PortalConstants.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.StringDef;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Constant values used for Portal */
+public class PortalConstants {
+
+ /** Enumeration of pending reasons, for {@link IPortalProgressCallback#setPendingReason}. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ PendingReason.IN_PROGRESS,
+ PendingReason.PROGRESS_REQUEST_ANY_NETWORK,
+ PendingReason.PROGRESS_REQUEST_WIFI,
+ PendingReason.PROGRESS_REQUEST_MOBILE,
+ PendingReason.PROGRESS_RETRY,
+ PendingReason.PROGRESS_REQUEST_REMOVED,
+ PendingReason.MAX
+ })
+ public @interface PendingReason {
+ /**
+ * Don't used this, use {@link IPortalProgressCallback#setProgressCount} ot {@link
+ * IPortalProgressCallback#setProgressPercentage} will reset pending reason to in progress.
+ */
+ int IN_PROGRESS = 0;
+
+ /** Clients required network. */
+ int PROGRESS_REQUEST_ANY_NETWORK = 1;
+
+ /** Clients required a wifi network. */
+ int PROGRESS_REQUEST_WIFI = 2;
+
+ /** Client required a mobile data */
+ int PROGRESS_REQUEST_MOBILE = 3;
+
+ /** Client needs to wait for retry */
+ int PROGRESS_RETRY = 4;
+
+ /** Client required to remove added task */
+ int PROGRESS_REQUEST_REMOVED = 5;
+
+ int MAX = 6;
+ }
+
+ /** Bundle keys used in {@link IPortalProgressService#onGetRemainingValues}. */
+ @Retention(RetentionPolicy.SOURCE)
+ @StringDef({RemainingValues.REMAINING_SIZE_TO_BE_DOWNLOAD_IN_KB})
+ public @interface RemainingValues {
+ /** Remaining size to download in MB. */
+ String REMAINING_SIZE_TO_BE_DOWNLOAD_IN_KB = "RemainingSizeInKB";
+ }
+
+ private PortalConstants() {}
+}
diff --git a/main/java/com/google/android/setupcompat/portal/PortalHelper.java b/main/java/com/google/android/setupcompat/portal/PortalHelper.java
new file mode 100644
index 0000000..370db96
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/portal/PortalHelper.java
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Build.VERSION;
+import android.os.Build.VERSION_CODES;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Process;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.util.Log;
+import androidx.annotation.NonNull;
+import com.google.android.setupcompat.internal.Preconditions;
+import com.google.android.setupcompat.portal.PortalConstants.RemainingValues;
+
+/** This class is responsible for safely executing methods on SetupNotificationService. */
+public class PortalHelper {
+
+ private static final String TAG = "PortalHelper";
+
+ public static final String EXTRA_KEY_IS_SETUP_WIZARD = "isSetupWizard";
+
+ public static final String ACTION_BIND_SETUP_NOTIFICATION_SERVICE =
+ "com.google.android.setupcompat.portal.SetupNotificationService.BIND";
+
+ public static final String RESULT_BUNDLE_KEY_RESULT = "Result";
+ public static final String RESULT_BUNDLE_KEY_ERROR = "Error";
+ public static final String RESULT_BUNDLE_KEY_PORTAL_NOTIFICATION_AVAILABLE =
+ "PortalNotificationAvailable";
+
+ public static final Intent NOTIFICATION_SERVICE_INTENT =
+ new Intent(ACTION_BIND_SETUP_NOTIFICATION_SERVICE)
+ .setPackage("com.google.android.setupwizard");
+
+ /**
+ * Binds SetupNotificationService. For more detail see {@link Context#bindService(Intent,
+ * ServiceConnection, int)}
+ */
+ public static boolean bindSetupNotificationService(
+ @NonNull Context context, @NonNull ServiceConnection connection) {
+ Preconditions.checkNotNull(context, "Context cannot be null");
+ Preconditions.checkNotNull(connection, "ServiceConnection cannot be null");
+ try {
+ return context.bindService(NOTIFICATION_SERVICE_INTENT, connection, Context.BIND_AUTO_CREATE);
+ } catch (SecurityException e) {
+ Log.e(TAG, "Exception occurred while binding SetupNotificationService", e);
+ return false;
+ }
+ }
+
+ /**
+ * Registers a progress service to SUW service. The function response for bind service and invoke
+ * function safely, and returns the result using {@link RegisterCallback}.
+ *
+ * @param context The application context.
+ * @param component Identifies the progress service to execute.
+ * @param callback Receives register result. {@link RegisterCallback#onSuccess} called while
+ * register succeed. {@link RegisterCallback#onFailure} called while register failed.
+ */
+ public static void registerProgressService(
+ @NonNull Context context,
+ @NonNull ProgressServiceComponent component,
+ @NonNull RegisterCallback callback) {
+ Preconditions.checkNotNull(context, "Context cannot be null");
+ Preconditions.checkNotNull(component, "ProgressServiceComponent cannot be null");
+ Preconditions.checkNotNull(callback, "RegisterCallback cannot be null");
+
+ ServiceConnection connection =
+ new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder binder) {
+ if (binder != null) {
+ ISetupNotificationService service =
+ ISetupNotificationService.Stub.asInterface(binder);
+ try {
+ if (VERSION.SDK_INT >= VERSION_CODES.N) {
+ final ServiceConnection serviceConnection = this;
+ service.registerProgressService(
+ component,
+ getCurrentUserHandle(),
+ new IPortalRegisterResultListener.Stub() {
+ @Override
+ public void onResult(Bundle result) {
+ if (result.getBoolean(RESULT_BUNDLE_KEY_RESULT, false)) {
+ callback.onSuccess(
+ result.getBoolean(
+ RESULT_BUNDLE_KEY_PORTAL_NOTIFICATION_AVAILABLE, false));
+ } else {
+ callback.onFailure(
+ new IllegalStateException(
+ result.getString(RESULT_BUNDLE_KEY_ERROR, "Unknown error")));
+ }
+ context.unbindService(serviceConnection);
+ }
+ });
+ } else {
+ callback.onFailure(
+ new IllegalStateException(
+ "SetupNotificationService is not supported before Android N"));
+ context.unbindService(this);
+ }
+ } catch (RemoteException | NullPointerException e) {
+ callback.onFailure(e);
+ context.unbindService(this);
+ }
+ } else {
+ callback.onFailure(
+ new IllegalStateException("SetupNotification should not return null binder"));
+ context.unbindService(this);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ // Do nothing when service disconnected
+ }
+ };
+
+ if (!bindSetupNotificationService(context, connection)) {
+ Log.e(TAG, "Failed to bind SetupNotificationService.");
+ callback.onFailure(new SecurityException("Failed to bind SetupNotificationService."));
+ }
+ }
+
+ public static void isPortalAvailable(
+ @NonNull Context context, @NonNull final PortalAvailableResultListener listener) {
+ ServiceConnection connection =
+ new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder binder) {
+ if (binder != null) {
+ ISetupNotificationService service =
+ ISetupNotificationService.Stub.asInterface(binder);
+
+ try {
+ listener.onResult(service.isPortalAvailable());
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to invoke SetupNotificationService#isPortalAvailable");
+ listener.onResult(false);
+ }
+ }
+ context.unbindService(this);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {}
+ };
+
+ if (!bindSetupNotificationService(context, connection)) {
+ Log.e(
+ TAG,
+ "Failed to bind SetupNotificationService. Do you have permission"
+ + " \"com.google.android.setupwizard.SETUP_PROGRESS_SERVICE\"");
+ listener.onResult(false);
+ }
+ }
+
+ public static void isProgressServiceAlive(
+ @NonNull final Context context,
+ @NonNull final ProgressServiceComponent component,
+ @NonNull final ProgressServiceAliveResultListener listener) {
+ Preconditions.checkNotNull(context, "Context cannot be null");
+ Preconditions.checkNotNull(component, "ProgressServiceComponent cannot be null");
+ Preconditions.checkNotNull(listener, "ProgressServiceAliveResultCallback cannot be null");
+
+ ServiceConnection connection =
+ new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder binder) {
+ if (binder != null) {
+ ISetupNotificationService service =
+ ISetupNotificationService.Stub.asInterface(binder);
+
+ try {
+ if (VERSION.SDK_INT >= VERSION_CODES.N) {
+ listener.onResult(
+ service.isProgressServiceAlive(component, getCurrentUserHandle()));
+ } else {
+ listener.onResult(false);
+ }
+
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to invoke SetupNotificationService#isProgressServiceAlive");
+ listener.onResult(false);
+ }
+ }
+ context.unbindService(this);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {}
+ };
+
+ if (!bindSetupNotificationService(context, connection)) {
+ Log.e(
+ TAG,
+ "Failed to bind SetupNotificationService. Do you have permission"
+ + " \"com.google.android.setupwizard.SETUP_PROGRESS_SERVICE\"");
+ listener.onResult(false);
+ }
+ }
+
+ private static UserHandle getCurrentUserHandle() {
+ if (VERSION.SDK_INT >= VERSION_CODES.N) {
+ return UserHandle.getUserHandleForUid(Process.myUid());
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Creates the {@code Bundle} including the bind progress service result.
+ *
+ * @param succeed whether bind service success or not.
+ * @param errorMsg describe the reason why bind service failed.
+ * @return A bundle include bind result and error message.
+ */
+ public static Bundle createResultBundle(
+ boolean succeed, String errorMsg, boolean isPortalNotificationAvailable) {
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(RESULT_BUNDLE_KEY_RESULT, succeed);
+ if (!succeed) {
+ bundle.putString(RESULT_BUNDLE_KEY_ERROR, errorMsg);
+ }
+ bundle.putBoolean(
+ RESULT_BUNDLE_KEY_PORTAL_NOTIFICATION_AVAILABLE, isPortalNotificationAvailable);
+ return bundle;
+ }
+
+ /**
+ * Returns {@code true}, if the intent is bound from SetupWizard, otherwise returns false.
+ *
+ * @param intent that received when onBind.
+ */
+ public static boolean isFromSUW(Intent intent) {
+ return intent != null && intent.getBooleanExtra(EXTRA_KEY_IS_SETUP_WIZARD, false);
+ }
+
+ /** A callback for accepting the results of SetupNotificationService. */
+ public interface RegisterCallback {
+ void onSuccess(boolean isPortalNow);
+
+ void onFailure(Throwable throwable);
+ }
+
+ public interface RegisterNotificationCallback {
+ void onSuccess();
+
+ void onFailure(Throwable throwable);
+ }
+
+ public interface ProgressServiceAliveResultListener {
+ void onResult(boolean isAlive);
+ }
+
+ public interface PortalAvailableResultListener {
+ void onResult(boolean isAvailable);
+ }
+
+ public static class RemainingValueBuilder {
+ private final Bundle bundle = new Bundle();
+
+ public static RemainingValueBuilder createBuilder() {
+ return new RemainingValueBuilder();
+ }
+
+ public RemainingValueBuilder setRemainingSizeInKB(int size) {
+ Preconditions.checkArgument(
+ size >= 0, "The remainingSize should be positive integer or zero.");
+ bundle.putInt(RemainingValues.REMAINING_SIZE_TO_BE_DOWNLOAD_IN_KB, size);
+ return this;
+ }
+
+ public Bundle build() {
+ return bundle;
+ }
+
+ private RemainingValueBuilder() {}
+ }
+
+ private PortalHelper() {}
+}
+
+
diff --git a/main/java/com/google/android/setupcompat/portal/PortalResultHelper.java b/main/java/com/google/android/setupcompat/portal/PortalResultHelper.java
new file mode 100644
index 0000000..cec2990
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/portal/PortalResultHelper.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.os.Bundle;
+
+public class PortalResultHelper {
+
+ public static final String RESULT_BUNDLE_KEY_RESULT = "Result";
+ public static final String RESULT_BUNDLE_KEY_ERROR = "Error";
+
+ public static boolean isSuccess(Bundle bundle) {
+ return bundle.getBoolean(RESULT_BUNDLE_KEY_RESULT, false);
+ }
+
+ public static String getErrorMessage(Bundle bundle) {
+ return bundle.getString(RESULT_BUNDLE_KEY_ERROR, null);
+ }
+
+ public static Bundle createSuccessBundle() {
+ Bundle resultBundle = new Bundle();
+ resultBundle.putBoolean(RESULT_BUNDLE_KEY_RESULT, true);
+ return resultBundle;
+ }
+
+ public static Bundle createFailureBundle(String errorMessage) {
+ Bundle resultBundle = new Bundle();
+ resultBundle.putBoolean(RESULT_BUNDLE_KEY_RESULT, false);
+ resultBundle.putString(RESULT_BUNDLE_KEY_ERROR, errorMessage);
+ return resultBundle;
+ }
+
+ private PortalResultHelper() {}
+ ;
+}
diff --git a/main/java/com/google/android/setupcompat/portal/ProgressServiceComponent.java b/main/java/com/google/android/setupcompat/portal/ProgressServiceComponent.java
new file mode 100644
index 0000000..be11239
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/portal/ProgressServiceComponent.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.google.android.setupcompat.portal;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+import androidx.annotation.DrawableRes;
+import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
+import com.google.android.setupcompat.internal.Preconditions;
+
+/**
+ * A class that represents how a progress service to be registered to {@link
+ * com.google.android.setupcompat.portal.ISetupNotificationService}.
+ */
+public class ProgressServiceComponent implements Parcelable {
+ private final String packageName;
+ private final String taskName;
+ private final boolean isSilent;
+ private final boolean autoRebind;
+ private final long timeoutForReRegister;
+ @StringRes private final int displayNameResId;
+ @DrawableRes private final int displayIconResId;
+ private final Intent serviceIntent;
+ private final Intent itemClickIntent;
+
+ private ProgressServiceComponent(
+ String packageName,
+ String taskName,
+ boolean isSilent,
+ boolean autoRebind,
+ long timeoutForReRegister,
+ @StringRes int displayNameResId,
+ @DrawableRes int displayIconResId,
+ Intent serviceIntent,
+ Intent itemClickIntent) {
+ this.packageName = packageName;
+ this.taskName = taskName;
+ this.isSilent = isSilent;
+ this.autoRebind = autoRebind;
+ this.timeoutForReRegister = timeoutForReRegister;
+ this.displayNameResId = displayNameResId;
+ this.displayIconResId = displayIconResId;
+ this.serviceIntent = serviceIntent;
+ this.itemClickIntent = itemClickIntent;
+ }
+
+ /** Returns a new instance of {@link Builder}. */
+ public static Builder newBuilder() {
+ return new ProgressServiceComponent.Builder();
+ }
+
+ /** Returns the package name where the service exist. */
+ @NonNull
+ public String getPackageName() {
+ return packageName;
+ }
+
+ /** Returns the service class name */
+ @NonNull
+ public String getTaskName() {
+ return taskName;
+ }
+
+ /** Returns the whether the service is silent or not */
+ public boolean isSilent() {
+ return isSilent;
+ }
+
+ /** Auto rebind progress service while service connection disconnect. Default: true */
+ public boolean isAutoRebind() {
+ return autoRebind;
+ }
+
+ /** The timeout period waiting for client register progress service again. */
+ public long getTimeoutForReRegister() {
+ return timeoutForReRegister;
+ }
+
+ /** Returns the string resource id of display name. */
+ @StringRes
+ public int getDisplayName() {
+ return displayNameResId;
+ }
+
+ /** Returns the drawable resource id of display icon. */
+ @DrawableRes
+ public int getDisplayIcon() {
+ return displayIconResId;
+ }
+
+ /** Returns the Intent used to bind progress service. */
+ public Intent getServiceIntent() {
+ return serviceIntent;
+ }
+
+ /** Returns the Intent to start the user interface while progress item click. */
+ public Intent getItemClickIntent() {
+ return itemClickIntent;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(getPackageName());
+ dest.writeString(getTaskName());
+ dest.writeInt(isSilent() ? 1 : 0);
+ dest.writeInt(getDisplayName());
+ dest.writeInt(getDisplayIcon());
+ dest.writeParcelable(getServiceIntent(), 0);
+ dest.writeParcelable(getItemClickIntent(), 0);
+ dest.writeInt(isAutoRebind() ? 1 : 0);
+ dest.writeLong(getTimeoutForReRegister());
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<ProgressServiceComponent> CREATOR =
+ new Creator<ProgressServiceComponent>() {
+ @Override
+ public ProgressServiceComponent createFromParcel(Parcel in) {
+ return ProgressServiceComponent.newBuilder()
+ .setPackageName(in.readString())
+ .setTaskName(in.readString())
+ .setSilentMode(in.readInt() == 1)
+ .setDisplayName(in.readInt())
+ .setDisplayIcon(in.readInt())
+ .setServiceIntent(in.readParcelable(Intent.class.getClassLoader()))
+ .setItemClickIntent(in.readParcelable(Intent.class.getClassLoader()))
+ .setAutoRebind(in.readInt() == 1)
+ .setTimeoutForReRegister(in.readLong())
+ .build();
+ }
+
+ @Override
+ public ProgressServiceComponent[] newArray(int size) {
+ return new ProgressServiceComponent[size];
+ }
+ };
+
+ /** Builder class for {@link ProgressServiceComponent} objects */
+ public static class Builder {
+ private String packageName;
+ private String taskName;
+ private boolean isSilent = false;
+ private boolean autoRebind = true;
+ private long timeoutForReRegister = 0L;
+ @StringRes private int displayNameResId;
+ @DrawableRes private int displayIconResId;
+ private Intent serviceIntent;
+ private Intent itemClickIntent;
+
+ /** Sets the packages name which is the service exists */
+ public Builder setPackageName(@NonNull String packageName) {
+ this.packageName = packageName;
+ return this;
+ }
+
+ /** Sets a name to identify what task this progress is. */
+ public Builder setTaskName(@NonNull String taskName) {
+ this.taskName = taskName;
+ return this;
+ }
+
+ /** Sets the service as silent mode, it executes without UI on PortalActivity. */
+ public Builder setSilentMode(boolean isSilent) {
+ this.isSilent = isSilent;
+ return this;
+ }
+
+ /** Sets the service need auto rebind or not when service connection disconnected. */
+ public Builder setAutoRebind(boolean autoRebind) {
+ this.autoRebind = autoRebind;
+ return this;
+ }
+
+ /**
+ * Sets the timeout period waiting for the client register again, only works when auto-rebind
+ * disabled. When 0 is set, will read default configuration from SUW.
+ */
+ public Builder setTimeoutForReRegister(long timeoutForReRegister) {
+ this.timeoutForReRegister = timeoutForReRegister;
+ return this;
+ }
+
+ /** Sets the name which is displayed on PortalActivity */
+ public Builder setDisplayName(@StringRes int displayNameResId) {
+ this.displayNameResId = displayNameResId;
+ return this;
+ }
+
+ /** Sets the icon which is display on PortalActivity */
+ public Builder setDisplayIcon(@DrawableRes int displayIconResId) {
+ this.displayIconResId = displayIconResId;
+ return this;
+ }
+
+ public Builder setServiceIntent(Intent serviceIntent) {
+ this.serviceIntent = serviceIntent;
+ return this;
+ }
+
+ public Builder setItemClickIntent(Intent itemClickIntent) {
+ this.itemClickIntent = itemClickIntent;
+ return this;
+ }
+
+ public ProgressServiceComponent build() {
+ Preconditions.checkNotNull(packageName, "packageName cannot be null.");
+ Preconditions.checkNotNull(taskName, "serviceClass cannot be null.");
+ Preconditions.checkNotNull(serviceIntent, "Service intent cannot be null.");
+ Preconditions.checkNotNull(itemClickIntent, "Item click intent cannot be null");
+ if (!isSilent) {
+ Preconditions.checkArgument(
+ displayNameResId != 0, "Invalidate resource id of display name");
+ Preconditions.checkArgument(
+ displayIconResId != 0, "Invalidate resource id of display icon");
+ }
+ return new ProgressServiceComponent(
+ packageName,
+ taskName,
+ isSilent,
+ autoRebind,
+ timeoutForReRegister,
+ displayNameResId,
+ displayIconResId,
+ serviceIntent,
+ itemClickIntent);
+ }
+
+ private Builder() {}
+ }
+}
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 0952f0b..8f807e6 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -24,19 +24,10 @@
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.InsetDrawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.PersistableBundle;
import android.util.AttributeSet;
-import android.util.StateSet;
-import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
@@ -57,12 +48,12 @@
import com.google.android.setupcompat.PartnerCustomizationLayout;
import com.google.android.setupcompat.R;
import com.google.android.setupcompat.internal.FooterButtonPartnerConfig;
-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;
import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -77,6 +68,8 @@
@Nullable private final ViewStub footerStub;
@VisibleForTesting final boolean applyPartnerResources;
+ @VisibleForTesting final boolean applyDynamicColor;
+ @VisibleForTesting final boolean useFullDynamicColor;
private LinearLayout buttonContainer;
private FooterButton primaryButton;
@@ -94,8 +87,8 @@
@ColorInt private final int footerBarPrimaryBackgroundColor;
@ColorInt private final int footerBarSecondaryBackgroundColor;
private boolean removeFooterBarWhenEmpty = true;
+ private boolean isSecondaryButtonInPrimaryStyle = false;
- private static final float DEFAULT_DISABLED_ALPHA = 0.26f;
private static final AtomicInteger nextGeneratedId = new AtomicInteger(1);
@VisibleForTesting public final FooterBarMixinMetrics metrics = new FooterBarMixinMetrics();
@@ -113,7 +106,7 @@
if (applyPartnerResources) {
updateButtonTextColorWithPartnerConfig(
button,
- (id == primaryButtonId)
+ (id == primaryButtonId || isSecondaryButtonInPrimaryStyle)
? PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR
: PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR);
}
@@ -141,6 +134,25 @@
}
}
}
+
+ @Override
+ @TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
+ public void onLocaleChanged(Locale locale) {
+ if (buttonContainer != null) {
+ Button button = buttonContainer.findViewById(id);
+ if (button != null && locale != null) {
+ button.setTextLocale(locale);
+ }
+ }
+ }
+
+ @Override
+ @TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
+ public void onDirectionChanged(int direction) {
+ if (buttonContainer != null && direction != -1) {
+ buttonContainer.setLayoutDirection(direction);
+ }
+ }
};
}
@@ -159,6 +171,14 @@
layout instanceof PartnerCustomizationLayout
&& ((PartnerCustomizationLayout) layout).shouldApplyPartnerResource();
+ applyDynamicColor =
+ layout instanceof PartnerCustomizationLayout
+ && ((PartnerCustomizationLayout) layout).shouldApplyDynamicColor();
+
+ useFullDynamicColor =
+ layout instanceof PartnerCustomizationLayout
+ && ((PartnerCustomizationLayout) layout).useFullDynamicColor();
+
TypedArray a =
context.obtainStyledAttributes(attrs, R.styleable.SucFooterBarMixin, defStyleAttr, 0);
defaultPadding =
@@ -253,11 +273,14 @@
return;
}
- @ColorInt
- int color =
- PartnerConfigHelper.get(context)
- .getColor(context, PartnerConfig.CONFIG_FOOTER_BAR_BG_COLOR);
- buttonContainer.setBackgroundColor(color);
+ // skip apply partner resources on footerbar background if dynamic color enabled
+ if (!useFullDynamicColor) {
+ @ColorInt
+ int color =
+ PartnerConfigHelper.get(context)
+ .getColor(context, PartnerConfig.CONFIG_FOOTER_BAR_BG_COLOR);
+ buttonContainer.setBackgroundColor(color);
+ }
footerBarPaddingTop =
(int)
@@ -359,7 +382,14 @@
/** Sets secondary button for footer. */
@MainThread
public void setSecondaryButton(FooterButton footerButton) {
+ setSecondaryButton(footerButton, /*usePrimaryStyle= */ false);
+ }
+
+ /** Sets secondary button for footer. Allow to use the primary button style. */
+ @MainThread
+ public void setSecondaryButton(FooterButton footerButton, boolean usePrimaryStyle) {
ensureOnMainThread("setSecondaryButton");
+ isSecondaryButtonInPrimaryStyle = usePrimaryStyle;
ensureFooterInflated();
// Setup button partner config
@@ -368,16 +398,25 @@
.setPartnerTheme(
getPartnerTheme(
footerButton,
- /* defaultPartnerTheme= */ R.style.SucPartnerCustomizationButton_Secondary,
- /* buttonBackgroundColorConfig= */ PartnerConfig
- .CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR))
- .setButtonBackgroundConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR)
+ /* defaultPartnerTheme= */ usePrimaryStyle
+ ? R.style.SucPartnerCustomizationButton_Primary
+ : R.style.SucPartnerCustomizationButton_Secondary,
+ /* buttonBackgroundColorConfig= */ usePrimaryStyle
+ ? PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_BG_COLOR
+ : PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR))
+ .setButtonBackgroundConfig(
+ usePrimaryStyle
+ ? PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_BG_COLOR
+ : PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR)
.setButtonDisableAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_ALPHA)
.setButtonDisableBackgroundConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_BG_COLOR)
.setButtonIconConfig(getDrawablePartnerConfig(footerButton.getButtonType()))
.setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
.setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
- .setTextColorConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR)
+ .setTextColorConfig(
+ usePrimaryStyle
+ ? PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_TEXT_COLOR
+ : PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_TEXT_COLOR)
.setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
.setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
.setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
@@ -410,6 +449,16 @@
buttonContainer.removeAllViews();
if (tempSecondaryButton != null) {
+ if (isSecondaryButtonInPrimaryStyle) {
+ // Since the secondary button has the same style (with background) as the primary button,
+ // we need to have the left padding equal to the right padding.
+ updateFooterBarPadding(
+ buttonContainer,
+ buttonContainer.getPaddingRight(),
+ buttonContainer.getPaddingTop(),
+ buttonContainer.getPaddingRight(),
+ buttonContainer.getPaddingBottom());
+ }
buttonContainer.addView(tempSecondaryButton);
}
addSpace();
@@ -426,7 +475,7 @@
protected void onFooterButtonInflated(Button button, @ColorInt int defaultButtonBackgroundColor) {
// Try to set default background
if (defaultButtonBackgroundColor != 0) {
- updateButtonBackground(button, defaultButtonBackgroundColor);
+ FooterButtonStyleUtils.updateButtonBackground(button, defaultButtonBackgroundColor);
} else {
// TODO: get button background color from activity theme
}
@@ -559,208 +608,51 @@
if (!applyPartnerResources) {
return;
}
- updateButtonTextColorWithPartnerConfig(
- button, footerButtonPartnerConfig.getButtonTextColorConfig());
- updateButtonTextSizeWithPartnerConfig(
- button, footerButtonPartnerConfig.getButtonTextSizeConfig());
- updateButtonMinHeightWithPartnerConfig(
- button, footerButtonPartnerConfig.getButtonMinHeightConfig());
- updateButtonTypeFaceWithPartnerConfig(
+
+ // If dynamic color enabled, these colors won't be overrode by partner config.
+ // Instead, these colors align with the current theme colors.
+ if (!applyDynamicColor) {
+ updateButtonTextColorWithPartnerConfig(
+ button, footerButtonPartnerConfig.getButtonTextColorConfig());
+ FooterButtonStyleUtils.updateButtonBackgroundWithPartnerConfig(
+ context,
+ button,
+ footerButtonPartnerConfig.getButtonBackgroundConfig(),
+ footerButtonPartnerConfig.getButtonDisableAlphaConfig(),
+ footerButtonPartnerConfig.getButtonDisableBackgroundConfig());
+ FooterButtonStyleUtils.updateButtonRippleColorWithPartnerConfig(
+ context, button, footerButtonPartnerConfig);
+ }
+
+ FooterButtonStyleUtils.updateButtonTextSizeWithPartnerConfig(
+ context, button, footerButtonPartnerConfig.getButtonTextSizeConfig());
+ FooterButtonStyleUtils.updateButtonMinHeightWithPartnerConfig(
+ context, button, footerButtonPartnerConfig.getButtonMinHeightConfig());
+ FooterButtonStyleUtils.updateButtonTypeFaceWithPartnerConfig(
+ context,
button,
footerButtonPartnerConfig.getButtonTextTypeFaceConfig(),
footerButtonPartnerConfig.getButtonTextStyleConfig());
- updateButtonBackgroundWithPartnerConfig(
+ FooterButtonStyleUtils.updateButtonRadiusWithPartnerConfig(
+ context, button, footerButtonPartnerConfig.getButtonRadiusConfig());
+ FooterButtonStyleUtils.updateButtonIconWithPartnerConfig(
+ context,
button,
- footerButtonPartnerConfig.getButtonBackgroundConfig(),
- footerButtonPartnerConfig.getButtonDisableAlphaConfig(),
- footerButtonPartnerConfig.getButtonDisableBackgroundConfig());
- updateButtonRadiusWithPartnerConfig(button, footerButtonPartnerConfig.getButtonRadiusConfig());
- updateButtonIconWithPartnerConfig(button, footerButtonPartnerConfig.getButtonIconConfig());
- updateButtonRippleColorWithPartnerConfig(button, footerButtonPartnerConfig);
+ footerButtonPartnerConfig.getButtonIconConfig(),
+ primaryButtonId == button.getId());
}
private void updateButtonTextColorWithPartnerConfig(
Button button, PartnerConfig buttonTextColorConfig) {
if (button.isEnabled()) {
- @ColorInt
- int color = PartnerConfigHelper.get(context).getColor(context, buttonTextColorConfig);
- if (color != Color.TRANSPARENT) {
- button.setTextColor(ColorStateList.valueOf(color));
- }
+ FooterButtonStyleUtils.updateButtonTextEnabledColorWithPartnerConfig(
+ context, button, buttonTextColorConfig);
} else {
- // disable state will use the default disable state color
- button.setTextColor(
- button.getId() == primaryButtonId ? primaryDefaultTextColor : secondaryDefaultTextColor);
- }
- }
-
- private void updateButtonTextSizeWithPartnerConfig(
- Button button, PartnerConfig buttonTextSizeConfig) {
- float size = PartnerConfigHelper.get(context).getDimension(context, buttonTextSizeConfig);
- if (size > 0) {
- button.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
- }
- }
-
- private void updateButtonMinHeightWithPartnerConfig(
- Button button, PartnerConfig buttonMinHeightConfig) {
- if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonMinHeightConfig)) {
- float size = PartnerConfigHelper.get(context).getDimension(context, buttonMinHeightConfig);
- if (size > 0) {
- button.setMinHeight((int) size);
- }
- }
- }
-
- private void updateButtonTypeFaceWithPartnerConfig(
- Button button, PartnerConfig buttonTextTypeFaceConfig, PartnerConfig buttonTextStyleConfig) {
- String fontFamilyName =
- PartnerConfigHelper.get(context).getString(context, buttonTextTypeFaceConfig);
-
- int textStyleValue = Typeface.NORMAL;
- if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonTextStyleConfig)) {
- textStyleValue =
- PartnerConfigHelper.get(context)
- .getInteger(context, buttonTextStyleConfig, Typeface.NORMAL);
- }
- Typeface font = Typeface.create(fontFamilyName, textStyleValue);
- if (font != null) {
- button.setTypeface(font);
- }
- }
-
- @TargetApi(VERSION_CODES.Q)
- private void updateButtonBackgroundWithPartnerConfig(
- Button button,
- PartnerConfig buttonBackgroundConfig,
- PartnerConfig buttonDisableAlphaConfig,
- PartnerConfig buttonDisableBackgroundConfig) {
- Preconditions.checkArgument(
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q,
- "Update button background only support on sdk Q or higher");
- @ColorInt int color;
- @ColorInt int disabledColor;
- float disabledAlpha;
- int[] DISABLED_STATE_SET = {-android.R.attr.state_enabled};
- int[] ENABLED_STATE_SET = {};
- color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundConfig);
- disabledAlpha =
- PartnerConfigHelper.get(context).getFraction(context, buttonDisableAlphaConfig, 0f);
- disabledColor =
- PartnerConfigHelper.get(context).getColor(context, buttonDisableBackgroundConfig);
-
- if (color != Color.TRANSPARENT) {
- if (disabledAlpha <= 0f) {
- // if no partner resource, fallback to theme disable alpha
- float alpha;
- TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.disabledAlpha});
- alpha = a.getFloat(0, DEFAULT_DISABLED_ALPHA);
- a.recycle();
- disabledAlpha = alpha;
- }
- if (disabledColor == Color.TRANSPARENT) {
- // if no partner resource, fallback to button background color
- disabledColor = color;
- }
-
- // Set text color for ripple.
- ColorStateList colorStateList =
- new ColorStateList(
- new int[][] {DISABLED_STATE_SET, ENABLED_STATE_SET},
- new int[] {convertRgbToArgb(disabledColor, disabledAlpha), 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.
- // 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]);
- button.refreshDrawableState();
- button.setBackgroundTintList(colorStateList);
- }
- }
-
- private void updateButtonBackground(Button button, @ColorInt int color) {
- button.getBackground().mutate().setColorFilter(color, Mode.SRC_ATOP);
- }
-
- private void updateButtonRadiusWithPartnerConfig(
- Button button, PartnerConfig buttonRadiusConfig) {
- if (Build.VERSION.SDK_INT >= VERSION_CODES.N) {
- float radius = PartnerConfigHelper.get(context).getDimension(context, buttonRadiusConfig);
- GradientDrawable gradientDrawable = getGradientDrawable(button);
- if (gradientDrawable != null) {
- gradientDrawable.setCornerRadius(radius);
- }
- }
- }
-
- private void updateButtonRippleColorWithPartnerConfig(
- Button button, FooterButtonPartnerConfig footerButtonPartnerConfig) {
- // RippleDrawable is available after sdk 21. And because on lower sdk the RippleDrawable is
- // unavailable. Since Stencil customization provider only works on Q+, there is no need to
- // perform any customization for versions 21.
- if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- RippleDrawable rippleDrawable = getRippleDrawable(button);
- if (rippleDrawable == null) {
- return;
- }
-
- int[] pressedState = {android.R.attr.state_pressed};
- @ColorInt int color;
- // Get partner text color.
- color =
- PartnerConfigHelper.get(context)
- .getColor(context, footerButtonPartnerConfig.getButtonTextColorConfig());
-
- float alpha =
- PartnerConfigHelper.get(context)
- .getFraction(context, footerButtonPartnerConfig.getButtonRippleColorAlphaConfig());
-
- // Set text color for ripple.
- ColorStateList colorStateList =
- new ColorStateList(
- new int[][] {pressedState, StateSet.NOTHING},
- new int[] {convertRgbToArgb(color, alpha), Color.TRANSPARENT});
- rippleDrawable.setColor(colorStateList);
- }
- }
-
- private void updateButtonIconWithPartnerConfig(Button button, PartnerConfig buttonIconConfig) {
- if (button == null) {
- return;
- }
- Drawable icon = null;
- if (buttonIconConfig != null) {
- icon = PartnerConfigHelper.get(context).getDrawable(context, buttonIconConfig);
- }
- setButtonIcon(button, icon);
- }
-
- private void setButtonIcon(Button button, Drawable icon) {
- if (button == null) {
- return;
- }
-
- if (icon != null) {
- // TODO: restrict the icons to a reasonable size
- int h = icon.getIntrinsicHeight();
- int w = icon.getIntrinsicWidth();
- icon.setBounds(0, 0, w, h);
- }
-
- Drawable iconStart = null;
- Drawable iconEnd = null;
- if (button.getId() == primaryButtonId) {
- iconEnd = icon;
- } else if (button.getId() == secondaryButtonId) {
- iconStart = icon;
- }
- if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
- button.setCompoundDrawablesRelative(iconStart, null, iconEnd, null);
- } else {
- button.setCompoundDrawables(iconStart, null, iconEnd, null);
+ FooterButtonStyleUtils.updateButtonTextDisableColor(
+ button,
+ /* is Primary= */ (primaryButtonId == button.getId() || isSecondaryButtonInPrimaryStyle)
+ ? primaryDefaultTextColor
+ : secondaryDefaultTextColor);
}
}
@@ -799,43 +691,6 @@
return result;
}
- GradientDrawable getGradientDrawable(Button button) {
- // RippleDrawable is available after sdk 21, InsetDrawable#getDrawable is available after
- // sdk 19. So check the sdk is higher than sdk 21 and since Stencil customization provider only
- // works on Q+, there is no need to perform any customization for versions 21.
- if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- Drawable drawable = button.getBackground();
- if (drawable instanceof InsetDrawable) {
- LayerDrawable layerDrawable = (LayerDrawable) ((InsetDrawable) drawable).getDrawable();
- return (GradientDrawable) layerDrawable.getDrawable(0);
- } else if (drawable instanceof RippleDrawable) {
- InsetDrawable insetDrawable = (InsetDrawable) ((RippleDrawable) drawable).getDrawable(0);
- return (GradientDrawable) insetDrawable.getDrawable();
- }
- }
- return null;
- }
-
- RippleDrawable getRippleDrawable(Button button) {
- // RippleDrawable is available after sdk 21. And because on lower sdk the RippleDrawable is
- // unavailable. Since Stencil customization provider only works on Q+, there is no need to
- // perform any customization for versions 21.
- if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
- Drawable drawable = button.getBackground();
- if (drawable instanceof InsetDrawable) {
- return (RippleDrawable) ((InsetDrawable) drawable).getDrawable();
- } else if (drawable instanceof RippleDrawable) {
- return (RippleDrawable) drawable;
- }
- }
- return null;
- }
-
- @ColorInt
- private static int convertRgbToArgb(@ColorInt int color, float alpha) {
- return Color.argb((int) (alpha * 255), Color.red(color), Color.green(color), Color.blue(color));
- }
-
protected View inflateFooter(@LayoutRes int footer) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
LayoutInflater inflater =
diff --git a/main/java/com/google/android/setupcompat/template/FooterButton.java b/main/java/com/google/android/setupcompat/template/FooterButton.java
index b23b1bb..90c13ec 100644
--- a/main/java/com/google/android/setupcompat/template/FooterButton.java
+++ b/main/java/com/google/android/setupcompat/template/FooterButton.java
@@ -34,6 +34,7 @@
import com.google.android.setupcompat.R;
import com.google.android.setupcompat.logging.CustomEvent;
import java.lang.annotation.Retention;
+import java.util.Locale;
/**
* Definition of a footer button. Clients can use this class to customize attributes like text,
@@ -53,6 +54,8 @@
private OnClickListener onClickListenerWhenDisabled;
private OnButtonEventListener buttonListener;
private int clickCount = 0;
+ private Locale locale;
+ private int direction;
public FooterButton(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SucFooterButton);
@@ -78,11 +81,15 @@
CharSequence text,
@Nullable OnClickListener listener,
@ButtonType int buttonType,
- @StyleRes int theme) {
+ @StyleRes int theme,
+ Locale locale,
+ int direction) {
this.text = text;
onClickListener = listener;
this.buttonType = buttonType;
this.theme = theme;
+ this.locale = locale;
+ this.direction = direction;
}
/** Returns the text that this footer button is displaying. */
@@ -142,6 +149,16 @@
return enabled;
}
+ /** Returns the layout direction for this footer button. */
+ public int getLayoutDirection() {
+ return direction;
+ }
+
+ /** Returns the text locale for this footer button. */
+ public Locale getTextLocale() {
+ return locale;
+ }
+
/**
* Sets the visibility state of this footer button.
*
@@ -172,6 +189,22 @@
}
}
+ /** Sets the text locale to be displayed on footer button. */
+ public void setTextLocale(Locale locale) {
+ this.locale = locale;
+ if (buttonListener != null) {
+ buttonListener.onLocaleChanged(locale);
+ }
+ }
+
+ /** Sets the layout direction to be displayed on footer button. */
+ public void setLayoutDirection(int direction) {
+ this.direction = direction;
+ if (buttonListener != null) {
+ buttonListener.onDirectionChanged(direction);
+ }
+ }
+
/**
* Registers a callback to be invoked when footer button API has set.
*
@@ -201,6 +234,10 @@
void onVisibilityChanged(int visibility);
void onTextChanged(CharSequence text);
+
+ void onLocaleChanged(Locale locale);
+
+ void onDirectionChanged(int direction);
}
/** Maximum valid value of ButtonType */
@@ -308,12 +345,16 @@
* .setListener(primaryButton)
* .setButtonType(ButtonType.NEXT)
* .setTheme(R.style.SuwGlifButton_Primary)
+ * .setTextLocale(Locale.CANADA)
+ * .setLayoutDirection(View.LAYOUT_DIRECTION_LTR)
* .build();
* </pre>
*/
public static class Builder {
private final Context context;
private String text = "";
+ private Locale locale = null;
+ private int direction = -1;
private OnClickListener onClickListener = null;
@ButtonType private int buttonType = ButtonType.OTHER;
private int theme = 0;
@@ -334,6 +375,18 @@
return this;
}
+ /** Sets the {@code locale} of FooterButton. */
+ public Builder setTextLocale(Locale locale) {
+ this.locale = locale;
+ return this;
+ }
+
+ /** Sets the {@code direction} of FooterButton. */
+ public Builder setLayoutDirection(int direction) {
+ this.direction = direction;
+ return this;
+ }
+
/** Sets the {@code listener} of FooterButton. */
public Builder setListener(@Nullable OnClickListener listener) {
onClickListener = listener;
@@ -353,7 +406,7 @@
}
public FooterButton build() {
- return new FooterButton(text, onClickListener, buttonType, theme);
+ return new FooterButton(text, onClickListener, buttonType, theme, locale, direction);
}
}
}
diff --git a/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java b/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java
new file mode 100644
index 0000000..98a1426
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/template/FooterButtonStyleUtils.java
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ */
+
+package com.google.android.setupcompat.template;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.graphics.PorterDuff.Mode;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.InsetDrawable;
+import android.graphics.drawable.LayerDrawable;
+import android.graphics.drawable.RippleDrawable;
+import android.os.Build;
+import android.os.Build.VERSION_CODES;
+import android.util.StateSet;
+import android.util.TypedValue;
+import android.widget.Button;
+import androidx.annotation.ColorInt;
+import androidx.annotation.VisibleForTesting;
+import com.google.android.setupcompat.internal.FooterButtonPartnerConfig;
+import com.google.android.setupcompat.internal.Preconditions;
+import com.google.android.setupcompat.partnerconfig.PartnerConfig;
+import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper;
+
+/** Utils for updating the button style. */
+public class FooterButtonStyleUtils {
+ private static final float DEFAULT_DISABLED_ALPHA = 0.26f;
+
+ static void updateButtonTextEnabledColorWithPartnerConfig(
+ Context context, Button button, PartnerConfig buttonEnableTextColorConfig) {
+ @ColorInt
+ int color = PartnerConfigHelper.get(context).getColor(context, buttonEnableTextColorConfig);
+ if (color != Color.TRANSPARENT) {
+ button.setTextColor(ColorStateList.valueOf(color));
+ }
+ }
+
+ static void updateButtonTextDisableColor(Button button, ColorStateList defaultTextColor) {
+ // TODO : add disable footer button text color partner config
+
+ // disable state will use the default disable state color
+ button.setTextColor(defaultTextColor);
+ }
+
+ @TargetApi(VERSION_CODES.Q)
+ static void updateButtonBackgroundWithPartnerConfig(
+ Context context,
+ Button button,
+ PartnerConfig buttonBackgroundConfig,
+ PartnerConfig buttonDisableAlphaConfig,
+ PartnerConfig buttonDisableBackgroundConfig) {
+ Preconditions.checkArgument(
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q,
+ "Update button background only support on sdk Q or higher");
+ @ColorInt int disabledColor;
+ float disabledAlpha;
+ int[] DISABLED_STATE_SET = {-android.R.attr.state_enabled};
+ int[] ENABLED_STATE_SET = {};
+ @ColorInt
+ int color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundConfig);
+ disabledAlpha =
+ PartnerConfigHelper.get(context).getFraction(context, buttonDisableAlphaConfig, 0f);
+ disabledColor =
+ PartnerConfigHelper.get(context).getColor(context, buttonDisableBackgroundConfig);
+
+ if (color != Color.TRANSPARENT) {
+ if (disabledAlpha <= 0f) {
+ // if no partner resource, fallback to theme disable alpha
+ TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.disabledAlpha});
+ float alpha = a.getFloat(0, DEFAULT_DISABLED_ALPHA);
+ a.recycle();
+ disabledAlpha = alpha;
+ }
+ if (disabledColor == Color.TRANSPARENT) {
+ // if no partner resource, fallback to button background color
+ disabledColor = color;
+ }
+
+ // Set text color for ripple.
+ ColorStateList colorStateList =
+ new ColorStateList(
+ new int[][] {DISABLED_STATE_SET, ENABLED_STATE_SET},
+ new int[] {convertRgbToArgb(disabledColor, disabledAlpha), 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.
+ // 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]);
+ button.refreshDrawableState();
+ button.setBackgroundTintList(colorStateList);
+ }
+ }
+
+ static void updateButtonRippleColorWithPartnerConfig(
+ Context context, Button button, FooterButtonPartnerConfig footerButtonPartnerConfig) {
+ // RippleDrawable is available after sdk 21. And because on lower sdk the RippleDrawable is
+ // unavailable. Since Stencil customization provider only works on Q+, there is no need to
+ // perform any customization for versions 21.
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ RippleDrawable rippleDrawable = getRippleDrawable(button);
+ if (rippleDrawable == null) {
+ return;
+ }
+
+ int[] pressedState = {android.R.attr.state_pressed};
+ // Get partner text color.
+ @ColorInt
+ int color =
+ PartnerConfigHelper.get(context)
+ .getColor(context, footerButtonPartnerConfig.getButtonTextColorConfig());
+
+ float alpha =
+ PartnerConfigHelper.get(context)
+ .getFraction(context, footerButtonPartnerConfig.getButtonRippleColorAlphaConfig());
+
+ // Set text color for ripple.
+ ColorStateList colorStateList =
+ new ColorStateList(
+ new int[][] {pressedState, StateSet.NOTHING},
+ new int[] {convertRgbToArgb(color, alpha), Color.TRANSPARENT});
+ rippleDrawable.setColor(colorStateList);
+ }
+ }
+
+ static void updateButtonTextSizeWithPartnerConfig(
+ Context context, Button button, PartnerConfig buttonTextSizeConfig) {
+ float size = PartnerConfigHelper.get(context).getDimension(context, buttonTextSizeConfig);
+ if (size > 0) {
+ button.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
+ }
+ }
+
+ static void updateButtonMinHeightWithPartnerConfig(
+ Context context, Button button, PartnerConfig buttonMinHeightConfig) {
+ if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonMinHeightConfig)) {
+ float size = PartnerConfigHelper.get(context).getDimension(context, buttonMinHeightConfig);
+ if (size > 0) {
+ button.setMinHeight((int) size);
+ }
+ }
+ }
+
+ static void updateButtonTypeFaceWithPartnerConfig(
+ Context context,
+ Button button,
+ PartnerConfig buttonTextTypeFaceConfig,
+ PartnerConfig buttonTextStyleConfig) {
+ String fontFamilyName =
+ PartnerConfigHelper.get(context).getString(context, buttonTextTypeFaceConfig);
+
+ int textStyleValue = Typeface.NORMAL;
+ if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonTextStyleConfig)) {
+ textStyleValue =
+ PartnerConfigHelper.get(context)
+ .getInteger(context, buttonTextStyleConfig, Typeface.NORMAL);
+ }
+ Typeface font = Typeface.create(fontFamilyName, textStyleValue);
+ if (font != null) {
+ button.setTypeface(font);
+ }
+ }
+
+ static void updateButtonRadiusWithPartnerConfig(
+ Context context, Button button, PartnerConfig buttonRadiusConfig) {
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.N) {
+ float radius = PartnerConfigHelper.get(context).getDimension(context, buttonRadiusConfig);
+ GradientDrawable gradientDrawable = getGradientDrawable(button);
+ if (gradientDrawable != null) {
+ gradientDrawable.setCornerRadius(radius);
+ }
+ }
+ }
+
+ static void updateButtonIconWithPartnerConfig(
+ Context context, Button button, PartnerConfig buttonIconConfig, boolean isPrimary) {
+ if (button == null) {
+ return;
+ }
+ Drawable icon = null;
+ if (buttonIconConfig != null) {
+ icon = PartnerConfigHelper.get(context).getDrawable(context, buttonIconConfig);
+ }
+ setButtonIcon(button, icon, isPrimary);
+ }
+
+ private static void setButtonIcon(Button button, Drawable icon, boolean isPrimary) {
+ if (button == null) {
+ return;
+ }
+
+ if (icon != null) {
+ // TODO: restrict the icons to a reasonable size
+ int h = icon.getIntrinsicHeight();
+ int w = icon.getIntrinsicWidth();
+ icon.setBounds(0, 0, w, h);
+ }
+
+ Drawable iconStart = null;
+ Drawable iconEnd = null;
+ if (isPrimary) {
+ iconEnd = icon;
+ } else {
+ iconStart = icon;
+ }
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
+ button.setCompoundDrawablesRelative(iconStart, null, iconEnd, null);
+ } else {
+ button.setCompoundDrawables(iconStart, null, iconEnd, null);
+ }
+ }
+
+ static void updateButtonBackground(Button button, @ColorInt int color) {
+ button.getBackground().mutate().setColorFilter(color, Mode.SRC_ATOP);
+ }
+
+ @VisibleForTesting
+ public static GradientDrawable getGradientDrawable(Button button) {
+ // RippleDrawable is available after sdk 21, InsetDrawable#getDrawable is available after
+ // sdk 19. So check the sdk is higher than sdk 21 and since Stencil customization provider only
+ // works on Q+, there is no need to perform any customization for versions 21.
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ Drawable drawable = button.getBackground();
+ if (drawable instanceof InsetDrawable) {
+ LayerDrawable layerDrawable = (LayerDrawable) ((InsetDrawable) drawable).getDrawable();
+ return (GradientDrawable) layerDrawable.getDrawable(0);
+ } else if (drawable instanceof RippleDrawable) {
+ InsetDrawable insetDrawable = (InsetDrawable) ((RippleDrawable) drawable).getDrawable(0);
+ return (GradientDrawable) insetDrawable.getDrawable();
+ }
+ }
+ return null;
+ }
+
+ static RippleDrawable getRippleDrawable(Button button) {
+ // RippleDrawable is available after sdk 21. And because on lower sdk the RippleDrawable is
+ // unavailable. Since Stencil customization provider only works on Q+, there is no need to
+ // perform any customization for versions 21.
+ if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
+ Drawable drawable = button.getBackground();
+ if (drawable instanceof InsetDrawable) {
+ return (RippleDrawable) ((InsetDrawable) drawable).getDrawable();
+ } else if (drawable instanceof RippleDrawable) {
+ return (RippleDrawable) drawable;
+ }
+ }
+ return null;
+ }
+
+ @ColorInt
+ private static int convertRgbToArgb(@ColorInt int color, float alpha) {
+ return Color.argb((int) (alpha * 255), Color.red(color), Color.green(color), Color.blue(color));
+ }
+
+ private FooterButtonStyleUtils() {}
+}
diff --git a/main/java/com/google/android/setupcompat/template/StatusBarMixin.java b/main/java/com/google/android/setupcompat/template/StatusBarMixin.java
index a818793..c0f1c45 100644
--- a/main/java/com/google/android/setupcompat/template/StatusBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/StatusBarMixin.java
@@ -112,10 +112,14 @@
*/
public void setStatusBarBackground(Drawable background) {
if (partnerCustomizationLayout.shouldApplyPartnerResource()) {
+ // If full dynamic color enabled which means this activity is running outside of setup
+ // flow, the colors should refer to R.style.SudFullDynamicColorThemeGlifV3.
+ if (!partnerCustomizationLayout.useFullDynamicColor()) {
Context context = partnerCustomizationLayout.getContext();
background =
PartnerConfigHelper.get(context)
.getDrawable(context, PartnerConfig.CONFIG_STATUS_BAR_BACKGROUND);
+ }
}
if (statusBarLayout == null) {
diff --git a/main/java/com/google/android/setupcompat/template/SystemNavBarMixin.java b/main/java/com/google/android/setupcompat/template/SystemNavBarMixin.java
index 8050406..32c708c 100644
--- a/main/java/com/google/android/setupcompat/template/SystemNavBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/SystemNavBarMixin.java
@@ -47,6 +47,7 @@
private final TemplateLayout templateLayout;
@Nullable private final Window windowOfActivity;
@VisibleForTesting final boolean applyPartnerResources;
+ @VisibleForTesting final boolean useFullDynamicColor;
private int sucSystemNavBarBackgroundColor = 0;
/**
@@ -61,6 +62,10 @@
this.applyPartnerResources =
layout instanceof PartnerCustomizationLayout
&& ((PartnerCustomizationLayout) layout).shouldApplyPartnerResource();
+
+ this.useFullDynamicColor =
+ layout instanceof PartnerCustomizationLayout
+ && ((PartnerCustomizationLayout) layout).useFullDynamicColor();
}
/**
@@ -109,10 +114,14 @@
public void setSystemNavBarBackground(int color) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && windowOfActivity != null) {
if (applyPartnerResources) {
- Context context = templateLayout.getContext();
- color =
- PartnerConfigHelper.get(context)
- .getColor(context, PartnerConfig.CONFIG_NAVIGATION_BAR_BG_COLOR);
+ // If full dynamic color enabled which means this activity is running outside of setup
+ // flow, the colors should refer to R.style.SudFullDynamicColorThemeGlifV3.
+ if (!useFullDynamicColor) {
+ Context context = templateLayout.getContext();
+ color =
+ PartnerConfigHelper.get(context)
+ .getColor(context, PartnerConfig.CONFIG_NAVIGATION_BAR_BG_COLOR);
+ }
}
windowOfActivity.setNavigationBarColor(color);
}
diff --git a/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
new file mode 100644
index 0000000..ea54745
--- /dev/null
+++ b/main/java/com/google/android/setupcompat/util/BuildCompatUtils.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+package com.google.android.setupcompat.util;
+
+import android.os.Build;
+
+/**
+ * An util class to check whether the current OS version is higher or equal to sdk version of
+ * device.
+ */
+public final class BuildCompatUtils {
+
+ /**
+ * Implementation of BuildCompat.isAtLeast*() suitable for use in Setup
+ *
+ * <p>BuildCompat.isAtLeast*() can be changed by Android Release team, and once that is changed it
+ * may take weeks for that to propagate to stable/prerelease/experimental SDKs in Google3. Also it
+ * can be different in all these channels. This can cause random issues, especially with sidecars
+ * (i.e., the code running on R may not know that it runs on R).
+ *
+ * <p>This still should try using BuildCompat.isAtLeastR() as source of truth, but also checking
+ * for VERSION_SDK_INT and VERSION.CODENAME in case when BuildCompat implementation returned
+ * false. Note that both checks should be >= and not = to make sure that when Android version
+ * increases (i.e., from R to S), this does not stop working.
+ *
+ * <p>Supported configurations:
+ *
+ * <ul>
+ * <li>For current Android release: while new API is not finalized yet (CODENAME = "S", SDK_INT
+ * = 30|31)
+ * <li>For current Android release: when new API is finalized (CODENAME = "REL", SDK_INT = 31)
+ * <li>For next Android release (CODENAME = "T", SDK_INT = 30+)
+ * </ul>
+ *
+ * <p>Note that Build.VERSION_CODES.S cannot be used here until final SDK is available in all
+ * Google3 channels, because it is equal to Build.VERSION_CODES.CUR_DEVELOPMENT before API
+ * finalization.
+ *
+ * @return Whether the current OS version is higher or equal to S.
+ */
+ public static boolean isAtLeastS() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
+ return false;
+ }
+ return (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 31)
+ || (Build.VERSION.CODENAME.length() == 1
+ && Build.VERSION.CODENAME.charAt(0) >= 'S'
+ && Build.VERSION.CODENAME.charAt(0) <= 'Z');
+ }
+
+ private BuildCompatUtils() {}
+}
diff --git a/main/res/values/attrs.xml b/main/res/values/attrs.xml
index 585a28a..07f87ed 100644
--- a/main/res/values/attrs.xml
+++ b/main/res/values/attrs.xml
@@ -32,6 +32,7 @@
This attribute will be ignored and use partner resource when inside setup wizard flow.
The default value is true. -->
<attr name="sucUsePartnerResource" format="boolean" />
+ <attr name="sucFullDynamicColor" format="boolean" />
</declare-styleable>
<!-- Status bar attributes; only takes effect on M or above -->
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
index 5a71afe..c10055e 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
@@ -233,6 +233,34 @@
// The padding top of the content
CONFIG_CONTENT_PADDING_TOP(PartnerConfigKey.KEY_CONTENT_PADDING_TOP, ResourceType.DIMENSION),
+ // The text size of the content info.
+ CONFIG_CONTENT_INFO_TEXT_SIZE(
+ PartnerConfigKey.KEY_CONTENT_INFO_TEXT_SIZE, ResourceType.DIMENSION),
+
+ // The font family of the content info.
+ CONFIG_CONTENT_INFO_FONT_FAMILY(
+ PartnerConfigKey.KEY_CONTENT_INFO_FONT_FAMILY, ResourceType.STRING),
+
+ // The text line spacing extra of the content info.
+ CONFIG_CONTENT_INFO_LINE_SPACING_EXTRA(
+ PartnerConfigKey.KEY_CONTENT_INFO_LINE_SPACING_EXTRA, ResourceType.DIMENSION),
+
+ // The icon size of the content info.
+ CONFIG_CONTENT_INFO_ICON_SIZE(
+ PartnerConfigKey.KEY_CONTENT_INFO_ICON_SIZE, ResourceType.DIMENSION),
+
+ // The icon margin end of the content info.
+ CONFIG_CONTENT_INFO_ICON_MARGIN_END(
+ PartnerConfigKey.KEY_CONTENT_INFO_ICON_MARGIN_END, ResourceType.DIMENSION),
+
+ // The padding top of the content info.
+ CONFIG_CONTENT_INFO_PADDING_TOP(
+ PartnerConfigKey.KEY_CONTENT_INFO_PADDING_TOP, ResourceType.DIMENSION),
+
+ // The padding bottom of the content info.
+ CONFIG_CONTENT_INFO_PADDING_BOTTOM(
+ PartnerConfigKey.KEY_CONTENT_INFO_PADDING_BOTTOM, ResourceType.DIMENSION),
+
// The title text size of list items.
CONFIG_ITEMS_TITLE_TEXT_SIZE(PartnerConfigKey.KEY_ITEMS_TITLE_TEXT_SIZE, ResourceType.DIMENSION),
@@ -283,6 +311,11 @@
CONFIG_PROGRESS_ILLUSTRATION_UPDATE(
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_UPDATE, ResourceType.ILLUSTRATION),
+ // The animation of loading screen used in those activities which is finishing setup.
+ // For example:com.google.android.setupwizard.FINAL_HOLD
+ CONFIG_PROGRESS_ILLUSTRATION_FINAL_HOLD(
+ PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_FINAL_HOLD, ResourceType.ILLUSTRATION),
+
// The animation of loading screen to define how long showing on the pages.
CONFIG_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS(
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS, ResourceType.INTEGER),
@@ -307,6 +340,11 @@
CONFIG_LOADING_LOTTIE_UPDATE(
PartnerConfigKey.KEY_LOADING_LOTTIE_UPDATE, ResourceType.ILLUSTRATION),
+ // The animation for S+ devices used in those screens which is updating devices.
+ // For example:com.google.android.setupwizard.COMPAT_EARLY_UPDATE
+ CONFIG_LOADING_LOTTIE_FINAL_HOLD(
+ PartnerConfigKey.KEY_LOADING_LOTTIE_FINAL_HOLD, ResourceType.ILLUSTRATION),
+
// The transition type to decide the transition between activities or fragments.
CONFIG_TRANSITION_TYPE(PartnerConfigKey.KEY_TRANSITION_TYPE, ResourceType.INTEGER),
@@ -326,6 +364,10 @@
CONFIG_LOTTIE_LIGHT_THEME_CUSTOMIZATION_UPDATE(
PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_UPDATE, ResourceType.STRING_ARRAY),
+ // The list of keypath and color map, applied to update animation when light theme.
+ CONFIG_LOTTIE_LIGHT_THEME_CUSTOMIZATION_FINAL_HOLD(
+ PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_FINAL_HOLD, ResourceType.STRING_ARRAY),
+
// The list of keypath and color map, applied to default animation when dark theme.
CONFIG_LOTTIE_DARK_THEME_CUSTOMIZATION_DEFAULT(
PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_DEFAULT, ResourceType.STRING_ARRAY),
@@ -340,7 +382,31 @@
// The list of keypath and color map, applied to update animation when dark theme.
CONFIG_LOTTIE_DARK_THEME_CUSTOMIZATION_UPDATE(
- PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_UPDATE, ResourceType.STRING_ARRAY);
+ PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_UPDATE, ResourceType.STRING_ARRAY),
+
+ // The list of keypath and color map, applied to final hold animation when dark theme.
+ CONFIG_LOTTIE_DARK_THEME_CUSTOMIZATION_FINAL_HOLD(
+ PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_FINAL_HOLD, ResourceType.STRING_ARRAY),
+
+ // The padding top of the content frame of loading layout.
+ CONFIG_LOADING_LAYOUT_PADDING_TOP(
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_TOP, ResourceType.DIMENSION),
+
+ // The padding start of the content frame of loading layout.
+ CONFIG_LOADING_LAYOUT_PADDING_START(
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_START, ResourceType.DIMENSION),
+
+ // The padding end of the content frame of loading layout.
+ CONFIG_LOADING_LAYOUT_PADDING_END(
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_END, ResourceType.DIMENSION),
+
+ // The padding bottom of the content frame of loading layout.
+ CONFIG_LOADING_LAYOUT_PADDING_BOTTOM(
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_BOTTOM, ResourceType.DIMENSION),
+
+ // The height of the header of the loading layout.
+ CONFIG_LOADING_LAYOUT_HEADER_HEIGHT(
+ PartnerConfigKey.KEY_LOADING_LAYOUT_HEADER_HEIGHT, ResourceType.DIMENSION);
/** Resource type of the partner resources type. */
public enum ResourceType {
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
index f53ee40..2ca8876 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
@@ -66,7 +66,7 @@
@VisibleForTesting public static Bundle applyExtendedPartnerConfigBundle = null;
- @VisibleForTesting static Bundle applyDynamicColorBundle = null;
+ @VisibleForTesting public static Bundle applyDynamicColorBundle = null;
private static PartnerConfigHelper instance = null;
@@ -159,6 +159,13 @@
Resources resource = resourceEntry.getResources();
int resId = resourceEntry.getResourceId();
+ // for @null
+ TypedValue outValue = new TypedValue();
+ resource.getValue(resId, outValue, true);
+ if (outValue.type == TypedValue.TYPE_REFERENCE && outValue.data == 0) {
+ return result;
+ }
+
if (Build.VERSION.SDK_INT >= VERSION_CODES.M) {
result = resource.getColor(resId, null);
} else {
@@ -600,7 +607,7 @@
}
/** Returns true if the SetupWizard supports the dynamic color during setup flow. */
- public static boolean shouldApplyDynamicColor(@NonNull Context context) {
+ public static boolean isSetupWizardDynamicColorEnabled(@NonNull Context context) {
if (applyDynamicColorBundle == null) {
try {
applyDynamicColorBundle =
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
index 4f21ae2..a810908 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
@@ -83,6 +83,13 @@
PartnerConfigKey.KEY_CONTENT_FONT_FAMILY,
PartnerConfigKey.KEY_CONTENT_LAYOUT_GRAVITY,
PartnerConfigKey.KEY_CONTENT_PADDING_TOP,
+ PartnerConfigKey.KEY_CONTENT_INFO_TEXT_SIZE,
+ PartnerConfigKey.KEY_CONTENT_INFO_FONT_FAMILY,
+ PartnerConfigKey.KEY_CONTENT_INFO_LINE_SPACING_EXTRA,
+ PartnerConfigKey.KEY_CONTENT_INFO_ICON_SIZE,
+ PartnerConfigKey.KEY_CONTENT_INFO_ICON_MARGIN_END,
+ PartnerConfigKey.KEY_CONTENT_INFO_PADDING_TOP,
+ PartnerConfigKey.KEY_CONTENT_INFO_PADDING_BOTTOM,
PartnerConfigKey.KEY_ITEMS_TITLE_TEXT_SIZE,
PartnerConfigKey.KEY_ITEMS_SUMMARY_TEXT_SIZE,
PartnerConfigKey.KEY_ITEMS_SUMMARY_MARGIN_TOP,
@@ -96,20 +103,29 @@
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_ACCOUNT,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_CONNECTION,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_UPDATE,
+ PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_FINAL_HOLD,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS,
PartnerConfigKey.KEY_LOADING_LOTTIE_ACCOUNT,
PartnerConfigKey.KEY_LOADING_LOTTIE_CONNECTION,
PartnerConfigKey.KEY_LOADING_LOTTIE_DEFAULT,
PartnerConfigKey.KEY_LOADING_LOTTIE_UPDATE,
+ PartnerConfigKey.KEY_LOADING_LOTTIE_FINAL_HOLD,
PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_DEFAULT,
PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_ACCOUNT,
PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_CONNECTION,
PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_UPDATE,
+ PartnerConfigKey.KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_FINAL_HOLD,
PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_DEFAULT,
PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_ACCOUNT,
PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_CONNECTION,
PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_UPDATE,
+ PartnerConfigKey.KEY_LOADING_DARK_THEME_CUSTOMIZATION_FINAL_HOLD,
PartnerConfigKey.KEY_TRANSITION_TYPE,
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_TOP,
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_START,
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_END,
+ PartnerConfigKey.KEY_LOADING_LAYOUT_CONTENT_PADDING_BOTTOM,
+ PartnerConfigKey.KEY_LOADING_LAYOUT_HEADER_HEIGHT,
})
// TODO: can be removed and always reference PartnerConfig.getResourceName()?
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
@@ -296,6 +312,27 @@
// The padding top of the content
String KEY_CONTENT_PADDING_TOP = "setup_design_content_padding_top";
+ // The text size of the content info.
+ String KEY_CONTENT_INFO_TEXT_SIZE = "setup_design_content_info_text_size";
+
+ // The font family of the content info.
+ String KEY_CONTENT_INFO_FONT_FAMILY = "setup_design_content_info_font_family";
+
+ // The text line spacing extra of the content info.
+ String KEY_CONTENT_INFO_LINE_SPACING_EXTRA = "setup_design_content_info_line_spacing_extra";
+
+ // The icon size of the content info.
+ String KEY_CONTENT_INFO_ICON_SIZE = "setup_design_content_info_icon_size";
+
+ // The icon margin end of the content info.
+ String KEY_CONTENT_INFO_ICON_MARGIN_END = "setup_design_content_info_icon_margin_end";
+
+ // The padding top of the content info.
+ String KEY_CONTENT_INFO_PADDING_TOP = "setup_design_content_info_padding_top";
+
+ // The padding bottom of the content info.
+ String KEY_CONTENT_INFO_PADDING_BOTTOM = "setup_design_content_info_padding_bottom";
+
// The title text size of list items.
String KEY_ITEMS_TITLE_TEXT_SIZE = "setup_design_items_title_text_size";
@@ -339,6 +376,10 @@
// For example:com.google.android.setupwizard.COMPAT_EARLY_UPDATE
String KEY_PROGRESS_ILLUSTRATION_UPDATE = "progress_illustration_custom_update";
+ // The animation of loading screen used in those activities which is updating device.
+ // For example:com.google.android.setupwizard.FINAL_HOLD
+ String KEY_PROGRESS_ILLUSTRATION_FINAL_HOLD = "final_hold_custom_illustration";
+
// The minimum illustration display time, set to 0 may cause the illustration stuck
String KEY_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS = "progress_illustration_display_minimum_ms";
@@ -358,6 +399,10 @@
// For example:com.google.android.setupwizard.COMPAT_EARLY_UPDATE
String KEY_LOADING_LOTTIE_UPDATE = "loading_animation_custom_update";
+ // The animation for S+ devices used in those screens which is updating devices.
+ // For example:com.google.android.setupwizard.FINAL_HOLD
+ String KEY_LOADING_LOTTIE_FINAL_HOLD = "loading_animation_custom_final_hold";
+
// A string-array to list all the key path and color map for default animation for light theme.
// For example: background:#FFFFFF
String KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_DEFAULT =
@@ -377,6 +422,11 @@
// For example: background:#FFFFFF
String KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_UPDATE = "loading_light_theme_customization_update";
+ // A string-array to list all the key path and color map for final hold animation for light theme.
+ // For example: background:#FFFFFF
+ String KEY_LOADING_LIGHT_THEME_CUSTOMIZATION_FINAL_HOLD =
+ "loading_light_theme_customization_final_hold";
+
// A string-array to list all the key path and color map for default animation for dark theme.
// For example: background:#000000
String KEY_LOADING_DARK_THEME_CUSTOMIZATION_DEFAULT = "loading_dark_theme_customization_default";
@@ -394,6 +444,26 @@
// For example: background:#000000
String KEY_LOADING_DARK_THEME_CUSTOMIZATION_UPDATE = "loading_dark_theme_customization_update";
+ // A string-array to list all the key path and color map for final hold animation for dark theme.
+ // For example: background:#000000
+ String KEY_LOADING_DARK_THEME_CUSTOMIZATION_FINAL_HOLD =
+ "loading_dark_theme_customization_final_hold";
+
// The transition type between activities
String KEY_TRANSITION_TYPE = "setup_design_transition_type";
+
+ // A padding top of the content frame of loading layout.
+ String KEY_LOADING_LAYOUT_CONTENT_PADDING_TOP = "loading_layout_content_padding_top";
+
+ // A padding start of the content frame of loading layout.
+ String KEY_LOADING_LAYOUT_CONTENT_PADDING_START = "loading_layout_content_padding_start";
+
+ // A padding end of the content frame of loading layout.
+ String KEY_LOADING_LAYOUT_CONTENT_PADDING_END = "loading_layout_content_padding_end";
+
+ // A padding bottom of the content frame of loading layout.
+ String KEY_LOADING_LAYOUT_CONTENT_PADDING_BOTTOM = "loading_layout_content_padding_bottom";
+
+ // A height of the header of loading layout.
+ String KEY_LOADING_LAYOUT_HEADER_HEIGHT = "loading_layout_header_height";
}