Add loopable EDU lottie files and convert to light theme manually.

These new assets are better at looping than the previous ones.

Followed go/sysui-illustration-eng to map from dark to light colors
programmatically. Handling the mapping in code is preferred over having
separate lottie assets for light and dark theme.

Test: Manual
Bug: 263157739
Change-Id: Ia3cd2a1e7d349188d182d796ba927f1c513d4716
This commit is contained in:
Brian Isganitis 2023-01-18 22:59:23 +00:00
parent b21ad2da8c
commit 4bcc9bc816
7 changed files with 68 additions and 7 deletions

View File

@ -37,7 +37,7 @@
app:layout_constraintTop_toBottomOf="@id/title"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/taskbar_edu_splitscreen_transient" />
app:lottie_rawRes="@raw/taskbar_edu_splitscreen" />
<TextView
android:id="@+id/splitscreen_text"
@ -61,7 +61,7 @@
app:layout_constraintTop_toBottomOf="@id/title"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/taskbar_edu_suggestions_transient" />
app:lottie_rawRes="@raw/taskbar_edu_suggestions" />
<TextView
android:id="@+id/suggestions_text"

View File

@ -22,12 +22,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/taskbar_edu_stashing"
app:layout_constraintEnd_toEndOf="@id/animation"
app:layout_constraintStart_toStartOf="@id/animation"
app:layout_constraintEnd_toEndOf="@id/swipe_animation"
app:layout_constraintStart_toStartOf="@id/swipe_animation"
app:layout_constraintTop_toTopOf="parent" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation"
android:id="@+id/swipe_animation"
android:layout_width="@dimen/taskbar_edu_swipe_lottie_width"
android:layout_height="@dimen/taskbar_edu_swipe_lottie_height"
android:layout_marginTop="@dimen/taskbar_edu_tooltip_vertical_margin"
@ -38,6 +38,6 @@
app:layout_constraintTop_toBottomOf="@id/title"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/taskbar_edu_stashing_transient" />
app:lottie_rawRes="@raw/taskbar_edu_stashing" />
</merge>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -79,4 +79,16 @@
<!-- Recents overview -->
<color name="recents_filter_icon">#333333</color>
<!-- Lottie light theme colors. -->
<color name="lottie_blue400">#669df6</color>
<color name="lottie_blue600">#1a73e8</color>
<color name="lottie_green400">#5bb974</color>
<color name="lottie_green600">#1e8e3e</color>
<color name="lottie_grey200">#e8eaed</color>
<color name="lottie_grey600">#80868b</color>
<color name="lottie_grey700">#5f6368</color>
<color name="lottie_red600">#d93025</color>
<color name="lottie_yellow400">#fcc934</color>
<color name="lottie_yellow600">#f9ab00</color>
</resources>

View File

@ -15,11 +15,17 @@
*/
package com.android.launcher3.taskbar
import android.graphics.PorterDuff.Mode.SRC_ATOP
import android.graphics.PorterDuffColorFilter
import android.view.View
import android.view.ViewGroup
import androidx.annotation.IntDef
import androidx.annotation.LayoutRes
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieProperty.COLOR_FILTER
import com.airbnb.lottie.model.KeyPath
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.Utilities.IS_RUNNING_IN_TEST_HARNESS
import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_EDU_TOOLTIP
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN
@ -82,7 +88,10 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
tooltipStep = TOOLTIP_STEP_FEATURES
inflateTooltip(R.layout.taskbar_edu_swipe)
tooltip?.show()
tooltip?.apply {
findViewById<LottieAnimationView>(R.id.swipe_animation).supportLightTheme()
show()
}
}
/**
@ -99,6 +108,9 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
tooltipStep = TOOLTIP_STEP_NONE
inflateTooltip(R.layout.taskbar_edu_features)
tooltip?.apply {
findViewById<LottieAnimationView>(R.id.splitscreen_animation).supportLightTheme()
findViewById<LottieAnimationView>(R.id.suggestions_animation).supportLightTheme()
findViewById<View>(R.id.done_button)?.setOnClickListener { hide() }
if (DisplayController.isTransientTaskbar(activityContext)) {
(layoutParams as ViewGroup.MarginLayoutParams).bottomMargin +=
@ -145,3 +157,37 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
pw?.println("$prefix\ttooltipStep=$tooltipStep")
}
}
/**
* Maps colors in the dark-themed Lottie assets to their light-themed equivalents.
*
* For instance, `".blue100" to R.color.lottie_blue400` means objects that are material blue100 in
* dark theme should be changed to material blue400 in light theme.
*/
private val DARK_TO_LIGHT_COLORS =
mapOf(
".blue100" to R.color.lottie_blue400,
".blue400" to R.color.lottie_blue600,
".green100" to R.color.lottie_green400,
".green400" to R.color.lottie_green600,
".grey300" to R.color.lottie_grey600,
".grey400" to R.color.lottie_grey700,
".grey800" to R.color.lottie_grey200,
".red400" to R.color.lottie_red600,
".yellow100" to R.color.lottie_yellow400,
".yellow400" to R.color.lottie_yellow600,
)
private fun LottieAnimationView.supportLightTheme() {
if (Utilities.isDarkTheme(context)) {
return
}
addLottieOnCompositionLoadedListener {
DARK_TO_LIGHT_COLORS.forEach { (key, color) ->
addValueCallback(KeyPath("**", key, "**"), COLOR_FILTER) {
PorterDuffColorFilter(context.getColor(color), SRC_ATOP)
}
}
}
}