Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhanghai/appiconloader
Android app icon loader from AOSP iconloaderlib
https://github.com/zhanghai/appiconloader
android android-icon android-library image-loader imageloader
Last synced: about 1 hour ago
JSON representation
Android app icon loader from AOSP iconloaderlib
- Host: GitHub
- URL: https://github.com/zhanghai/appiconloader
- Owner: zhanghai
- License: apache-2.0
- Created: 2020-03-28T05:22:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-03T23:33:29.000Z (over 2 years ago)
- Last Synced: 2025-01-31T00:08:59.459Z (8 days ago)
- Topics: android, android-icon, android-library, image-loader, imageloader
- Language: Java
- Homepage: https://play.google.com/store/apps/details?id=me.zhanghai.android.appiconloader.sample
- Size: 735 KB
- Stars: 166
- Watchers: 8
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# AppIconLoader
[![Android CI status](https://github.com/zhanghai/AppIconLoader/workflows/Android%20CI/badge.svg)](https://github.com/zhanghai/AppIconLoader/actions) [![GitHub release](https://img.shields.io/github/v/release/zhanghai/AppIconLoader)](https://github.com/zhanghai/AppIconLoader/releases) [![License](https://img.shields.io/github/license/zhanghai/AppIconLoader?color=blue)](LICENSE)
Android app icon loader from AOSP [iconloaderlib](https://android.googlesource.com/platform/frameworks/libs/systemui/+/refs/heads/master/iconloaderlib/), with optional Glide and Coil integration.
This is not an officially supported Google product.
## Why AppIconLoader?
Because [`PackageManager.getApplicationIcon()`](https://developer.android.com/reference/android/content/pm/PackageManager#getApplicationIcon(android.content.pm.ApplicationInfo)) (or [`PackageItemInfo.loadIcon()`](https://developer.android.com/reference/android/content/pm/PackageItemInfo#loadIcon(android.content.pm.PackageManager))) just doesn't work well with [adaptive icons](https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive). Non-adaptive icons usually have some shadow baked in (it's the recommended behavior), however adaptive icons never contain a shadow themselves, so we'll need to manually add the shadow or icons with a white background will just blend into our app's own background.
This library packaged the AOSP iconloaderlib for loading app icons, which has proper shadow and badging logic, and added easy integration with Glide and Coil.
Meanwhile, by passing `true` for the `shrinkNonAdaptiveIcons` parameter, this library can also synthesize adaptive icons for apps that don't have it.
## Preview
[Sample APK](https://github.com/zhanghai/AppIconLoader/releases/latest/download/sample-release.apk)
## Integration
Gradle:
```gradle
// For using with Glide.
implementation 'me.zhanghai.android.appiconloader:appiconloader-glide:1.5.0'
// For using with Coil.
implementation 'me.zhanghai.android.appiconloader:appiconloader-coil:1.5.0'
// For using AppIconLoader directly.
implementation 'me.zhanghai.android.appiconloader:appiconloader:1.5.0'
// For using iconloaderlib directly.
implementation 'me.zhanghai.android.appiconloader:appiconloader-iconloaderlib:1.5.0'
```## Usage
### Glide integration
See [Glide's documentation on registering a `ModuleLoader`](https://bumptech.github.io/glide/tut/custom-modelloader.html#registering-our-modelloader-with-glide).
Inside your implementation of `AppGlideModule.registerComponents()`, you can have something like the following code fragment:
```java
int iconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size);
registry.prepend(PackageInfo.class, Bitmap.class, new AppIconModelLoader.Factory(iconSize,
false, context));
```See also the sample app's [`AppGlideModule` implementation](sample/src/main/java/me/zhanghai/android/appiconloader/sample/AppGlideModule.java).
After the setup above, Glide will support loading app icons with the app's `PackageInfo`.
```java
GlideApp.with(imageView)
.load(packageInfo)
.into(imageView);
```### Coil integration
```kotlin
val iconSize = context.resources.getDimensionPixelSize(R.dimen.app_icon_size)
Coil.setImageLoader(
ImageLoader.Builder(context)
.components {
add(AppIconKeyer())
add(AppIconFetcher.Factory(iconSize, false, context))
}
.build()
)
```After the setup above, Coil will support loading app icons with the app's `PackageInfo`.
```kotlin
imageView.loadAny(packageInfo)
```### AppIconLoader
[`AppIconLoader`](appiconloader/src/main/java/me/zhanghai/android/appiconloader/AppIconLoader.java) is the API exposed by this library, and you can simply call `AppIconLoader.loadIcon()` to load an app icon. You can also use `AppIconLoader.getIconKey()` to generate a cache key for your loaded icon.
### iconloaderlib
Please refer to [its source code](https://android.googlesource.com/platform/frameworks/libs/systemui/+/refs/heads/master/iconloaderlib/).
## License
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.