Loading packages/SettingsLib/Spa/gallery/res/raw/accessibility_shortcut_type_triple_tap.json 0 → 100644 +1959 −0 File added.Preview size limit exceeded, changes collapsed. Show changes packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/page/IllustrationPage.kt +9 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,15 @@ object IllustrationPageProvider : SettingsPageProvider { @Composable private fun IllustrationPage() { Column(Modifier.verticalScroll(rememberScrollState())) { Preference(object : PreferenceModel { override val title = "Lottie Illustration" }) Illustration(object : IllustrationModel { override val resId = R.raw.accessibility_shortcut_type_triple_tap override val resourceType = ResourceType.LOTTIE }) Preference(object : PreferenceModel { override val title = "Image Illustration" }) Loading packages/SettingsLib/Spa/spa/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ android_library { "androidx.compose.ui_ui-tooling-preview", "androidx.navigation_navigation-compose", "com.google.android.material_material", "lottie_compose", ], kotlincflags: [ "-Xjvm-default=all", Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/Illustration.kt +6 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import com.android.settingslib.spa.framework.theme.SettingsDimension import com.android.settingslib.spa.widget.ui.ImageBox import com.android.settingslib.spa.widget.ui.Lottie enum class ResourceType { IMAGE, LOTTIE } /** Loading Loading @@ -72,7 +72,7 @@ fun Illustration( Column( modifier = modifier .fillMaxWidth() .padding(SettingsDimension.illustrationPadding), .padding(horizontal = SettingsDimension.illustrationPadding), horizontalAlignment = Alignment.CenterHorizontally, ) { val illustrationModifier = modifier Loading @@ -85,7 +85,10 @@ fun Illustration( when (resourceType) { ResourceType.LOTTIE -> { // TODO: Add Lottie function after lottie is enabled. Lottie( resId = resId, modifier = illustrationModifier, ) } ResourceType.IMAGE -> { ImageBox( Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Lottie.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.android.settingslib.spa.widget.ui import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants import com.airbnb.lottie.compose.animateLottieCompositionAsState import com.airbnb.lottie.compose.rememberLottieComposition @Composable fun Lottie( resId: Int, modifier: Modifier = Modifier, ) { Box( modifier = modifier, ) { BaseLottie(resId) } } @Composable private fun BaseLottie(resId: Int) { val composition by rememberLottieComposition( LottieCompositionSpec.RawRes(resId) ) val progress by animateLottieCompositionAsState( composition, iterations = LottieConstants.IterateForever, ) LottieAnimation( composition = composition, progress = { progress }, ) } Loading
packages/SettingsLib/Spa/gallery/res/raw/accessibility_shortcut_type_triple_tap.json 0 → 100644 +1959 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
packages/SettingsLib/Spa/gallery/src/com/android/settingslib/spa/gallery/page/IllustrationPage.kt +9 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,15 @@ object IllustrationPageProvider : SettingsPageProvider { @Composable private fun IllustrationPage() { Column(Modifier.verticalScroll(rememberScrollState())) { Preference(object : PreferenceModel { override val title = "Lottie Illustration" }) Illustration(object : IllustrationModel { override val resId = R.raw.accessibility_shortcut_type_triple_tap override val resourceType = ResourceType.LOTTIE }) Preference(object : PreferenceModel { override val title = "Image Illustration" }) Loading
packages/SettingsLib/Spa/spa/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ android_library { "androidx.compose.ui_ui-tooling-preview", "androidx.navigation_navigation-compose", "com.google.android.material_material", "lottie_compose", ], kotlincflags: [ "-Xjvm-default=all", Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/Illustration.kt +6 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import com.android.settingslib.spa.framework.theme.SettingsDimension import com.android.settingslib.spa.widget.ui.ImageBox import com.android.settingslib.spa.widget.ui.Lottie enum class ResourceType { IMAGE, LOTTIE } /** Loading Loading @@ -72,7 +72,7 @@ fun Illustration( Column( modifier = modifier .fillMaxWidth() .padding(SettingsDimension.illustrationPadding), .padding(horizontal = SettingsDimension.illustrationPadding), horizontalAlignment = Alignment.CenterHorizontally, ) { val illustrationModifier = modifier Loading @@ -85,7 +85,10 @@ fun Illustration( when (resourceType) { ResourceType.LOTTIE -> { // TODO: Add Lottie function after lottie is enabled. Lottie( resId = resId, modifier = illustrationModifier, ) } ResourceType.IMAGE -> { ImageBox( Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/ui/Lottie.kt 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.android.settingslib.spa.widget.ui import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants import com.airbnb.lottie.compose.animateLottieCompositionAsState import com.airbnb.lottie.compose.rememberLottieComposition @Composable fun Lottie( resId: Int, modifier: Modifier = Modifier, ) { Box( modifier = modifier, ) { BaseLottie(resId) } } @Composable private fun BaseLottie(resId: Int) { val composition by rememberLottieComposition( LottieCompositionSpec.RawRes(resId) ) val progress by animateLottieCompositionAsState( composition, iterations = LottieConstants.IterateForever, ) LottieAnimation( composition = composition, progress = { progress }, ) }