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

Commit d3e4c280 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I76349d86,I003eaedd,I89961f96,If96a18f5,I32ab6e9f, ... into main

* changes:
  Clean-up QS footer actions initialization
  Delete DensityAwareComposeView
  Delete the COMPOSE_QS_FOOTER_ACTIONS flag
  Delete the old implementation of the QS footer actions
  Delete the COMPOSE_PEOPLE_SPACE flag
  Delete the old implementation of PeopleSpaceActivity
parents ed66de50 6049a0f9
Loading
Loading
Loading
Loading
+0 −96
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.compose.ui.platform

import android.content.Context
import android.content.res.Configuration
import android.util.AttributeSet
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.AbstractComposeView

/**
 * A ComposeView that recreates its composition if the display size or font scale was changed.
 *
 * TODO(b/317317814): Remove this workaround.
 */
class DensityAwareComposeView(context: Context) : OpenComposeView(context) {
    private var lastDensityDpi: Int = -1
    private var lastFontScale: Float = -1f

    override fun onAttachedToWindow() {
        super.onAttachedToWindow()

        val configuration = context.resources.configuration
        lastDensityDpi = configuration.densityDpi
        lastFontScale = configuration.fontScale
    }

    override fun dispatchConfigurationChanged(newConfig: Configuration) {
        super.dispatchConfigurationChanged(newConfig)

        // If the density or font scale changed, we dispose then recreate the composition. Note that
        // we do this here after dispatching the new configuration to children (instead of doing
        // this in onConfigurationChanged()) because the new configuration should first be
        // dispatched to the AndroidComposeView that holds the current density before we recreate
        // the composition.
        val densityDpi = newConfig.densityDpi
        val fontScale = newConfig.fontScale
        if (densityDpi != lastDensityDpi || fontScale != lastFontScale) {
            lastDensityDpi = densityDpi
            lastFontScale = fontScale

            disposeComposition()
            if (isAttachedToWindow) {
                createComposition()
            }
        }
    }
}

/** A fork of [androidx.compose.ui.platform.ComposeView] that is open and can be subclassed. */
open class OpenComposeView
internal constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
    AbstractComposeView(context, attrs, defStyleAttr) {

    private val content = mutableStateOf<(@Composable () -> Unit)?>(null)

    @Suppress("RedundantVisibilityModifier")
    protected override var shouldCreateCompositionOnAttachedToWindow: Boolean = false

    @Composable
    override fun Content() {
        content.value?.invoke()
    }

    override fun getAccessibilityClassName(): CharSequence {
        return javaClass.name
    }

    /**
     * Set the Jetpack Compose UI content for this view. Initial composition will occur when the
     * view becomes attached to a window or when [createComposition] is called, whichever comes
     * first.
     */
    fun setContent(content: @Composable () -> Unit) {
        shouldCreateCompositionOnAttachedToWindow = true
        this.content.value = content
        if (isAttachedToWindow) {
            createComposition()
        }
    }
}
+0 −29
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright 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.
-->

<!-- Action buttons for footer in QS/QQS, containing settings button, power off button etc -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/footer_actions_height"
    android:elevation="@dimen/qs_panel_elevation"
    android:paddingTop="@dimen/qs_footer_actions_top_padding"
    android:paddingBottom="@dimen/qs_footer_actions_bottom_padding"
    android:background="@drawable/qs_footer_actions_background"
    android:gravity="center_vertical|end"
    android:layout_gravity="bottom"
/>
 No newline at end of file
+0 −28
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/qs_footer_action_button_size"
    android:layout_height="@dimen/qs_footer_action_button_size"
    android:visibility="gone">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="@dimen/qs_footer_icon_size"
        android:layout_height="@dimen/qs_footer_icon_size"
        android:layout_gravity="center"
        android:scaleType="centerInside" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
 No newline at end of file
+0 −39
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/qs_footer_action_button_size"
    android:layout_height="@dimen/qs_footer_action_button_size"
    android:background="@drawable/qs_footer_action_circle"
    android:visibility="gone">
    <TextView
        android:id="@+id/number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="@style/TextAppearance.QS.SecurityFooter"
        android:layout_gravity="center"
        android:textColor="?attr/onShadeInactiveVariant"
        android:textSize="18sp"/>
    <ImageView
        android:id="@+id/new_dot"
        android:layout_width="12dp"
        android:layout_height="12dp"
        android:scaleType="fitCenter"
        android:layout_gravity="bottom|end"
        android:src="@drawable/fgs_dot"
        android:contentDescription="@string/fgs_dot_content_description" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
 No newline at end of file
+0 −66
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<com.android.systemui.animation.view.LaunchableLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="@dimen/qs_security_footer_single_line_height"
    android:layout_weight="1"
    android:orientation="horizontal"
    android:paddingHorizontal="@dimen/qs_footer_padding"
    android:gravity="center_vertical"
    android:layout_marginEnd="@dimen/qs_footer_action_inset"
    android:background="@drawable/qs_security_footer_background"
    android:visibility="gone">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="@dimen/qs_footer_icon_size"
        android:layout_height="@dimen/qs_footer_icon_size"
        android:gravity="start"
        android:layout_marginEnd="12dp"
        android:contentDescription="@null"
        android:src="@drawable/ic_info_outline"
        android:tint="?attr/onSurfaceVariant" />

    <TextView
        android:id="@+id/text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:maxLines="1"
        android:ellipsize="end"
        android:textAppearance="@style/TextAppearance.QS.SecurityFooter"
        android:textColor="?attr/onSurfaceVariant"/>

    <ImageView
        android:id="@+id/new_dot"
        android:layout_width="12dp"
        android:layout_height="12dp"
        android:scaleType="fitCenter"
        android:src="@drawable/fgs_dot"
        android:contentDescription="@string/fgs_dot_content_description"
        />

    <ImageView
        android:id="@+id/chevron_icon"
        android:layout_width="@dimen/qs_footer_icon_size"
        android:layout_height="@dimen/qs_footer_icon_size"
        android:layout_marginStart="8dp"
        android:contentDescription="@null"
        android:src="@*android:drawable/ic_chevron_end"
        android:autoMirrored="true"
        android:tint="?attr/onSurfaceVariant" />
</com.android.systemui.animation.view.LaunchableLinearLayout>
 No newline at end of file
Loading