diff --git a/packages/SystemUI/compose/gallery/Android.bp b/packages/SystemUI/compose/gallery/Android.bp deleted file mode 100644 index 5a7a1e1807a33..0000000000000 --- a/packages/SystemUI/compose/gallery/Android.bp +++ /dev/null @@ -1,86 +0,0 @@ -// 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 { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"], -} - -android_library { - name: "SystemUIComposeGalleryLib", - manifest: "AndroidManifest.xml", - - srcs: [ - "src/**/*.kt", - ":SystemUI-tests-utils", - ], - - resource_dirs: [ - "res", - ], - - static_libs: [ - "SystemUI-core", - "SystemUIComposeCore", - "SystemUIComposeFeatures", - - "androidx.compose.runtime_runtime", - "androidx.compose.material3_material3", - "androidx.compose.material_material-icons-extended", - "androidx.activity_activity-compose", - "androidx.navigation_navigation-compose", - - "androidx.appcompat_appcompat", - - // TODO(b/240431193): Remove the dependencies and depend on - // SystemUI-test-utils directly. - "androidx.test.runner", - "mockito-target-extended-minus-junit4", - "testables", - "truth-prebuilt", - "androidx.test.uiautomator", - "kotlinx_coroutines_test", - ], - - libs: [ - "android.test.mock", - ], - - kotlincflags: ["-Xjvm-default=all"], -} - -android_app { - name: "SystemUIComposeGallery", - defaults: ["platform_app_defaults"], - manifest: "app/AndroidManifest.xml", - - static_libs: [ - "SystemUIComposeGalleryLib", - ], - - platform_apis: true, - system_ext_specific: true, - certificate: "platform", - privileged: true, - - optimize: { - proguard_flags_files: ["proguard-rules.pro"], - }, - - dxflags: ["--multi-dex"], -} diff --git a/packages/SystemUI/compose/gallery/AndroidManifest.xml b/packages/SystemUI/compose/gallery/AndroidManifest.xml deleted file mode 100644 index 2f30651a6acf9..0000000000000 --- a/packages/SystemUI/compose/gallery/AndroidManifest.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/packages/SystemUI/compose/gallery/TEST_MAPPING b/packages/SystemUI/compose/gallery/TEST_MAPPING deleted file mode 100644 index c7f8a92164188..0000000000000 --- a/packages/SystemUI/compose/gallery/TEST_MAPPING +++ /dev/null @@ -1,15 +0,0 @@ -{ - "presubmit": [ - { - "name": "SystemUIComposeGalleryTests", - "options": [ - { - "exclude-annotation": "org.junit.Ignore" - }, - { - "exclude-annotation": "androidx.test.filters.FlakyTest" - } - ] - } - ] -} \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/app/AndroidManifest.xml b/packages/SystemUI/compose/gallery/app/AndroidManifest.xml deleted file mode 100644 index 1f3fd8c312d9e..0000000000000 --- a/packages/SystemUI/compose/gallery/app/AndroidManifest.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - diff --git a/packages/SystemUI/compose/gallery/proguard-rules.pro b/packages/SystemUI/compose/gallery/proguard-rules.pro deleted file mode 100644 index 481bb43481410..0000000000000 --- a/packages/SystemUI/compose/gallery/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/drawable-v24/ic_launcher_foreground.xml b/packages/SystemUI/compose/gallery/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 966abaff20743..0000000000000 --- a/packages/SystemUI/compose/gallery/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/drawable/ic_launcher_background.xml b/packages/SystemUI/compose/gallery/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 61bb79edb7090..0000000000000 --- a/packages/SystemUI/compose/gallery/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten1.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten1.jpeg deleted file mode 100644 index 6241b0b44bb60..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten1.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten2.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten2.jpeg deleted file mode 100644 index 870ef13ee2d9e..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten2.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten3.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten3.jpeg deleted file mode 100644 index bb7261c100334..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten3.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten4.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten4.jpeg deleted file mode 100644 index e34b7ddf58cef..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten4.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten5.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten5.jpeg deleted file mode 100644 index 9cde24be59efb..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten5.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/drawable/kitten6.jpeg b/packages/SystemUI/compose/gallery/res/drawable/kitten6.jpeg deleted file mode 100644 index 17825b639a268..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/drawable/kitten6.jpeg and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher.xml b/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 03eed2533da28..0000000000000 --- a/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher_round.xml b/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 03eed2533da28..0000000000000 --- a/packages/SystemUI/compose/gallery/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher.webp b/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index c209e78ecd372..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher_round.webp b/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher_round.webp deleted file mode 100644 index b2dfe3d1ba5cf..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher.webp b/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 4f0f1d64e58ba..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher_round.webp b/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher_round.webp deleted file mode 100644 index 62b611da08167..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher.webp b/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher.webp deleted file mode 100644 index 948a3070fe34c..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher_round.webp b/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher_round.webp deleted file mode 100644 index 1b9a6956b3acd..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher.webp b/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher.webp deleted file mode 100644 index 28d4b77f9f036..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher_round.webp b/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9287f5083623b..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher.webp b/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher.webp deleted file mode 100644 index aa7d6427e6fa1..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher_round.webp b/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9126ae37cbc35..0000000000000 Binary files a/packages/SystemUI/compose/gallery/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/packages/SystemUI/compose/gallery/res/values/colors.xml b/packages/SystemUI/compose/gallery/res/values/colors.xml deleted file mode 100644 index a2fcbffc26c07..0000000000000 --- a/packages/SystemUI/compose/gallery/res/values/colors.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - #FFFFFF - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/values/strings.xml b/packages/SystemUI/compose/gallery/res/values/strings.xml deleted file mode 100644 index 86bdb05688371..0000000000000 --- a/packages/SystemUI/compose/gallery/res/values/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - SystemUI Gallery - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/res/values/themes.xml b/packages/SystemUI/compose/gallery/res/values/themes.xml deleted file mode 100644 index 45fa1f5dfb5ca..0000000000000 --- a/packages/SystemUI/compose/gallery/res/values/themes.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ButtonsScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ButtonsScreen.kt deleted file mode 100644 index 881a1def113a0..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ButtonsScreen.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - * - */ - -@file:OptIn(ExperimentalMaterial3Api::class) - -package com.android.systemui.compose.gallery - -import androidx.compose.foundation.layout.Column -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import com.android.systemui.compose.SysUiButton -import com.android.systemui.compose.SysUiOutlinedButton -import com.android.systemui.compose.SysUiTextButton - -@Composable -fun ButtonsScreen( - modifier: Modifier = Modifier, -) { - Column( - modifier = modifier, - ) { - SysUiButton( - onClick = {}, - ) { - Text("SysUiButton") - } - - SysUiButton( - onClick = {}, - enabled = false, - ) { - Text("SysUiButton - disabled") - } - - SysUiOutlinedButton( - onClick = {}, - ) { - Text("SysUiOutlinedButton") - } - - SysUiOutlinedButton( - onClick = {}, - enabled = false, - ) { - Text("SysUiOutlinedButton - disabled") - } - - SysUiTextButton( - onClick = {}, - ) { - Text("SysUiTextButton") - } - - SysUiTextButton( - onClick = {}, - enabled = false, - ) { - Text("SysUiTextButton - disabled") - } - } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ColorsScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ColorsScreen.kt deleted file mode 100644 index dfa1b26f464ef..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ColorsScreen.kt +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import com.android.systemui.compose.theme.LocalAndroidColorScheme - -/** The screen that shows all the Material 3 colors. */ -@Composable -fun MaterialColorsScreen() { - val colors = MaterialTheme.colorScheme - ColorsScreen( - listOf( - "primary" to colors.primary, - "onPrimary" to colors.onPrimary, - "primaryContainer" to colors.primaryContainer, - "onPrimaryContainer" to colors.onPrimaryContainer, - "inversePrimary" to colors.inversePrimary, - "secondary" to colors.secondary, - "onSecondary" to colors.onSecondary, - "secondaryContainer" to colors.secondaryContainer, - "onSecondaryContainer" to colors.onSecondaryContainer, - "tertiary" to colors.tertiary, - "onTertiary" to colors.onTertiary, - "tertiaryContainer" to colors.tertiaryContainer, - "onTertiaryContainer" to colors.onTertiaryContainer, - "background" to colors.background, - "onBackground" to colors.onBackground, - "surface" to colors.surface, - "onSurface" to colors.onSurface, - "surfaceVariant" to colors.surfaceVariant, - "onSurfaceVariant" to colors.onSurfaceVariant, - "inverseSurface" to colors.inverseSurface, - "inverseOnSurface" to colors.inverseOnSurface, - "error" to colors.error, - "onError" to colors.onError, - "errorContainer" to colors.errorContainer, - "onErrorContainer" to colors.onErrorContainer, - "outline" to colors.outline, - ) - ) -} - -/** The screen that shows all the Android colors. */ -@Composable -fun AndroidColorsScreen() { - val colors = LocalAndroidColorScheme.current - ColorsScreen( - listOf( - "colorPrimary" to colors.colorPrimary, - "colorPrimaryDark" to colors.colorPrimaryDark, - "colorAccent" to colors.colorAccent, - "colorAccentPrimary" to colors.colorAccentPrimary, - "colorAccentSecondary" to colors.colorAccentSecondary, - "colorAccentTertiary" to colors.colorAccentTertiary, - "colorAccentPrimaryVariant" to colors.colorAccentPrimaryVariant, - "colorAccentSecondaryVariant" to colors.colorAccentSecondaryVariant, - "colorAccentTertiaryVariant" to colors.colorAccentTertiaryVariant, - "colorSurface" to colors.colorSurface, - "colorSurfaceHighlight" to colors.colorSurfaceHighlight, - "colorSurfaceVariant" to colors.colorSurfaceVariant, - "colorSurfaceHeader" to colors.colorSurfaceHeader, - "colorError" to colors.colorError, - "colorBackground" to colors.colorBackground, - "colorBackgroundFloating" to colors.colorBackgroundFloating, - "panelColorBackground" to colors.panelColorBackground, - "textColorPrimary" to colors.textColorPrimary, - "textColorSecondary" to colors.textColorSecondary, - "textColorTertiary" to colors.textColorTertiary, - "textColorPrimaryInverse" to colors.textColorPrimaryInverse, - "textColorSecondaryInverse" to colors.textColorSecondaryInverse, - "textColorTertiaryInverse" to colors.textColorTertiaryInverse, - "textColorOnAccent" to colors.textColorOnAccent, - "colorForeground" to colors.colorForeground, - "colorForegroundInverse" to colors.colorForegroundInverse, - ) - ) -} - -@Composable -private fun ColorsScreen( - colors: List>, -) { - LazyColumn( - Modifier.fillMaxWidth(), - ) { - colors.forEach { (name, color) -> item { ColorTile(color, name) } } - } -} - -@Composable -private fun ColorTile( - color: Color, - name: String, -) { - Row( - Modifier.padding(16.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - val shape = RoundedCornerShape(16.dp) - Spacer( - Modifier.border(1.dp, MaterialTheme.colorScheme.onBackground, shape) - .background(color, shape) - .size(64.dp) - ) - Spacer(Modifier.width(16.dp)) - Text(name) - } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ConfigurationControls.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ConfigurationControls.kt deleted file mode 100644 index 990d060207df1..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ConfigurationControls.kt +++ /dev/null @@ -1,210 +0,0 @@ -package com.android.systemui.compose.gallery - -import android.graphics.Point -import android.os.UserHandle -import android.view.Display -import android.view.WindowManagerGlobal -import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.DarkMode -import androidx.compose.material.icons.filled.FormatSize -import androidx.compose.material.icons.filled.FormatTextdirectionLToR -import androidx.compose.material.icons.filled.FormatTextdirectionRToL -import androidx.compose.material.icons.filled.InvertColors -import androidx.compose.material.icons.filled.LightMode -import androidx.compose.material.icons.filled.Smartphone -import androidx.compose.material.icons.filled.Tablet -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.Icon -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.unit.LayoutDirection -import androidx.compose.ui.unit.dp -import kotlin.math.max -import kotlin.math.min - -enum class FontScale(val scale: Float) { - Small(0.85f), - Normal(1f), - Big(1.15f), - Bigger(1.30f), -} - -/** A configuration panel that allows to toggle the theme, font scale and layout direction. */ -@Composable -fun ConfigurationControls( - theme: Theme, - fontScale: FontScale, - layoutDirection: LayoutDirection, - onChangeTheme: () -> Unit, - onChangeLayoutDirection: () -> Unit, - onChangeFontScale: () -> Unit, - modifier: Modifier = Modifier, -) { - // The display we are emulating, if any. - var emulatedDisplayName by rememberSaveable { mutableStateOf(null) } - val emulatedDisplay = - emulatedDisplayName?.let { name -> EmulatedDisplays.firstOrNull { it.name == name } } - - LaunchedEffect(emulatedDisplay) { - val wm = WindowManagerGlobal.getWindowManagerService() - - val defaultDisplayId = Display.DEFAULT_DISPLAY - if (emulatedDisplay == null) { - wm.clearForcedDisplayDensityForUser(defaultDisplayId, UserHandle.myUserId()) - wm.clearForcedDisplaySize(defaultDisplayId) - } else { - val density = emulatedDisplay.densityDpi - - // Emulate the display and make sure that we use the maximum available space possible. - val initialSize = Point() - wm.getInitialDisplaySize(defaultDisplayId, initialSize) - val width = emulatedDisplay.width - val height = emulatedDisplay.height - val minOfSize = min(width, height) - val maxOfSize = max(width, height) - if (initialSize.x < initialSize.y) { - wm.setForcedDisplaySize(defaultDisplayId, minOfSize, maxOfSize) - } else { - wm.setForcedDisplaySize(defaultDisplayId, maxOfSize, minOfSize) - } - wm.setForcedDisplayDensityForUser(defaultDisplayId, density, UserHandle.myUserId()) - } - } - - // TODO(b/231131244): Fork FlowRow from Accompanist and use that instead to make sure that users - // don't miss any available configuration. - LazyRow(modifier) { - // Dark/light theme. - item { - TextButton(onChangeTheme) { - val text: String - val icon: ImageVector - - when (theme) { - Theme.System -> { - icon = Icons.Default.InvertColors - text = "System" - } - Theme.Dark -> { - icon = Icons.Default.DarkMode - text = "Dark" - } - Theme.Light -> { - icon = Icons.Default.LightMode - text = "Light" - } - } - - Icon(icon, null) - Spacer(Modifier.width(8.dp)) - Text(text) - } - } - - // Font scale. - item { - TextButton(onChangeFontScale) { - Icon(Icons.Default.FormatSize, null) - Spacer(Modifier.width(8.dp)) - - Text(fontScale.name) - } - } - - // Layout direction. - item { - TextButton(onChangeLayoutDirection) { - when (layoutDirection) { - LayoutDirection.Ltr -> { - Icon(Icons.Default.FormatTextdirectionLToR, null) - Spacer(Modifier.width(8.dp)) - Text("LTR") - } - LayoutDirection.Rtl -> { - Icon(Icons.Default.FormatTextdirectionRToL, null) - Spacer(Modifier.width(8.dp)) - Text("RTL") - } - } - } - } - - // Display emulation. - EmulatedDisplays.forEach { display -> - item { - DisplayButton( - display, - emulatedDisplay == display, - { emulatedDisplayName = it?.name }, - ) - } - } - } -} - -@Composable -private fun DisplayButton( - display: EmulatedDisplay, - selected: Boolean, - onChangeEmulatedDisplay: (EmulatedDisplay?) -> Unit, -) { - val onClick = { - if (selected) { - onChangeEmulatedDisplay(null) - } else { - onChangeEmulatedDisplay(display) - } - } - - val content: @Composable RowScope.() -> Unit = { - Icon(display.icon, null) - Spacer(Modifier.width(8.dp)) - Text(display.name) - } - - if (selected) { - Button(onClick, contentPadding = ButtonDefaults.TextButtonContentPadding, content = content) - } else { - TextButton(onClick, content = content) - } -} - -/** The displays that can be emulated from this Gallery app. */ -private val EmulatedDisplays = - listOf( - EmulatedDisplay( - "Phone", - Icons.Default.Smartphone, - width = 1440, - height = 3120, - densityDpi = 560, - ), - EmulatedDisplay( - "Tablet", - Icons.Default.Tablet, - width = 2560, - height = 1600, - densityDpi = 320, - ), - ) - -private data class EmulatedDisplay( - val name: String, - val icon: ImageVector, - val width: Int, - val height: Int, - val densityDpi: Int, -) diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ExampleFeatureScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ExampleFeatureScreen.kt deleted file mode 100644 index 6e1721490f983..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/ExampleFeatureScreen.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.foundation.layout.Column -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import com.android.systemui.ExampleFeature - -/** The screen that shows ExampleFeature. */ -@Composable -fun ExampleFeatureScreen(modifier: Modifier = Modifier) { - Column(modifier) { ExampleFeature("This is an example feature!") } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryActivity.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryActivity.kt deleted file mode 100644 index bb2d2feba39fa..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryActivity.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.compose.gallery - -import android.app.UiModeManager -import android.content.Context -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.runtime.SideEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.runtime.setValue -import androidx.compose.ui.graphics.Color -import androidx.core.view.WindowCompat -import com.android.systemui.compose.rememberSystemUiController - -class GalleryActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - WindowCompat.setDecorFitsSystemWindows(window, false) - val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager - - setContent { - var theme by rememberSaveable { mutableStateOf(Theme.System) } - val onChangeTheme = { - // Change to the next theme for a toggle behavior. - theme = - when (theme) { - Theme.System -> Theme.Dark - Theme.Dark -> Theme.Light - Theme.Light -> Theme.System - } - } - - val isSystemInDarkTheme = isSystemInDarkTheme() - val isDark = theme == Theme.Dark || (theme == Theme.System && isSystemInDarkTheme) - val useDarkIcons = !isDark - val systemUiController = rememberSystemUiController() - SideEffect { - systemUiController.setSystemBarsColor( - color = Color.Transparent, - darkIcons = useDarkIcons, - ) - - uiModeManager.setApplicationNightMode( - when (theme) { - Theme.System -> UiModeManager.MODE_NIGHT_AUTO - Theme.Dark -> UiModeManager.MODE_NIGHT_YES - Theme.Light -> UiModeManager.MODE_NIGHT_NO - } - ) - } - - GalleryApp(theme, onChangeTheme) - } - } -} - -enum class Theme { - System, - Dark, - Light, -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryApp.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryApp.kt deleted file mode 100644 index 6805bf83dff44..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/GalleryApp.kt +++ /dev/null @@ -1,202 +0,0 @@ -package com.android.systemui.compose.gallery - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.systemBarsPadding -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.ui.unit.Density -import androidx.compose.ui.unit.LayoutDirection -import androidx.compose.ui.unit.dp -import androidx.navigation.compose.NavHost -import androidx.navigation.compose.rememberNavController -import com.android.systemui.compose.theme.SystemUITheme - -/** The gallery app screens. */ -object GalleryAppScreens { - private val Typography = ChildScreen("typography") { TypographyScreen() } - private val MaterialColors = ChildScreen("material_colors") { MaterialColorsScreen() } - private val AndroidColors = ChildScreen("android_colors") { AndroidColorsScreen() } - private val Buttons = ChildScreen("buttons") { ButtonsScreen() } - private val ExampleFeature = ChildScreen("example_feature") { ExampleFeatureScreen() } - - private val PeopleEmpty = - ChildScreen("people_empty") { navController -> - EmptyPeopleScreen(onResult = { navController.popBackStack() }) - } - private val PeopleFew = - ChildScreen("people_few") { navController -> - FewPeopleScreen(onResult = { navController.popBackStack() }) - } - private val PeopleFull = - ChildScreen("people_full") { navController -> - FullPeopleScreen(onResult = { navController.popBackStack() }) - } - private val People = - ParentScreen( - "people", - mapOf( - "Empty" to PeopleEmpty, - "Few" to PeopleFew, - "Full" to PeopleFull, - ) - ) - private val UserSwitcherSingleUser = - ChildScreen("user_switcher_single") { navController -> - UserSwitcherScreen( - userCount = 1, - onFinished = navController::popBackStack, - ) - } - private val UserSwitcherThreeUsers = - ChildScreen("user_switcher_three") { navController -> - UserSwitcherScreen( - userCount = 3, - onFinished = navController::popBackStack, - ) - } - private val UserSwitcherFourUsers = - ChildScreen("user_switcher_four") { navController -> - UserSwitcherScreen( - userCount = 4, - onFinished = navController::popBackStack, - ) - } - private val UserSwitcherFiveUsers = - ChildScreen("user_switcher_five") { navController -> - UserSwitcherScreen( - userCount = 5, - onFinished = navController::popBackStack, - ) - } - private val UserSwitcherSixUsers = - ChildScreen("user_switcher_six") { navController -> - UserSwitcherScreen( - userCount = 6, - onFinished = navController::popBackStack, - ) - } - private val UserSwitcher = - ParentScreen( - "user_switcher", - mapOf( - "Single" to UserSwitcherSingleUser, - "Three" to UserSwitcherThreeUsers, - "Four" to UserSwitcherFourUsers, - "Five" to UserSwitcherFiveUsers, - "Six" to UserSwitcherSixUsers, - ) - ) - - val Home = - ParentScreen( - "home", - mapOf( - "Typography" to Typography, - "Material colors" to MaterialColors, - "Android colors" to AndroidColors, - "Example feature" to ExampleFeature, - "Buttons" to Buttons, - "People" to People, - "User Switcher" to UserSwitcher, - ) - ) -} - -/** The main content of the app, that shows [GalleryAppScreens.Home] by default. */ -@Composable -private fun MainContent(onControlToggleRequested: () -> Unit) { - Box(Modifier.fillMaxSize()) { - val navController = rememberNavController() - NavHost( - navController = navController, - startDestination = GalleryAppScreens.Home.identifier, - ) { - screen(GalleryAppScreens.Home, navController, onControlToggleRequested) - } - } -} - -/** - * The top-level composable shown when starting the app. This composable always shows a - * [ConfigurationControls] at the top of the screen, above the [MainContent]. - */ -@Composable -fun GalleryApp( - theme: Theme, - onChangeTheme: () -> Unit, -) { - val systemFontScale = LocalDensity.current.fontScale - var fontScale: FontScale by rememberSaveable { - mutableStateOf( - FontScale.values().firstOrNull { it.scale == systemFontScale } ?: FontScale.Normal - ) - } - val context = LocalContext.current - val density = Density(context.resources.displayMetrics.density, fontScale.scale) - val onChangeFontScale = { - fontScale = - when (fontScale) { - FontScale.Small -> FontScale.Normal - FontScale.Normal -> FontScale.Big - FontScale.Big -> FontScale.Bigger - FontScale.Bigger -> FontScale.Small - } - } - - val systemLayoutDirection = LocalLayoutDirection.current - var layoutDirection by rememberSaveable { mutableStateOf(systemLayoutDirection) } - val onChangeLayoutDirection = { - layoutDirection = - when (layoutDirection) { - LayoutDirection.Ltr -> LayoutDirection.Rtl - LayoutDirection.Rtl -> LayoutDirection.Ltr - } - } - - CompositionLocalProvider( - LocalDensity provides density, - LocalLayoutDirection provides layoutDirection, - ) { - SystemUITheme { - Surface( - Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background, - ) { - Column(Modifier.fillMaxSize().systemBarsPadding()) { - var showControls by rememberSaveable { mutableStateOf(true) } - - if (showControls) { - ConfigurationControls( - theme, - fontScale, - layoutDirection, - onChangeTheme, - onChangeLayoutDirection, - onChangeFontScale, - Modifier.padding(horizontal = 16.dp), - ) - - Spacer(Modifier.height(4.dp)) - } - - MainContent(onControlToggleRequested = { showControls = !showControls }) - } - } - } - } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/PeopleScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/PeopleScreen.kt deleted file mode 100644 index 2f0df7790ffd9..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/PeopleScreen.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext -import com.android.systemui.people.emptyPeopleSpaceViewModel -import com.android.systemui.people.fewPeopleSpaceViewModel -import com.android.systemui.people.fullPeopleSpaceViewModel -import com.android.systemui.people.ui.compose.PeopleScreen -import com.android.systemui.people.ui.viewmodel.PeopleViewModel - -@Composable -fun EmptyPeopleScreen(onResult: (PeopleViewModel.Result) -> Unit) { - val context = LocalContext.current.applicationContext - val viewModel = emptyPeopleSpaceViewModel(context) - PeopleScreen(viewModel, onResult) -} - -@Composable -fun FewPeopleScreen(onResult: (PeopleViewModel.Result) -> Unit) { - val context = LocalContext.current.applicationContext - val viewModel = fewPeopleSpaceViewModel(context) - PeopleScreen(viewModel, onResult) -} - -@Composable -fun FullPeopleScreen(onResult: (PeopleViewModel.Result) -> Unit) { - val context = LocalContext.current.applicationContext - val viewModel = fullPeopleSpaceViewModel(context) - PeopleScreen(viewModel, onResult) -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/Screen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/Screen.kt deleted file mode 100644 index d7d0d721b01c2..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/Screen.kt +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.compose.composable -import androidx.navigation.compose.navigation - -/** - * A screen in an app. It is either an [ParentScreen] which lists its child screens to navigate to - * them or a [ChildScreen] which shows some content. - */ -sealed class Screen(val identifier: String) - -class ParentScreen( - identifier: String, - val children: Map, -) : Screen(identifier) - -class ChildScreen( - identifier: String, - val content: @Composable (NavController) -> Unit, -) : Screen(identifier) - -/** Create the navigation graph for [screen]. */ -fun NavGraphBuilder.screen( - screen: Screen, - navController: NavController, - onControlToggleRequested: () -> Unit, -) { - when (screen) { - is ChildScreen -> composable(screen.identifier) { screen.content(navController) } - is ParentScreen -> { - val menuRoute = "${screen.identifier}_menu" - navigation(startDestination = menuRoute, route = screen.identifier) { - // The menu to navigate to one of the children screens. - composable(menuRoute) { - ScreenMenu(screen, navController, onControlToggleRequested) - } - - // The content of the child screens. - screen.children.forEach { (_, child) -> - screen( - child, - navController, - onControlToggleRequested, - ) - } - } - } - } -} - -@Composable -private fun ScreenMenu( - screen: ParentScreen, - navController: NavController, - onControlToggleRequested: () -> Unit, -) { - LazyColumn( - Modifier.padding(horizontal = 16.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), - ) { - item { - Surface( - Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.tertiaryContainer, - shape = CircleShape, - ) { - Column( - Modifier.clickable(onClick = onControlToggleRequested).padding(16.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Text("Toggle controls") - } - } - } - - screen.children.forEach { (name, child) -> - item { - Surface( - Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.secondaryContainer, - shape = CircleShape, - ) { - Column( - Modifier.clickable { navController.navigate(child.identifier) } - .padding(16.dp), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Text(name) - } - } - } - } - } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/TypographyScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/TypographyScreen.kt deleted file mode 100644 index 147025ed1d606..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/TypographyScreen.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.foundation.horizontalScroll -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.style.TextOverflow - -/** The screen that shows the Material text styles. */ -@Composable -fun TypographyScreen() { - val typography = MaterialTheme.typography - - Column( - Modifier.fillMaxSize() - .horizontalScroll(rememberScrollState()) - .verticalScroll(rememberScrollState()), - ) { - FontLine("displayLarge", typography.displayLarge) - FontLine("displayMedium", typography.displayMedium) - FontLine("displaySmall", typography.displaySmall) - FontLine("headlineLarge", typography.headlineLarge) - FontLine("headlineMedium", typography.headlineMedium) - FontLine("headlineSmall", typography.headlineSmall) - FontLine("titleLarge", typography.titleLarge) - FontLine("titleMedium", typography.titleMedium) - FontLine("titleSmall", typography.titleSmall) - FontLine("bodyLarge", typography.bodyLarge) - FontLine("bodyMedium", typography.bodyMedium) - FontLine("bodySmall", typography.bodySmall) - FontLine("labelLarge", typography.labelLarge) - FontLine("labelMedium", typography.labelMedium) - FontLine("labelSmall", typography.labelSmall) - } -} - -@Composable -private fun FontLine(name: String, style: TextStyle) { - Text( - "$name (${style.fontSize}/${style.lineHeight}, W${style.fontWeight?.weight})", - style = style, - maxLines = 1, - overflow = TextOverflow.Visible, - ) -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/UserSwitcherScreen.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/UserSwitcherScreen.kt deleted file mode 100644 index fe9707d226840..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/compose/gallery/UserSwitcherScreen.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext -import com.android.systemui.user.Fakes.fakeUserSwitcherViewModel -import com.android.systemui.user.ui.compose.UserSwitcherScreen - -@Composable -fun UserSwitcherScreen( - userCount: Int, - onFinished: () -> Unit, -) { - val context = LocalContext.current.applicationContext - UserSwitcherScreen( - viewModel = fakeUserSwitcherViewModel(context, userCount = userCount), - onFinished = onFinished, - ) -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/people/Fakes.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/people/Fakes.kt deleted file mode 100644 index 0966c3233ad50..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/people/Fakes.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.people - -import android.content.Context -import android.graphics.Bitmap -import android.graphics.Canvas -import android.graphics.Color -import android.graphics.Paint -import android.graphics.drawable.Icon -import androidx.core.graphics.drawable.toIcon -import com.android.systemui.R -import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.people.data.model.PeopleTileModel -import com.android.systemui.people.ui.viewmodel.PeopleViewModel -import com.android.systemui.people.widget.PeopleTileKey - -/** A [PeopleViewModel] that does not have any conversations. */ -fun emptyPeopleSpaceViewModel(@Application context: Context): PeopleViewModel { - return fakePeopleSpaceViewModel(context, emptyList(), emptyList()) -} - -/** A [PeopleViewModel] that has a few conversations. */ -fun fewPeopleSpaceViewModel(@Application context: Context): PeopleViewModel { - return fakePeopleSpaceViewModel( - context, - priorityTiles = - listOf( - fakeTile(context, id = "0", Color.RED, "Priority"), - fakeTile(context, id = "1", Color.BLUE, "Priority NewStory", hasNewStory = true), - ), - recentTiles = - listOf( - fakeTile(context, id = "2", Color.GREEN, "Recent Important", isImportant = true), - fakeTile(context, id = "3", Color.CYAN, "Recent DndBlocking", isDndBlocking = true), - ), - ) -} - -/** A [PeopleViewModel] that has a lot of conversations. */ -fun fullPeopleSpaceViewModel(@Application context: Context): PeopleViewModel { - return fakePeopleSpaceViewModel( - context, - priorityTiles = - listOf( - fakeTile(context, id = "0", Color.RED, "Priority"), - fakeTile(context, id = "1", Color.BLUE, "Priority NewStory", hasNewStory = true), - fakeTile(context, id = "2", Color.GREEN, "Priority Important", isImportant = true), - fakeTile( - context, - id = "3", - Color.CYAN, - "Priority DndBlocking", - isDndBlocking = true, - ), - fakeTile( - context, - id = "4", - Color.MAGENTA, - "Priority NewStory Important", - hasNewStory = true, - isImportant = true, - ), - ), - recentTiles = - listOf( - fakeTile( - context, - id = "5", - Color.RED, - "Recent NewStory DndBlocking", - hasNewStory = true, - isDndBlocking = true, - ), - fakeTile( - context, - id = "6", - Color.BLUE, - "Recent Important DndBlocking", - isImportant = true, - isDndBlocking = true, - ), - fakeTile( - context, - id = "7", - Color.GREEN, - "Recent NewStory Important DndBlocking", - hasNewStory = true, - isImportant = true, - isDndBlocking = true, - ), - fakeTile(context, id = "8", Color.CYAN, "Recent"), - fakeTile(context, id = "9", Color.MAGENTA, "Recent"), - ), - ) -} - -private fun fakePeopleSpaceViewModel( - @Application context: Context, - priorityTiles: List, - recentTiles: List, -): PeopleViewModel { - return PeopleViewModel( - context, - FakePeopleTileRepository(priorityTiles, recentTiles), - FakePeopleWidgetRepository(), - ) -} - -private fun fakeTile( - @Application context: Context, - id: String, - iconColor: Int, - username: String, - hasNewStory: Boolean = false, - isImportant: Boolean = false, - isDndBlocking: Boolean = false -): PeopleTileModel { - return PeopleTileModel( - PeopleTileKey(id, /* userId= */ 0, /* packageName */ ""), - username, - fakeUserIcon(context, iconColor), - hasNewStory, - isImportant, - isDndBlocking, - ) -} - -private fun fakeUserIcon(@Application context: Context, color: Int): Icon { - val size = context.resources.getDimensionPixelSize(R.dimen.avatar_size_for_medium) - val bitmap = - Bitmap.createBitmap( - size, - size, - Bitmap.Config.ARGB_8888, - ) - val canvas = Canvas(bitmap) - val paint = Paint().apply { this.color = color } - val radius = size / 2f - canvas.drawCircle(/* cx= */ radius, /* cy= */ radius, /* radius= */ radius, paint) - return bitmap.toIcon() -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/qs/footer/Fakes.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/qs/footer/Fakes.kt deleted file mode 100644 index 6588e22721fb0..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/qs/footer/Fakes.kt +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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.qs.footer - -import android.content.Context -import android.os.UserHandle -import android.view.View -import com.android.internal.util.UserIcons -import com.android.systemui.R -import com.android.systemui.animation.Expandable -import com.android.systemui.classifier.FalsingManagerFake -import com.android.systemui.common.shared.model.Icon -import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.globalactions.GlobalActionsDialogLite -import com.android.systemui.qs.footer.data.model.UserSwitcherStatusModel -import com.android.systemui.qs.footer.domain.interactor.FooterActionsInteractor -import com.android.systemui.qs.footer.domain.model.SecurityButtonConfig -import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel -import com.android.systemui.util.mockito.mock -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flowOf - -/** A list of fake [FooterActionsViewModel] to be used in screenshot tests and the gallery. */ -fun fakeFooterActionsViewModels( - @Application context: Context, -): List { - return listOf( - fakeFooterActionsViewModel(context), - fakeFooterActionsViewModel(context, showPowerButton = false, isGuestUser = true), - fakeFooterActionsViewModel(context, showUserSwitcher = false), - fakeFooterActionsViewModel(context, showUserSwitcher = false, foregroundServices = 4), - fakeFooterActionsViewModel( - context, - foregroundServices = 4, - hasNewForegroundServices = true, - userId = 1, - ), - fakeFooterActionsViewModel( - context, - securityText = "Security", - foregroundServices = 4, - showUserSwitcher = false, - ), - fakeFooterActionsViewModel( - context, - securityText = "Security (not clickable)", - securityClickable = false, - foregroundServices = 4, - hasNewForegroundServices = true, - userId = 2, - ), - ) -} - -private fun fakeFooterActionsViewModel( - @Application context: Context, - securityText: String? = null, - securityClickable: Boolean = true, - foregroundServices: Int = 0, - hasNewForegroundServices: Boolean = false, - showUserSwitcher: Boolean = true, - showPowerButton: Boolean = true, - userId: Int = UserHandle.USER_OWNER, - isGuestUser: Boolean = false, -): FooterActionsViewModel { - val interactor = - FakeFooterActionsInteractor( - securityButtonConfig = - flowOf( - securityText?.let { text -> - SecurityButtonConfig( - icon = - Icon.Resource( - R.drawable.ic_info_outline, - contentDescription = null, - ), - text = text, - isClickable = securityClickable, - ) - } - ), - foregroundServicesCount = flowOf(foregroundServices), - hasNewForegroundServices = flowOf(hasNewForegroundServices), - userSwitcherStatus = - flowOf( - if (showUserSwitcher) { - UserSwitcherStatusModel.Enabled( - currentUserName = "foo", - currentUserImage = - UserIcons.getDefaultUserIcon( - context.resources, - userId, - /* light= */ false, - ), - isGuestUser = isGuestUser, - ) - } else { - UserSwitcherStatusModel.Disabled - } - ), - deviceMonitoringDialogRequests = flowOf(), - ) - - return FooterActionsViewModel( - context, - interactor, - FalsingManagerFake(), - globalActionsDialogLite = mock(), - showPowerButton = showPowerButton, - ) -} - -private class FakeFooterActionsInteractor( - override val securityButtonConfig: Flow = flowOf(null), - override val foregroundServicesCount: Flow = flowOf(0), - override val hasNewForegroundServices: Flow = flowOf(false), - override val userSwitcherStatus: Flow = - flowOf(UserSwitcherStatusModel.Disabled), - override val deviceMonitoringDialogRequests: Flow = flowOf(), - private val onShowDeviceMonitoringDialogFromView: (View) -> Unit = {}, - private val onShowDeviceMonitoringDialog: (Context) -> Unit = {}, - private val onShowForegroundServicesDialog: (View) -> Unit = {}, - private val onShowPowerMenuDialog: (GlobalActionsDialogLite, View) -> Unit = { _, _ -> }, - private val onShowSettings: (Expandable) -> Unit = {}, - private val onShowUserSwitcher: (View) -> Unit = {}, -) : FooterActionsInteractor { - override fun showDeviceMonitoringDialog(view: View) { - onShowDeviceMonitoringDialogFromView(view) - } - - override fun showDeviceMonitoringDialog(quickSettingsContext: Context) { - onShowDeviceMonitoringDialog(quickSettingsContext) - } - - override fun showForegroundServicesDialog(view: View) { - onShowForegroundServicesDialog(view) - } - - override fun showPowerMenuDialog(globalActionsDialogLite: GlobalActionsDialogLite, view: View) { - onShowPowerMenuDialog(globalActionsDialogLite, view) - } - - override fun showSettings(expandable: Expandable) { - onShowSettings(expandable) - } - - override fun showUserSwitcher(view: View) { - onShowUserSwitcher(view) - } -} diff --git a/packages/SystemUI/compose/gallery/src/com/android/systemui/user/Fakes.kt b/packages/SystemUI/compose/gallery/src/com/android/systemui/user/Fakes.kt deleted file mode 100644 index 91a73ea16dc49..0000000000000 --- a/packages/SystemUI/compose/gallery/src/com/android/systemui/user/Fakes.kt +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.user - -import android.content.Context -import androidx.appcompat.content.res.AppCompatResources -import com.android.systemui.common.shared.model.Text -import com.android.systemui.compose.gallery.R -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.power.data.repository.FakePowerRepository -import com.android.systemui.power.domain.interactor.PowerInteractor -import com.android.systemui.user.data.repository.FakeUserRepository -import com.android.systemui.user.domain.interactor.UserInteractor -import com.android.systemui.user.shared.model.UserActionModel -import com.android.systemui.user.shared.model.UserModel -import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel -import com.android.systemui.util.mockito.mock - -object Fakes { - private val USER_TINT_COLORS = - arrayOf( - 0x000000, - 0x0000ff, - 0x00ff00, - 0x00ffff, - 0xff0000, - 0xff00ff, - 0xffff00, - 0xffffff, - ) - - fun fakeUserSwitcherViewModel( - context: Context, - userCount: Int, - ): UserSwitcherViewModel { - return UserSwitcherViewModel.Factory( - userInteractor = - UserInteractor( - repository = - FakeUserRepository().apply { - setUsers( - (0 until userCount).map { index -> - UserModel( - id = index, - name = - Text.Loaded( - when (index % 6) { - 0 -> "Ross Geller" - 1 -> "Phoebe Buffay" - 2 -> "Monica Geller" - 3 -> "Rachel Greene" - 4 -> "Chandler Bing" - else -> "Joey Tribbiani" - } - ), - image = - checkNotNull( - AppCompatResources.getDrawable( - context, - when (index % 6) { - 0 -> R.drawable.kitten1 - 1 -> R.drawable.kitten2 - 2 -> R.drawable.kitten3 - 3 -> R.drawable.kitten4 - 4 -> R.drawable.kitten5 - else -> R.drawable.kitten6 - }, - ) - ), - isSelected = index == 0, - isSelectable = true, - ) - } - ) - setActions( - UserActionModel.values().mapNotNull { - if (it == UserActionModel.NAVIGATE_TO_USER_MANAGEMENT) { - null - } else { - it - } - } - ) - }, - controller = mock(), - activityStarter = mock(), - keyguardInteractor = - KeyguardInteractor( - repository = - FakeKeyguardRepository().apply { setKeyguardShowing(false) }, - ), - ), - powerInteractor = - PowerInteractor( - repository = FakePowerRepository(), - ) - ) - .create(UserSwitcherViewModel::class.java) - } -} diff --git a/packages/SystemUI/compose/gallery/tests/Android.bp b/packages/SystemUI/compose/gallery/tests/Android.bp deleted file mode 100644 index 3e01f7d2c431f..0000000000000 --- a/packages/SystemUI/compose/gallery/tests/Android.bp +++ /dev/null @@ -1,47 +0,0 @@ -// 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 { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"], -} - -android_test { - name: "SystemUIComposeGalleryTests", - manifest: "AndroidManifest.xml", - test_suites: ["device-tests"], - sdk_version: "current", - certificate: "platform", - - srcs: [ - "src/**/*.kt", - ], - - static_libs: [ - "SystemUIComposeGalleryLib", - - "androidx.test.runner", - "androidx.test.ext.junit", - - "androidx.compose.runtime_runtime", - "androidx.compose.ui_ui-test-junit4", - "androidx.compose.ui_ui-test-manifest", - ], - - kotlincflags: ["-Xjvm-default=enable"], -} diff --git a/packages/SystemUI/compose/gallery/tests/AndroidManifest.xml b/packages/SystemUI/compose/gallery/tests/AndroidManifest.xml deleted file mode 100644 index 5eeb3ad24e5aa..0000000000000 --- a/packages/SystemUI/compose/gallery/tests/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/compose/gallery/tests/src/com/android/systemui/compose/gallery/ScreenshotsTests.kt b/packages/SystemUI/compose/gallery/tests/src/com/android/systemui/compose/gallery/ScreenshotsTests.kt deleted file mode 100644 index 66ecc8d4fde54..0000000000000 --- a/packages/SystemUI/compose/gallery/tests/src/com/android/systemui/compose/gallery/ScreenshotsTests.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.compose.gallery - -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.android.systemui.compose.theme.SystemUITheme -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class ScreenshotsTests { - @get:Rule val composeRule = createComposeRule() - - @Test - fun exampleFeatureScreenshotTest() { - // TODO(b/230832101): Wire this with the screenshot diff testing infra. We should reuse the - // configuration of the features in the gallery app to populate the UIs. - composeRule.setContent { SystemUITheme { ExampleFeatureScreen() } } - } -}