Merge "Import translations. DO NOT MERGE ANYWHERE" into udc-dev
diff --git a/res/drawable/clock_color_size_button_background.xml b/res/drawable/clock_color_size_button_background.xml
new file mode 100644
index 0000000..08d1c45
--- /dev/null
+++ b/res/drawable/clock_color_size_button_background.xml
@@ -0,0 +1,27 @@
+<!--
+ Copyright (C) 2023 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.
+-->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:colorControlHighlight">
+
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/clock_color_size_button_corner_radius" />
+ <solid android:color="?android:colorControlHighlight" />
+ </shape>
+ </item>
+
+ <item android:drawable="@drawable/clock_color_size_button_background_base" />
+</ripple>
diff --git a/res/drawable/clock_color_size_button_background_base.xml b/res/drawable/clock_color_size_button_background_base.xml
new file mode 100644
index 0000000..2e6f2be
--- /dev/null
+++ b/res/drawable/clock_color_size_button_background_base.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2023 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <corners android:radius="@dimen/clock_color_size_button_corner_radius" />
+ <solid android:color="@color/color_surface" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/ic_settings.xml b/res/drawable/ic_settings.xml
new file mode 100644
index 0000000..3b9076e
--- /dev/null
+++ b/res/drawable/ic_settings.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright (C) 2023 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tintMode="multiply"
+ android:tint="@color/color_accent_primary">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M370,880L354,752Q341,747 329.5,740Q318,733 307,725L188,775L78,585L181,507Q180,500 180,493.5Q180,487 180,480Q180,473 180,466.5Q180,460 181,453L78,375L188,185L307,235Q318,227 330,220Q342,213 354,208L370,80L590,80L606,208Q619,213 630.5,220Q642,227 653,235L772,185L882,375L779,453Q780,460 780,466.5Q780,473 780,480Q780,487 780,493.5Q780,500 778,507L881,585L771,775L653,725Q642,733 630,740Q618,747 606,752L590,880L370,880ZM440,800L519,800L533,694Q564,686 590.5,670.5Q617,655 639,633L738,674L777,606L691,541Q696,527 698,511.5Q700,496 700,480Q700,464 698,448.5Q696,433 691,419L777,354L738,286L639,328Q617,305 590.5,289.5Q564,274 533,266L520,160L441,160L427,266Q396,274 369.5,289.5Q343,305 321,327L222,286L183,354L269,418Q264,433 262,448Q260,463 260,480Q260,496 262,511Q264,526 269,541L183,606L222,674L321,632Q343,655 369.5,670.5Q396,686 427,694L440,800ZM482,620Q540,620 581,579Q622,538 622,480Q622,422 581,381Q540,340 482,340Q423,340 382.5,381Q342,422 342,480Q342,538 382.5,579Q423,620 482,620ZM480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480Z"/>
+</vector>
diff --git a/res/layout/clock_carousel.xml b/res/layout/clock_carousel.xml
index 35defd6..dbeb4dd 100644
--- a/res/layout/clock_carousel.xml
+++ b/res/layout/clock_carousel.xml
@@ -33,7 +33,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" />
+ android:layout_gravity="center"
+ android:clipChildren="false" />
</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
@@ -47,7 +48,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" />
+ android:layout_gravity="center"
+ android:clipChildren="false"/>
</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
@@ -62,7 +64,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" />
+ android:layout_gravity="center"
+ android:clipChildren="false"/>
</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
@@ -76,7 +79,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" />
+ android:layout_gravity="center"
+ android:clipChildren="false"/>
</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
@@ -90,7 +94,8 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center" />
+ android:layout_gravity="center"
+ android:clipChildren="false" />
</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
<androidx.constraintlayout.helper.widget.Carousel
diff --git a/res/layout/clock_color_and_size_button.xml b/res/layout/clock_color_and_size_button.xml
new file mode 100644
index 0000000..ff5a519
--- /dev/null
+++ b/res/layout/clock_color_and_size_button.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minHeight="@dimen/clock_color_size_button_min_height"
+ android:background="@drawable/clock_color_size_button_background"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingVertical="@dimen/clock_color_size_button_vertical_padding"
+ android:paddingHorizontal="@dimen/clock_color_size_button_horizontal_padding">
+
+ <ImageView
+ android:layout_width="@dimen/clock_color_size_button_icon_size"
+ android:layout_height="@dimen/clock_color_size_button_icon_size"
+ android:src="@drawable/ic_settings"
+ android:importantForAccessibility="no"
+ android:layout_marginEnd="@dimen/clock_color_size_button_icon_margin_end"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/color_accent_primary"
+ android:text="@string/clock_color_and_size_title" />
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/color_section_view2.xml b/res/layout/color_section_view2.xml
index 687bcef..851bc5d 100644
--- a/res/layout/color_section_view2.xml
+++ b/res/layout/color_section_view2.xml
@@ -37,7 +37,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingVertical="24dp"
+ android:paddingVertical="20dp"
android:paddingHorizontal="24dp"
android:weightSum="@integer/color_section_num_columns">
<include
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0d5a9a8..cb4876a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -164,4 +164,12 @@
<dimen name="clock_carousel_scale" format="float">0.5</dimen>
<!-- Alpha of the carousel items that are not selected and at the side -->
<dimen name="clock_carousel_alpha" format="float">0.4</dimen>
+
+ <!-- Clock color and size button -->
+ <dimen name="clock_color_size_button_min_height">32dp</dimen>
+ <dimen name="clock_color_size_button_horizontal_padding">12dp</dimen>
+ <dimen name="clock_color_size_button_vertical_padding">6dp</dimen>
+ <dimen name="clock_color_size_button_corner_radius">16dp</dimen>
+ <dimen name="clock_color_size_button_icon_size">24dp</dimen>
+ <dimen name="clock_color_size_button_icon_margin_end">8dp</dimen>
</resources>
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index 3c1d31d..786db54 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -115,6 +115,7 @@
mClockCarouselViewModel,
mClockViewFactory,
wallpaperPreviewNavigator,
+ sectionNavigationController,
wallpaperInteractor)
: new ScreenPreviewSectionController(
activity,
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
index def3778..cf80dc1 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
@@ -57,8 +57,11 @@
viewModel.allClockIds.collect { allClockIds ->
carouselView.setUpClockCarouselView(
clockIds = allClockIds,
- onGetClockPreview = { clockId -> clockViewFactory.getView(clockId) },
+ onGetClockController = { clockId ->
+ clockViewFactory.getController(clockId)
+ },
onClockSelected = { clockId -> viewModel.setSelectedClock(clockId) },
+ getPreviewRatio = { clockViewFactory.getRatio() }
)
}
}
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
index 90d7c42..3eae7aa 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
@@ -22,7 +22,9 @@
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.constraintlayout.helper.widget.Carousel
+import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.get
+import com.android.systemui.plugins.ClockController
import com.android.wallpaper.R
class ClockCarouselView(
@@ -35,21 +37,66 @@
) {
private val carousel: Carousel
+ private val motionLayout: MotionLayout
private lateinit var adapter: ClockCarouselAdapter
+ private lateinit var scalingUpClock: ClockController
+ private lateinit var scalingDownClock: ClockController
init {
- val view = LayoutInflater.from(context).inflate(R.layout.clock_carousel, this)
- carousel = view.requireViewById(R.id.carousel)
+ val clockCarousel = LayoutInflater.from(context).inflate(R.layout.clock_carousel, this)
+ carousel = clockCarousel.requireViewById(R.id.carousel)
+ motionLayout = clockCarousel.requireViewById(R.id.motion_container)
}
fun setUpClockCarouselView(
clockIds: List<String>,
- onGetClockPreview: (clockId: String) -> View,
+ onGetClockController: (clockId: String) -> ClockController,
onClockSelected: (clockId: String) -> Unit,
+ getPreviewRatio: () -> Float,
) {
- adapter = ClockCarouselAdapter(clockIds, onGetClockPreview, onClockSelected)
+ adapter =
+ ClockCarouselAdapter(clockIds, onGetClockController, onClockSelected, getPreviewRatio)
carousel.setAdapter(adapter)
carousel.refresh()
+ motionLayout.setTransitionListener(
+ object : MotionLayout.TransitionListener {
+ override fun onTransitionStarted(
+ motionLayout: MotionLayout?,
+ startId: Int,
+ endId: Int
+ ) {
+ val scalingDownClockId = adapter.clockIds[carousel.currentIndex]
+ val scalingUpIdx =
+ if (endId == R.id.next) (carousel.currentIndex + 1) % adapter.count()
+ else (carousel.currentIndex - 1 + adapter.count()) % adapter.count()
+ val scalingUpClockId = adapter.clockIds[scalingUpIdx]
+ scalingDownClock = adapter.onGetClockController(scalingDownClockId)
+ scalingUpClock = adapter.onGetClockController(scalingUpClockId)
+ }
+
+ override fun onTransitionChange(
+ motionLayout: MotionLayout?,
+ startId: Int,
+ endId: Int,
+ progress: Float
+ ) {
+ scalingDownClock.animations.onPickerCarouselSwiping(
+ 1 - progress,
+ getPreviewRatio()
+ )
+ scalingUpClock.animations.onPickerCarouselSwiping(progress, getPreviewRatio())
+ }
+
+ override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {}
+
+ override fun onTransitionTrigger(
+ motionLayout: MotionLayout?,
+ triggerId: Int,
+ positive: Boolean,
+ progress: Float
+ ) {}
+ }
+ )
}
fun setSelectedClockIndex(
@@ -60,8 +107,9 @@
class ClockCarouselAdapter(
val clockIds: List<String>,
- val onGetClockPreview: (clockId: String) -> View,
- val onClockSelected: (clockId: String) -> Unit,
+ val onGetClockController: (clockId: String) -> ClockController,
+ private val onClockSelected: (clockId: String) -> Unit,
+ val getPreviewRatio: () -> Float,
) : Carousel.Adapter {
override fun count(): Int {
@@ -72,15 +120,29 @@
val viewRoot = view as ViewGroup
val clockHostView = viewRoot[0] as ViewGroup
clockHostView.removeAllViews()
- val clockView = onGetClockPreview(clockIds[index])
+ val clockView = onGetClockController(clockIds[index]).largeClock.view
// The clock view might still be attached to an existing parent. Detach before adding to
// another parent.
(clockView.parent as? ViewGroup)?.removeView(clockView)
clockHostView.addView(clockView)
+ // initialize scaling state for all clocks
+ if (view.id != MIDDLE_VIEW_IN_START_STATE) {
+ onGetClockController(clockIds[index])
+ .animations
+ .onPickerCarouselSwiping(0F, getPreviewRatio())
+ } else {
+ onGetClockController(clockIds[index])
+ .animations
+ .onPickerCarouselSwiping(1F, getPreviewRatio())
+ }
}
override fun onNewItem(index: Int) {
onClockSelected.invoke(clockIds[index])
}
}
+
+ companion object {
+ const val MIDDLE_VIEW_IN_START_STATE = R.id.item_view_2
+ }
}
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt b/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
index 3222c87..67c7002 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
@@ -33,9 +33,20 @@
) {
private val timeTickListeners: ConcurrentHashMap<Int, TimeTicker> = ConcurrentHashMap()
private val clockControllers: HashMap<String, ClockController> = HashMap()
+ private var ticker: TimeTicker? = null
+ fun getRatio(): Float {
+ val screenSizeCalculator = ScreenSizeCalculator.getInstance()
+ val screenSize = screenSizeCalculator.getScreenSize(activity.windowManager.defaultDisplay)
+ return activity.resources.getDimensionPixelSize(R.dimen.screen_preview_height).toFloat() /
+ screenSize.y.toFloat()
+ }
+
+ fun getController(clockId: String): ClockController {
+ return clockControllers[clockId] ?: initClockController(clockId)
+ }
fun getView(clockId: String): View {
- return (clockControllers[clockId] ?: initClockController(clockId)).largeClock.view
+ return getController(clockId).largeClock.view
}
fun updateColorForAllClocks(@ColorInt seedColor: Int?) {
@@ -79,14 +90,9 @@
controller.largeClock.events.onRegionDarknessChanged(isRegionDark)
// Configure font size
- val screenSizeCalculator = ScreenSizeCalculator.getInstance()
- val screenSize = screenSizeCalculator.getScreenSize(activity.windowManager.defaultDisplay)
- val ratio =
- activity.resources.getDimensionPixelSize(R.dimen.screen_preview_height).toFloat() /
- screenSize.y.toFloat()
controller.largeClock.events.onFontSettingChanged(
activity.resources.getDimensionPixelSize(R.dimen.large_clock_text_size).toFloat() *
- ratio
+ getRatio()
)
clockControllers[clockId] = controller
return controller
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
index 6dbc7ef..0303b41 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -19,15 +19,19 @@
import android.app.Activity
import android.content.Context
+import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
+import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import com.android.customization.picker.clock.ui.binder.ClockCarouselViewBinder
+import com.android.customization.picker.clock.ui.fragment.ClockSettingsFragment
import com.android.customization.picker.clock.ui.view.ClockCarouselView
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
import com.android.wallpaper.R
+import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController
import com.android.wallpaper.model.WallpaperColorsViewModel
import com.android.wallpaper.model.WallpaperPreviewNavigator
import com.android.wallpaper.module.CurrentWallpaperInfoFactory
@@ -49,6 +53,7 @@
private val clockCarouselViewModel: ClockCarouselViewModel,
private val clockViewFactory: ClockViewFactory,
wallpaperPreviewNavigator: WallpaperPreviewNavigator,
+ private val navigationController: CustomizationSectionNavigationController,
wallpaperInteractor: WallpaperInteractor,
) :
ScreenPreviewSectionController(
@@ -63,11 +68,21 @@
) {
private var clockCarouselBinding: ClockCarouselViewBinder.Binding? = null
+ private var clockColorAndSizeButton: View? = null
override val hideLockScreenClockPreview = true
override fun createView(context: Context): ScreenPreviewView {
val view = super.createView(context)
+
+ val clockColorAndSizeButtonStub: ViewStub =
+ view.requireViewById(R.id.clock_color_and_size_button)
+ clockColorAndSizeButtonStub.layoutResource = R.layout.clock_color_and_size_button
+ clockColorAndSizeButton = clockColorAndSizeButtonStub.inflate() as View
+ clockColorAndSizeButton?.setOnClickListener {
+ navigationController.navigateTo(ClockSettingsFragment())
+ }
+
val carouselViewStub: ViewStub = view.requireViewById(R.id.clock_carousel_view_stub)
carouselViewStub.layoutResource = R.layout.clock_carousel_view
val carouselView = carouselViewStub.inflate() as ClockCarouselView
@@ -94,6 +109,7 @@
override fun onScreenSwitched(isOnLockScreen: Boolean) {
super.onScreenSwitched(isOnLockScreen)
+ clockColorAndSizeButton?.isVisible = isOnLockScreen
if (isOnLockScreen) {
clockCarouselBinding?.show()
} else {