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

Commit 141a1589 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Add actions to the top bar of edit mode

On the DefaultEditTileGrid (used by InfiniteGridLayout and
PaginatedGridLayout) add actions for the TopAppBar.

* If scene_container is enabled, add an action to go to Settings
* If qs_edit_mode_tabs is enabled, add an action to reset the tiles.

If only one action is visible, just the icon will appear, if more than
one action is visible, they will be grouped in a DropdownMenu.

Test: atest InfiniteGridLayoutEditTileGridTest
Test: atest EditTopBarActionsViewModelTest
Flag: com.android.systemui.scene_container
Flag: com.android.systemui.qs_edit_mode_tabs
Fixes: 411410845
Change-Id: I9e7a54a291834eec47202f0b43b967e87c8b5336
parent 00eb52d9
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.qs.panels.ui.viewmodel

import android.content.Intent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.icons.Settings
import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.plugins.activityStarter
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.eq
import org.mockito.kotlin.verify

@SmallTest
@RunWith(AndroidJUnit4::class)
class EditTopBarActionsViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val Kosmos.underTest by Kosmos.Fixture { editTopBarActionsViewModelFactory.create() }

    @Test
    @DisableSceneContainer
    fun sceneContainerDisabled_baseActionsEmpty() =
        kosmos.runTest { assertThat(underTest.actions).isEmpty() }

    @Test
    @EnableSceneContainer
    fun sceneContainerEnabled_baseActionsHasSettings() =
        kosmos.runTest {
            val settingsAction = underTest.actions.single()

            assertThat(settingsAction.icon).isEqualTo(Settings)
            assertThat(settingsAction.labelId).isEqualTo(R.string.qs_edit_settings)

            settingsAction.onClick()
            val intentCaptor = argumentCaptor<Intent>()
            verify(activityStarter).startActivity(intentCaptor.capture(), eq(true))
            assertThat(intentCaptor.lastValue.action)
                .isEqualTo("com.android.settings.SHADE_SETTINGS")
        }
}
+6 −0
Original line number Diff line number Diff line
@@ -2739,6 +2739,12 @@
    <!-- Tooltip for the edit mode button indicating that tiles can be resized [CHAR LIMIT=60] -->
    <string name="qs_edit_mode_tooltip">Resize Quick Settings tiles</string>

    <!-- Edit mode menu entry for Settings [CHAR LIMIT=20] -->
    <string name="qs_edit_settings">Settings</string>

    <!-- Edit mode menu for extra options -->
    <string name="qs_edit_menu_content_description">Options</string>

    <!-- SysUI Tuner: Options for how clock is displayed [CHAR LIMIT=NONE] -->
    <string name="tuner_time">Time</string>

+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.common.ui.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val MoreVert: ImageVector
    get() {
        if (_MoreVert != null) {
            return _MoreVert!!
        }
        _MoreVert =
            ImageVector.Builder(
                    name = "MoreVert",
                    defaultWidth = 24.dp,
                    defaultHeight = 24.dp,
                    viewportWidth = 960f,
                    viewportHeight = 960f,
                    autoMirror = true,
                )
                .apply {
                    path(fill = SolidColor(Color(0xFFE8EAED))) {
                        moveTo(480f, 800f)
                        quadToRelative(-33f, 0f, -56.5f, -23.5f)
                        reflectiveQuadTo(400f, 720f)
                        quadToRelative(0f, -33f, 23.5f, -56.5f)
                        reflectiveQuadTo(480f, 640f)
                        quadToRelative(33f, 0f, 56.5f, 23.5f)
                        reflectiveQuadTo(560f, 720f)
                        quadToRelative(0f, 33f, -23.5f, 56.5f)
                        reflectiveQuadTo(480f, 800f)
                        close()
                        moveTo(480f, 560f)
                        quadToRelative(-33f, 0f, -56.5f, -23.5f)
                        reflectiveQuadTo(400f, 480f)
                        quadToRelative(0f, -33f, 23.5f, -56.5f)
                        reflectiveQuadTo(480f, 400f)
                        quadToRelative(33f, 0f, 56.5f, 23.5f)
                        reflectiveQuadTo(560f, 480f)
                        quadToRelative(0f, 33f, -23.5f, 56.5f)
                        reflectiveQuadTo(480f, 560f)
                        close()
                        moveTo(480f, 320f)
                        quadToRelative(-33f, 0f, -56.5f, -23.5f)
                        reflectiveQuadTo(400f, 240f)
                        quadToRelative(0f, -33f, 23.5f, -56.5f)
                        reflectiveQuadTo(480f, 160f)
                        quadToRelative(33f, 0f, 56.5f, 23.5f)
                        reflectiveQuadTo(560f, 240f)
                        quadToRelative(0f, 33f, -23.5f, 56.5f)
                        reflectiveQuadTo(480f, 320f)
                        close()
                    }
                }
                .build()

        return _MoreVert!!
    }

