Skip to content

Commit 4381ae9

Browse files
committed
Fix icon mapping for packs using flattened strings
Some icon packs define components in appfilter.xml using the standard flattened `ComponentName` format (e.g. "com.example/.MainActivity") instead of the "ComponentInfo{...}" format. This caused icon lookups to fail due to mismatched keys. This change normalizes all component keys using `ComponentName`'s `flattenToShortString()` and parses both formats in appfilter.xml, ensuring compatibility with a wider range of icon packs.
1 parent 1d4cd7a commit 4381ae9

File tree

1 file changed

+25
-3
lines changed
  • app/src/main/java/de/markusfisch/android/pielauncher/graphics

1 file changed

+25
-3
lines changed

app/src/main/java/de/markusfisch/android/pielauncher/graphics/IconPack.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,22 @@ public void loadComponentAndDrawableNames(
7474
"item".equals(parser.getName())) {
7575
String component = parser.getAttributeValue(
7676
null, "component");
77+
if (component == null) {
78+
component = parser.getAttributeValue(
79+
null, "activity");
80+
}
81+
if (component == null || component.isEmpty()) {
82+
continue;
83+
}
7784
String drawable = parser.getAttributeValue(
7885
null, "drawable");
79-
if (component != null && !component.isEmpty() &&
80-
drawable != null && !drawable.isEmpty()) {
86+
if (drawable == null || drawable.isEmpty()) {
87+
continue;
88+
}
89+
ComponentName cn = parseComponent(component);
90+
if (cn != null) {
91+
map.put(cn.flattenToShortString(), drawable);
92+
} else {
8193
map.put(component, drawable);
8294
}
8395
}
@@ -226,11 +238,21 @@ public Drawable getIcon(ComponentName componentName) {
226238
return null;
227239
}
228240
drawableName = componentToDrawableNames.get(
229-
componentName.toString());
241+
componentName.flattenToShortString());
230242
}
231243
return selectedPack.getDrawable(drawableName);
232244
}
233245

246+
private static ComponentName parseComponent(String s) {
247+
if (s == null) {
248+
return null;
249+
}
250+
if (s.startsWith("ComponentInfo{") && s.endsWith("}")) {
251+
s = s.substring(14, s.length() - 1);
252+
}
253+
return ComponentName.unflattenFromString(s);
254+
}
255+
234256
private static List<ResolveInfo> queryIntentActivities(
235257
PackageManager pm,
236258
Intent intent) {

0 commit comments

Comments
 (0)