Quick load icon pack.
Read the icon package resources, unify the size, and crop the original icons if the resources do not contain theme icons
- SDK Version >= 21
- kotlin
- install the custom icon pack Pure Icon Pack or Others you like
- Import AAR
- Gradle or Download IconPackManager
dependencies {
implementation 'com.iamverylovely:IconPackManager:3.5' //release
}
- Code Sample
import com.iamverycute.iconpackmanager.IconPackManager
// IconPackManager
val ipm = IconPackManager(applicationContext)
// Add rules for custom icon
ipm.addRule("com.android.chrome", "browser")
.addRule("com.android.email", "mail") /** Use this method to add rules when you need to specify icons for an application,
parameter 1: package name, parameter 2: keyword (icon resource name) Fuzzy Matching
How to get keywords? see icon pack.apk assets/appfilter.xml
*/
<resources> <!-- appfilter.xml, extract [icon pack].apk, see the assets directory -->
<!-- Get the keyword from the "component" property -->
<item component="ComponentInfo{cn.nubia.browser/com.android.browser.BrowserLauncher}" drawable="browser"/>
<item component="ComponentInfo{com.android.browser/com.android.browser.BrowserActivity}" drawable="browser"/>
<item component="ComponentInfo{com.motorola.camera/com.motorola.camera.Camera}" drawable="camera_2"/>
<item component="ComponentInfo{cn.nubia.deskclock.preset/cn.nubia.deskclock.DeskClock}" drawable="clock"/>
<item component="ComponentInfo{com.android.alarmclock/com.meizu.flyme.alarmclock.DeskClock}" drawable="flyme_clock"/>
<item component="ComponentInfo{com.android.BBKClock/com.android.BBKClock.Timer}" drawable="clock"/>
</resources>
Iterate over this Map(ipm.isSupportedIconPacks()) to get all the icon package names if necessary.
// load icon pack
ipm.isSupportedIconPacks().forEach {
/** If you have more than one icon pack theme installed, you need to exclude it here
filter other icon pack**/
// if (it.value.name != "your icon pack")
//get icon pack name
val iconPackName = it.value.name
//get icon from icon pack
val icon = it.value.loadIcon(applicationInfo)
//if not found icon
if(icon == null)
it.value.iconCutCircle(applicationInfo.loadIcon(packageManager).toBitmap(),scaleF)
}
Generating electricity for love.
- feedback:[email protected]