Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e61a3da2 authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Enable & disable swipe interaction where appropriate

Bug: 340253296
Bug: 343495953
Test: Manually tested the interaction
Flag: com.android.systemui.clock_reactive_variants
Change-Id: I1ff11ee2b591ef9f941c91b0b1390d71503a08fe
parent e7a08cf4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.customization.picker.clock.ui.viewmodel.ClockSettingsViewMode
import com.android.customization.picker.color.ui.binder.ColorOptionIconBinder
import com.android.customization.picker.common.ui.view.ItemSpacing
import com.android.themepicker.R
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.picker.option.ui.binder.OptionItemBinder
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.mapNotNull
@@ -198,6 +199,9 @@ object ClockSettingsBinder {
                        )
                        .collect { (clockId, size) ->
                            clockHostView.removeAllViews()
                            if (BaseFlags.get().isClockReactiveVariantsEnabled()) {
                                clockViewFactory.setReactiveTouchInteractionEnabled(clockId, true)
                            }
                            val clockView =
                                when (size) {
                                    ClockSize.DYNAMIC -> clockViewFactory.getLargeView(clockId)
+9 −11
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselItemViewModel
import com.android.systemui.plugins.clocks.ClockController
import com.android.themepicker.R
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
import java.lang.Float.max

@@ -408,8 +409,11 @@ class ClockCarouselView(
                    ?: return
            val clockId = clocks[index].clockId

            // Add the clock view to the cloc host view
            // Add the clock view to the clock host view
            clockHostView.removeAllViews()
            if (BaseFlags.get().isClockReactiveVariantsEnabled()) {
                clockViewFactory.setReactiveTouchInteractionEnabled(clockId, false)
            }
            val clockView =
                when (clockSize) {
                    ClockSize.DYNAMIC -> clockViewFactory.getLargeView(clockId)
@@ -454,22 +458,16 @@ class ClockCarouselView(
                it.pivotX = it.width / 2F
                it.pivotY = it.height / 2F
            }

            val controller = clockViewFactory.getController(clockId)
            if (isMiddleView) {
                clockScaleView.scaleX = 1f
                clockScaleView.scaleY = 1f
                clockViewFactory
                    .getController(clockId)
                    .largeClock
                    .animations
                    .onPickerCarouselSwiping(1F)
                controller.largeClock.animations.onPickerCarouselSwiping(1F)
            } else {
                clockScaleView.scaleX = CLOCK_CAROUSEL_VIEW_SCALE
                clockScaleView.scaleY = CLOCK_CAROUSEL_VIEW_SCALE
                clockViewFactory
                    .getController(clockId)
                    .largeClock
                    .animations
                    .onPickerCarouselSwiping(0F)
                controller.largeClock.animations.onPickerCarouselSwiping(0F)
            }
        }

+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ interface ClockViewFactory {
     */
    fun getSmallView(clockId: String): View

    /** Enables or disables the reactive swipe interaction */
    fun setReactiveTouchInteractionEnabled(clockId: String, enable: Boolean)

    fun updateColorForAllClocks(@ColorInt seedColor: Int?)

    fun updateColor(clockId: String, @ColorInt seedColor: Int?)
+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.WeatherData
import com.android.systemui.shared.clocks.ClockRegistry
import com.android.themepicker.R
import com.android.wallpaper.config.BaseFlags
import com.android.wallpaper.util.TimeUtils.TimeTicker
import java.util.concurrent.ConcurrentHashMap

@@ -81,6 +82,14 @@ class ClockViewFactoryImpl(
        return smallClockFrame
    }

    /** Enables or disables the reactive swipe interaction */
    override fun setReactiveTouchInteractionEnabled(clockId: String, enable: Boolean) {
        check(BaseFlags.get().isClockReactiveVariantsEnabled()) {
            "isClockReactiveVariantsEnabled is disabled"
        }
        getController(clockId).events.isReactiveTouchInteractionEnabled = enable
    }

    private fun createSmallClockFrame(): FrameLayout {
        val smallClockFrame = FrameLayout(appContext)
        val layoutParams =
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ class FakeClockViewFactory(

    override fun getController(clockId: String): ClockController = clockControllers.get(clockId)!!

    override fun setReactiveTouchInteractionEnabled(clockId: String, enable: Boolean) {
        TODO("Not yet implemented")
    }

    override fun getLargeView(clockId: String): View {
        TODO("Not yet implemented")
    }