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

Commit b1f38863 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Add data layer for volume dialog ringer

Flag: com.android.systemui.volume_redesign
Bug: 369993851
Test: Build, passes presubmits
Change-Id: I98485dfbc7b809a8883d46de1fff774a1f459314
parent a2174571
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.volume.dialog.ringer.data

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.volume.dialog.ringer.shared.model.VolumeDialogRingerModel
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.update

/** Stores the state of volume dialog ringer model */
@SysUISingleton
class VolumeDialogRingerRepository @Inject constructor() {

    private val mutableRingerModel = MutableStateFlow<VolumeDialogRingerModel?>(null)
    val ringerModel: Flow<VolumeDialogRingerModel> = mutableRingerModel.filterNotNull()

    fun updateRingerModel(update: (current: VolumeDialogRingerModel?) -> VolumeDialogRingerModel) {
        mutableRingerModel.update(update)
    }
}
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.volume.dialog.ringer.shared.model

import com.android.settingslib.volume.shared.model.RingerMode

/** Models the state of the volume dialog ringer. */
data class VolumeDialogRingerModel(
    val availableModes: List<RingerMode>,
    /** Current ringer mode internal */
    val currentRingerMode: RingerMode,
    /** whether the ringer is allowed given the current ZenMode */
    val isEnabled: Boolean,
    /** Whether the current ring stream level is zero or the controller state is muted */
    val isMuted: Boolean,
    /** Ring stream level */
    val level: Int,
    /** Ring stream maximum level */
    val levelMax: Int,
)
+21 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.volume.dialog.ringer.data

import com.android.systemui.kosmos.Kosmos

val Kosmos.volumeDialogRingerRepository by Kosmos.Fixture { VolumeDialogRingerRepository() }