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

Commit 5ab29ad3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Dual Shade] Set the shade invocation zone to always be split 50/50." into main

parents da61b0b8 94367ecd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -118,12 +118,12 @@ class ShadeModeInteractorImplTest : SysuiTestCase() {
        }

    @Test
    fun getTopEdgeSplitFraction_wideScreen_leftSideLarger() =
    fun getTopEdgeSplitFraction_wideScreen_splitInHalf() =
        testScope.runTest {
            // Ensure isShadeLayoutWide is collected.
            val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
            kosmos.shadeRepository.setShadeLayoutWide(true)

            assertThat(underTest.getTopEdgeSplitFraction()).isGreaterThan(0.5f)
            assertThat(underTest.getTopEdgeSplitFraction()).isEqualTo(0.5f)
        }
}
+1 −5
Original line number Diff line number Diff line
@@ -79,11 +79,7 @@ interface ShadeInteractor : BaseShadeInteractor {
     * The fraction between [0..1] (i.e., percentage) of screen width to consider the threshold
     * between "top-left" and "top-right" for the purposes of dual-shade invocation.
     *
     * When the dual-shade is not wide, this always returns 0.5 (the top edge is evenly split). On
     * wide layouts however, a larger fraction is returned because only the area of the system
     * status icons is considered top-right.
     *
     * Note that this fraction only determines the split between the absolute left and right
     * Note that this fraction only determines the *split* between the absolute left and right
     * directions. In RTL layouts, the "top-start" edge will resolve to "top-right", and "top-end"
     * will resolve to "top-left".
     */
+3 −13
Original line number Diff line number Diff line
@@ -76,10 +76,8 @@ interface ShadeModeInteractor {

class ShadeModeInteractorImpl
@Inject
constructor(
    @Application applicationScope: CoroutineScope,
    private val repository: ShadeRepository,
) : ShadeModeInteractor {
constructor(@Application applicationScope: CoroutineScope, repository: ShadeRepository) :
    ShadeModeInteractor {

    override val isShadeLayoutWide: StateFlow<Boolean> = repository.isShadeLayoutWide

@@ -92,15 +90,7 @@ constructor(
                initialValue = determineShadeMode(isShadeLayoutWide.value),
            )

    @FloatRange(from = 0.0, to = 1.0)
    override fun getTopEdgeSplitFraction(): Float {
        // Note: this implicitly relies on isShadeLayoutWide being hot (i.e. collected). This
        // assumption allows us to query its value on demand (during swipe source detection) instead
        // of running another infinite coroutine.
        // TODO(b/338577208): Instead of being fixed at 0.8f, this should dynamically updated based
        //  on the position of system-status icons in the status bar.
        return if (repository.isShadeLayoutWide.value) 0.8f else 0.5f
    }
    @FloatRange(from = 0.0, to = 1.0) override fun getTopEdgeSplitFraction(): Float = 0.5f

    private fun determineShadeMode(isShadeLayoutWide: Boolean): ShadeMode {
        return when {