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

Commit 014d4fd7 authored by George Lin's avatar George Lin
Browse files

Enable side-tap for scrolling clock carousel (2/2)

Tapping the side should scroll the clock carousel
Tapping the middle preview leads to the preview screen

Test: See bug. Manually tested.
Bug: 281953291
Change-Id: I01b450e5682e7c4fa781a8e96987a06b9f95f58f
parent 6408d097
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@ object ClockCarouselViewBinder {
                }
            )
        screenPreviewClickView.accessibilityDelegate = carouselAccessibilityDelegate
        screenPreviewClickView.setOnSideClickedListener { isStart ->
            if (isStart) carouselView.scrollToPrevious() else carouselView.scrollToNext()
        }

        lifecycleOwner.lifecycleScope.launch {
            lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
+24 −0
Original line number Diff line number Diff line
@@ -100,6 +100,29 @@ class ClockCarouselView(
        }
    }

    fun scrollToNext() {
        if (
            carousel.count <= 1 ||
                (!carousel.isInfinite && carousel.currentIndex == carousel.count - 1)
        ) {
            // No need to scroll if the count is equal or less than 1
            return
        }
        if (motionLayout.currentState == R.id.start) {
            motionLayout.transitionToState(R.id.next, TRANSITION_DURATION)
        }
    }

    fun scrollToPrevious() {
        if (carousel.count <= 1 || (!carousel.isInfinite && carousel.currentIndex == 0)) {
            // No need to scroll if the count is equal or less than 1
            return
        }
        if (motionLayout.currentState == R.id.start) {
            motionLayout.transitionToState(R.id.previous, TRANSITION_DURATION)
        }
    }

    fun getContentDescription(index: Int): String {
        return adapter.getContentDescription(index, resources)
    }
@@ -485,6 +508,7 @@ class ClockCarouselView(
        // The carousel needs to have at least 5 different clock faces to be infinite
        const val MIN_CLOCKS_TO_ENABLE_INFINITE_CAROUSEL = 5
        const val CLOCK_CAROUSEL_VIEW_SCALE = 0.5f
        const val TRANSITION_DURATION = 250

        val itemViewIds =
            listOf(