Skip to content

Commit 02eed07

Browse files
fs-sifatiamrasel
andauthored
Add icon pack support in favorite apps shortcut (#113)
* Add icon pack support in favorite apps shortcut * minor improvements --------- Co-authored-by: fs-sifat <125657944+fs-sifat@users.noreply.github.com> Co-authored-by: Md Rasel Hossain <77199897+iamrasel@users.noreply.github.com>
1 parent 4fd4a79 commit 02eed07

File tree

1 file changed

+13
-4
lines changed
  • app/src/main/kotlin/rasel/lunar/launcher/helpers

1 file changed

+13
-4
lines changed

app/src/main/kotlin/rasel/lunar/launcher/helpers/UniUtils.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ import androidx.core.view.isVisible
3939
import com.google.android.material.imageview.ShapeableImageView
4040
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
4141
import rasel.lunar.launcher.R
42+
import rasel.lunar.launcher.apps.IconPackManager.Companion.getDrawableIconForPackage
4243
import rasel.lunar.launcher.helpers.Constants.Companion.ACCESSIBILITY_SERVICE_LOCK_SCREEN
4344
import rasel.lunar.launcher.helpers.Constants.Companion.AUTHENTICATOR_TYPE
4445
import rasel.lunar.launcher.helpers.Constants.Companion.DEFAULT_ICON_SIZE
46+
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APPS_LAYOUT
4547
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_APP_NO_
4648
import rasel.lunar.launcher.helpers.Constants.Companion.KEY_ICON_SIZE
4749
import rasel.lunar.launcher.helpers.Constants.Companion.MAX_FAVORITE_APPS
@@ -192,6 +194,7 @@ internal class UniUtils {
192194
/* favorite apps */
193195
private fun populateFavApps(context: Context, linearLayoutCompat: LinearLayoutCompat) {
194196
val prefsFavApps = context.getSharedPreferences(PREFS_FAVORITE_APPS, 0)
197+
val useIconPack = context.getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_APPS_LAYOUT, 0) != 0
195198
if (linearLayoutCompat.isVisible || prefsFavApps.all.toString().length < 3) {
196199
linearLayoutCompat.visibility = View.GONE
197200
} else {
@@ -208,12 +211,18 @@ internal class UniUtils {
208211
layoutParams = LinearLayoutCompat.LayoutParams(
209212
(iconSize * resources.displayMetrics.density).toInt(),
210213
(iconSize * resources.displayMetrics.density).toInt(), 1F)
211-
}.let {
212-
it.setImageDrawable(context.packageManager.getApplicationIcon(packageName))
213-
it.setOnClickListener {
214+
}.let { sImageView ->
215+
context.packageManager.getApplicationIcon(packageName).let { defaultIcon ->
216+
sImageView.setImageDrawable(
217+
if (context.getSharedPreferences(PREFS_SETTINGS, 0).getInt(KEY_APPS_LAYOUT, 0) != 0)
218+
getDrawableIconForPackage(packageName, defaultIcon)
219+
else defaultIcon
220+
)
221+
}
222+
sImageView.setOnClickListener {
214223
context.startActivity(context.packageManager.getLaunchIntentForPackage(packageName))
215224
}
216-
linearLayoutCompat.addView(it)
225+
linearLayoutCompat.addView(sImageView)
217226
}
218227
} catch (nameNotFoundException: PackageManager.NameNotFoundException) {
219228
context.getSharedPreferences(PREFS_FAVORITE_APPS, 0)

0 commit comments

Comments
 (0)