mirror of
https://github.com/jrpie/Launcher.git
synced 2025-04-11 14:54:31 +02:00
fix problem which switching from grayscale icons back to normal
Some checks are pending
Android CI / build (push) Waiting to run
Some checks are pending
Android CI / build (push) Waiting to run
This commit is contained in:
parent
e02ca4091f
commit
3597baee1f
4 changed files with 16 additions and 14 deletions
|
@ -194,7 +194,7 @@ fun getApps(
|
||||||
loadList.add(detailedAppInfo)
|
loadList.add(detailedAppInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadList.sortBy { it.getCustomLabel(context).toString() }
|
loadList.sortBy { it.getCustomLabel(context) }
|
||||||
|
|
||||||
var end = System.currentTimeMillis()
|
var end = System.currentTimeMillis()
|
||||||
Log.i(LOG_TAG, "${loadList.size} apps loaded (${end - start}ms)")
|
Log.i(LOG_TAG, "${loadList.size} apps loaded (${end - start}ms)")
|
||||||
|
|
|
@ -27,10 +27,14 @@ fun View.blink(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taken from: https://stackoverflow.com/a/30340794/12787264
|
// Taken from: https://stackoverflow.com/a/30340794/12787264
|
||||||
fun ImageView.transformGrayscale() {
|
fun ImageView.transformGrayscale(grayscale: Boolean) {
|
||||||
this.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
this.colorFilter = if (grayscale) {
|
||||||
setSaturation(0f)
|
ColorMatrixColorFilter(ColorMatrix().apply {
|
||||||
})
|
setSaturation(0f)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class AppsRecyclerAdapter(
|
||||||
|
|
||||||
private val apps = (activity.applicationContext as Application).apps
|
private val apps = (activity.applicationContext as Application).apps
|
||||||
private val appsListDisplayed: MutableList<AbstractDetailedAppInfo> = mutableListOf()
|
private val appsListDisplayed: MutableList<AbstractDetailedAppInfo> = mutableListOf()
|
||||||
|
private val grayscale = LauncherPreferences.theme().monochromeIcons()
|
||||||
|
|
||||||
// temporarily disable auto launch
|
// temporarily disable auto launch
|
||||||
var disableAutoLaunch: Boolean = false
|
var disableAutoLaunch: Boolean = false
|
||||||
|
@ -79,20 +80,19 @@ class AppsRecyclerAdapter(
|
||||||
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
||||||
var appLabel = appsListDisplayed[i].getCustomLabel(activity)
|
var appLabel = appsListDisplayed[i].getCustomLabel(activity)
|
||||||
|
|
||||||
|
val appIcon = appsListDisplayed[i].getIcon(activity)
|
||||||
|
|
||||||
|
viewHolder.img.transformGrayscale(grayscale)
|
||||||
|
viewHolder.img.setImageDrawable(appIcon.constantState?.newDrawable() ?: appIcon)
|
||||||
|
|
||||||
if (layout.useBadgedText) {
|
if (layout.useBadgedText) {
|
||||||
appLabel = activity.packageManager.getUserBadgedLabel(
|
appLabel = activity.packageManager.getUserBadgedLabel(
|
||||||
appLabel,
|
appLabel,
|
||||||
appsListDisplayed[i].getUser(activity)
|
appsListDisplayed[i].getUser(activity)
|
||||||
).toString()
|
).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
val appIcon = appsListDisplayed[i].getIcon(activity)
|
|
||||||
|
|
||||||
viewHolder.textView.text = appLabel
|
viewHolder.textView.text = appLabel
|
||||||
viewHolder.img.setImageDrawable(appIcon)
|
|
||||||
|
|
||||||
if (LauncherPreferences.theme().monochromeIcons())
|
|
||||||
viewHolder.img.transformGrayscale()
|
|
||||||
|
|
||||||
// decide when to show the options popup menu about
|
// decide when to show the options popup menu about
|
||||||
if (intention == ListActivity.ListActivityIntention.VIEW) {
|
if (intention == ListActivity.ListActivityIntention.VIEW) {
|
||||||
|
|
|
@ -143,9 +143,7 @@ class ActionsRecyclerAdapter(val activity: Activity) :
|
||||||
val description = gesture.getDescription(activity)
|
val description = gesture.getDescription(activity)
|
||||||
viewHolder.descriptionTextView.text = description
|
viewHolder.descriptionTextView.text = description
|
||||||
|
|
||||||
|
viewHolder.img.transformGrayscale(LauncherPreferences.theme().monochromeIcons())
|
||||||
if (LauncherPreferences.theme().monochromeIcons())
|
|
||||||
viewHolder.img.transformGrayscale()
|
|
||||||
|
|
||||||
updateViewHolder(gesture, viewHolder)
|
updateViewHolder(gesture, viewHolder)
|
||||||
viewHolder.img.setOnClickListener { chooseApp(gesture) }
|
viewHolder.img.setOnClickListener { chooseApp(gesture) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue