Skip to content

Use IconPackManager to easily read resources from icon packs, if you are developing desktop applications, using this library will be a great help!

License

Notifications You must be signed in to change notification settings

iamverycute/IconPackManager

 
 

Repository files navigation

IconPackManager

Maven Central API: 21+ (shields.io) License: Apache-2.0 (shields.io)

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

Prerequisites

  • SDK Version >= 21
  • kotlin
  • install the custom icon pack Pure Icon Pack or Others you like

Quick Start

  1. Import AAR
dependencies {
    implementation 'com.iamverylovely:IconPackManager:3.5' //release
}
  1. 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)
}

Demo

img0

About

Generating electricity for love.

About

Use IconPackManager to easily read resources from icon packs, if you are developing desktop applications, using this library will be a great help!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 97.0%
  • Batchfile 3.0%