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

Commit 11fc1c0b authored by Prince's avatar Prince Committed by Prince Donkor
Browse files

SystemUI: Remove CommunalTutorialIndicator usage

Remove deprecated CommunalTutorialIndicator files and dependencies
in preparation for cleaning up communal project code. Changes include:

- Remove KeyguardPreviewRenderer dependency
- Clean up blueprint-related usages
- Delete CommunalTutorialIndicator implementation files

Fixes: 383587536
Test: Build Tested
Flag: NONE Removal of files
Change-Id: I9e8b09becea8b40fd37bfc2c7eb8bcae11370d66
parent ab0eb701
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import androidx.constraintlayout.widget.ConstraintSet
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.ui.view.layout.sections.CommunalTutorialIndicatorSection
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.view.KeyguardRootView
@@ -71,7 +70,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() {
    @Mock private lateinit var splitShadeGuidelines: SplitShadeGuidelines
    @Mock private lateinit var aodNotificationIconsSection: AodNotificationIconsSection
    @Mock private lateinit var aodBurnInSection: AodBurnInSection
    @Mock private lateinit var communalTutorialIndicatorSection: CommunalTutorialIndicatorSection
    @Mock private lateinit var clockSection: ClockSection
    @Mock private lateinit var smartspaceSection: SmartspaceSection
    @Mock private lateinit var keyguardSliceViewSection: KeyguardSliceViewSection
@@ -94,7 +92,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() {
                defaultNSSLSection,
                aodNotificationIconsSection,
                aodBurnInSection,
                communalTutorialIndicatorSection,
                clockSection,
                smartspaceSection,
                keyguardSliceViewSection,
+0 −51
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.communal.ui.binder

import android.widget.TextView
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.communal.ui.viewmodel.CommunalTutorialIndicatorViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import kotlinx.coroutines.DisposableHandle
import com.android.app.tracing.coroutines.launchTraced as launch

/** View binder for communal tutorial indicator shown on keyguard. */
object CommunalTutorialIndicatorViewBinder {
    fun bind(
        view: TextView,
        viewModel: CommunalTutorialIndicatorViewModel,
        isPreviewMode: Boolean = false,
    ): DisposableHandle {
        val disposableHandle =
            view.repeatWhenAttached {
                repeatOnLifecycle(Lifecycle.State.STARTED) {
                    launch {
                        viewModel.showIndicator(isPreviewMode).collect { showIndicator ->
                            view.isVisible = showIndicator
                        }
                    }

                    launch { viewModel.alpha.collect { view.alpha = it } }
                }
            }

        return disposableHandle
    }
}
+0 −131
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.communal.ui.view.layout.sections

import android.content.res.Resources
import android.graphics.Typeface
import android.graphics.Typeface.NORMAL
import android.view.Gravity
import android.view.View
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.res.ResourcesCompat
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.ui.binder.CommunalTutorialIndicatorViewBinder
import com.android.systemui.communal.ui.viewmodel.CommunalTutorialIndicatorViewModel
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.view.layout.sections.removeView
import com.android.systemui.res.R
import javax.inject.Inject
import kotlinx.coroutines.DisposableHandle

class CommunalTutorialIndicatorSection
@Inject
constructor(
    @Main private val resources: Resources,
    private val communalTutorialIndicatorViewModel: CommunalTutorialIndicatorViewModel,
    private val communalInteractor: CommunalInteractor,
) : KeyguardSection() {
    private var communalTutorialIndicatorHandle: DisposableHandle? = null

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (!communalInteractor.isCommunalEnabled.value) {
            return
        }
        val padding =
            constraintLayout.resources.getDimensionPixelSize(
                R.dimen.communal_tutorial_indicator_padding
            )
        val view =
            TextView(constraintLayout.context).apply {
                id = R.id.communal_tutorial_indicator
                visibility = View.GONE
                background =
                    ResourcesCompat.getDrawable(
                        context.resources,
                        R.drawable.keyguard_bottom_affordance_bg,
                        context.theme
                    )
                foreground =
                    ResourcesCompat.getDrawable(
                        context.resources,
                        R.drawable.keyguard_bottom_affordance_selected_border,
                        context.theme
                    )
                gravity = Gravity.CENTER_VERTICAL
                typeface = Typeface.create("google-sans", NORMAL)
                text = constraintLayout.context.getString(R.string.communal_tutorial_indicator_text)
                setPadding(padding, padding, padding, padding)
            }
        constraintLayout.addView(view)
    }

    override fun bindData(constraintLayout: ConstraintLayout) {
        if (!communalInteractor.isCommunalEnabled.value) {
            return
        }
        communalTutorialIndicatorHandle =
            CommunalTutorialIndicatorViewBinder.bind(
                constraintLayout.requireViewById(R.id.communal_tutorial_indicator),
                communalTutorialIndicatorViewModel,
            )
    }

    override fun applyConstraints(constraintSet: ConstraintSet) {
        if (!communalInteractor.isCommunalEnabled.value) {
            return
        }
        val tutorialIndicatorId = R.id.communal_tutorial_indicator
        val width = resources.getDimensionPixelSize(R.dimen.communal_tutorial_indicator_fixed_width)
        val horizontalOffsetMargin =
            resources.getDimensionPixelSize(R.dimen.communal_tutorial_indicator_horizontal_offset)

        constraintSet.apply {
            constrainWidth(tutorialIndicatorId, width)
            constrainHeight(tutorialIndicatorId, WRAP_CONTENT)
            connect(
                tutorialIndicatorId,
                ConstraintSet.RIGHT,
                ConstraintSet.PARENT_ID,
                ConstraintSet.RIGHT,
                horizontalOffsetMargin
            )
            connect(
                tutorialIndicatorId,
                ConstraintSet.TOP,
                ConstraintSet.PARENT_ID,
                ConstraintSet.TOP
            )
            connect(
                tutorialIndicatorId,
                ConstraintSet.BOTTOM,
                ConstraintSet.PARENT_ID,
                ConstraintSet.BOTTOM
            )
            setVisibility(tutorialIndicatorId, View.GONE)
        }
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
        communalTutorialIndicatorHandle?.dispose()
        constraintLayout.removeView(R.id.communal_tutorial_indicator)
    }
}
+0 −47
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.communal.ui.viewmodel

import com.android.systemui.communal.domain.interactor.CommunalTutorialInteractor
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.flowOf

/** View model for communal tutorial indicator on keyguard */
class CommunalTutorialIndicatorViewModel
@Inject
constructor(private val communalTutorialInteractor: CommunalTutorialInteractor) {
    /**
     * An observable for whether the tutorial indicator view should be visible.
     *
     * @param isPreviewMode Whether for preview keyguard mode in wallpaper settings.
     */
    fun showIndicator(isPreviewMode: Boolean): StateFlow<Boolean> {
        return if (isPreviewMode) {
            MutableStateFlow(false).asStateFlow()
        } else {
            communalTutorialInteractor.isTutorialAvailable
        }
    }

    /** An observable for the alpha level for the tutorial indicator. */
    // TODO("b/383587536") find replacement for keyguardBottomAreaInteractor alpha
    val alpha: Flow<Float> = flowOf(0f)
}
+0 −16
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.FrameLayout
import android.widget.TextView
import android.window.InputTransferToken
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
@@ -52,8 +51,6 @@ import com.android.keyguard.ClockEventController
import com.android.systemui.animation.view.LaunchableImageView
import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.communal.ui.binder.CommunalTutorialIndicatorViewBinder
import com.android.systemui.communal.ui.viewmodel.CommunalTutorialIndicatorViewModel
import com.android.systemui.customization.R as customR
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
@@ -118,7 +115,6 @@ constructor(
    @Assisted bundle: Bundle,
    private val shadeInteractor: ShadeInteractor,
    private val secureSettings: SecureSettings,
    private val communalTutorialViewModel: CommunalTutorialIndicatorViewModel,
    private val defaultShortcutsSection: DefaultShortcutsSection,
    private val keyguardQuickAffordanceViewBinder: KeyguardQuickAffordanceViewBinder,
) {
@@ -369,7 +365,6 @@ constructor(
                    ),
            )
        }
        setupCommunalTutorialIndicator(keyguardRootView)
    }

    private fun setupShortcuts(keyguardRootView: ConstraintLayout) {
@@ -487,17 +482,6 @@ constructor(
        )
    }

    private fun setupCommunalTutorialIndicator(keyguardRootView: ConstraintLayout) {
        keyguardRootView.findViewById<TextView>(R.id.communal_tutorial_indicator)?.let {
            indicatorView ->
            CommunalTutorialIndicatorViewBinder.bind(
                indicatorView,
                communalTutorialViewModel,
                isPreviewMode = true,
            )
        }
    }

    @Style.Type
    private suspend fun fetchThemeStyleFromSetting(): Int {
        val overlayPackageJson =
Loading