From 42c18d681ff3ab49d9f34e3cebd08fc91bcf08d8 Mon Sep 17 00:00:00 2001 From: Raj Yengisetty Date: Fri, 13 Jun 2014 13:00:04 -0700 Subject: Revert "Trebuchet : Icon pack support" This is no longer needed because of the awesome new Themes Engine This reverts commit 89970649602163ba8cb5c01c4c77534f45b66121. Change-Id: I1dca53b8c8020ecb6ab7b0da6931f380564eda85 --- res/drawable-hdpi/ic_iconpacks.png | Bin 1045 -> 0 bytes res/drawable-mdpi/ic_iconpacks.png | Bin 769 -> 0 bytes res/drawable-xhdpi/ic_iconpacks.png | Bin 1430 -> 0 bytes res/drawable-xxhdpi/ic_iconpacks.png | Bin 2146 -> 0 bytes res/drawable/iconpack_button.xml | 21 - res/layout/iconpack_chooser.xml | 28 -- res/layout/overview_panel.xml | 4 +- res/values-af/cm_strings.xml | 4 - res/values-ar/cm_strings.xml | 4 - res/values-ca/cm_strings.xml | 4 - res/values-cs/cm_strings.xml | 4 - res/values-da/cm_strings.xml | 4 - res/values-de/cm_strings.xml | 4 - res/values-el/cm_strings.xml | 4 - res/values-es-rXA/cm_strings.xml | 4 - res/values-es/cm_strings.xml | 4 - res/values-et/cm_strings.xml | 4 - res/values-fi/cm_strings.xml | 4 - res/values-fr/cm_strings.xml | 4 - res/values-hu/cm_strings.xml | 4 - res/values-in/cm_strings.xml | 4 - res/values-it/cm_strings.xml | 4 - res/values-iw/cm_strings.xml | 4 - res/values-ja/cm_strings.xml | 4 - res/values-lb/cm_strings.xml | 4 - res/values-lt/cm_strings.xml | 4 - res/values-nb/cm_strings.xml | 4 - res/values-nl/cm_strings.xml | 4 - res/values-pl/cm_strings.xml | 4 - res/values-pt-rBR/cm_strings.xml | 4 - res/values-pt-rPT/cm_strings.xml | 4 - res/values-ru/cm_strings.xml | 4 - res/values-si/cm_strings.xml | 4 - res/values-sk/cm_strings.xml | 4 - res/values-sr/cm_strings.xml | 4 - res/values-sv/cm_strings.xml | 4 - res/values-th/cm_strings.xml | 4 - res/values-tr/cm_strings.xml | 4 - res/values-uk/cm_strings.xml | 4 - res/values-zh-rCN/cm_strings.xml | 4 - res/values-zh-rHK/cm_strings.xml | 4 - res/values-zh-rTW/cm_strings.xml | 4 - res/values/cm_strings.xml | 5 - src/com/android/launcher3/IconCache.java | 27 +- src/com/android/launcher3/IconPackHelper.java | 440 --------------------- src/com/android/launcher3/IconPickerActivity.java | 152 ------- .../launcher3/settings/SettingsProvider.java | 5 - 47 files changed, 3 insertions(+), 819 deletions(-) delete mode 100644 res/drawable-hdpi/ic_iconpacks.png delete mode 100644 res/drawable-mdpi/ic_iconpacks.png delete mode 100644 res/drawable-xhdpi/ic_iconpacks.png delete mode 100644 res/drawable-xxhdpi/ic_iconpacks.png delete mode 100644 res/drawable/iconpack_button.xml delete mode 100644 res/layout/iconpack_chooser.xml delete mode 100644 src/com/android/launcher3/IconPackHelper.java delete mode 100644 src/com/android/launcher3/IconPickerActivity.java diff --git a/res/drawable-hdpi/ic_iconpacks.png b/res/drawable-hdpi/ic_iconpacks.png deleted file mode 100644 index 7985c1847..000000000 Binary files a/res/drawable-hdpi/ic_iconpacks.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_iconpacks.png b/res/drawable-mdpi/ic_iconpacks.png deleted file mode 100644 index 36e35c215..000000000 Binary files a/res/drawable-mdpi/ic_iconpacks.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_iconpacks.png b/res/drawable-xhdpi/ic_iconpacks.png deleted file mode 100644 index 207d68a35..000000000 Binary files a/res/drawable-xhdpi/ic_iconpacks.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_iconpacks.png b/res/drawable-xxhdpi/ic_iconpacks.png deleted file mode 100644 index d1aea29da..000000000 Binary files a/res/drawable-xxhdpi/ic_iconpacks.png and /dev/null differ diff --git a/res/drawable/iconpack_button.xml b/res/drawable/iconpack_button.xml deleted file mode 100644 index fedfb7a8e..000000000 --- a/res/drawable/iconpack_button.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - diff --git a/res/layout/iconpack_chooser.xml b/res/layout/iconpack_chooser.xml deleted file mode 100644 index 6caf9f765..000000000 --- a/res/layout/iconpack_chooser.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml index b6707417c..cf9f616d7 100644 --- a/res/layout/overview_panel.xml +++ b/res/layout/overview_panel.xml @@ -2,7 +2,7 @@ Scroll wallpaper - - Pick icon pack - Default icons - No icon packs installed - Google diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java index a6b02aeb0..1dade8027 100644 --- a/src/com/android/launcher3/IconCache.java +++ b/src/com/android/launcher3/IconCache.java @@ -45,8 +45,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; -import com.android.launcher3.settings.SettingsProvider; - /** * Cache of application icons. Icons can be made from any thread. */ @@ -59,8 +57,6 @@ public class IconCache { private static final boolean DEBUG = true; - private IconPackHelper mIconPackHelper; - private static class CacheEntry { public Bitmap icon; public String title; @@ -83,9 +79,6 @@ public class IconCache { // need to set mIconDpi before getting default icon mDefaultIcon = makeDefaultIcon(); - - mIconPackHelper = new IconPackHelper(context); - loadIconPack(); } public Drawable getFullResDefaultActivityIcon() { @@ -133,14 +126,7 @@ public class IconCache { resources = null; } if (resources != null) { - int iconId = 0; - if (mIconPackHelper != null && mIconPackHelper.isIconPackLoaded()) { - iconId = mIconPackHelper.getResourceIdForActivityIcon(info); - if (iconId != 0) { - return getFullResIcon(mIconPackHelper.getIconPackResources(), iconId); - } - } - iconId = info.getIconResource(); + int iconId = info.getIconResource(); if (iconId != 0) { return getFullResIcon(resources, iconId); } @@ -161,16 +147,6 @@ public class IconCache { return b; } - private void loadIconPack() { - mIconPackHelper.unloadIconPack(); - String iconPack = SettingsProvider.getStringCustomDefault(mContext, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_ICON_PACK, ""); - if (!TextUtils.isEmpty(iconPack) && !mIconPackHelper.loadIconPack(iconPack)) { - SettingsProvider.putString(mContext, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_ICON_PACK, ""); - } - } - /** * Remove any records for the supplied ComponentName. */ @@ -202,7 +178,6 @@ public class IconCache { synchronized (mCache) { mCache.clear(); } - loadIconPack(); } /** diff --git a/src/com/android/launcher3/IconPackHelper.java b/src/com/android/launcher3/IconPackHelper.java deleted file mode 100644 index 520e8df8b..000000000 --- a/src/com/android/launcher3/IconPackHelper.java +++ /dev/null @@ -1,440 +0,0 @@ -package com.android.launcher3; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ComponentName; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.content.res.Resources; -import android.content.res.XmlResourceParser; -import android.graphics.drawable.Drawable; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import com.android.launcher3.settings.SettingsProvider; - -public class IconPackHelper { - - public final static String[] sSupportedActions = new String[] { - "org.adw.launcher.THEMES", - "com.gau.go.launcherex.theme" - }; - - public static final String[] sSupportedCategories = new String[] { - "com.fede.launcher.THEME_ICONPACK", - "com.anddoes.launcher.THEME", - "com.teslacoilsw.launcher.THEME" - }; - - // Holds package/class -> drawable - private Map mIconPackResources; - private final Context mContext; - private String mLoadedIconPackName; - private Resources mLoadedIconPackResource; - - IconPackHelper(Context context) { - mContext = context; - mIconPackResources = new HashMap(); - } - - public static Map getSupportedPackages(Context context) { - Intent i = new Intent(); - Map packages = new HashMap(); - PackageManager packageManager = context.getPackageManager(); - for (String action : sSupportedActions) { - i.setAction(action); - for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) { - IconPackInfo info = new IconPackInfo(r, packageManager); - packages.put(r.activityInfo.packageName, info); - } - } - i = new Intent(Intent.ACTION_MAIN); - for (String category : sSupportedCategories) { - i.addCategory(category); - for (ResolveInfo r : packageManager.queryIntentActivities(i, 0)) { - IconPackInfo info = new IconPackInfo(r, packageManager); - packages.put(r.activityInfo.packageName, info); - } - i.removeCategory(category); - } - return packages; - } - - private static void loadResourcesFromXmlParser(XmlPullParser parser, - Map iconPackResources) throws XmlPullParserException, IOException { - int eventType = parser.getEventType(); - do { - - if (eventType != XmlPullParser.START_TAG) { - continue; - } - - if (!parser.getName().equalsIgnoreCase("item")) { - continue; - } - - String component = parser.getAttributeValue(null, "component"); - String drawable = parser.getAttributeValue(null, "drawable"); - - // Validate component/drawable exist - if (TextUtils.isEmpty(component) || TextUtils.isEmpty(drawable)) { - continue; - } - - // Validate format/length of component - if (!component.startsWith("ComponentInfo{") || !component.endsWith("}") - || component.length() < 16) { - continue; - } - - // Sanitize stored value - component = component.substring(14, component.length() - 1).toLowerCase(); - - ComponentName name = null; - if (!component.contains("/")) { - // Package icon reference - iconPackResources.put(component, drawable); - } else { - name = ComponentName.unflattenFromString(component); - if (name != null) { - iconPackResources.put(name.getPackageName(), drawable); - iconPackResources.put(name.getClassName(), drawable); - } - } - } while ((eventType = parser.next()) != XmlPullParser.END_DOCUMENT); - } - - private static void loadApplicationResources(Context context, - Map iconPackResources, String packageName) { - Field[] drawableItems = null; - try { - Context appContext = context.createPackageContext(packageName, - Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); - drawableItems = Class.forName(packageName+".R$drawable", - true, appContext.getClassLoader()).getFields(); - } catch (Exception e){ - return; - } - - for (Field f : drawableItems) { - String name = f.getName(); - - String icon = name.toLowerCase(); - name = name.replaceAll("_", "."); - - iconPackResources.put(name, icon); - - int activityIndex = name.lastIndexOf("."); - if (activityIndex <= 0 || activityIndex == name.length() - 1) { - continue; - } - - String iconPackage = name.substring(0, activityIndex); - if (TextUtils.isEmpty(iconPackage)) { - continue; - } - iconPackResources.put(iconPackage, icon); - - String iconActivity = name.substring(activityIndex + 1); - if (TextUtils.isEmpty(iconActivity)) { - continue; - } - iconPackResources.put(iconPackage + "." + iconActivity, icon); - } - } - - public boolean loadIconPack(String packageName) { - mIconPackResources = getIconPackResources(mContext, packageName); - Resources res = null; - try { - res = mContext.getPackageManager().getResourcesForApplication(packageName); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - return false; - } - mLoadedIconPackResource = res; - mLoadedIconPackName = packageName; - return true; - } - - public static Map getIconPackResources(Context context, String packageName) { - if (TextUtils.isEmpty(packageName)) { - return null; - } - - Resources res = null; - try { - res = context.getPackageManager().getResourcesForApplication(packageName); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - return null; - } - - XmlPullParser parser = null; - InputStream inputStream = null; - Map iconPackResources = new HashMap(); - - try { - inputStream = res.getAssets().open("appfilter.xml"); - XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); - parser = factory.newPullParser(); - parser.setInput(inputStream, "UTF-8"); - } catch (Exception e) { - // Catch any exception since we want to fall back to parsing the xml/ - // resource in all cases - int resId = res.getIdentifier("appfilter", "xml", packageName); - if (resId != 0) { - parser = res.getXml(resId); - } - } - - if (parser != null) { - try { - loadResourcesFromXmlParser(parser, iconPackResources); - return iconPackResources; - } catch (XmlPullParserException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - // Cleanup resources - if (parser instanceof XmlResourceParser) { - ((XmlResourceParser) parser).close(); - } - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException e) { - } - } - } - } - - // Application uses a different theme format (most likely launcher pro) - int arrayId = res.getIdentifier("theme_iconpack", "array", packageName); - if (arrayId == 0) { - arrayId = res.getIdentifier("icon_pack", "array", packageName); - } - - if (arrayId != 0) { - String[] iconPack = res.getStringArray(arrayId); - for (String entry : iconPack) { - - if (TextUtils.isEmpty(entry)) { - continue; - } - - String icon = entry.toLowerCase(); - entry = entry.replaceAll("_", "."); - - iconPackResources.put(entry, icon); - - int activityIndex = entry.lastIndexOf("."); - if (activityIndex <= 0 || activityIndex == entry.length() - 1) { - continue; - } - - String iconPackage = entry.substring(0, activityIndex); - if (TextUtils.isEmpty(iconPackage)) { - continue; - } - iconPackResources.put(iconPackage, icon); - - String iconActivity = entry.substring(activityIndex + 1); - if (TextUtils.isEmpty(iconActivity)) { - continue; - } - iconPackResources.put(iconPackage + "." + iconActivity, icon); - } - } else { - loadApplicationResources(context, iconPackResources, packageName); - } - return iconPackResources; - } - - public void unloadIconPack() { - mLoadedIconPackResource = null; - mLoadedIconPackName = null; - if (mIconPackResources != null) { - mIconPackResources.clear(); - } - } - - public static void pickIconPack(final Context context, final boolean pickIcon) { - Map supportedPackages = getSupportedPackages(context); - if (supportedPackages.isEmpty()) { - Toast.makeText(context, R.string.no_iconpacks_summary, Toast.LENGTH_SHORT).show(); - return; - } - - final IconAdapter adapter = new IconAdapter(context, supportedPackages); - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.dialog_pick_iconpack_title); - if (!pickIcon) { - builder.setAdapter(adapter, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int position) { - if (adapter.isOriginalIconPack(position)) { - return; - } - String selectedPackage = adapter.getItem(position); - SettingsProvider.putString(context, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_ICON_PACK, selectedPackage); - LauncherAppState.getInstance().getIconCache().flush(); - LauncherAppState.getInstance().getModel().forceReload(); - } - }); - } else { - builder.setAdapter(adapter, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - String selectedPackage = adapter.getItem(which); - Launcher launcherActivity = (Launcher) context; - if (TextUtils.isEmpty(selectedPackage)) { - launcherActivity.onActivityResult(Launcher.REQUEST_PICK_ICON, Activity.RESULT_OK, null); - } else { - Intent i = new Intent(); - i.setClass(context, IconPickerActivity.class); - i.putExtra(IconPickerActivity.PACKAGE_NAME_EXTRA, selectedPackage); - launcherActivity.startActivityForResult(i, Launcher.REQUEST_PICK_ICON); - } - } - }); - } - builder.show().getWindow().getDecorView().setAlpha(0.8f); - } - - boolean isIconPackLoaded() { - return mLoadedIconPackResource != null && - mLoadedIconPackName != null && - mIconPackResources != null; - } - - private int getResourceIdForDrawable(String resource) { - int resId = mLoadedIconPackResource.getIdentifier(resource, "drawable", mLoadedIconPackName); - return resId; - } - - public Resources getIconPackResources() { - return mLoadedIconPackResource; - } - - public int getResourceIdForActivityIcon(ActivityInfo info) { - String drawable = mIconPackResources.get(info.name.toLowerCase()); - if (drawable == null) { - // Icon pack doesn't have an icon for the activity, fallback to package icon - drawable = mIconPackResources.get(info.packageName.toLowerCase()); - if (drawable == null) { - return 0; - } - } - return getResourceIdForDrawable(drawable); - } - - static class IconPackInfo { - String packageName; - CharSequence label; - Drawable icon; - - IconPackInfo(ResolveInfo r, PackageManager packageManager) { - packageName = r.activityInfo.packageName; - icon = r.loadIcon(packageManager); - label = r.loadLabel(packageManager); - } - - IconPackInfo(){ - } - - public IconPackInfo(String label, Drawable icon, String packageName) { - this.label = label; - this.icon = icon; - this.packageName = packageName; - } - } - - private static class IconAdapter extends BaseAdapter { - ArrayList mSupportedPackages; - LayoutInflater mLayoutInflater; - String mCurrentIconPack; - int mCurrentIconPackPosition; - - IconAdapter(Context ctx, Map supportedPackages) { - mLayoutInflater = LayoutInflater.from(ctx); - mSupportedPackages = new ArrayList(supportedPackages.values()); - Collections.sort(mSupportedPackages, new Comparator() { - @Override - public int compare(IconPackInfo lhs, IconPackInfo rhs) { - return lhs.label.toString().compareToIgnoreCase(rhs.toString()); - } - }); - - Resources res = ctx.getResources(); - String defaultLabel = res.getString(R.string.default_iconpack_title); - Drawable icon = res.getDrawable(R.mipmap.ic_launcher_home); - mSupportedPackages.add(0, new IconPackInfo(defaultLabel, icon, "")); - - mCurrentIconPack = SettingsProvider.getStringCustomDefault(ctx, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_ICON_PACK, ""); - } - - @Override - public int getCount() { - return mSupportedPackages.size(); - } - - @Override - public String getItem(int position) { - return (String) mSupportedPackages.get(position).packageName; - } - - @Override - public long getItemId(int position) { - return 0; - } - - public boolean isOriginalIconPack(int position) { - return mCurrentIconPackPosition == position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - convertView = mLayoutInflater.inflate(R.layout.iconpack_chooser, null); - } - IconPackInfo info = mSupportedPackages.get(position); - TextView txtView = (TextView) convertView.findViewById(R.id.title); - txtView.setText(info.label); - ImageView imgView = (ImageView) convertView.findViewById(R.id.icon); - imgView.setImageDrawable(info.icon); - ImageView chk = (ImageView) convertView.findViewById(R.id.check); - boolean isCurrentIconPack = info.packageName.equals(mCurrentIconPack); - chk.setVisibility(isCurrentIconPack ? View.VISIBLE : View.GONE); - if (isCurrentIconPack) { - mCurrentIconPackPosition = position; - } - return convertView; - } - } - -} \ No newline at end of file diff --git a/src/com/android/launcher3/IconPickerActivity.java b/src/com/android/launcher3/IconPickerActivity.java deleted file mode 100644 index 5f08eda68..000000000 --- a/src/com/android/launcher3/IconPickerActivity.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.android.launcher3; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.Map; - -import android.app.Activity; -import android.app.ActivityManager; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Resources; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.AsyncTask; -import android.os.Bundle; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.GridView; -import android.widget.ImageView; - -public class IconPickerActivity extends Activity { - - public static final String SELECTED_RESOURCE_EXTRA = "selected_resource"; - public static final String SELECTED_BITMAP_EXTRA = "bitmap"; - public static final String PACKAGE_NAME_EXTRA = "package"; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - ActivityManager activityManager = - (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - int iconSize = activityManager.getLauncherLargeIconSize(); - final String pkgName = getIntent().getStringExtra(PACKAGE_NAME_EXTRA); - - GridView gridview = new GridView(this); - gridview.setNumColumns(GridView.AUTO_FIT); - gridview.setHorizontalSpacing(40); - gridview.setVerticalSpacing(40); - gridview.setPadding(20, 20, 20, 0); - gridview.setFastScrollEnabled(true); - gridview.setColumnWidth(iconSize); - gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); - - gridview.setAdapter(new ImageAdapter(this, pkgName)); - gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View v, int position, long id) { - Intent in = new Intent(); - DrawableInfo d = (DrawableInfo) adapterView.getAdapter().getItem(position); - in.putExtra(SELECTED_RESOURCE_EXTRA, pkgName + "|" + d.resource_name); - in.putExtra(SELECTED_BITMAP_EXTRA, ((BitmapDrawable)d.drawable.get()).getBitmap()); - setResult(Activity.RESULT_OK, in); - finish(); - } - }); - setContentView(gridview); - } - - public class ImageAdapter extends BaseAdapter { - private Context mContext; - private Resources mResources; - private ArrayList mDrawables = new ArrayList(); - - public class FetchDrawable extends AsyncTask { - WeakReference mImageView; - - FetchDrawable(ImageView imgView) { - mImageView = new WeakReference(imgView); - } - - @Override - protected Drawable doInBackground(Integer... position) { - DrawableInfo info = getItem(position[0]); - int itemId = info.resource_id; - Drawable d = mResources.getDrawable(itemId); - info.drawable = new WeakReference(d); - return d; - } - - @Override - public void onPostExecute(Drawable result) { - if (mImageView.get() != null) { - mImageView.get().setImageDrawable(result); - } - } - } - - public ImageAdapter(Context c, String pkgName) { - mContext = c; - Map resources = IconPackHelper.getIconPackResources(c, pkgName); - try { - mResources = c.getPackageManager().getResourcesForApplication(pkgName); - LinkedHashSet drawables = new LinkedHashSet(resources.values()); - for (String s : drawables) { - int id = mResources.getIdentifier(s, "drawable", pkgName); - if (id != 0) { - mDrawables.add(new DrawableInfo(s, id)); - } - } - } catch (NameNotFoundException e) { - } - } - - public int getCount() { - return mDrawables.size(); - } - - public DrawableInfo getItem(int position) { - return mDrawables.get(position); - } - - public long getItemId(int position) { - return 0; - } - - public View getView(final int position, View convertView, ViewGroup parent) { - final ImageView imageView; - if (convertView == null) { - imageView = new ImageView(mContext); - imageView.setLayoutParams(new GridView.LayoutParams( - GridView.LayoutParams.WRAP_CONTENT, GridView.LayoutParams.WRAP_CONTENT)); - imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); - } else { - imageView = (ImageView) convertView; - Object tag = imageView.getTag(); - if (tag != null && tag instanceof FetchDrawable) { - ((FetchDrawable) tag).cancel(true); - } - } - FetchDrawable req = new FetchDrawable(imageView); - imageView.setTag(req); - req.execute(position); - return imageView; - } - } - - private class DrawableInfo { - WeakReference drawable; - final String resource_name; - final int resource_id; - DrawableInfo(String n, int i) { - resource_name = n; - resource_id = i; - } - } -} diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index de1d4002e..6e5f9d9b3 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -40,7 +40,6 @@ public final class SettingsProvider { public static final String SETTINGS_UI_GENERAL_ICONS_LARGE = "ui_general_icons_large"; public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_FAMILY = "ui_general_icons_text_font"; public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_STYLE = "ui_general_icons_text_font_style"; - public static final String SETTINGS_UI_GENERAL_ICONS_ICON_PACK = "ui_general_iconpack"; public static SharedPreferences get(Context context) { return context.getSharedPreferences(SETTINGS_KEY, Context.MODE_MULTI_PROCESS); @@ -77,8 +76,4 @@ public final class SettingsProvider { public static String getString(Context context, String key, int resource) { return getStringCustomDefault(context, key, context.getResources().getString(resource)); } - - public static void putString(Context context, String key, String value) { - get(context).edit().putString(key, value).commit(); - } } -- cgit v1.2.3