@Suppress("ObjectPropertyName") private var _MoreVert: ImageVector? = null
+84 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.common.ui.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val Reset: ImageVector
    get() {
        if (_Reset != null) {
            return _Reset!!
        }
        _Reset =
            ImageVector.Builder(
                    name = "Reset",
                    defaultWidth = 24.dp,
                    defaultHeight = 24.dp,
                    viewportWidth = 960f,
                    viewportHeight = 960f,
                    autoMirror = true,
                )
                .apply {
                    path(fill = SolidColor(Color.Black)) {
                        moveTo(480f, 800f)
                        quadToRelative(-134f, 0f, -227f, -93f)
                        reflectiveQuadToRelative(-93f, -227f)
                        quadToRelative(0f, -134f, 93f, -227f)
                        reflectiveQuadToRelative(227f, -93f)
                        quadToRelative(69f, 0f, 132f, 28.5f)
                        reflectiveQuadTo(720f, 270f)
                        verticalLineToRelative(-70f)
                        quadToRelative(0f, -17f, 11.5f, -28.5f)
                        reflectiveQuadTo(760f, 160f)
                        quadToRelative(17f, 0f, 28.5f, 11.5f)
                        reflectiveQuadTo(800f, 200f)
                        verticalLineToRelative(200f)
                        quadToRelative(0f, 17f, -11.5f, 28.5f)
                        reflectiveQuadTo(760f, 440f)
                        lineTo(560f, 440f)
                        quadToRelative(-17f, 0f, -28.5f, -11.5f)
                        reflectiveQuadTo(520f, 400f)
                        quadToRelative(0f, -17f, 11.5f, -28.5f)
                        reflectiveQuadTo(560f, 360f)
                        horizontalLineToRelative(128f)
                        quadToRelative(-32f, -56f, -87.5f, -88f)
                        reflectiveQuadTo(480f, 240f)
                        quadToRelative(-100f, 0f, -170f, 70f)
                        reflectiveQuadToRelative(-70f, 170f)
                        quadToRelative(0f, 100f, 70f, 170f)
                        reflectiveQuadToRelative(170f, 70f)
                        quadToRelative(68f, 0f, 124.5f, -34.5f)
                        reflectiveQuadTo(692f, 593f)
                        quadToRelative(8f, -14f, 22.5f, -19.5f)
                        reflectiveQuadToRelative(29.5f, -0.5f)
                        quadToRelative(16f, 5f, 23f, 21f)
                        reflectiveQuadToRelative(-1f, 30f)
                        quadToRelative(-41f, 80f, -117f, 128f)
                        reflectiveQuadToRelative(-169f, 48f)
                        close()
                    }
                }
                .build()

        return _Reset!!
    }

