Commit 2dcff919 authored by Amit Kumar's avatar Amit Kumar

Fix #29, #33

parents 331fcf0b 9f9d6103
package org.indin.blisslaunchero.framework;
import org.indin.blisslaunchero.framework.customviews.AdaptiveIconDrawableCompat;
import org.indin.blisslaunchero.framework.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
......@@ -13,6 +9,10 @@ import android.graphics.drawable.Drawable;
import android.support.v4.content.res.ResourcesCompat;
import android.util.Log;
import org.indin.blisslaunchero.framework.customviews.AdaptiveIconDrawableCompat;
import org.indin.blisslaunchero.framework.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;
/**
* Created by falcon on 19/4/18.
*/
......@@ -43,7 +43,7 @@ public class AdaptiveIconProvider {
XmlResourceParser manifestParser;
String iconName = null;
int iconId;
int iconId = 0;
try {
manifestParser = assetManager.openXmlResourceParser("AndroidManifest.xml");
int eventType;
......@@ -52,18 +52,20 @@ public class AdaptiveIconProvider {
while ((eventType = manifestParser.nextToken()) != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && manifestParser.getName().equals(
matcher)) {
iconId = manifestParser.getAttributeResourceValue(
ANDROID_SCHEMA, "icon",
0);
for (int i = 0; i < manifestParser.getAttributeCount(); i++) {
if (manifestParser.getAttributeName(i).equalsIgnoreCase("icon")) {
iconId = Integer.parseInt(
manifestParser.getAttributeValue(i).substring(1));
break;
}
}
if (iconId != 0) {
iconName = resources.getResourceName(iconId);
if (iconName.contains("/")) {
iconName = iconName.split("/")[1];
}
break;
}
if (iconId == 0) {
} else {
matcher = "activity";
}
}
......@@ -73,15 +75,21 @@ public class AdaptiveIconProvider {
}
XmlResourceParser parser = null;
if (iconId != 0) {
parser = resources.getXml(iconId);
}
for (int dir = 0; dir < IC_DIRS.length && parser == null; dir++) {
for (int config = 0; config < IC_CONFIGS.length && parser == null; config++) {
for (String name : iconName != null && !iconName.equals("ic_launcher")
? new String[]{iconName, "ic_launcher"} : new String[]{"ic_launcher"}) {
try {
parser = assetManager.openXmlResourceParser(
"res/" + IC_DIRS[dir] + IC_CONFIGS[config] + "/" + name
+ ".xml");
String path = "res/" + IC_DIRS[dir] + IC_CONFIGS[config] + "/" + name
+ ".xml";
Log.i(TAG, "path: " + path);
parser = assetManager.openXmlResourceParser(path);
} catch (Exception e) {
e.printStackTrace();
continue;
}
......@@ -96,7 +104,8 @@ public class AdaptiveIconProvider {
if (parser != null) {
int event;
while ((event = parser.getEventType()) != XmlPullParser.END_DOCUMENT) {
Log.i(TAG, packageName + ":parserName: " + parser.getName()+" "+parser.getAttributeCount());
Log.i(TAG, packageName + ":parserName: " + parser.getName() + " "
+ parser.getAttributeCount());
if (event == XmlPullParser.START_TAG) {
switch (parser.getName()) {
case "background":
......
......@@ -182,6 +182,7 @@ public class IconsHandler {
systemIcon = new AdaptiveIconProvider().load(ctx, componentName.getPackageName());
if(systemIcon != null){
Log.i(TAG, "getDrawableIconForPackage: herrrre");
cacheStoreDrawable(componentName.toString(), systemIcon);
return systemIcon;
}
......
......@@ -30,6 +30,9 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
if (launchIntent == null) {//for some plugin app
return;
}
BlissLauncher.getApplication(ctx).resetIconsHandler();
AppAddEvent appAddEvent = new AppAddEvent();
appAddEvent.packageName = packageName;
EventBus.getDefault().post(appAddEvent);
......@@ -43,6 +46,8 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
launchIntent.getComponent(), user);
}
BlissLauncher.getApplication(ctx).resetIconsHandler();
AppChangeEvent appChangeEvent = new AppChangeEvent();
appChangeEvent.packageName = packageName;
EventBus.getDefault().post(appChangeEvent);
......@@ -56,8 +61,6 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
EventBus.getDefault().post(appRemoveEvent);
}
BlissLauncher.getApplication(ctx).resetIconsHandler();
// Reload application list
final AppProvider provider = BlissLauncher.getApplication(ctx).getAppProvider();
if (provider != null) {
......
......@@ -44,7 +44,6 @@ import android.os.Bundle;
import android.os.UserManager;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.util.Log;
public class AppUtils {
......@@ -84,7 +83,6 @@ public class AppUtils {
Drawable appIcon = iconsHandler.getDrawableIconForPackage(
activityInfo.getComponentName(), user);
Log.i(TAG, "loadAll: here");
boolean isSystemApp = false;
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
......
......@@ -33,8 +33,6 @@ subprojects {
spotless {
java {
target '**/*.java'
importOrder 'java', 'javax', 'org', 'com', 'com.diffplug', '' // A sequence of package names
removeUnusedImports() // removes any unused imports
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment