summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java245
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java8
-rw-r--r--src/com/android/launcher2/Launcher.java2
3 files changed, 25 insertions, 230 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index bd7046348..401e8addf 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -28,8 +28,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
-import android.animation.ValueAnimator;
-import android.app.WallpaperManager;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
@@ -73,8 +71,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
*/
public enum ContentType {
Applications,
- Widgets,
- Wallpapers
+ Widgets
}
// Refs
@@ -87,7 +84,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private ContentType mContentType;
private ArrayList<ApplicationInfo> mApps;
private List<Object> mWidgets;
- private List<ResolveInfo> mWallpapers;
// Caching
private Drawable mDefaultWidgetBackground;
@@ -100,7 +96,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private int mMaxWidgetSpan, mMinWidgetSpan;
private int mCellWidthGap, mCellHeightGap;
private int mWidgetCountX, mWidgetCountY;
- private int mWallpaperCountX, mWallpaperCountY;
private final int mWidgetPreviewIconPaddedDimension;
private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
private PagedViewCellLayout mWidgetSpacingLayout;
@@ -117,7 +112,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mContentType = ContentType.Applications;
mApps = new ArrayList<ApplicationInfo>();
mWidgets = new ArrayList<Object>();
- mWallpapers = new ArrayList<ResolveInfo>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
mWidgetPreviewCache = new LruCache<Object, Bitmap>(sWidgetPreviewCacheSize) {
protected int sizeOf(Object key, Bitmap value) {
@@ -140,8 +134,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 10);
mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
- mWallpaperCountX = a.getInt(R.styleable.AppsCustomizePagedView_wallpaperCountX, 2);
- mWallpaperCountY = a.getInt(R.styleable.AppsCustomizePagedView_wallpaperCountY, 2);
a.recycle();
// Create a dummy page that we can use to approximate the cell dimensions of widgets and
@@ -196,27 +188,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mWidgets.addAll(mPackageManager.queryIntentActivities(shortcutsIntent, 0));
Collections.sort(mWidgets,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
-
- // Get the list of wallpapers
- Intent wallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
- mWallpapers = mPackageManager.queryIntentActivities(wallpapersIntent,
- PackageManager.GET_META_DATA);
- Collections.sort(mWallpapers,
- new LauncherModel.ShortcutNameComparator(mPackageManager));
- // Move Live Wallpapers to the front of the list
- Context c = getContext();
- ResolveInfo liveWallpapers = removeResolveInfoWithComponentName(mWallpapers,
- new ComponentName(c.getString(R.string.live_wallpaper_picker_package_name),
- c.getString(R.string.live_wallpaper_picker_class_name)));
- if (liveWallpapers != null) {
- mWallpapers.add(0, liveWallpapers);
- }
- // Move Wallpapers to the front of the list
- ResolveInfo wallpapers = removeResolveInfoWithComponentName(mWallpapers,
- new ComponentName(c.getPackageName(), WallpaperChooser.class.getName()));
- if (wallpapers != null) {
- mWallpapers.add(0, wallpapers);
- }
}
/**
@@ -328,39 +299,31 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
});
} else if (v instanceof PagedViewWidget) {
- if (v.getTag() instanceof ResolveInfo) {
- final ResolveInfo info = (ResolveInfo) v.getTag();
- if (mWallpapers.contains(info)) {
- // Start the wallpaper picker
- animateClickFeedback(v, new Runnable() {
- @Override
- public void run() {
- // add the shortcut
- Intent createWallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
- ComponentName name = new ComponentName(info.activityInfo.packageName,
- info.activityInfo.name);
- createWallpapersIntent.setComponent(name);
- mLauncher.processWallpaper(createWallpapersIntent);
+ // Add the widget to the current workspace screen
+ Workspace w = mLauncher.getWorkspace();
+ int currentWorkspaceScreen = mLauncher.getCurrentWorkspaceScreen();
+ final CellLayout cl = (CellLayout) w.getChildAt(currentWorkspaceScreen);
+ final View dragView = v.findViewById(R.id.widget_preview);
+ final ItemInfo itemInfo = (ItemInfo) v.getTag();
+ animateClickFeedback(v, new Runnable() {
+ @Override
+ public void run() {
+ cl.calculateSpans(itemInfo);
+ if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) {
+ if (LauncherApplication.isScreenLarge()) {
+ animateItemOntoScreen(dragView, cl, itemInfo);
+ } else {
+ mLauncher.addExternalItemToScreen(itemInfo, cl);
+ itemInfo.dropPos = null;
}
- });
+
+ // Hide the pane so we can see the workspace we dropped on
+ mLauncher.showWorkspace(true);
+ } else {
+ mLauncher.showOutOfSpaceMessage();
+ }
}
- } else {
- // Let the user know that they have to long press to add a widget
- Toast.makeText(getContext(), R.string.long_press_widget_to_add,
- Toast.LENGTH_SHORT).show();
-
- // Create a little animation to show that the widget can move
- float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
- final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
- AnimatorSet bounce = new AnimatorSet();
- ValueAnimator tyuAnim = ObjectAnimator.ofFloat(p, "translationY", offsetY);
- tyuAnim.setDuration(125);
- ValueAnimator tydAnim = ObjectAnimator.ofFloat(p, "translationY", 0f);
- tydAnim.setDuration(100);
- bounce.play(tyuAnim).before(tydAnim);
- bounce.setInterpolator(new AccelerateInterpolator());
- bounce.start();
- }
+ });
}
}
@@ -797,160 +760,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- /*
- * This method fetches an xml file specified in the manifest identified by
- * WallpaperManager.WALLPAPER_PREVIEW_META_DATA). The xml file specifies
- * an image which will be used as the wallpaper preview for an activity
- * which responds to ACTION_SET_WALLPAPER. This image is returned and used
- * in the customize drawer.
- */
- private Drawable parseWallpaperPreviewXml(ResolveInfo ri) {
- ActivityInfo activityInfo = ri.activityInfo;
- XmlResourceParser parser = null;
- ComponentName component = new ComponentName(ri.activityInfo.packageName,
- ri.activityInfo.name);
- try {
- parser = activityInfo.loadXmlMetaData(mPackageManager,
- WallpaperManager.WALLPAPER_PREVIEW_META_DATA);
- if (parser == null) {
- Slog.w(LOG_TAG, "No " + WallpaperManager.WALLPAPER_PREVIEW_META_DATA
- + " meta-data for " + "wallpaper provider '" + component + '\'');
- return null;
- }
-
- AttributeSet attrs = Xml.asAttributeSet(parser);
-
- int type;
- while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
- && type != XmlPullParser.START_TAG) {
- // drain whitespace, comments, etc.
- }
-
- String nodeName = parser.getName();
- if (!"wallpaper-preview".equals(nodeName)) {
- Slog.w(LOG_TAG, "Meta-data does not start with wallpaper-preview tag for "
- + "wallpaper provider '" + component + '\'');
- return null;
- }
-
- // If metaData was null, we would have returned earlier when getting
- // the parser No need to do the check here
- Resources res = mPackageManager.getResourcesForApplication(
- activityInfo.applicationInfo);
-
- TypedArray sa = res.obtainAttributes(attrs,
- com.android.internal.R.styleable.WallpaperPreviewInfo);
-
- TypedValue value = sa.peekValue(
- com.android.internal.R.styleable.WallpaperPreviewInfo_staticWallpaperPreview);
- if (value == null) return null;
-
- return res.getDrawable(value.resourceId);
- } catch (Exception e) {
- Slog.w(LOG_TAG, "XML parsing failed for wallpaper provider '" + component + '\'', e);
- return null;
- } finally {
- if (parser != null) parser.close();
- }
- }
- private FastBitmapDrawable getWallpaperPreview(ResolveInfo info, int cellWidth, int cellHeight){
- // Return the cached version if necessary
- Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
- if (cachedBitmap != null) {
- return new FastBitmapDrawable(cachedBitmap);
- }
-
- // Get the preview
- Resources resources = getContext().getResources();
- Drawable wallpaperPreview = parseWallpaperPreviewXml(info);
- Drawable wallpaperIcon = null;
- int expectedWidth;
- int expectedHeight;
- if (wallpaperPreview != null) {
- expectedWidth = wallpaperPreview.getIntrinsicWidth();
- expectedHeight = wallpaperPreview.getIntrinsicHeight();
- } else {
- wallpaperPreview = mDefaultWidgetBackground;
- expectedWidth = expectedHeight = Math.min(cellWidth, cellHeight);
-
- // Draw the icon in the top left corner
- String packageName = info.activityInfo.packageName;
- try {
- if (info.icon > 0) {
- wallpaperIcon = mPackageManager.getDrawable(packageName, info.icon, null);
- }
- if (wallpaperIcon == null) {
- wallpaperIcon = resources.getDrawable(R.drawable.ic_launcher_application);
- }
- } catch (Resources.NotFoundException e) {}
- }
-
- // Create the bitmap
- Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
- renderDrawableToBitmap(wallpaperPreview, preview, 0, 0, expectedWidth, expectedHeight,
- 1f, 1f);
- if (wallpaperIcon != null) {
- int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
- int offset = (int) (iconSize * sWidgetPreviewIconPaddingPercentage);
- renderDrawableToBitmap(wallpaperIcon, preview, offset, offset, iconSize, iconSize,
- 1f, 1f);
- }
-
- FastBitmapDrawable previewDrawable = new FastBitmapDrawable(preview);
- previewDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
- mWidgetPreviewCache.put(info, preview);
- return previewDrawable;
- }
- /*
- * Wallpapers PagedView implementation
- */
- public void syncWallpaperPages() {
- // Ensure that we have the right number of pages
- Context context = getContext();
- int numWidgetsPerPage = mWallpaperCountX * mWallpaperCountY;
- int numPages = (int) Math.ceil(mWallpapers.size() / (float) numWidgetsPerPage);
- for (int i = 0; i < numPages; ++i) {
- PagedViewGridLayout layout = new PagedViewGridLayout(context, mWallpaperCountX,
- mWallpaperCountY);
- setupPage(layout);
- addView(layout);
- }
- }
- public void syncWallpaperPageItems(int page) {
- PagedViewGridLayout layout = (PagedViewGridLayout) getChildAt(page);
- layout.removeAllViews();
-
- // Calculate the dimensions of each cell we are giving to each widget
- int numWidgetsPerPage = mWallpaperCountX * mWallpaperCountY;
- int offset = page * numWidgetsPerPage;
- int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
- - ((mWallpaperCountX - 1) * mCellWidthGap)) / mWallpaperCountX);
- int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
- - ((mWallpaperCountY - 1) * mCellHeightGap)) / mWallpaperCountY);
- for (int i = 0; i < Math.min(numWidgetsPerPage, mWallpapers.size() - offset); ++i) {
- ResolveInfo info = mWallpapers.get(offset + i);
- PagedViewWidget widget = (PagedViewWidget) mLayoutInflater.inflate(
- R.layout.apps_customize_wallpaper, layout, false);
-
- // Fill in the shortcuts information
- FastBitmapDrawable preview = getWallpaperPreview(info, cellWidth, cellHeight);
- widget.applyFromResolveInfo(mPackageManager, info, preview, null, false);
- widget.setTag(info);
- widget.setOnClickListener(this);
- widget.setOnLongClickListener(this);
- widget.setOnTouchListener(this);
-
- // Layout each widget
- int ix = i % mWallpaperCountX;
- int iy = i / mWallpaperCountX;
- PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
- cellHeight);
- lp.leftMargin = (ix * cellWidth) + (ix * mCellWidthGap);
- lp.topMargin = (iy * cellHeight) + (iy * mCellHeightGap);
- layout.addView(widget, lp);
- }
- }
-
@Override
public void syncPages() {
removeAllViews();
@@ -961,9 +770,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
case Widgets:
syncWidgetPages();
break;
- case Wallpapers:
- syncWallpaperPages();
- break;
}
}
@Override
@@ -975,9 +781,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
case Widgets:
syncWidgetPageItems(page);
break;
- case Wallpapers:
- syncWallpaperPageItems(page);
- break;
}
}
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index cd8e7efb0..120317795 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -33,7 +33,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private static final String APPS_TAB_TAG = "APPS";
private static final String WIDGETS_TAB_TAG = "WIDGETS";
- private static final String WALLPAPERS_TAB_TAG = "WALLPAPERS";
private final LayoutInflater mLayoutInflater;
@@ -78,9 +77,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
tabView.setText(mContext.getString(R.string.widgets_tab_label));
addTab(newTabSpec(WIDGETS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
- tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
- tabView.setText(mContext.getString(R.string.wallpapers_tab_label));
- addTab(newTabSpec(WALLPAPERS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
setOnTabChangedListener(this);
// Set the width of the tab bar to match the content (for now)
@@ -102,8 +98,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
return AppsCustomizePagedView.ContentType.Applications;
} else if (tag.equals(WIDGETS_TAB_TAG)) {
return AppsCustomizePagedView.ContentType.Widgets;
- } else if (tag.equals(WALLPAPERS_TAB_TAG)) {
- return AppsCustomizePagedView.ContentType.Wallpapers;
}
return AppsCustomizePagedView.ContentType.Applications;
}
@@ -116,8 +110,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
return APPS_TAB_TAG;
} else if (type == AppsCustomizePagedView.ContentType.Widgets) {
return WIDGETS_TAB_TAG;
- } else if (type == AppsCustomizePagedView.ContentType.Wallpapers) {
- return WALLPAPERS_TAB_TAG;
}
return APPS_TAB_TAG;
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 5cf8e9cdf..eb98b4d12 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -3217,7 +3217,7 @@ public final class Launcher extends Activity
// Find the app market activity by resolving an intent.
// (If multiple app markets are installed, it will return the ResolverActivity.)
ComponentName activityName = intent.resolveActivity(getPackageManager());
- if (activityName != null && LauncherApplication.isScreenLarge()) {
+ if (activityName != null) {
mAppMarketIntent = intent;
sAppMarketIcon = updateTextButtonWithIconFromExternalActivity(
R.id.market_button, activityName, R.drawable.app_market_generic);