show proper hidden icon drawables at the activity
This commit is contained in:
parent
d1e615f55c
commit
17c3179c47
|
@ -1,5 +1,7 @@
|
||||||
package com.simplemobiletools.launcher.activities
|
package com.simplemobiletools.launcher.activities
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
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.R
|
||||||
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
import com.simplemobiletools.launcher.adapters.HiddenIconsAdapter
|
||||||
import com.simplemobiletools.launcher.extensions.getColumnCount
|
import com.simplemobiletools.launcher.extensions.getColumnCount
|
||||||
|
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||||
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
import com.simplemobiletools.launcher.extensions.hiddenIconsDB
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
import kotlinx.android.synthetic.main.activity_hidden_icons.*
|
import kotlinx.android.synthetic.main.activity_hidden_icons.*
|
||||||
|
@ -29,10 +32,25 @@ class HiddenIconsActivity : SimpleActivity() {
|
||||||
private fun updateIcons() {
|
private fun updateIcons() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val hiddenIcons = hiddenIconsDB.getHiddenIcons().toMutableList() as ArrayList<HiddenIcon>
|
val hiddenIcons = hiddenIconsDB.getHiddenIcons().toMutableList() as ArrayList<HiddenIcon>
|
||||||
HiddenIconsAdapter(this, hiddenIcons) {
|
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||||
|
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
|
|
||||||
}.apply {
|
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
||||||
manage_hidden_icons_list.adapter = this
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.bumptech.glide.request.transition.DrawableCrossFadeFactory
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.portrait
|
import com.simplemobiletools.commons.extensions.portrait
|
||||||
import com.simplemobiletools.commons.extensions.realScreenSize
|
import com.simplemobiletools.commons.extensions.realScreenSize
|
||||||
import com.simplemobiletools.commons.helpers.mydebug
|
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.SimpleActivity
|
import com.simplemobiletools.launcher.activities.SimpleActivity
|
||||||
import com.simplemobiletools.launcher.models.HiddenIcon
|
import com.simplemobiletools.launcher.models.HiddenIcon
|
||||||
|
@ -50,7 +49,6 @@ class HiddenIconsAdapter(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
mydebug("size ${activity.realScreenSize.x}")
|
|
||||||
val iconWidth = activity.realScreenSize.x / currentColumnCount
|
val iconWidth = activity.realScreenSize.x / currentColumnCount
|
||||||
iconPadding = (iconWidth * 0.1f).toInt()
|
iconPadding = (iconWidth * 0.1f).toInt()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue