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

Commit 35839833 authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge "Home Controls: Update controls ui for sysui."

parents 9beb7653 85416058
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.controls.controller

interface ControlsTileResourceConfiguration {
    fun getTileTitleId(): Int
    fun getTileImageId(): Int
}
 No newline at end of file
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.controls.controller

import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import javax.inject.Inject

/**
 * Default Instance for ControlsTileResourceConfiguration.
 */
@SysUISingleton
class ControlsTileResourceConfigurationImpl @Inject constructor()
    : ControlsTileResourceConfiguration {
    override fun getTileTitleId(): Int {
        return R.string.quick_controls_title
    }

    override fun getTileImageId(): Int {
        return R.drawable.controls_icon
    }
}
 No newline at end of file
+18 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.settings.SecureSettings
import com.android.internal.widget.LockPatternUtils
import com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT
import com.android.systemui.controls.controller.ControlsTileResourceConfiguration
import com.android.systemui.controls.controller.ControlsTileResourceConfigurationImpl
import dagger.Lazy
import java.util.Optional
import javax.inject.Inject
@@ -49,13 +51,20 @@ class ControlsComponent @Inject constructor(
    private val lockPatternUtils: LockPatternUtils,
    private val keyguardStateController: KeyguardStateController,
    private val userTracker: UserTracker,
    private val secureSettings: SecureSettings
    private val secureSettings: SecureSettings,
    private val optionalControlsTileResourceConfiguration:
        Optional<ControlsTileResourceConfiguration>
) {
    private val contentResolver: ContentResolver
        get() = context.contentResolver

    private var canShowWhileLockedSetting = false

    private val controlsTileResourceConfiguration: ControlsTileResourceConfiguration =
        optionalControlsTileResourceConfiguration.orElse(
            ControlsTileResourceConfigurationImpl()
        )

    val showWhileLockedObserver = object : ContentObserver(null) {
        override fun onChange(selfChange: Boolean) {
            updateShowWhileLocked()
@@ -121,4 +130,12 @@ class ControlsComponent @Inject constructor(
    enum class Visibility {
        AVAILABLE, AVAILABLE_AFTER_UNLOCK, UNAVAILABLE
    }

    fun getTileTitleId(): Int {
        return controlsTileResourceConfiguration.getTileTitleId()
    }

    fun getTileImageId(): Int {
        return controlsTileResourceConfiguration.getTileImageId()
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.controls.controller.ControlsBindingControllerImpl
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.controls.controller.ControlsControllerImpl
import com.android.systemui.controls.controller.ControlsFavoritePersistenceWrapper
import com.android.systemui.controls.controller.ControlsTileResourceConfiguration
import com.android.systemui.controls.management.ControlsEditingActivity
import com.android.systemui.controls.management.ControlsFavoritingActivity
import com.android.systemui.controls.management.ControlsListingController
@@ -92,6 +93,9 @@ abstract class ControlsModule {
    @BindsOptionalOf
    abstract fun optionalPersistenceWrapper(): ControlsFavoritePersistenceWrapper

    @BindsOptionalOf
    abstract fun provideControlsTileResourceConfiguration(): ControlsTileResourceConfiguration

    @Binds
    @IntoMap
    @ClassKey(ControlsProviderSelectorActivity::class)
+8 −5
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.Handler
import android.os.Looper
import android.service.quicksettings.Tile
import android.view.View
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.logging.MetricsLogger
import com.android.systemui.R
@@ -69,7 +70,9 @@ class DeviceControlsTile @Inject constructor(

    private var hasControlsApps = AtomicBoolean(false)

    private val icon = ResourceIcon.get(R.drawable.controls_icon)
    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    val icon: QSTile.Icon
        get() = ResourceIcon.get(controlsComponent.getTileImageId())

    private val listingCallback = object : ControlsListingController.ControlsListingCallback {
        override fun onServicesUpdated(serviceInfos: List<ControlsServiceInfo>) {
@@ -120,14 +123,14 @@ class DeviceControlsTile @Inject constructor(

    override fun handleUpdateState(state: QSTile.State, arg: Any?) {
        state.label = tileLabel

        state.contentDescription = state.label
        state.icon = icon
        if (controlsComponent.isEnabled() && hasControlsApps.get()) {
            if (controlsComponent.getVisibility() == AVAILABLE) {
                state.state = Tile.STATE_ACTIVE
                state.secondaryLabel = controlsComponent
                val structure = controlsComponent
                    .getControlsController().get().getPreferredStructure().structure
                state.state = Tile.STATE_ACTIVE
                state.secondaryLabel = if (structure == tileLabel) null else structure
            } else {
                state.state = Tile.STATE_INACTIVE
                state.secondaryLabel = mContext.getText(R.string.controls_tile_locked)
@@ -149,6 +152,6 @@ class DeviceControlsTile @Inject constructor(
    override fun handleLongClick(view: View?) {}

    override fun getTileLabel(): CharSequence {
        return mContext.getText(R.string.quick_controls_title)
        return mContext.getText(controlsComponent.getTileTitleId())
    }
}
Loading