mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
fix: Revert smartspace text color changes
This commit reverts1912177c58and0363d8eacbdue 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:
@@ -1,24 +1,17 @@
|
|||||||
package app.lawnchair.smartspace
|
package app.lawnchair.smartspace
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.viewpager.widget.PagerAdapter
|
import androidx.viewpager.widget.PagerAdapter
|
||||||
import app.lawnchair.preferences2.PreferenceManager2.Companion.getInstance
|
|
||||||
import app.lawnchair.smartspace.model.SmartspaceTarget
|
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.R
|
||||||
import com.android.launcher3.util.Themes
|
import com.android.launcher3.util.Themes
|
||||||
import com.patrykmichalik.opto.core.firstBlocking
|
|
||||||
|
|
||||||
class CardPagerAdapter(context: Context) : PagerAdapter() {
|
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 currentTextColor = Themes.getAttrColor(context, R.attr.workspaceTextColor)
|
||||||
private val targets = mutableListOf<SmartspaceTarget>()
|
private val targets = mutableListOf<SmartspaceTarget>()
|
||||||
private var smartspaceTargets = targets
|
private var smartspaceTargets = targets
|
||||||
@@ -78,9 +71,7 @@ class CardPagerAdapter(context: Context) : PagerAdapter() {
|
|||||||
val target = smartspaceTargets[viewHolder.position]
|
val target = smartspaceTargets[viewHolder.position]
|
||||||
val card = viewHolder.card
|
val card = viewHolder.card
|
||||||
card.setSmartspaceTarget(target, smartspaceTargets.size > 1)
|
card.setSmartspaceTarget(target, smartspaceTargets.size > 1)
|
||||||
val isDark = isWallpaperDark(card.context)
|
card.setPrimaryTextColor(currentTextColor)
|
||||||
val dynamicColors = if (isDark) Color.WHITE else Color.BLACK
|
|
||||||
card.setPrimaryTextColor(if (colorMode == ColorMode.AUTO) dynamicColors else currentTextColor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCount() = smartspaceTargets.size
|
override fun getCount() = smartspaceTargets.size
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user