fix: Revert smartspace text color changes

This commit reverts 1912177c58 and 0363d8eacb due to issues regarding the contrast checker and text color, causing accessibility issues. A future option to manually change the text color to something else should be considered instead.

Fixes #6073
Fixes #6080
Fixes #6152
This commit is contained in:
SuperDragonXD
2025-12-20 21:25:53 +08:00
parent a96751af7e
commit e614c19a4e
2 changed files with 1 additions and 26 deletions

View File

@@ -1,24 +1,17 @@
package app.lawnchair.smartspace
import android.content.Context
import android.graphics.Color
import android.util.SparseArray
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import app.lawnchair.preferences2.PreferenceManager2.Companion.getInstance
import app.lawnchair.smartspace.model.SmartspaceTarget
import app.lawnchair.theme.color.ColorMode
import app.lawnchair.util.isWallpaperDark
import com.android.launcher3.R
import com.android.launcher3.util.Themes
import com.patrykmichalik.opto.core.firstBlocking
class CardPagerAdapter(context: Context) : PagerAdapter() {
private val preferenceManager2 = getInstance(context)
val colorMode: ColorMode = preferenceManager2.workspaceTextColor.firstBlocking()
private val currentTextColor = Themes.getAttrColor(context, R.attr.workspaceTextColor)
private val targets = mutableListOf<SmartspaceTarget>()
private var smartspaceTargets = targets
@@ -78,9 +71,7 @@ class CardPagerAdapter(context: Context) : PagerAdapter() {
val target = smartspaceTargets[viewHolder.position]
val card = viewHolder.card
card.setSmartspaceTarget(target, smartspaceTargets.size > 1)
val isDark = isWallpaperDark(card.context)
val dynamicColors = if (isDark) Color.WHITE else Color.BLACK
card.setPrimaryTextColor(if (colorMode == ColorMode.AUTO) dynamicColors else currentTextColor)
card.setPrimaryTextColor(currentTextColor)
}
override fun getCount() = smartspaceTargets.size

View File

@@ -1,16 +0,0 @@
package app.lawnchair.util
import android.content.Context
import android.graphics.Color
import app.lawnchair.wallpaper.WallpaperColorsCompat
import app.lawnchair.wallpaper.WallpaperManagerCompat
fun isWallpaperDark(context: Context): Boolean {
val wallpaperManager = WallpaperManagerCompat.INSTANCE.get(context)
val colors: WallpaperColorsCompat? = wallpaperManager.wallpaperColors
return colors?.primaryColor?.let { argb ->
val darkness =
1 - (0.299 * Color.red(argb) + 0.587 * Color.green(argb) + 0.114 * Color.blue(argb)) / 255
darkness >= 0.5
} ?: false
}