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

Commit 8415180e authored by Becky Siegel's avatar Becky Siegel Committed by Automerger Merge Worker
Browse files

Merge "[conflict] Merge "Merge "Add basic structure for keyboard backlight...

Merge "[conflict] Merge "Merge "Add basic structure for keyboard backlight indicator functionality" into tm-qpr-dev am: 44aa0c7f" into tm-qpr-dev-plus-aosp am: cf78af27" into udc-dev am: f3efc71a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21800699



Change-Id: I07de4863b6c75327c90590dd0d776a060cc83777
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1dfa51bf f3efc71a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyboard.backlight.ui.KeyboardBacklightDialogCoordinator
import javax.inject.Inject

/** A [CoreStartable] that launches components interested in physical keyboard interaction. */
@@ -28,11 +29,12 @@ import javax.inject.Inject
class PhysicalKeyboardCoreStartable
@Inject
constructor(
    private val keyboardBacklightDialogCoordinator: KeyboardBacklightDialogCoordinator,
    private val featureFlags: FeatureFlags,
) : CoreStartable {
    override fun start() {
        if (featureFlags.isEnabled(Flags.KEYBOARD_BACKLIGHT_INDICATOR)) {
            // TODO(b/268645743) start listening for keyboard backlight brightness
            keyboardBacklightDialogCoordinator.startListening()
        }
    }
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.keyboard.backlight.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyboard.data.repository.KeyboardRepository
import com.android.systemui.keyboard.shared.model.BacklightModel
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf

/** Allows listening to changes to keyboard backlight level */
@SysUISingleton
class KeyboardBacklightInteractor
@Inject
constructor(
    private val keyboardRepository: KeyboardRepository,
) {

    /** Emits current backlight level as [BacklightModel] or null if keyboard is not connected */
    val backlight: Flow<BacklightModel?> =
        keyboardRepository.keyboardConnected.flatMapLatest { connected ->
            if (connected) keyboardRepository.backlight else flowOf(null)
        }
}
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.keyboard.backlight.ui

import android.content.Context
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyboard.backlight.ui.view.KeyboardBacklightDialog
import com.android.systemui.keyboard.backlight.ui.viewmodel.BacklightDialogViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/**
 * Based on the state produced from [BacklightDialogViewModel] shows or hides keyboard backlight
 * indicator
 */
@SysUISingleton
class KeyboardBacklightDialogCoordinator
@Inject
constructor(
    @Application private val applicationScope: CoroutineScope,
    private val context: Context,
    private val viewModel: BacklightDialogViewModel,
) {

    var dialog: KeyboardBacklightDialog? = null

    fun startListening() {
        applicationScope.launch {
            viewModel.dialogContent.collect { dialogViewModel ->
                if (dialogViewModel != null) {
                    if (dialog == null) {
                        dialog = KeyboardBacklightDialog(context, dialogViewModel)
                        // pass viewModel and show
                    }
                } else {
                    dialog?.dismiss()
                    dialog = null
                }
            }
        }
    }
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.keyboard.backlight.ui.view

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import com.android.systemui.keyboard.backlight.ui.viewmodel.BacklightDialogContentViewModel

class KeyboardBacklightDialog(context: Context, val viewModel: BacklightDialogContentViewModel) :
    Dialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // TODO(b/268650355) Implement the dialog
    }
}
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.keyboard.backlight.ui.viewmodel

data class BacklightDialogContentViewModel(val currentValue: Int, val maxValue: Int)
Loading