mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Show icons in Grayscale in the dark theme
This commit is contained in:
parent
ded2c780e5
commit
140f387c41
3 changed files with 18 additions and 8 deletions
|
@ -13,10 +13,7 @@ import android.widget.PopupMenu
|
|||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.finnmglas.launcher.R
|
||||
import com.finnmglas.launcher.extern.FontAwesome
|
||||
import com.finnmglas.launcher.extern.REQUEST_CHOOSE_APP
|
||||
import com.finnmglas.launcher.extern.REQUEST_UNINSTALL
|
||||
import com.finnmglas.launcher.extern.openAppSettings
|
||||
import com.finnmglas.launcher.extern.*
|
||||
import com.finnmglas.launcher.intendedChoosePause
|
||||
|
||||
class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forApp: String?):
|
||||
|
@ -63,6 +60,8 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp
|
|||
viewHolder.textView.text = appLabel
|
||||
viewHolder.img.setImageDrawable(appIcon)
|
||||
|
||||
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
|
||||
|
||||
viewHolder.menuDots.setOnClickListener{ //creating a popup menu
|
||||
|
||||
val popup = PopupMenu(activity, viewHolder.menuDots)
|
||||
|
|
|
@ -7,10 +7,7 @@ import android.content.DialogInterface
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BlendMode
|
||||
import android.graphics.BlendModeColorFilter
|
||||
import android.graphics.Color
|
||||
import android.graphics.*
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
|
@ -18,10 +15,12 @@ import android.provider.Settings
|
|||
import android.view.View
|
||||
import android.view.animation.*
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import com.finnmglas.launcher.R
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
/** Variables for all of the app */
|
||||
var upApp = ""
|
||||
var downApp = ""
|
||||
|
@ -345,3 +344,12 @@ fun manipulateColor(color: Int, factor: Float): Int {
|
|||
b.coerceAtMost(255)
|
||||
)
|
||||
}
|
||||
|
||||
// Taken from: https://stackoverflow.com/a/30340794/12787264
|
||||
fun transformGrayscale(imageView: ImageView){
|
||||
val matrix = ColorMatrix()
|
||||
matrix.setSaturation(0f)
|
||||
|
||||
val filter = ColorMatrixColorFilter(matrix)
|
||||
imageView.colorFilter = filter
|
||||
}
|
|
@ -51,6 +51,9 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
try {
|
||||
viewHolder.img.setImageDrawable(activity.packageManager.getApplicationIcon(content.toString()))
|
||||
viewHolder.img.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||
|
||||
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
|
||||
|
||||
viewHolder.removeAction.setOnClickListener{
|
||||
val sharedPref = activity.getSharedPreferences(
|
||||
activity.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||
|
|
Loading…
Add table
Reference in a new issue