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

Commit 8c8a5a22 authored by Anton Potapov's avatar Anton Potapov
Browse files

Introduce new QS tiles core interfaces

These interfaces represent core entities used in domain and ViewModel
layers of the new QS tiles.

Test: auto: passes presubmits; new code is unused as per this CL
Bug: 299908705
Change-Id: Iaf9fc8c4646f6d64943179b38842b76055cc8839
parent b90e7f68
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
package com.android.systemui.qs.tiles.base.interactor

import com.android.systemui.qs.tiles.viewmodel.QSTileState
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow

/**
 * Provides data and availability for the tile. In most cases it would delegate data retrieval to
 * repository, manager, controller or a combination of those. Avoid doing long running operations in
 * these methods because there is no background thread guarantee. Use [Flow.flowOn] (typically
 * with @Background [CoroutineDispatcher]) instead to move the calculations to another thread.
 */
interface QSTileDataInteractor<DATA_TYPE> {

    /**
     * Returns the data to be mapped to [QSTileState]. Make sure to start the flow [Flow.onStart]
     * with the current state to update the tile as soon as possible.
     */
    fun tileData(qsTileDataRequest: QSTileDataRequest): Flow<DATA_TYPE>

    /**
     * Returns tile availability - whether this device currently supports this tile. Make sure to
     * start the flow [Flow.onStart] with the current state to update the tile as soon as possible.
     */
    fun availability(): Flow<Boolean>
}
+6 −0
Original line number Diff line number Diff line
package com.android.systemui.qs.tiles.base.interactor

data class QSTileDataRequest(
    val userId: Int,
    val trigger: StateUpdateTrigger,
)
+13 −0
Original line number Diff line number Diff line
package com.android.systemui.qs.tiles.base.interactor

import android.annotation.WorkerThread
import com.android.systemui.qs.tiles.viewmodel.QSTileUserAction

interface QSTileUserActionInteractor<DATA_TYPE> {

    /**
     * Processes user input based on [userAction] and [currentData]. It's safe to run long running
     * computations inside this function in this.
     */
    @WorkerThread suspend fun handleInput(userAction: QSTileUserAction, currentData: DATA_TYPE)
}
+11 −0
Original line number Diff line number Diff line
package com.android.systemui.qs.tiles.base.interactor

import com.android.systemui.qs.tiles.viewmodel.QSTileState
import com.android.systemui.qs.tiles.viewmodel.QSTileUserAction

sealed interface StateUpdateTrigger {
    class UserAction<T>(val action: QSTileUserAction, val tileState: QSTileState, val tileData: T) :
        StateUpdateTrigger
    data object ForceUpdate : StateUpdateTrigger
    data object InitialRequest : StateUpdateTrigger
}
+14 −0
Original line number Diff line number Diff line
package com.android.systemui.qs.tiles.viewmodel

import android.graphics.drawable.Icon
import com.android.systemui.qs.pipeline.shared.TileSpec

data class QSTileConfig(
    val tileSpec: TileSpec,
    val tileIcon: Icon,
    val tileLabel: CharSequence,
// TODO(b/299908705): Fill necessary params
/*
val instanceId: InstanceId,
 */
)
Loading