Skip to content

Commit e92a76b

Browse files
authored
Add badge icon for work profile apps (pull request #342)
1 parent ee90034 commit e92a76b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/com/vincent_falzon/discreetlauncher/core/ApplicationsList.java

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.content.SharedPreferences ;
2828
import android.content.pm.LauncherActivityInfo ;
2929
import android.content.pm.LauncherApps ;
30+
import android.content.pm.PackageManager ;
3031
import android.content.res.Resources ;
3132
import android.graphics.Bitmap ;
3233
import android.graphics.Canvas ;
@@ -110,6 +111,7 @@ public void update(Context context)
110111
// Retrieve the list of user profiles
111112
UserManager userManager = (UserManager)context.getSystemService(Context.USER_SERVICE) ;
112113
List<UserHandle> userProfiles = userManager.getUserProfiles() ;
114+
PackageManager apkManager = context.getPackageManager() ;
113115

114116
// Browse all user profiles
115117
Drawable icon ;
@@ -137,6 +139,11 @@ public void update(Context context)
137139
if(color_tint == 0) icon = activity.getIcon(0) ;
138140
else icon = applyColorTint(resources, activity.getIcon(0), color_tint) ;
139141
}
142+
143+
// Add a badge to the chosen icon if the app is in a work profile
144+
if(userHandle != null) icon = apkManager.getUserBadgedIcon(icon, profile) ;
145+
146+
// Resize the icon to the user-defined size
140147
icon.setBounds(0, 0, icon_size, icon_size) ;
141148

142149
// Check if the application is the launcher to provide menu access using its icon

0 commit comments

Comments
 (0)