Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone #72

Open
wants to merge 1 commit into
base: standalone
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 68 additions & 31 deletions src/org/adw/launcher/LauncherModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import static android.util.Log.e;
import static android.util.Log.w;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.text.Collator;
Expand Down Expand Up @@ -47,6 +50,7 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Process;
Expand Down Expand Up @@ -1619,37 +1623,70 @@ static Drawable getIcon(PackageManager manager, Context context, ActivityInfo ac
Resources themeResources = null;
if(AlmostNexusSettingsHelper.getThemeIcons(context)){
activityInfo.name=activityInfo.name.toLowerCase().replace(".", "_");
try {
themeResources = manager.getResourcesForApplication(themePackage);
} catch (NameNotFoundException e) {
//e.printStackTrace();
}
if(themeResources!=null){
int resource_id = themeResources.getIdentifier(activityInfo.name, "drawable", themePackage);
if(resource_id!=0){
icon=themeResources.getDrawable(resource_id);
}

// use IconShader
if(icon==null){
if (compiledIconShaderName==null ||
compiledIconShaderName.compareTo(themePackage)!=0){
compiledIconShader = null;
resource_id = themeResources.getIdentifier("shader", "xml", themePackage);
if(resource_id!=0){
XmlResourceParser xpp = themeResources.getXml(resource_id);
compiledIconShader = IconShader.parseXml(xpp);
}
}

if(compiledIconShader!=null){
icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
try {
icon = IconShader.processIcon(icon, compiledIconShader);
} catch (Exception e) {}
}
}
}

if (themePackage.contains("droidicon")) {
Uri CONTENT_URI = Uri
.parse("content://"
+ themePackage +".provider.DynamicIconsProvider"
+ "/icon");
Uri content = Uri.withAppendedPath(CONTENT_URI,
activityInfo.name);

try {
ContentResolver cr = context.getContentResolver();
cr.acquireContentProviderClient(content);
InputStream in = cr
.openAssetFileDescriptor(content, "")
.createInputStream();
BitmapFactory.Options opts = new BitmapFactory.Options();

opts.inDensity = 120;
Bitmap defaultIcon = BitmapFactory.decodeStream(in,
null, opts);

icon = new BitmapDrawable(defaultIcon);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
} else {
try {
themeResources = manager.getResourcesForApplication(themePackage);
} catch (NameNotFoundException e) {
//e.printStackTrace();
}
if(themeResources!=null){
int resource_id = themeResources.getIdentifier(activityInfo.name, "drawable", themePackage);
if(resource_id!=0){
icon=themeResources.getDrawable(resource_id);
}

// use IconShader
if(icon==null){
if (compiledIconShaderName==null ||
compiledIconShaderName.compareTo(themePackage)!=0){
compiledIconShader = null;
resource_id = themeResources.getIdentifier("shader", "xml", themePackage);
if(resource_id!=0){
XmlResourceParser xpp = themeResources.getXml(resource_id);
compiledIconShader = IconShader.parseXml(xpp);
}
}

if(compiledIconShader!=null){
icon = Utilities.createIconThumbnail(activityInfo.loadIcon(manager), context);
try {
icon = IconShader.processIcon(icon, compiledIconShader);
} catch (Exception e) {}
}
}
}
}
}

if(icon==null){
Expand Down
3 changes: 3 additions & 0 deletions src/org/adw/launcher/MyLauncherSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ public void onClick(DialogInterface dialog, int which) {
intent.addCategory("android.intent.category.DEFAULT");
PackageManager pm=getPackageManager();
List<ResolveInfo> themes=pm.queryIntentActivities(intent, 0);
intent=new Intent("org.adw.launcher.THEMES.DYNAMIC");
intent.addCategory("android.intent.category.DEFAULT");
themes.addAll(pm.queryIntentActivities(intent, 0));
String[] entries = new String[themes.size()+1];
String[] values = new String[themes.size()+1];
entries[0]=Launcher.THEME_DEFAULT;
Expand Down