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

Commit 4a61571b authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Introduce new QS tiles core interfaces" into main

parents 2ca486fe 8c8a5a22
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