Merge pull request #115 from esensar/fix/floating-menu-icon-colors

Update icon colors in popups to match text color
This commit is contained in:
Tibor Kaputa 2023-09-06 10:41:57 +02:00 committed by GitHub
commit 8fcbc4cb10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -4,13 +4,17 @@ import android.app.Activity
import android.content.ComponentName import android.content.ComponentName
import android.content.Intent import android.content.Intent
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.content.res.ColorStateList
import android.net.Uri import android.net.Uri
import android.provider.Settings import android.provider.Settings
import android.view.ContextThemeWrapper import android.view.ContextThemeWrapper
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
import android.widget.PopupMenu import android.widget.PopupMenu
import androidx.core.view.forEach
import com.google.android.material.color.MaterialColors
import com.simplemobiletools.commons.extensions.getPopupMenuTheme import com.simplemobiletools.commons.extensions.getPopupMenuTheme
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.commons.helpers.isQPlus
import com.simplemobiletools.launcher.R import com.simplemobiletools.launcher.R
@ -77,6 +81,10 @@ fun Activity.handleGridItemPopupMenu(anchorView: View, gridItem: HomeScreenGridI
} }
inflate(R.menu.menu_app_icon) inflate(R.menu.menu_app_icon)
menu.forEach {
val color = MaterialColors.getColor(contextTheme, android.R.attr.textColorPrimary, getProperTextColor())
it.iconTintList = ColorStateList.valueOf(color)
}
menu.findItem(R.id.rename).isVisible = (gridItem.type == ITEM_TYPE_ICON || gridItem.type == ITEM_TYPE_FOLDER) && !isOnAllAppsFragment menu.findItem(R.id.rename).isVisible = (gridItem.type == ITEM_TYPE_ICON || gridItem.type == ITEM_TYPE_FOLDER) && !isOnAllAppsFragment
menu.findItem(R.id.hide_icon).isVisible = gridItem.type == ITEM_TYPE_ICON && isOnAllAppsFragment menu.findItem(R.id.hide_icon).isVisible = gridItem.type == ITEM_TYPE_ICON && isOnAllAppsFragment
menu.findItem(R.id.resize).isVisible = gridItem.type == ITEM_TYPE_WIDGET menu.findItem(R.id.resize).isVisible = gridItem.type == ITEM_TYPE_WIDGET