From c535650db266d5ffa877ff60aa6c7738d0da2b9a Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Mon, 8 Jun 2020 16:14:58 -0400 Subject: [PATCH] Animate the priority ring in the onboarding Test: manual Fixes: 155490513 Change-Id: I5cb6b09420337a2957d5174c1e150d400eef3a03 --- core/res/res/values/symbols.xml | 7 ++ .../notification/ConversationIconFactory.java | 4 +- .../layout/priority_onboarding_half_shell.xml | 56 ++++++++++- .../src/com/android/systemui/Prefs.java | 2 +- .../row/NotificationConversationInfo.java | 5 +- .../row/PriorityOnboardingDialogController.kt | 95 +++++++++++++++++-- 6 files changed, 155 insertions(+), 14 deletions(-) diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 23ae1e7d271ed..c0cb39a56dd6e 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3956,6 +3956,13 @@ + + + + + + + diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/ConversationIconFactory.java b/packages/SettingsLib/src/com/android/settingslib/notification/ConversationIconFactory.java index d5f1ece5f83f6..549bc8a455cf4 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/ConversationIconFactory.java +++ b/packages/SettingsLib/src/com/android/settingslib/notification/ConversationIconFactory.java @@ -86,7 +86,7 @@ public class ConversationIconFactory extends BaseIconFactory { /** * Returns the conversation info drawable */ - private Drawable getBaseIconDrawable(ShortcutInfo shortcutInfo) { + public Drawable getBaseIconDrawable(ShortcutInfo shortcutInfo) { return mLauncherApps.getShortcutIconDrawable(shortcutInfo, mFillResIconDpi); } @@ -94,7 +94,7 @@ public class ConversationIconFactory extends BaseIconFactory { * Get the {@link Drawable} that represents the app icon, badged with the work profile icon * if appropriate. */ - private Drawable getAppBadge(String packageName, int userId) { + public Drawable getAppBadge(String packageName, int userId) { Drawable badge = null; try { final ApplicationInfo appInfo = mPackageManager.getApplicationInfoAsUser( diff --git a/packages/SystemUI/res/layout/priority_onboarding_half_shell.xml b/packages/SystemUI/res/layout/priority_onboarding_half_shell.xml index bf2eac3c8ff3c..3f0e514a9af22 100644 --- a/packages/SystemUI/res/layout/priority_onboarding_half_shell.xml +++ b/packages/SystemUI/res/layout/priority_onboarding_half_shell.xml @@ -38,11 +38,61 @@ android:background="@drawable/rounded_bg_full" > + + + + android:layout_width="@*android:dimen/conversation_avatar_size" + android:layout_height="@*android:dimen/conversation_avatar_size" + android:scaleType="centerCrop" + android:importantForAccessibility="no" + /> + + + + + + + (R.id.conversation_icon)?.setImageDrawable(icon) + findViewById(R.id.icon)?.setImageDrawable(badge) + val mImportanceRingView = findViewById(R.id.conversation_icon_badge_ring) + val conversationIconBadgeBg = findViewById(R.id.conversation_icon_badge_bg) + + val ring: GradientDrawable = mImportanceRingView.drawable as GradientDrawable + ring.mutate() + val bg = conversationIconBadgeBg.drawable as GradientDrawable + bg.mutate() + val ringColor = context.getResources() + .getColor(com.android.internal.R.color.conversation_important_highlight) + val standardThickness = context.resources.getDimensionPixelSize( + com.android.internal.R.dimen.importance_ring_stroke_width) + val largeThickness = context.resources.getDimensionPixelSize( + com.android.internal.R.dimen.importance_ring_anim_max_stroke_width) + val standardSize = context.resources.getDimensionPixelSize( + com.android.internal.R.dimen.importance_ring_size) + val baseSize = standardSize - standardThickness * 2 + val largeSize = baseSize + largeThickness * 2 + val bgSize = context.resources.getDimensionPixelSize( + com.android.internal.R.dimen.conversation_icon_size_badged) + + val animatorUpdateListener: ValueAnimator.AnimatorUpdateListener + = ValueAnimator.AnimatorUpdateListener { animation -> + val strokeWidth = animation.animatedValue as Int + ring.setStroke(strokeWidth, ringColor) + val newSize = baseSize + strokeWidth * 2 + ring.setSize(newSize, newSize) + mImportanceRingView.invalidate() + } + + val growAnimation: ValueAnimator = ValueAnimator.ofInt(0, largeThickness) + growAnimation.interpolator = LINEAR_OUT_SLOW_IN + growAnimation.duration = IMPORTANCE_ANIM_GROW_DURATION + growAnimation.addUpdateListener(animatorUpdateListener) + + val shrinkAnimation: ValueAnimator + = ValueAnimator.ofInt(largeThickness, standardThickness) + shrinkAnimation.duration = IMPORTANCE_ANIM_SHRINK_DURATION + shrinkAnimation.startDelay = IMPORTANCE_ANIM_SHRINK_DELAY + shrinkAnimation.interpolator = OVERSHOOT + shrinkAnimation.addUpdateListener(animatorUpdateListener) + shrinkAnimation.addListener(object : AnimatorListenerAdapter() { + override fun onAnimationStart(animation: Animator?) { + // Shrink the badge bg so that it doesn't peek behind the animation + bg.setSize(baseSize, baseSize); + conversationIconBadgeBg.invalidate(); + } + + override fun onAnimationEnd(animation: Animator?) { + // Reset bg back to normal size + bg.setSize(bgSize, bgSize); + conversationIconBadgeBg.invalidate(); + + } + }) + + val anims = AnimatorSet() + anims.startDelay = IMPORTANCE_ANIM_DELAY + anims.playSequentially(growAnimation, shrinkAnimation) val gapWidth = dialog.context.getResources().getDimensionPixelSize( R.dimen.conversation_onboarding_bullet_gap_width) @@ -180,6 +260,7 @@ class PriorityOnboardingDialogController @Inject constructor( height = WRAP_CONTENT } } + anims.start() } }