@Suppress("ObjectPropertyName") private var _Reset: ImageVector? = null
+116 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.common.ui.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val Settings: ImageVector
    get() {
        if (_Settings != null) {
            return _Settings!!
        }
        _Settings =
            ImageVector.Builder(
                    name = "Settings",
                    defaultWidth = 24.dp,
                    defaultHeight = 24.dp,
                    viewportWidth = 960f,
                    viewportHeight = 960f,
                    autoMirror = true,
                )
                .apply {
                    path(fill = SolidColor(Color.Black)) {
                        moveTo(433f, 880f)
                        quadToRelative(-27f, 0f, -46.5f, -18f)
                        reflectiveQuadTo(363f, 818f)
                        lineToRelative(-9f, -66f)
                        quadToRelative(-13f, -5f, -24.5f, -12f)
                        reflectiveQuadTo(307f, 725f)
                        lineToRelative(-62f, 26f)
                        quadToRelative(-25f, 11f, -50f, 2f)
                        reflectiveQuadToRelative(-39f, -32f)
                        lineToRelative(-47f, -82f)
                        quadToRelative(-14f, -23f, -8f, -49f)
                        reflectiveQuadToRelative(27f, -43f)
                        lineToRelative(53f, -40f)
                        quadToRelative(-1f, -7f, -1f, -13.5f)
                        verticalLineToRelative(-27f)
                        quadToRelative(0f, -6.5f, 1f, -13.5f)
                        lineToRelative(-53f, -40f)
                        quadToRelative(-21f, -17f, -27f, -43f)
                        reflectiveQuadToRelative(8f, -49f)
                        lineToRelative(47f, -82f)
                        quadToRelative(14f, -23f, 39f, -32f)
                        reflectiveQuadToRelative(50f, 2f)
                        lineToRelative(62f, 26f)
                        quadToRelative(11f, -8f, 23f, -15f)
                        reflectiveQuadToRelative(24f, -12f)
                        lineToRelative(9f, -66f)
                        quadToRelative(4f, -26f, 23.5f, -44f)
                        reflectiveQuadToRelative(46.5f, -18f)
                        horizontalLineToRelative(94f)
                        quadToRelative(27f, 0f, 46.5f, 18f)
                        reflectiveQuadToRelative(23.5f, 44f)
                        lineToRelative(9f, 66f)
                        quadToRelative(13f, 5f, 24.5f, 12f)
                        reflectiveQuadToRelative(22.5f, 15f)
                        lineToRelative(62f, -26f)
                        quadToRelative(25f, -11f, 50f, -2f)
                        reflectiveQuadToRelative(39f, 32f)
                        lineToRelative(47f, 82f)
                        quadToRelative(14f, 23f, 8f, 49f)
                        reflectiveQuadToRelative(-27f, 43f)
                        lineToRelative(-53f, 40f)
                        quadToRelative(1f, 7f, 1f, 13.5f)
                        verticalLineToRelative(27f)
                        quadToRelative(0f, 6.5f, -2f, 13.5f)
                        lineToRelative(53f, 40f)
                        quadToRelative(21f, 17f, 27f, 43f)
                        reflectiveQuadToRelative(-8f, 49f)
                        lineToRelative(-48f, 82f)
                        quadToRelative(-14f, 23f, -39f, 32f)
                        reflectiveQuadToRelative(-50f, -2f)
                        lineToRelative(-60f, -26f)
                        quadToRelative(-11f, 8f, -23f, 15f)
                        reflectiveQuadToRelative(-24f, 12f)
                        lineToRelative(-9f, 66f)
                        quadToRelative(-4f, 26f, -23.5f, 44f)
                        reflectiveQuadTo(527f, 880f)
                        horizontalLineToRelative(-94f)
                        close()
                        moveTo(482f, 620f)
                        quadToRelative(58f, 0f, 99f, -41f)
                        reflectiveQuadToRelative(41f, -99f)
                        quadToRelative(0f, -58f, -41f, -99f)
                        reflectiveQuadToRelative(-99f, -41f)
                        quadToRelative(-59f, 0f, -99.5f, 41f)
                        reflectiveQuadTo(342f, 480f)
                        quadToRelative(0f, 58f, 40.5f, 99f)
                        reflectiveQuadToRelative(99.5f, 41f)
                        close()
                    }
                }
                .build()

        return _Settings!!
    }

private var _Settings: ImageVector? = null
Loading