Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanth committed Jul 24, 2019
1 parent ff1a03b commit f041008
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 96 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Version 3.0

* Feature: Search icons inside iconpacks
* Feature: Posidon Launcher support
* Bug: App Icon size issue on main list
* Bug: Exclude other icon managers on main list
* Bug: Masked icon preview always shows as empty (whitecons etc.,)
*
* Crash report Fixes and various performance improvements

Version 1.3

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId "dev.ukanth.iconmanager"
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 27
versionCode 3000
versionName "3.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
111 changes: 57 additions & 54 deletions app/src/main/java/dev/ukanth/iconmgr/IconPackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public List<IPObj> updateIconPacks(IPObjDao ipObjDao, boolean forceReload, Mater
packageList.add(info.packageName);
}
}
List<ResolveInfo> rinfo = pm.queryIntentActivities(new Intent("com.gau.go.launcherex.theme"), PackageManager.GET_META_DATA);
rinfo.addAll(pm.queryIntentActivities(new Intent("com.novalauncher.THEME"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA));

List<ResolveInfo> rinfo = new ArrayList<>();
for (String intent : IconPackUtil.ICON_INTENTS) {
rinfo.addAll(pm.queryIntentActivities(new Intent(intent), PackageManager.GET_META_DATA));
}
loadIconPack(rinfo, ipObjDao, installedIconPacks);
return installedIconPacks;
}
Expand All @@ -75,12 +75,16 @@ public void insertIconPack(final IPObjDao ipObjDao, final String packageName) {
final PackageManager pm = mContext.getPackageManager();
final IconPackUtil ip = new IconPackUtil();
//detect if it's iconpack or not
List<ResolveInfo> rinfo = pm.queryIntentActivities(new Intent("com.gau.go.launcherex.theme"), PackageManager.GET_META_DATA);
List<ResolveInfo> rinfo = new ArrayList<>();
for (String intent : IconPackUtil.ICON_INTENTS) {
rinfo.addAll(pm.queryIntentActivities(new Intent(intent), PackageManager.GET_META_DATA));
}
/*List<ResolveInfo> rinfo = pm.queryIntentActivities(new Intent("com.gau.go.launcherex.theme"), PackageManager.GET_META_DATA);
rinfo.addAll(pm.queryIntentActivities(new Intent("com.novalauncher.THEME"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("com.teslacoilsw.launcher.THEME"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("com.anddoes.launcher.THEME"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("com.fede.launcher.THEME_ICONPACK"), PackageManager.GET_META_DATA));
rinfo.addAll(pm.queryIntentActivities(new Intent("com.fede.launcher.THEME_ICONPACK"), PackageManager.GET_META_DATA));*/
List<String> excludedPackage = Util.getExcludedPackages();
for (ResolveInfo ri : rinfo) {
if (ri.activityInfo.packageName.equals(packageName) && !excludePackages.contains(packageName)) {
Expand Down Expand Up @@ -108,61 +112,13 @@ public void insertIconPack(final IPObjDao ipObjDao, final String packageName) {
}
}

class ProcessPack implements Callable<IPObj> {
String pkgName;
IPObjDao ipObjDao;
boolean onlyMissed = false;

public ProcessPack(String pkgName, IPObjDao ipObjDao, boolean onlyMissed) {
this.pkgName = pkgName;
this.ipObjDao = ipObjDao;
this.onlyMissed = onlyMissed;
}

@Override
public IPObj call() throws Exception {
IPObj obj = new IPObj();
IconPackUtil ip = new IconPackUtil();
IconAttr attr = new IconAttr();
if (!onlyMissed) {
obj.setIconPkg(pkgName);
PackageManager pm = mContext.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(obj.getIconPkg(), PackageManager.GET_META_DATA);
obj.setIconType("GO");
obj.setInstallTime(pm.getPackageInfo(obj.getIconPkg(), 0).lastUpdateTime);
obj.setIconName(mContext.getPackageManager().getApplicationLabel(ai).toString());
obj.setTotal(ip.calcTotal(obj.getIconPkg()));
attr.setDeleted(false);
obj.setMissed(ip.getMissingApps(obj.getIconPkg(), Util.getInstalledApps()).size());
attr.setSize(Util.getApkSize(obj.getIconPkg()));
obj.setAdditional(attr.toString());
ipObjDao.insert(obj);
sendIntent(pkgName);
} else {
IPObj obj2 = ipObjDao.queryBuilder().where(IPObjDao.Properties.IconPkg.eq(pkgName)).unique();
if (obj2.getMissed() == 0 || obj2.getAdditional() == null) {
attr.setDeleted(false);
obj2.setMissed(ip.getMissingApps(obj2.getIconPkg(), Util.getInstalledApps()).size());
attr.setSize(Util.getApkSize(obj2.getIconPkg()));
obj2.setAdditional(attr.toString());
ipObjDao.update(obj2);
}
sendIntent(pkgName);
obj = obj2;
}
return obj;
}

}

private void sendIntent(String pkgName) {
Intent intentNotify = new Intent();
intentNotify.setAction("insertlist");
intentNotify.putExtra("pkgName", pkgName);
mContext.sendBroadcast(intentNotify);
}


private void loadIconPack(List<ResolveInfo> rinfo, final IPObjDao ipObjDao, final List<IPObj> installedIconPacks) {

ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(2);
Expand Down Expand Up @@ -202,4 +158,51 @@ private void loadIconPack(List<ResolveInfo> rinfo, final IPObjDao ipObjDao, fina
Thread.currentThread().interrupt();
}
}

class ProcessPack implements Callable<IPObj> {
String pkgName;
IPObjDao ipObjDao;
boolean onlyMissed = false;

public ProcessPack(String pkgName, IPObjDao ipObjDao, boolean onlyMissed) {
this.pkgName = pkgName;
this.ipObjDao = ipObjDao;
this.onlyMissed = onlyMissed;
}

@Override
public IPObj call() throws Exception {
IPObj obj = new IPObj();
IconPackUtil ip = new IconPackUtil();
IconAttr attr = new IconAttr();
if (!onlyMissed) {
obj.setIconPkg(pkgName);
PackageManager pm = mContext.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo(obj.getIconPkg(), PackageManager.GET_META_DATA);
obj.setIconType("GO");
obj.setInstallTime(pm.getPackageInfo(obj.getIconPkg(), 0).lastUpdateTime);
obj.setIconName(mContext.getPackageManager().getApplicationLabel(ai).toString());
obj.setTotal(ip.calcTotal(obj.getIconPkg()));
attr.setDeleted(false);
obj.setMissed(ip.getMissingApps(obj.getIconPkg(), Util.getInstalledApps()).size());
attr.setSize(Util.getApkSize(obj.getIconPkg()));
obj.setAdditional(attr.toString());
ipObjDao.insert(obj);
sendIntent(pkgName);
} else {
IPObj obj2 = ipObjDao.queryBuilder().where(IPObjDao.Properties.IconPkg.eq(pkgName)).unique();
if (obj2.getMissed() == 0 || obj2.getAdditional() == null) {
attr.setDeleted(false);
obj2.setMissed(ip.getMissingApps(obj2.getIconPkg(), Util.getInstalledApps()).size());
attr.setSize(Util.getApkSize(obj2.getIconPkg()));
obj2.setAdditional(attr.toString());
ipObjDao.update(obj2);
}
sendIntent(pkgName);
obj = obj2;
}
return obj;
}

}
}
36 changes: 34 additions & 2 deletions app/src/main/java/dev/ukanth/iconmgr/IconPackUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import dev.ukanth.iconmgr.dao.IPObj;
import dev.ukanth.iconmgr.util.Util;

/**
Expand All @@ -52,6 +53,17 @@ public class IconPackUtil {
private static final String TAG = "MicoPacks";
private Resources iconPackres = null;


public final static String[] ICON_INTENTS = new String[] {
"com.fede.launcher.THEME_ICONPACK",
"com.anddoes.launcher.THEME",
"com.novalauncher.THEME",
"com.teslacoilsw.launcher.THEME",
"com.gau.go.launcherex.theme",
"org.adw.launcher.THEMES",
"org.adw.launcher.icons.ACTION_PICK_ICON"
};

public static @ColorInt
int getPaletteColorFromApp(Icon app) {
return getPaletteColorFromBitmap(app.getIconBitmap());
Expand Down Expand Up @@ -140,7 +152,6 @@ private Bitmap loadBitmap(String drawableName, String packageName) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

new Thread(() -> {
Intent broadcastIntent = new Intent();
broadcastIntent.putExtra("image",byteArray);
Expand Down Expand Up @@ -426,6 +437,27 @@ private Bitmap getMostAppropriateBackImage(Bitmap defaultBitmap, List<Bitmap> mB

}

/*public List<Icon> lookUpSearch(final String searchQuery, List<IPObj> objList) {
try {
ExecutorService service = Executors.newFixedThreadPool(3);
List<Future<Set<Icon>>> futures = new ArrayList<Future<Set<Icon>>>();
for (final IPObj attr : objList) {
Callable<Set<Icon>> callable = () -> getFilterIcons(attr.getIconPkg(), searchQuery);
futures.add(service.submit(callable));
}
service.shutdown();
List<Icon> outputs = new ArrayList<>();
for (Future<Set<Icon>> future : futures) {
outputs.addAll(future.get());
}
return outputs;
} catch (Exception e) {
e.printStackTrace();
}
return new ArrayList();
}*/

public Set<Icon> processXpp(final String packageName, List<Attrb> input) {
try {
ExecutorService service = Executors.newFixedThreadPool(5);
Expand All @@ -436,7 +468,7 @@ public Set<Icon> processXpp(final String packageName, List<Attrb> input) {
if (isSupported(listPackages, attr.key)) {
Bitmap iconBitmap = loadBitmap(attr.value, packageName);
if (iconBitmap != null) {
return new Icon(attr.value, iconBitmap);
return new Icon(attr.value, packageName, iconBitmap);
}
}
return new Icon("");
Expand Down
44 changes: 24 additions & 20 deletions app/src/main/java/dev/ukanth/iconmgr/IconPreviewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -33,6 +34,8 @@
import com.afollestad.materialdialogs.StackingBehavior;
import com.glidebitmappool.GlideBitmapPool;

import org.w3c.dom.Text;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
Expand Down Expand Up @@ -160,9 +163,6 @@ protected void onPause() {
@Override
protected void onDestroy() {
super.onDestroy();
/*if (iconViewReceiver != null) {
unregisterReceiver(iconViewReceiver);
}*/
}

private void saveImage(Icon icon, String packageName) {
Expand Down Expand Up @@ -279,6 +279,7 @@ protected void onPostExecute(Boolean aBoolean) {

gridLayout.removeAllViews();


if (themed_icons != null) {
List<Icon> list = new ArrayList<Icon>(themed_icons);
if (Prefs.isNonPreview() && nonthemed_icons != null) {
Expand All @@ -290,34 +291,37 @@ protected void onPostExecute(Boolean aBoolean) {

for (final Icon icon : list) {
if (icon.getIconBitmap() != null) {
/*RelativeLayout relativeLayout=new RelativeLayout(mContext);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
relativeLayout.setLayoutParams(params);
TextView textView = new TextView(mContext);
textView.setText(icon.getPackageName());*/
ImageView image = new ImageView(mContext);
image.setLayoutParams(params);
image.setPadding(15, 15, 15, 15);
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
image.setImageDrawable(new BitmapDrawable(getResources(), icon.getIconBitmap()));
image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new MaterialDialog.Builder(mContext)
.title(icon.getTitle())
.positiveText(R.string.save)
.onPositive((dialog, which) -> {
if (isStoragePermissionGranted()) {
saveImage(icon, packageName);
dialog.dismiss();
}
})
.negativeText(R.string.close)
.icon(new BitmapDrawable(getResources(), icon.getIconBitmap()))
.show();
}
});
image.setOnClickListener(v -> new MaterialDialog.Builder(mContext)
.title(icon.getTitle())
.positiveText(R.string.save)
.onPositive((dialog, which) -> {
if (isStoragePermissionGranted()) {
saveImage(icon, icon.getPackageName());
dialog.dismiss();
}
})
.negativeText(R.string.close)
.icon(new BitmapDrawable(getResources(), icon.getIconBitmap()))
.show());
image.setOnLongClickListener(view -> {
if (isStoragePermissionGranted()) {
saveImage(icon, packageName);
}
return true;
});
//relativeLayout.addView(image);
//relativeLayout.addView(textView);
gridLayout.addView(image);
}
}
Expand Down
Loading

0 comments on commit f041008

Please sign in to comment.