From 90eb7cdde1e8052f6a9fbb665799c125f73a3c4d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 22 Nov 2025 10:06:59 +0800 Subject: [PATCH] fix(deps): update dependency io.nlopez.compose.rules:ktlint to v0.4.28 (#6123) * fix(deps): update dependency io.nlopez.compose.rules:ktlint to v0.4.28 * Ktlint 1.8.0 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Goooler --- .editorconfig | 1 + build.gradle | 4 ++-- lawnchair/src/app/lawnchair/BlankActivity.kt | 1 + lawnchair/src/app/lawnchair/FeedBridge.kt | 2 ++ .../src/app/lawnchair/LawnchairLauncher.kt | 2 ++ .../lawnchair/allapps/views/SearchResultIcon.kt | 4 ++++ .../app/lawnchair/animation/PhysicsAnimator.kt | 2 ++ .../lawnchair/backup/ui/RestoreBackupScreen.kt | 2 ++ .../lawnchair/flowerpot/parser/LineParser.kt | 5 +++++ .../gestures/DirectionalGestureListener.kt | 2 ++ .../gestures/handlers/OpenAppGestureHandler.kt | 1 + .../src/app/lawnchair/icons/CustomIconPack.kt | 2 ++ .../lawnchair/icons/LawnchairIconProvider.kt | 6 ++++++ .../preferences2/SharedPreferencesMigration.kt | 5 +++++ .../search/adapter/SearchTargetFactory.kt | 1 + .../algorithms/LawnchairSearchAlgorithm.kt | 1 + .../lawnchair/search/algorithms/SearchUtils.kt | 2 ++ .../search/algorithms/data/IFileInfo.kt | 6 ++++++ .../data/calculator/internal/Evaluator.kt | 16 ++++++++++++++++ .../data/calculator/internal/Scanner.kt | 17 +++++++++++++++++ .../lawnchair/smartspace/BcSmartspaceCard.kt | 4 ++++ .../smartspace/InterceptingViewPager.kt | 1 + .../src/app/lawnchair/theme/ThemeProvider.kt | 3 +++ .../ui/placeholder/PlaceholderHighlight.kt | 1 + .../lawnchair/ui/popup/LauncherOptionsPopup.kt | 7 +++++++ .../app/lawnchair/ui/preferences/Preferences.kt | 2 ++ .../about/NightlyBuildsRepository.kt | 1 + .../ui/preferences/about/UpdateSection.kt | 6 ++++++ .../components/AnnouncementPreference.kt | 5 ++++- .../preferences/components/WallpaperPreview.kt | 2 ++ .../colorpreference/ColorSelectionPreference.kt | 1 + .../pickers/CustomColorPicker.kt | 1 + .../components/layout/NestedScrollStretch.kt | 3 +++ .../components/layout/TwoTabPreferenceLayout.kt | 1 + .../search/SearchProviderPreference.kt | 3 +++ .../destinations/FontSelectionPreference.kt | 2 ++ .../destinations/GeneralPreferences.kt | 1 + .../destinations/LauncherPopupPreference.kt | 3 +++ .../destinations/SmartspacePreferences.kt | 2 ++ .../src/app/lawnchair/util/Compatibility.kt | 3 +++ .../src/app/lawnchair/util/FormatterUtils.kt | 7 +++++++ lawnchair/src/app/lawnchair/util/SmartBorder.kt | 2 ++ .../lawnchair/views/FullScreenOverlayView.kt | 2 ++ .../com/android/systemui/monet/ColorScheme.kt | 2 ++ 44 files changed, 144 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 87cc9903e4..b5297ead85 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,6 +22,7 @@ ktlint_code_style = intellij_idea ktlint_function_naming_ignore_when_annotated_with = Composable ktlint_standard_discouraged-comment-location = disabled ktlint_standard_function-expression-body = disabled +ktlint_standard_mixed-condition-operators = disabled ktlint_compose_lambda-param-event-trailing = disabled [*.md] diff --git a/build.gradle b/build.gradle index d91212d5b7..1dcdea8f4d 100644 --- a/build.gradle +++ b/build.gradle @@ -469,8 +469,8 @@ spotless { } kotlin { target("lawnchair/src/**/*.kt") - ktlint().customRuleSets([ - "io.nlopez.compose.rules:ktlint:0.4.27", + ktlint("1.8.0").customRuleSets([ + "io.nlopez.compose.rules:ktlint:0.4.28", ]).editorConfigOverride([ "ktlint_compose_compositionlocal-allowlist": "disabled", "ktlint_compose_lambda-param-event-trailing": "disabled", diff --git a/lawnchair/src/app/lawnchair/BlankActivity.kt b/lawnchair/src/app/lawnchair/BlankActivity.kt index 64ced50756..d42f648671 100644 --- a/lawnchair/src/app/lawnchair/BlankActivity.kt +++ b/lawnchair/src/app/lawnchair/BlankActivity.kt @@ -97,6 +97,7 @@ class BlankActivity : ComponentActivity() { }.launch(requireNotNull(intent.getParcelableExtra("intent"))) } } + else -> { finish() return diff --git a/lawnchair/src/app/lawnchair/FeedBridge.kt b/lawnchair/src/app/lawnchair/FeedBridge.kt index f722409551..f6ff2a89a9 100644 --- a/lawnchair/src/app/lawnchair/FeedBridge.kt +++ b/lawnchair/src/app/lawnchair/FeedBridge.kt @@ -108,6 +108,7 @@ class FeedBridge(private val context: Context) { open fun isSigned(): Boolean { when { BuildConfig.DEBUG -> return true + Utilities.ATLEAST_P -> { val info = context.packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNING_CERTIFICATES) @@ -115,6 +116,7 @@ class FeedBridge(private val context: Context) { if (signingInfo!!.hasMultipleSigners()) return false return signingInfo.signingCertificateHistory.any { it.hashCode() == signatureHash } } + else -> { val info = context.packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES) return if (info.signatures!!.any { it.hashCode() != signatureHash }) false else info.signatures!!.isNotEmpty() diff --git a/lawnchair/src/app/lawnchair/LawnchairLauncher.kt b/lawnchair/src/app/lawnchair/LawnchairLauncher.kt index 9fc0581b8f..55fecf4796 100644 --- a/lawnchair/src/app/lawnchair/LawnchairLauncher.kt +++ b/lawnchair/src/app/lawnchair/LawnchairLauncher.kt @@ -128,6 +128,7 @@ class LawnchairLauncher : QuickstepLauncher() { -> { LawnchairApp.instance.restoreClockInStatusBar() } + else -> { workspace.updateStatusbarClock() } @@ -483,6 +484,7 @@ class LawnchairLauncher : QuickstepLauncher() { private fun restartIfPending() { when { sRestartFlags and FLAG_RESTART != 0 -> lawnchairApp.restart(false) + sRestartFlags and FLAG_RECREATE != 0 -> { sRestartFlags = 0 recreate() diff --git a/lawnchair/src/app/lawnchair/allapps/views/SearchResultIcon.kt b/lawnchair/src/app/lawnchair/allapps/views/SearchResultIcon.kt index afea3cdeec..b32dc7818e 100644 --- a/lawnchair/src/app/lawnchair/allapps/views/SearchResultIcon.kt +++ b/lawnchair/src/app/lawnchair/allapps/views/SearchResultIcon.kt @@ -79,10 +79,12 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) : allowLongClick = false bindFromAction(target, iconComponentKey == null) } + target.shortcutInfo != null -> { allowLongClick = true bindFromShortcutInfo(target.shortcutInfo) } + else -> { allowLongClick = true val className = extras.getString("class").orEmpty() @@ -207,7 +209,9 @@ class SearchResultIcon(context: Context, attrs: AttributeSet?) : info.bitmap = when { info.hasFlags(SearchActionItemInfo.FLAG_PRIMARY_ICON_FROM_TITLE) -> li.createIconBitmap("${info.title}", packageIcon.color) + icon == null -> packageIcon + else -> icon.loadDrawable(context)?.let { li.createBadgedIconBitmap(it, BaseIconFactory.IconOptions().setUser(info.user)) } } if (info.hasFlags(SearchActionItemInfo.FLAG_BADGE_WITH_COMPONENT_NAME) && target.extras.containsKey("class")) { diff --git a/lawnchair/src/app/lawnchair/animation/PhysicsAnimator.kt b/lawnchair/src/app/lawnchair/animation/PhysicsAnimator.kt index 828a536382..9bcf079393 100644 --- a/lawnchair/src/app/lawnchair/animation/PhysicsAnimator.kt +++ b/lawnchair/src/app/lawnchair/animation/PhysicsAnimator.kt @@ -368,8 +368,10 @@ class PhysicsAnimator private constructor(target: T) { flingConfigCopy.startVelocity = when { distanceToDestination > 0f && startVelocity >= 0f -> max(velocityToReachDestination, startVelocity) + distanceToDestination < 0f && startVelocity <= 0f -> min(velocityToReachDestination, startVelocity) + else -> startVelocity } diff --git a/lawnchair/src/app/lawnchair/backup/ui/RestoreBackupScreen.kt b/lawnchair/src/app/lawnchair/backup/ui/RestoreBackupScreen.kt index 75ac6b9369..ac12eff170 100644 --- a/lawnchair/src/app/lawnchair/backup/ui/RestoreBackupScreen.kt +++ b/lawnchair/src/app/lawnchair/backup/ui/RestoreBackupScreen.kt @@ -90,11 +90,13 @@ fun RestoreBackupScreen( ) { when (uiState) { is RestoreBackupUiState.Success -> RestoreBackupOptions(isPortrait, uiState.backup) + is RestoreBackupUiState.Loading -> { Box(modifier = Modifier.fillMaxSize()) { CircularProgressIndicator(modifier = Modifier.align(Alignment.Center)) } } + is RestoreBackupUiState.Error -> { val context = LocalContext.current val backDispatcher = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher diff --git a/lawnchair/src/app/lawnchair/flowerpot/parser/LineParser.kt b/lawnchair/src/app/lawnchair/flowerpot/parser/LineParser.kt index 4a4057dd04..acb2382cf1 100644 --- a/lawnchair/src/app/lawnchair/flowerpot/parser/LineParser.kt +++ b/lawnchair/src/app/lawnchair/flowerpot/parser/LineParser.kt @@ -29,12 +29,16 @@ object LineParser { return when (line[0]) { // Comment '#' -> Rules.NONE + // Version declaration '$' -> Rules.Version(line.rest.toInt()) + // Intent action ':' -> Rules.IntentAction(line.rest) + // Intent category ';' -> Rules.IntentCategory(line.rest) + // Code rule '&' -> { val parts = line.rest.split("|") @@ -42,6 +46,7 @@ object LineParser { val args = if (parts.size > 1) parts.subList(1, parts.size) else emptyList() Rules.CodeRule(ruleName, args.toTypedArray()) } + // Package else -> if (!line[0].isLetter()) { throw FlowerpotFormatException("Unknown rule identifier '${line[0]}' for version $version") diff --git a/lawnchair/src/app/lawnchair/gestures/DirectionalGestureListener.kt b/lawnchair/src/app/lawnchair/gestures/DirectionalGestureListener.kt index 94eb65ddad..4a01c8daf9 100644 --- a/lawnchair/src/app/lawnchair/gestures/DirectionalGestureListener.kt +++ b/lawnchair/src/app/lawnchair/gestures/DirectionalGestureListener.kt @@ -49,6 +49,7 @@ abstract class DirectionalGestureListener(ctx: Context?) : OnTouchListener { } true } + shouldReactToSwipe(diffX, velocityX) -> { if (diffX > 0) { Log.d("GESTURE_DETECTION", "Swipe Right Detected") @@ -59,6 +60,7 @@ abstract class DirectionalGestureListener(ctx: Context?) : OnTouchListener { } true } + else -> false } } diff --git a/lawnchair/src/app/lawnchair/gestures/handlers/OpenAppGestureHandler.kt b/lawnchair/src/app/lawnchair/gestures/handlers/OpenAppGestureHandler.kt index 9a2dfda3c0..2caaed1090 100644 --- a/lawnchair/src/app/lawnchair/gestures/handlers/OpenAppGestureHandler.kt +++ b/lawnchair/src/app/lawnchair/gestures/handlers/OpenAppGestureHandler.kt @@ -29,6 +29,7 @@ class OpenAppGestureHandler( null, ) } + is OpenAppTarget.Shortcut -> Unit } } diff --git a/lawnchair/src/app/lawnchair/icons/CustomIconPack.kt b/lawnchair/src/app/lawnchair/icons/CustomIconPack.kt index 7e5bd76fd4..327fa8ca66 100644 --- a/lawnchair/src/app/lawnchair/icons/CustomIconPack.kt +++ b/lawnchair/src/app/lawnchair/icons/CustomIconPack.kt @@ -95,6 +95,7 @@ class CustomIconPack(context: Context, packPackageName: String) : IconPack(conte } } } + "dynamic-clock" -> { val drawableName = parseXml["drawable"] if (drawableName != null) { @@ -154,6 +155,7 @@ class CustomIconPack(context: Context, packPackageName: String) : IconPack(conte endCategory() currentTitle = title } + "item" -> { val drawableName = parser["drawable"] ?: continue val resId = getDrawableId(drawableName) diff --git a/lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt b/lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt index e5d75c0709..3c8c023637 100644 --- a/lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt +++ b/lawnchair/src/app/lawnchair/icons/LawnchairIconProvider.kt @@ -131,23 +131,28 @@ class LawnchairIconProvider @JvmOverloads constructor( themeData = getThemeData(mCalendar.packageName, "") iconType = ICON_TYPE_CALENDAR } + !supportsIconTheme -> { // theming is disabled, don't populate theme data } + clock != null -> { // the icon supports dynamic clock, use dynamic themed clock themeData = getThemeData(mClock.packageName, "") iconType = ICON_TYPE_CLOCK } + packageName == mClock.packageName -> { // is clock app but icon might not be adaptive, fallback to static themed clock themeData = ThemedIconDrawable.ThemeData(context.resources, BuildConfig.APPLICATION_ID, R.drawable.themed_icon_static_clock) } + packageName == mCalendar.packageName -> { // calendar app, apply the dynamic calendar icon themeData = getThemeData(mCalendar.packageName, "") iconType = ICON_TYPE_CALENDAR } + else -> { // regular icon themeData = getThemeData(componentName) @@ -320,6 +325,7 @@ class LawnchairIconProvider @JvmOverloads constructor( } } } + ACTION_DATE_CHANGED -> { context.getSystemService()?.userProfiles?.forEach { user -> iconPack.getCalendars().forEach { componentName -> diff --git a/lawnchair/src/app/lawnchair/preferences2/SharedPreferencesMigration.kt b/lawnchair/src/app/lawnchair/preferences2/SharedPreferencesMigration.kt index 7e9d3312c3..0767d1ab9d 100644 --- a/lawnchair/src/app/lawnchair/preferences2/SharedPreferencesMigration.kt +++ b/lawnchair/src/app/lawnchair/preferences2/SharedPreferencesMigration.kt @@ -73,10 +73,15 @@ class SharedPreferencesMigration(private val context: Context) { val newKey = keys[key] ?: key when (value) { is Boolean -> mutablePreferences[booleanPreferencesKey(newKey)] = value + is Float -> mutablePreferences[floatPreferencesKey(newKey)] = value + is Int -> mutablePreferences[intPreferencesKey(newKey)] = value + is Long -> mutablePreferences[longPreferencesKey(newKey)] = value + is String -> mutablePreferences[stringPreferencesKey(newKey)] = value + is Set<*> -> { mutablePreferences[stringSetPreferencesKey(newKey)] = value as Set } diff --git a/lawnchair/src/app/lawnchair/search/adapter/SearchTargetFactory.kt b/lawnchair/src/app/lawnchair/search/adapter/SearchTargetFactory.kt index 0bfd357bfc..bab72d47b7 100644 --- a/lawnchair/src/app/lawnchair/search/adapter/SearchTargetFactory.kt +++ b/lawnchair/src/app/lawnchair/search/adapter/SearchTargetFactory.kt @@ -294,6 +294,7 @@ class SearchTargetFactory( MediaStore.Files.getContentUri("external"), info.fileId, ) + is FolderInfo -> File(info.path).file2Uri() } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairSearchAlgorithm.kt b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairSearchAlgorithm.kt index 9c334ab93f..82cbe113f9 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairSearchAlgorithm.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairSearchAlgorithm.kt @@ -226,6 +226,7 @@ sealed class LawnchairSearchAlgorithm( ) searchAlgorithm == LOCAL_SEARCH -> LawnchairLocalSearchAlgorithm(context) + else -> LawnchairAppSearchAlgorithm(context) } } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/SearchUtils.kt b/lawnchair/src/app/lawnchair/search/algorithms/SearchUtils.kt index 8d18a3f032..8e6231a6b5 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/SearchUtils.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/SearchUtils.kt @@ -59,12 +59,14 @@ fun Sequence.filterHiddenApps( HiddenAppsInSearch.ALWAYS -> { this } + HiddenAppsInSearch.IF_NAME_TYPED -> { filter { it.toComponentKey().toString() !in hiddenApps || it.title.toString().lowercase(Locale.getDefault()) == query } } + else -> { filter { it.toComponentKey().toString() !in hiddenApps } } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/data/IFileInfo.kt b/lawnchair/src/app/lawnchair/search/algorithms/data/IFileInfo.kt index 22bb95cb27..054790878f 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/data/IFileInfo.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/data/IFileInfo.kt @@ -34,10 +34,15 @@ data class FileInfo( @get:DrawableRes val iconRes = when (val mime = mimeType.orEmpty()) { in imageFileTypes.values -> R.drawable.ic_file_image + in videoFileTypes.values -> R.drawable.ic_file_video + in audioFileTypes.values -> R.drawable.ic_file_music + in androidPkgTypes.values -> R.drawable.ic_file_app + in archiveFileTypes.values -> R.drawable.ic_file_zip + in documentFileTypes.values -> when { mime.contains("excel") || mime.contains("csv") -> R.drawable.ic_file_excel mime.contains("word") -> R.drawable.ic_file_word @@ -46,6 +51,7 @@ data class FileInfo( mime.contains("srt") -> R.drawable.ic_file_subtitle else -> R.drawable.ic_file_text } + else -> R.drawable.ic_file_unknown } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Evaluator.kt b/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Evaluator.kt index 8e9ff478ae..4fe735781b 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Evaluator.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Evaluator.kt @@ -62,7 +62,9 @@ internal class Evaluator : ExprVisitor { return when (expr.operator.type) { BAR_BAR -> left or right + AMP_AMP -> left and right + else -> throw ExpressionException( "Invalid logical operator '${expr.operator.lexeme}'", ) @@ -75,17 +77,29 @@ internal class Evaluator : ExprVisitor { return when (expr.operator.type) { PLUS -> left + right + MINUS -> left - right + STAR -> left * right + SLASH -> left.divide(right, mathContext) + MODULO -> left.remainder(right, mathContext) + EXPONENT -> left pow right + EQUAL_EQUAL -> (left == right).toBigDecimal() + NOT_EQUAL -> (left != right).toBigDecimal() + GREATER -> (left > right).toBigDecimal() + GREATER_EQUAL -> (left >= right).toBigDecimal() + LESS -> (left < right).toBigDecimal() + LESS_EQUAL -> (left <= right).toBigDecimal() + else -> throw ExpressionException( "Invalid binary operator '${expr.operator.lexeme}'", ) @@ -99,9 +113,11 @@ internal class Evaluator : ExprVisitor { MINUS -> { right.negate() } + SQUARE_ROOT -> { right.pow(BigDecimal(0.5)) } + else -> throw ExpressionException("Invalid unary operator") } } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Scanner.kt b/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Scanner.kt index 5190cce396..216c1c783a 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Scanner.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/data/calculator/internal/Scanner.kt @@ -60,22 +60,39 @@ internal class Scanner( -> { // Ignore whitespace. } + '+' -> addToken(PLUS) + '-' -> addToken(MINUS) + '*' -> addToken(STAR) + '/' -> addToken(SLASH) + '%' -> addToken(MODULO) + '^' -> addToken(EXPONENT) + '√' -> addToken(SQUARE_ROOT) + '=' -> if (match('=')) addToken(EQUAL_EQUAL) else addToken(ASSIGN) + '!' -> if (match('=')) addToken(NOT_EQUAL) else invalidToken(c) + '>' -> if (match('=')) addToken(GREATER_EQUAL) else addToken(GREATER) + '<' -> if (match('=')) addToken(LESS_EQUAL) else addToken(LESS) + '|' -> if (match('|')) addToken(BAR_BAR) else invalidToken(c) + '&' -> if (match('&')) addToken(AMP_AMP) else invalidToken(c) + ',' -> addToken(COMMA) + '(' -> addToken(LEFT_PAREN) + ')' -> addToken(RIGHT_PAREN) + else -> { when { c.isDigit() -> number() diff --git a/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt b/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt index 1803406878..405b61ad55 100644 --- a/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt +++ b/lawnchair/src/app/lawnchair/smartspace/BcSmartspaceCard.kt @@ -110,9 +110,11 @@ class BcSmartspaceCard @JvmOverloads constructor( headerAction.hasIntent -> { BcSmartSpaceUtil.setOnClickListener(this, headerAction, null, "BcSmartspaceCard") } + baseAction.hasIntent -> { BcSmartSpaceUtil.setOnClickListener(this, baseAction, null, "BcSmartspaceCard") } + else -> { BcSmartSpaceUtil.setOnClickListener(this, headerAction, null, "BcSmartspaceCard") } @@ -171,11 +173,13 @@ class BcSmartspaceCard @JvmOverloads constructor( ) { textView.contentDescription = when { title.isNullOrEmpty() -> contentDescription + !contentDescription.isNullOrEmpty() -> context.getString( R.string.generic_smartspace_concatenated_desc, contentDescription, title, ) + else -> title } } diff --git a/lawnchair/src/app/lawnchair/smartspace/InterceptingViewPager.kt b/lawnchair/src/app/lawnchair/smartspace/InterceptingViewPager.kt index 5c8e488cd5..c093c906ab 100644 --- a/lawnchair/src/app/lawnchair/smartspace/InterceptingViewPager.kt +++ b/lawnchair/src/app/lawnchair/smartspace/InterceptingViewPager.kt @@ -30,6 +30,7 @@ class InterceptingViewPager @JvmOverloads constructor( postDelayed(longPressCallback, ViewConfiguration.getLongPressTimeout().toLong()) } } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { cancelScheduledLongPress() } diff --git a/lawnchair/src/app/lawnchair/theme/ThemeProvider.kt b/lawnchair/src/app/lawnchair/theme/ThemeProvider.kt index c6f539fd2d..702027ac8c 100644 --- a/lawnchair/src/app/lawnchair/theme/ThemeProvider.kt +++ b/lawnchair/src/app/lawnchair/theme/ThemeProvider.kt @@ -83,11 +83,14 @@ class ThemeProvider(private val context: Context) : SafeCloseable { val colorScheme get() = when (val accentColor = this.accentColor) { is ColorOption.SystemAccent -> systemColorScheme + is ColorOption.WallpaperPrimary -> { val wallpaperPrimary = wallpaperManager.wallpaperColors?.primaryColor getColorScheme(wallpaperPrimary ?: ColorOption.LawnchairBlue.color, colorStyle.style) } + is ColorOption.CustomColor -> getColorScheme(accentColor.color, colorStyle.style) + else -> getColorScheme(ColorOption.LawnchairBlue.color, colorStyle.style) } diff --git a/lawnchair/src/app/lawnchair/ui/placeholder/PlaceholderHighlight.kt b/lawnchair/src/app/lawnchair/ui/placeholder/PlaceholderHighlight.kt index fdc560fedd..2da4bcbb5f 100644 --- a/lawnchair/src/app/lawnchair/ui/placeholder/PlaceholderHighlight.kt +++ b/lawnchair/src/app/lawnchair/ui/placeholder/PlaceholderHighlight.kt @@ -150,6 +150,7 @@ private data class Shimmer( fraction = progress / progressForMaxAlpha, ) } + // From ProgressForOpaqueAlpha..1f we animate from 1..0 else -> { lerp( diff --git a/lawnchair/src/app/lawnchair/ui/popup/LauncherOptionsPopup.kt b/lawnchair/src/app/lawnchair/ui/popup/LauncherOptionsPopup.kt index b9983ee705..de2938014c 100644 --- a/lawnchair/src/app/lawnchair/ui/popup/LauncherOptionsPopup.kt +++ b/lawnchair/src/app/lawnchair/ui/popup/LauncherOptionsPopup.kt @@ -133,30 +133,37 @@ object LauncherOptionsPopup { icon = R.drawable.ic_wallpaper, isCarousel = true, ) + "lock" -> LauncherOptionMetadata( label = R.string.home_screen_lock, icon = R.drawable.ic_lock, ) + "sys_settings" -> LauncherOptionMetadata( label = R.string.system_settings, icon = R.drawable.ic_setting, ) + "edit_mode" -> LauncherOptionMetadata( label = R.string.edit_home_screen, icon = R.drawable.enter_home_gardening_icon, ) + "wallpaper" -> LauncherOptionMetadata( label = R.string.styles_wallpaper_button_text, icon = R.drawable.ic_palette, ) + "widgets" -> LauncherOptionMetadata( label = R.string.widget_button_text, icon = R.drawable.ic_widget, ) + "home_settings" -> LauncherOptionMetadata( label = R.string.settings_button_text, icon = R.drawable.ic_home_screen, ) + else -> throw IllegalArgumentException("invalid popup option") } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt index 82e06abcfd..5ccbdc9fa8 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt @@ -153,6 +153,7 @@ private fun PreferenceScreen( displayFeatures = displayFeatures, ) } + isExpandedScreen -> { Surface( color = MaterialTheme.colorScheme.surface, @@ -166,6 +167,7 @@ private fun PreferenceScreen( } } } + else -> { moveableNavHost() } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/about/NightlyBuildsRepository.kt b/lawnchair/src/app/lawnchair/ui/preferences/about/NightlyBuildsRepository.kt index 4403ebe981..0b756f341e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/about/NightlyBuildsRepository.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/about/NightlyBuildsRepository.kt @@ -79,6 +79,7 @@ class NightlyBuildsRepository( is IOException -> { Log.e(TAG, "Network error during update check", e) } + else -> { Log.e(TAG, "Failed to check for update", e) } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/about/UpdateSection.kt b/lawnchair/src/app/lawnchair/ui/preferences/about/UpdateSection.kt index 247cf14305..bb174a7a44 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/about/UpdateSection.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/about/UpdateSection.kt @@ -29,9 +29,11 @@ fun UpdateSection( ) { when (updateState) { UpdateState.Hidden -> { /* Render nothing */ } + UpdateState.Checking -> { CircularProgressIndicator(modifier = Modifier.padding(top = 8.dp)) } + UpdateState.UpToDate -> { Text( text = stringResource(R.string.pro_updated), @@ -40,6 +42,7 @@ fun UpdateSection( modifier = Modifier.padding(top = 8.dp), ) } + is UpdateState.Available -> { Button( onClick = onViewChanges, @@ -47,6 +50,7 @@ fun UpdateSection( Text(text = stringResource(R.string.download_update)) } } + is UpdateState.Downloading -> { LinearProgressIndicator( progress = { updateState.progress }, @@ -59,6 +63,7 @@ fun UpdateSection( style = MaterialTheme.typography.bodySmall, ) } + is UpdateState.Downloaded -> { Button( onClick = { @@ -68,6 +73,7 @@ fun UpdateSection( Text(text = stringResource(R.string.install_update)) } } + UpdateState.Failed -> { Text( text = stringResource(R.string.update_check_failed), diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/AnnouncementPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/AnnouncementPreference.kt index 0eb6548567..7cf80a044e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/AnnouncementPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/AnnouncementPreference.kt @@ -131,6 +131,7 @@ private fun AnnouncementItemContent( } SwipeToDismissBoxValue.EndToStart -> return@rememberSwipeToDismissBoxState false + SwipeToDismissBoxValue.Settled -> return@rememberSwipeToDismissBoxState false } return@rememberSwipeToDismissBoxState true @@ -180,7 +181,9 @@ private fun AnnouncementItemContent( fun calculateAlpha(progress: Float): Float { return when { - progress < 0.5f -> 1f // Fully opaque until halfway + progress < 0.5f -> 1f + + // Fully opaque until halfway else -> 1f - (progress - 0.5f) * 2 // Fade out linearly from halfway to the end } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/WallpaperPreview.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/WallpaperPreview.kt index 00d3497353..533aa8af6d 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/WallpaperPreview.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/WallpaperPreview.kt @@ -128,6 +128,7 @@ fun wallpaperDrawable( ) { value = when { wallpaperInfo != null -> wallpaperInfo.loadThumbnail(context.packageManager) + hasPermission -> { withContext(Dispatchers.IO) { wallpaperManager.drawable?.let { @@ -137,6 +138,7 @@ fun wallpaperDrawable( } } } + else -> null } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorSelectionPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorSelectionPreference.kt index f357bef305..c9a1afba0e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorSelectionPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/ColorSelectionPreference.kt @@ -140,6 +140,7 @@ fun ColorSelection( ) } } + 1 -> { CustomColorPicker( selectedColor = selectedColor.intValue, diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/pickers/CustomColorPicker.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/pickers/CustomColorPicker.kt index feb5dfb780..1d7cc17d07 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/pickers/CustomColorPicker.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/colorpreference/pickers/CustomColorPicker.kt @@ -185,6 +185,7 @@ fun CustomColorPicker( }, ) } + 1 -> { RgbColorPicker( selectedColor = selectedColor, diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/NestedScrollStretch.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/NestedScrollStretch.kt index 09c5fd933d..f83d7103b0 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/NestedScrollStretch.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/NestedScrollStretch.kt @@ -93,6 +93,7 @@ private class NestedScrollStretchConnection(context: Context, invalidate: Runnab val availableY = available.y when { source != NestedScrollSource.UserInput || height == 0 -> return Offset.Zero + availableY != 0f -> { if (availableY < 0f) { val consumed = topEdgeEffect.onPullDistance(availableY / height, 0f) @@ -117,6 +118,7 @@ private class NestedScrollStretchConnection(context: Context, invalidate: Runnab val availableY = available.y when { source != NestedScrollSource.UserInput || height == 0 -> return Offset.Zero + availableY != 0f -> { if (availableY > 0f) { topEdgeEffect.onPull(availableY / height) @@ -125,6 +127,7 @@ private class NestedScrollStretchConnection(context: Context, invalidate: Runnab bottomEdgeEffect.onPull(-availableY / height) } } + else -> { topEdgeEffect.onRelease() bottomEdgeEffect.onRelease() diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/TwoTabPreferenceLayout.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/TwoTabPreferenceLayout.kt index 84b06af97a..3e4bff3ef7 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/layout/TwoTabPreferenceLayout.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/layout/TwoTabPreferenceLayout.kt @@ -88,6 +88,7 @@ fun TwoTabPreferenceLayout( firstPageContent() } } + 1 -> { Column { secondPageContent() diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/search/SearchProviderPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/search/SearchProviderPreference.kt index ac5f1570c2..10c3920f17 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/search/SearchProviderPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/search/SearchProviderPreference.kt @@ -233,6 +233,7 @@ fun GenericSearchProviderPreference( description = stringResource(id = R.string.fuzzy_search_desc), ) } + SearchProviderId.WEB -> { SliderPreference( label = stringResource(id = R.string.max_web_suggestion_delay), @@ -248,6 +249,7 @@ fun GenericSearchProviderPreference( suggestionsUrlAdapter = prefs2.webSuggestionProviderSuggestionsUrl.getAdapter(), ) } + SearchProviderId.HISTORY -> { val context = LocalContext.current @@ -264,6 +266,7 @@ fun GenericSearchProviderPreference( }, ) } + else -> {} } } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt index d0618c228a..8c92102127 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/FontSelectionPreference.kt @@ -238,6 +238,7 @@ private fun FontSelectionItem( VariantDropdown(adapter = adapter, family = family) } } + onDelete != null -> { { IconButton( @@ -252,6 +253,7 @@ private fun FontSelectionItem( } } } + else -> null }, applyPaddings = false, diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt index c096dd80b9..fb061f458f 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/GeneralPreferences.kt @@ -238,6 +238,7 @@ private fun NotificationDotColorContrastWarnings( is ColorOption.WallpaperPrimary, is ColorOption.Default, -> true + else -> false } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/LauncherPopupPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/LauncherPopupPreference.kt index 21ce51cd70..295fc7d13a 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/LauncherPopupPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/LauncherPopupPreference.kt @@ -156,18 +156,21 @@ private fun LauncherPopupPreview(optionsList: List) { val shape = when { isSingleItem -> CircleShape + isFirst -> RoundedCornerShape( clipRadius.topStart, clipRadius.topEnd, defaultCorner, defaultCorner, ) + isLast -> RoundedCornerShape( defaultCorner, defaultCorner, clipRadius.bottomStart, clipRadius.bottomEnd, ) + else -> RoundedCornerShape(defaultCorner) } diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt index bba44fd307..9b32fcb241 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/SmartspacePreferences.kt @@ -81,9 +81,11 @@ fun SmartspacePreferences( LawnchairSmartspace -> { LawnchairSmartspaceSettings(smartspaceProvider) } + Smartspacer -> { SmartspacerSettings() } + else -> {} } } diff --git a/lawnchair/src/app/lawnchair/util/Compatibility.kt b/lawnchair/src/app/lawnchair/util/Compatibility.kt index 4052a92006..253651c1eb 100644 --- a/lawnchair/src/app/lawnchair/util/Compatibility.kt +++ b/lawnchair/src/app/lawnchair/util/Compatibility.kt @@ -10,8 +10,11 @@ val isOnePlusStock = checkOnePlusStock() private fun checkOnePlusStock(): Boolean = when { getSystemProperty("ro.rom.version", "") .contains(Regex("Oxygen OS|Hydrogen OS|O2_BETA|H2_BETA")) -> true + getSystemProperty("ro.oxygen.version", "").isNotEmpty() -> true + getSystemProperty("ro.hydrogen.version", "").isNotEmpty() -> true + else -> false } diff --git a/lawnchair/src/app/lawnchair/util/FormatterUtils.kt b/lawnchair/src/app/lawnchair/util/FormatterUtils.kt index c384e6c04d..87081311ee 100644 --- a/lawnchair/src/app/lawnchair/util/FormatterUtils.kt +++ b/lawnchair/src/app/lawnchair/util/FormatterUtils.kt @@ -24,30 +24,37 @@ fun formatShortElapsedTime(context: Context, millis: Long): String? { val roundedDays = duration.toDouble(DurationUnit.DAYS).round() measureFormat.format(Measure(roundedDays, MeasureUnit.DAY)) } + days >= 2 || days > 0 && hours == 0 -> { val roundedDays = duration.toDouble(DurationUnit.DAYS).round() measureFormat.format(Measure(roundedDays, MeasureUnit.DAY)) } + days > 0 -> measureFormat.formatMeasures( Measure(days, MeasureUnit.DAY), Measure(hours, MeasureUnit.HOUR), ) + hours >= 2 || hours > 0 && minutes == 0 -> { val roundedHours = duration.toDouble(DurationUnit.HOURS).round() measureFormat.format(Measure(roundedHours, MeasureUnit.HOUR)) } + hours > 0 -> measureFormat.formatMeasures( Measure(hours, MeasureUnit.HOUR), Measure(minutes, MeasureUnit.MINUTE), ) + minutes >= 2 || minutes > 0 && seconds == 0 -> { val roundedMinutes = duration.toDouble(DurationUnit.MINUTES).round() measureFormat.format(Measure(roundedMinutes, MeasureUnit.MINUTE)) } + minutes > 0 -> measureFormat.formatMeasures( Measure(minutes, MeasureUnit.MINUTE), Measure(seconds, MeasureUnit.SECOND), ) + else -> measureFormat.format(Measure(seconds, MeasureUnit.SECOND)) } } diff --git a/lawnchair/src/app/lawnchair/util/SmartBorder.kt b/lawnchair/src/app/lawnchair/util/SmartBorder.kt index 3944d0e64b..6ad708315b 100644 --- a/lawnchair/src/app/lawnchair/util/SmartBorder.kt +++ b/lawnchair/src/app/lawnchair/util/SmartBorder.kt @@ -221,6 +221,7 @@ fun cutOutline(outline: Outline, height: Float, cutTop: Boolean, cutBottom: Bool CornerRadius.Zero, ), ) + is Outline.Rounded -> Outline.Rounded( RoundRect( cutRect(outline.roundRect.boundingRect, height, cutTop, cutBottom), @@ -230,6 +231,7 @@ fun cutOutline(outline: Outline, height: Float, cutTop: Boolean, cutBottom: Bool outline.roundRect.bottomRightCornerRadius, ), ) + else -> outline } } diff --git a/lawnchair/src/app/lawnchair/views/FullScreenOverlayView.kt b/lawnchair/src/app/lawnchair/views/FullScreenOverlayView.kt index f11151035b..16584167d0 100644 --- a/lawnchair/src/app/lawnchair/views/FullScreenOverlayView.kt +++ b/lawnchair/src/app/lawnchair/views/FullScreenOverlayView.kt @@ -209,11 +209,13 @@ fun Activity.showFullScreenOverlay( overlayView.animateOut(durationOut, onOverlayReady) } } + FullScreenOverlayMode.SUCK_IN -> { overlayView.suckAnimation(durationOut) { onOverlayReady() } } + FullScreenOverlayMode.NONE -> { targetRootView?.removeView(overlayView) onOverlayReady() diff --git a/lawnchair/src/com/android/systemui/monet/ColorScheme.kt b/lawnchair/src/com/android/systemui/monet/ColorScheme.kt index 1484729506..3a53c60708 100644 --- a/lawnchair/src/com/android/systemui/monet/ColorScheme.kt +++ b/lawnchair/src/com/android/systemui/monet/ColorScheme.kt @@ -445,9 +445,11 @@ class ColorScheme( degrees < 0 -> { (degrees % 360) + 360 } + degrees >= 360 -> { degrees % 360 } + else -> { degrees }