diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-09-22 19:04:00 +0800 |
---|---|---|
committer | Nicole Huang <nicolehuang@google.com> | 2021-09-24 07:33:32 +0000 |
commit | 842dff4bdfeb011e05482eadb6076b07a9acd173 (patch) | |
tree | 297eae0637fc6859a2a42b90a7bf02b8181114fe | |
parent | 898ed76ec2c0ec65f2116a6af33ff08c5df6e549 (diff) | |
download | setupdesign-842dff4bdfeb011e05482eadb6076b07a9acd173.tar.gz |
Import updated Android Setupdesign Library 398203590
Copied from google3/third_party/java_src/android_libs/setupdesign
Test: mm
Included changes:
- 398203590 [SetupDesign] Dynamic color - update linked text color
- 397224761 [GlifLoadingLayout] Fix stuck because unexpected animatio...
- 397056960 [SetupDesign] Correct the color mapping for NV
- 397010084 [SetupDesign] Update the switch on/off color make sure it...
- 396747614 [Foldable] Set default typeface in variety of textAppeara...
- 396738782 [Foldable] Apply default font family to appcompat dialog ...
- 395896459 Automated g4 rollback of changelist 395427354.
- 395433307 [Foldable] Apply default font family to appcompat dialog ...
- 395427354 [GlifLoadingLayout] Add maximum time to wait animation fi...
- 395094760 [Foldable] Apply default font family to dialog button.
- 395053506 Automated g4 rollback of changelist 394597013.
- 394597013 [GlifLoadingLayout] Add maximum time to wait animation fi...
- 394182476 Automated g4 rollback of changelist 394160078.
- 394160078 [Foldable] Apply default font family to dialog button.
- 392854455 [Foldable] Set device default style for textView and for ...
- 392570490 Update the targetSdkVersion of both setup compat and setu...
- 391939054 [SetupDesign] Fix the the GlifLayout shift after reset Co...
- 391901589 Migrate android.support.annotation.NonNull to androidx.
Bug: 200764013
PiperOrigin-RevId: 398203590
Change-Id: Ib76d8fb623146633cb591013faed0151a5366444
19 files changed, 375 insertions, 133 deletions
diff --git a/lottie_loading_layout/AndroidManifest.xml b/lottie_loading_layout/AndroidManifest.xml index 3cf1948..67c363d 100644 --- a/lottie_loading_layout/AndroidManifest.xml +++ b/lottie_loading_layout/AndroidManifest.xml @@ -20,6 +20,6 @@ <uses-sdk android:minSdkVersion="14" - android:targetSdkVersion="30" /> + android:targetSdkVersion="31" /> </manifest> diff --git a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java index d239e3d..b3e6d64 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -30,10 +30,6 @@ import android.graphics.ColorFilter; import android.os.Build; import android.os.Build.VERSION_CODES; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.provider.Settings.Global; -import android.provider.Settings.SettingNotFoundException; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; @@ -78,7 +74,7 @@ import java.util.Map; * the set including "default", "account", "connection", "update", and "final_hold". {@code * app:sudLottieRes} can assign the json file of Lottie resource. */ -public class GlifLoadingLayout extends GlifLayout { +public class GlifLoadingLayout extends GlifLayout implements AnimatorListener { private static final String TAG = "GlifLoadingLayout"; View inflatedView; @@ -251,7 +247,7 @@ public class GlifLoadingLayout extends GlifLayout { if (activity == null) { throw new NullPointerException("activity should not be null"); } - registerAnimationFinishRunnable(activity::finish, /* allowFinishWithMaximumDuration= */ true); + registerAnimationFinishRunnable(activity::finish); } /** @@ -289,8 +285,7 @@ public class GlifLoadingLayout extends GlifLayout { if (finish) { activity.finish(); } - }, - /* allowFinishWithMaximumDuration= */ true); + }); } /** @@ -332,8 +327,7 @@ public class GlifLoadingLayout extends GlifLayout { if (finish) { activity.finish(); } - }, - /* allowFinishWithMaximumDuration= */ true); + }); } private void updateHeaderHeight() { @@ -424,6 +418,9 @@ public class GlifLoadingLayout extends GlifLayout { updateContentPadding((LinearLayout) inflatedView); } setLottieResource(); + + LottieAnimationView lottieView = findViewById(R.id.sud_lottie_view); + lottieView.addAnimatorListener(this); } } } @@ -660,6 +657,31 @@ public class GlifLoadingLayout extends GlifLayout { return super.findContainer(containerId); } + private boolean isAnimationStarted = false; + + @Override + public void onAnimationStart(Animator animation) { + isAnimationStarted = true; + } + + @Override + public void onAnimationEnd(Animator animation) { + isAnimationStarted = false; + + ArrayList<LottieAnimationFinishListener> clonedList = + new ArrayList<>(animationFinishListeners.size()); + clonedList.addAll(animationFinishListeners); + for (LottieAnimationFinishListener listener : clonedList) { + listener.onAnimationFinished(); + } + } + + @Override + public void onAnimationCancel(Animator animation) {} + + @Override + public void onAnimationRepeat(Animator animation) {} + /** The progress config used to maps to different animation */ public enum LottieAnimationConfig { CONFIG_DEFAULT( @@ -730,108 +752,36 @@ public class GlifLoadingLayout extends GlifLayout { * Register the {@link Runnable} as a callback class that will be perform when animation finished. */ public void registerAnimationFinishRunnable(Runnable runnable) { - registerAnimationFinishRunnable(runnable, /* allowFinishWithMaximumDuration= */ false); - } - - /** - * Register the {@link Runnable} as a callback class that will be perform when animation finished. - * {@code allowFinishWithMaximumDuration} to allow the animation finish advanced by {@link - * PartnerConfig#CONFIG_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS} config. The {@code runnable} - * will be performed if the Lottie animation finish played and the duration of Lottie animation - * less than @link PartnerConfig#CONFIG_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS} config. - */ - public void registerAnimationFinishRunnable( - Runnable runnable, boolean allowFinishWithMaximumDuration) { - if (allowFinishWithMaximumDuration) { - int delayMs = - PartnerConfigHelper.get(getContext()) - .getInteger( - getContext(), PartnerConfig.CONFIG_PROGRESS_ILLUSTRATION_DISPLAY_MINIMUM_MS, 0); - animationFinishListeners.add(new LottieAnimationFinishListener(this, runnable, delayMs)); - } else { - animationFinishListeners.add( - new LottieAnimationFinishListener(this, runnable, /* finishWithMinimumDuration= */ 0L)); - } + animationFinishListeners.add(new LottieAnimationFinishListener(this, runnable)); } /** The listener that to indicate the playing status for lottie animation. */ @VisibleForTesting public static class LottieAnimationFinishListener { - private final Handler handler; private final Runnable runnable; private final GlifLoadingLayout glifLoadingLayout; private final LottieAnimationView lottieAnimationView; @VisibleForTesting - AnimatorListener animatorListener = - new AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - // Do nothing. - } - - @Override - public void onAnimationEnd(Animator animation) { - onAnimationFinished(); - } - - @Override - public void onAnimationCancel(Animator animation) { - // Do nothing. - } - - @Override - public void onAnimationRepeat(Animator animation) { - // Do nothing. - } - }; - - @VisibleForTesting - LottieAnimationFinishListener( - GlifLoadingLayout glifLoadingLayout, Runnable runnable, long finishWithMinimumDuration) { + LottieAnimationFinishListener(GlifLoadingLayout glifLoadingLayout, Runnable runnable) { if (runnable == null) { throw new NullPointerException("Runnable can not be null"); } this.glifLoadingLayout = glifLoadingLayout; this.runnable = runnable; - this.handler = new Handler(Looper.getMainLooper()); this.lottieAnimationView = glifLoadingLayout.findLottieAnimationView(); - if (glifLoadingLayout.isLottieLayoutVisible() && !isZeroAnimatorDurationScale()) { + if (glifLoadingLayout.isAnimationStarted) { lottieAnimationView.setRepeatCount(0); - lottieAnimationView.addAnimatorListener(animatorListener); - if (finishWithMinimumDuration > 0) { - handler.postDelayed(this::onAnimationFinished, finishWithMinimumDuration); - } } else { onAnimationFinished(); } } @VisibleForTesting - boolean isZeroAnimatorDurationScale() { - try { - if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { - return Global.getFloat( - glifLoadingLayout.getContext().getContentResolver(), Global.ANIMATOR_DURATION_SCALE) - == 0f; - } else { - return false; - } - - } catch (SettingNotFoundException e) { - return false; - } - } - - @VisibleForTesting public void onAnimationFinished() { - handler.removeCallbacks(runnable); runnable.run(); - if (lottieAnimationView != null) { - lottieAnimationView.removeAnimatorListener(animatorListener); - } glifLoadingLayout.animationFinishListeners.remove(this); } } diff --git a/main/res/color-v31/sud_dynamic_switch_track_off_light.xml b/main/res/color-v31/sud_dynamic_switch_track_off_light.xml new file mode 100644 index 0000000..fc9cc97 --- /dev/null +++ b/main/res/color-v31/sud_dynamic_switch_track_off_light.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:color="@android:color/system_neutral2_500" android:lStar="45" /> +</selector>
\ No newline at end of file diff --git a/main/res/color-v31/sud_dynamic_switch_track_on_dark.xml b/main/res/color-v31/sud_dynamic_switch_track_on_dark.xml new file mode 100644 index 0000000..b8997f9 --- /dev/null +++ b/main/res/color-v31/sud_dynamic_switch_track_on_dark.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:color="@android:color/system_accent2_500" android:lStar="51" /> +</selector>
\ No newline at end of file diff --git a/main/res/color/sud_switch_thumb_off.xml b/main/res/color/sud_switch_thumb_off.xml new file mode 100644 index 0000000..8e54c8c --- /dev/null +++ b/main/res/color/sud_switch_thumb_off.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + <item android:state_enabled="false" + android:color="?attr/sudSwitchBarThumbOffColor" + android:alpha="?android:attr/disabledAlpha" /> + <item android:color="?attr/sudSwitchBarThumbOffColor" /> +</selector>
\ No newline at end of file diff --git a/main/res/color/sud_switch_thumb_on.xml b/main/res/color/sud_switch_thumb_on.xml new file mode 100644 index 0000000..494c179 --- /dev/null +++ b/main/res/color/sud_switch_thumb_on.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + <item android:state_enabled="false" + android:color="?attr/sudSwitchBarThumbOnColor" + android:alpha="?android:attr/disabledAlpha" /> + <item android:color="?attr/sudSwitchBarThumbOnColor" /> +</selector>
\ No newline at end of file diff --git a/main/res/color/sud_switch_track_off.xml b/main/res/color/sud_switch_track_off.xml new file mode 100644 index 0000000..4770393 --- /dev/null +++ b/main/res/color/sud_switch_track_off.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + <item android:state_enabled="false" + android:color="?attr/sudSwitchBarTrackOffColor" + android:alpha="?android:attr/disabledAlpha" /> + <item android:color="?attr/sudSwitchBarTrackOffColor" /> +</selector> diff --git a/main/res/color/sud_switch_track_on.xml b/main/res/color/sud_switch_track_on.xml index a95a1ee..fb93f05 100644 --- a/main/res/color/sud_switch_track_on.xml +++ b/main/res/color/sud_switch_track_on.xml @@ -17,10 +17,7 @@ <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <item android:state_enabled="false" - android:color="?android:attr/colorForeground" + android:color="?attr/sudSwitchBarTrackOnColor" android:alpha="?android:attr/disabledAlpha" /> - <item android:state_checked="true" - android:color="?android:attr/colorControlActivated" tools:ignore="NewApi" - android:alpha="?android:attr/disabledAlpha" /> - <item android:color="?android:attr/colorForeground" /> + <item android:color="?attr/sudSwitchBarTrackOnColor" /> </selector> diff --git a/main/res/drawable-v21/sud_switch_thumb_on.xml b/main/res/drawable-v21/sud_switch_thumb_on.xml deleted file mode 100644 index 224f181..0000000 --- a/main/res/drawable-v21/sud_switch_thumb_on.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2021 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> - -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> - <item - android:top="@dimen/sud_switch_thumb_margin" - android:left="@dimen/sud_switch_thumb_margin" - android:right="@dimen/sud_switch_thumb_margin" - android:bottom="@dimen/sud_switch_thumb_margin"> - <shape android:shape="oval"> - <size - android:height="@dimen/sud_switch_thumb_size" - android:width="@dimen/sud_switch_thumb_size" /> - <solid android:color="?android:attr/colorControlActivated" /> - </shape> - </item> -</layer-list>
\ No newline at end of file diff --git a/main/res/drawable/sud_switch_thumb_on.xml b/main/res/drawable/sud_switch_thumb_on.xml index cc1cf06..d4dad6f 100644 --- a/main/res/drawable/sud_switch_thumb_on.xml +++ b/main/res/drawable/sud_switch_thumb_on.xml @@ -26,7 +26,7 @@ <size android:height="@dimen/sud_switch_thumb_size" android:width="@dimen/sud_switch_thumb_size" /> - <solid android:color="?android:attr/colorAccent" tools:ignore="NewApi" /> + <solid android:color="@color/sud_switch_thumb_on" /> </shape> </item> </layer-list> diff --git a/main/res/values-h720dp/dimens.xml b/main/res/values-h720dp/dimens.xml new file mode 100644 index 0000000..e495f71 --- /dev/null +++ b/main/res/values-h720dp/dimens.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources xmlns:tools="http://schemas.android.com/tools"> + + <!-- Device default style --> + + <!-- Copy from Widget.DeviceDefault.Button.ButtonBar.AlertDialog --> + <!-- Dialog button bar height --> + <dimen name="sud_alert_dialog_button_bar_height">54dip</dimen> + +</resources> diff --git a/main/res/values-v31/colors.xml b/main/res/values-v31/colors.xml index 91587ee..3db968b 100644 --- a/main/res/values-v31/colors.xml +++ b/main/res/values-v31/colors.xml @@ -38,6 +38,8 @@ <color name="sud_system_accent1_200">@android:color/system_accent1_200</color> + <color name="sud_system_accent1_300">@android:color/system_accent1_300</color> + <color name="sud_system_accent1_600">@android:color/system_accent1_600</color> @@ -46,19 +48,23 @@ <color name="sud_system_neutral1_50">@android:color/system_neutral1_50</color> + <color name="sud_system_neutral1_400">@android:color/system_neutral1_400</color> + + <color name="sud_system_neutral1_700">@android:color/system_neutral1_700</color> + <color name="sud_system_neutral1_800">@android:color/system_neutral1_800</color> <color name="sud_system_neutral1_900">@android:color/system_neutral1_900</color> - <color name="sud_system_neutral2_50">@android:color/system_neutral1_50</color> + <color name="sud_system_neutral2_50">@android:color/system_neutral2_50</color> - <color name="sud_system_neutral2_100">@android:color/system_neutral1_100</color> + <color name="sud_system_neutral2_100">@android:color/system_neutral2_100</color> <color name="sud_system_neutral2_200">@android:color/system_neutral2_200</color> - <color name="sud_system_neutral2_300">@android:color/system_accent2_300</color> + <color name="sud_system_neutral2_300">@android:color/system_neutral2_300</color> <color name="sud_system_neutral2_400">@android:color/system_neutral2_400</color> @@ -77,4 +83,17 @@ <color name="sud_system_button_text">@color/sud_system_neutral1_900</color> <color name="sud_system_dividing_line">@color/sud_system_neutral2_300</color> -</resources>
\ No newline at end of file + + <color name="sud_dynamic_switch_thumb_off_light">@color/sud_system_neutral2_300</color> + + <color name="sud_dynamic_switch_track_off_dark">@color/sud_system_neutral1_700</color> + + <color name="sud_dynamic_switch_thumb_off_dark">@color/sud_system_neutral1_400</color> + + + <color name="sud_dynamic_switch_track_on_light">@color/sud_system_accent1_600</color> + + <color name="sud_dynamic_switch_thumb_on_light">@color/sud_system_accent1_100</color> + + <color name="sud_dynamic_switch_thumb_on_dark">@color/sud_system_accent1_100</color> +</resources> diff --git a/main/res/values-v31/styles.xml b/main/res/values-v31/styles.xml index 61523c3..4fa3012 100644 --- a/main/res/values-v31/styles.xml +++ b/main/res/values-v31/styles.xml @@ -15,24 +15,32 @@ limitations under the License. --> -<resources> +<resources xmlns:tools="http://schemas.android.com/tools"> <!-- Main theme for dynamic color --> <style name="SudDynamicColorThemeGlifV3" parent="SudThemeGlifV3"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> - <item name="android:textColorLink">@color/sud_dynamic_color_accent_glif_v3_dark</item> + <item name="android:textColorLink">@color/sud_system_accent1_300</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat</item> <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> <item name="sucFullDynamicColor">false</item> + <item name="sudSwitchBarThumbOnColor">@color/sud_dynamic_switch_thumb_on_dark</item> + <item name="sudSwitchBarTrackOnColor">@color/sud_dynamic_switch_track_on_dark</item> + <item name="sudSwitchBarThumbOffColor">@color/sud_dynamic_switch_thumb_off_dark</item> + <item name="sudSwitchBarTrackOffColor">@color/sud_dynamic_switch_track_off_dark</item> </style> <style name="SudDynamicColorThemeGlifV3.Light" parent="SudThemeGlifV3.Light"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> - <item name="android:textColorLink">@color/sud_dynamic_color_accent_glif_v3_light</item> + <item name="android:textColorLink">@color/sud_system_accent1_600</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat.Light</item> <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> <item name="sucFullDynamicColor">false</item> + <item name="sudSwitchBarThumbOnColor">@color/sud_dynamic_switch_thumb_on_light</item> + <item name="sudSwitchBarTrackOnColor">@color/sud_dynamic_switch_track_on_light</item> + <item name="sudSwitchBarThumbOffColor">@color/sud_dynamic_switch_thumb_off_light</item> + <item name="sudSwitchBarTrackOffColor">@color/sud_dynamic_switch_track_off_light</item> </style> <style name="SudFullDynamicColorThemeGlifV3" parent="SudDynamicColorThemeGlifV3"> @@ -90,6 +98,8 @@ <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_dark</item> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> <item name="dialogCornerRadius">@dimen/sud_glif_device_default_dialog_corner_radius</item> + <item name="buttonBarButtonStyle">@style/SudAppCompatButtonButtonBarAlertDialog</item> + <item name="android:windowTitleStyle">@style/SudWindowTitleStyle</item> </style> <style name="SudDynamicColorAlertDialogThemeCompat.Light" parent="Theme.AppCompat.Light.Dialog.Alert"> @@ -97,6 +107,27 @@ <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_light</item> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> <item name="dialogCornerRadius">@dimen/sud_glif_device_default_dialog_corner_radius</item> + <item name="buttonBarButtonStyle">@style/SudAppCompatButtonButtonBarAlertDialog.Light</item> + <item name="android:windowTitleStyle">@style/SudWindowTitleStyle</item> + </style> + + <style name="SudAppCompatButtonButtonBarAlertDialog" parent="Widget.AppCompat.ButtonBar.AlertDialog"> + <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium</item> + <item name="android:minWidth">@dimen/sud_alert_dialog_button_bar_width</item> + <item name="android:minHeight">@dimen/sud_alert_dialog_button_bar_height</item> + </style> + + <style name="SudAppCompatButtonButtonBarAlertDialog.Light" parent="SudAppCompatButtonButtonBarAlertDialog"> + <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium.Light</item> + </style> + + <style name="SudWindowTitleStyle" parent="RtlOverlay.DialogWindowTitle.AppCompat"> + <item name="android:textAppearance">@style/SudDeviceDefaultWindowTitleTextAppearance</item> + </style> + + <style name="SudDeviceDefaultWindowTitleTextAppearance" parent="android:TextAppearance.DeviceDefault.WindowTitle"> + <item name="android:textSize">@dimen/sud_alert_dialog_title_text_size</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> </style> <style name="SudFullDynamicColorAlertDialogThemeCompat" parent="SudDynamicColorAlertDialogThemeCompat"> @@ -117,6 +148,38 @@ <item name="dialogCornerRadius">@dimen/sud_glif_device_default_dialog_corner_radius</item> </style> + <style name="SudAlertDialogTheme" parent="android:Theme.DeviceDefault.Dialog.Alert"> + <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_dark</item> + <item name="android:buttonBarButtonStyle">@style/SudDeviceDefaultButtonBarButtonStyle</item> + </style> + + <style name="SudAlertDialogTheme.Light" parent="android:Theme.DeviceDefault.Light.Dialog.Alert"> + <item name="android:buttonBarButtonStyle">@style/SudDeviceDefaultButtonBarButtonStyle.Light</item> + </style> + + <!-- Can't set style Widget.DeviceDefault.Button.ButtonBar.AlertDialog as parent theme directly, + since it is not public. Thus here sets Widget.DeviceDefault.Button.Borderless.Colored and + bring the minWidth/minHeight. --> + <style name="SudDeviceDefaultButtonBarButtonStyle" parent="android:Widget.DeviceDefault.Button.Borderless.Colored"> + <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium</item> + <item name="android:minWidth">@dimen/sud_alert_dialog_button_bar_width</item> + <item name="android:minHeight">@dimen/sud_alert_dialog_button_bar_height</item> + </style> + + <style name="SudDeviceDefaultButtonBarButtonStyle.Light" parent="SudDeviceDefaultButtonBarButtonStyle"> + <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium.Light</item> + </style> + + <style name="SudTextAppearanceDeviceDefaultMedium" parent="android:TextAppearance.DeviceDefault.Medium"> + <item name="android:textSize">@dimen/sud_alert_dialog_button_bar_button_text_size</item> + <item name="android:textColor">@color/sud_dynamic_color_accent_glif_v3_dark</item> + <item name="android:textAllCaps">false</item> + </style> + + <style name="SudTextAppearanceDeviceDefaultMedium.Light" parent="SudTextAppearanceDeviceDefaultMedium"> + <item name="android:textColor">@color/sud_dynamic_color_accent_glif_v3_light</item> + </style> + <style name="SudThemeGlif" parent="SudBaseThemeGlif"> <item name="sucSystemNavBarBackgroundColor">?android:attr/navigationBarColor</item> <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> @@ -127,4 +190,58 @@ <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> </style> + <style name="SudThemeGlifV3" parent="SudBaseThemeGlifV3"> + + <!-- Copied from v27 SudThemeGlifV3 --> + <item name="android:navigationBarColor">@color/sud_glif_v3_nav_bar_color_dark</item> + <item name="android:navigationBarDividerColor" tools:ignore="NewApi">@color/sud_glif_v3_nav_bar_divider_color_dark</item> + <item name="android:windowLightNavigationBar" tools:ignore="NewApi">false</item> + <item name="sucLightSystemNavBar" tools:ignore="NewApi">?android:attr/windowLightNavigationBar</item> + <item name="sucSystemNavBarDividerColor" tools:ignore="NewApi">?android:attr/navigationBarDividerColor</item> + + <!-- Default font family--> + <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault</item> + <item name="android:textAppearanceInverse">@android:style/TextAppearance.DeviceDefault.Inverse</item> + <item name="android:textAppearanceLarge">@android:style/TextAppearance.DeviceDefault.Large</item> + <item name="android:textAppearanceMedium">@android:style/TextAppearance.DeviceDefault.Medium</item> + <!-- For textView --> + <item name="android:textAppearanceSmall">@android:style/TextAppearance.DeviceDefault.Small</item> + <item name="android:textAppearanceLargeInverse">@android:style/TextAppearance.DeviceDefault.Large.Inverse</item> + <!-- For editText --> + <item name="android:textAppearanceMediumInverse">@android:style/TextAppearance.DeviceDefault.Medium.Inverse</item> + <item name="android:textAppearanceSmallInverse">@android:style/TextAppearance.DeviceDefault.Small.Inverse</item> + <item name="android:textAppearanceSearchResultTitle">@android:style/TextAppearance.DeviceDefault.SearchResult.Title</item> + <item name="android:textAppearanceSearchResultSubtitle">@android:style/TextAppearance.DeviceDefault.SearchResult.Subtitle</item> + <item name="android:textAppearanceButton">@android:style/TextAppearance.DeviceDefault.Widget.Button</item> + <item name="android:textAppearanceLargePopupMenu">@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large</item> + <item name="android:textAppearanceSmallPopupMenu">@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small</item> + </style> + + <style name="SudThemeGlifV3.Light" parent="SudBaseThemeGlifV3.Light"> + + <!-- Copied from v27 SudThemeGlifV3.Light --> + <item name="android:navigationBarColor">@color/sud_glif_v3_nav_bar_color_light</item> + <item name="android:navigationBarDividerColor">@color/sud_glif_v3_nav_bar_divider_color_light</item> + <item name="android:windowLightNavigationBar">true</item> + <item name="sucLightSystemNavBar" tools:ignore="NewApi">?android:attr/windowLightNavigationBar</item> + <item name="sucSystemNavBarDividerColor" tools:ignore="NewApi">?android:attr/navigationBarDividerColor</item> + + <!-- Default font family--> + <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault</item> + <item name="android:textAppearanceInverse">@android:style/TextAppearance.DeviceDefault.Inverse</item> + <item name="android:textAppearanceLarge">@android:style/TextAppearance.DeviceDefault.Large</item> + <item name="android:textAppearanceMedium">@android:style/TextAppearance.DeviceDefault.Medium</item> + <!-- For textView --> + <item name="android:textAppearanceSmall">@android:style/TextAppearance.DeviceDefault.Small</item> + <item name="android:textAppearanceLargeInverse">@android:style/TextAppearance.DeviceDefault.Large.Inverse</item> + <!-- For editText --> + <item name="android:textAppearanceMediumInverse">@android:style/TextAppearance.DeviceDefault.Medium.Inverse</item> + <item name="android:textAppearanceSmallInverse">@android:style/TextAppearance.DeviceDefault.Small.Inverse</item> + <item name="android:textAppearanceSearchResultTitle">@android:style/TextAppearance.DeviceDefault.SearchResult.Title</item> + <item name="android:textAppearanceSearchResultSubtitle">@android:style/TextAppearance.DeviceDefault.SearchResult.Subtitle</item> + <item name="android:textAppearanceButton">@android:style/TextAppearance.DeviceDefault.Widget.Button</item> + <item name="android:textAppearanceLargePopupMenu">@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large</item> + <item name="android:textAppearanceSmallPopupMenu">@android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Small</item> + </style> + </resources> diff --git a/main/res/values/attrs.xml b/main/res/values/attrs.xml index c946912..48003a0 100644 --- a/main/res/values/attrs.xml +++ b/main/res/values/attrs.xml @@ -259,4 +259,10 @@ </declare-styleable> <attr name="sudLoadingHeaderHeight" format="dimension|reference" /> + + <!-- Glif Switch Bar style --> + <attr name="sudSwitchBarThumbOnColor" format="color|reference" /> + <attr name="sudSwitchBarThumbOffColor" format="color|reference" /> + <attr name="sudSwitchBarTrackOnColor" format="color|reference" /> + <attr name="sudSwitchBarTrackOffColor" format="color|reference" /> </resources> diff --git a/main/res/values/colors.xml b/main/res/values/colors.xml index 798abc9..3fe0b4b 100644 --- a/main/res/values/colors.xml +++ b/main/res/values/colors.xml @@ -140,8 +140,19 @@ <color name="sud_portal_pending_progress">@color/sud_portal_pending_progress_light</color> - <color name="sud_switch_track_off">#FF757575</color> - <color name="sud_switch_thumb_off">#BFFFFFFF</color> + + <color name="sud_switch_track_off_light">#FF55575E</color> + <color name="sud_switch_thumb_off_light">#FFA5ACB2</color> + <color name="sud_switch_track_off_dark">#FF454749</color> + <color name="sud_switch_thumb_off_dark">#FF8F9193</color> + + <color name="sud_switch_track_on_light">#3B78E7</color> + + <color name="sud_switch_thumb_on_light">#C6DAFC</color> + + <color name="sud_switch_track_on_dark">#824285F4</color> + + <color name="sud_switch_thumb_on_dark">#C6DAFC</color> <color name="sud_uniformity_backdrop_color">@android:color/white</color> diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml index 718604e..f7cdad4 100644 --- a/main/res/values/dimens.xml +++ b/main/res/values/dimens.xml @@ -17,6 +17,19 @@ <resources xmlns:tools="http://schemas.android.com/tools"> + <!-- Device default style --> + + <!-- Copy from Widget.DeviceDefault.Button.ButtonBar.AlertDialog --> + <!-- Dialog button bar width --> + <dimen name="sud_alert_dialog_button_bar_width">64dp</dimen> + <!-- Dialog button bar height --> + <dimen name="sud_alert_dialog_button_bar_height">48dip</dimen> + + <!-- Dialog button bar button text size --> + <dimen name="sud_alert_dialog_button_bar_button_text_size">14sp</dimen> + <!-- Dialog title text size --> + <dimen name="sud_alert_dialog_title_text_size">20sp</dimen> + <!-- General --> <dimen name="sud_layout_margin_sides">40dp</dimen> diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index 4725735..7c0065d 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -187,6 +187,10 @@ <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> <item name="sudLoadingHeaderHeight">@dimen/sud_loading_header_height</item> + <item name="sudSwitchBarThumbOnColor">@color/sud_switch_thumb_on_dark</item> + <item name="sudSwitchBarTrackOnColor">@color/sud_switch_track_on_dark</item> + <item name="sudSwitchBarThumbOffColor">@color/sud_switch_thumb_off_dark</item> + <item name="sudSwitchBarTrackOffColor">@color/sud_switch_track_off_dark</item> </style> <style name="SudThemeGlif" parent="SudBaseThemeGlif"/> @@ -264,6 +268,10 @@ <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> <item name="sudLoadingHeaderHeight">@dimen/sud_loading_header_height</item> + <item name="sudSwitchBarThumbOnColor">@color/sud_switch_thumb_on_light</item> + <item name="sudSwitchBarTrackOnColor">@color/sud_switch_track_on_light</item> + <item name="sudSwitchBarThumbOffColor">@color/sud_switch_thumb_off_light</item> + <item name="sudSwitchBarTrackOffColor">@color/sud_switch_track_off_light</item> </style> <style name="SudThemeGlif.Light" parent="SudBaseThemeGlif.Light"/> diff --git a/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java b/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java index d02839b..3eaf580 100644 --- a/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java +++ b/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java @@ -19,9 +19,11 @@ package com.google.android.setupdesign.view; import android.annotation.TargetApi; import android.content.Context; import android.content.res.TypedArray; +import android.os.Build; import android.os.Build.VERSION_CODES; import android.util.AttributeSet; import android.view.ViewGroup; +import android.view.WindowInsets; import android.widget.FrameLayout; import com.google.android.setupcompat.partnerconfig.PartnerConfig; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; @@ -40,6 +42,7 @@ public class IntrinsicSizeFrameLayout extends FrameLayout { private int intrinsicHeight = 0; private int intrinsicWidth = 0; + private Object lastInsets; // Use generic Object type for compatibility public IntrinsicSizeFrameLayout(Context context) { super(context); @@ -128,4 +131,20 @@ public class IntrinsicSizeFrameLayout extends FrameLayout { // Parent specified EXACTLY, or in all other cases, just return the original spec return measureSpec; } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { + if (lastInsets == null) { + requestApplyInsets(); + } + } + } + + @Override + public WindowInsets onApplyWindowInsets(WindowInsets insets) { + lastInsets = insets; + return super.onApplyWindowInsets(insets); + } } diff --git a/strings/AndroidManifest.xml b/strings/AndroidManifest.xml index e8316f3..c323fc7 100644 --- a/strings/AndroidManifest.xml +++ b/strings/AndroidManifest.xml @@ -20,6 +20,6 @@ <uses-sdk android:minSdkVersion="14" - android:targetSdkVersion="28" /> + android:targetSdkVersion="31" /> </manifest> |