show proper hidden icon drawables at the activity

This commit is contained in:
tibbi 2022-10-26 10:16:41 +02:00
parent d1e615f55c
commit 17c3179c47
2 changed files with 21 additions and 5 deletions

View File

@ -1,5 +1,7 @@
package com.simplemobiletools.launcher.activities
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
@ -7,6 +9,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.launcher.R
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
import com.simplemobiletools.launcher.extensions.getColumnCount
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
import com.simplemobiletools.launcher.models.HiddenIcon
import kotlinx.android.synthetic.main.activity_hidden_icons.*
@ -29,10 +32,25 @@ class HiddenIconsActivity : SimpleActivity() {
private fun updateIcons() {
ensureBackgroundThread {
val hiddenIcons = hiddenIconsDB.getHiddenIcons().toMutableList() as ArrayList<HiddenIcon>
HiddenIconsAdapter(this, hiddenIcons) {
val intent = Intent(Intent.ACTION_MAIN, null)
intent.addCategory(Intent.CATEGORY_LAUNCHER)
}.apply {
manage_hidden_icons_list.adapter = this
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
for (info in list) {
val componentInfo = info.activityInfo.applicationInfo
val packageName = componentInfo.packageName
val activityName = info.activityInfo.name
hiddenIcons.firstOrNull { it.getIconIdentifier() == "$packageName/$activityName" }?.apply {
drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName)
}
}
runOnUiThread {
HiddenIconsAdapter(this, hiddenIcons) {
}.apply {
manage_hidden_icons_list.adapter = this
}
}
}
}

View File

@ -11,7 +11,6 @@ import com.bumptech.glide.request.transition.DrawableCrossFadeFactory
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.portrait
import com.simplemobiletools.commons.extensions.realScreenSize
import com.simplemobiletools.commons.helpers.mydebug
import com.simplemobiletools.launcher.R
import com.simplemobiletools.launcher.activities.SimpleActivity
import com.simplemobiletools.launcher.models.HiddenIcon
@ -50,7 +49,6 @@ class HiddenIconsAdapter(
}
)
mydebug("size ${activity.realScreenSize.x}")
val iconWidth = activity.realScreenSize.x / currentColumnCount
iconPadding = (iconWidth * 0.1f).toInt()
}