diff options
18 files changed, 144 insertions, 154 deletions
diff --git a/res/drawable-hdpi/default_widget_preview_holo.9.png b/res/drawable-hdpi/default_widget_preview_holo.9.png Binary files differdeleted file mode 100644 index 0b4a6343f..000000000 --- a/res/drawable-hdpi/default_widget_preview_holo.9.png +++ /dev/null diff --git a/res/drawable-mdpi/default_widget_preview_holo.9.png b/res/drawable-mdpi/default_widget_preview_holo.9.png Binary files differdeleted file mode 100644 index 0bfdaef58..000000000 --- a/res/drawable-mdpi/default_widget_preview_holo.9.png +++ /dev/null diff --git a/res/drawable-xhdpi/default_widget_preview_holo.9.png b/res/drawable-xhdpi/default_widget_preview_holo.9.png Binary files differdeleted file mode 100644 index 42d57d843..000000000 --- a/res/drawable-xhdpi/default_widget_preview_holo.9.png +++ /dev/null diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index a50836168..ef3327295 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -35,7 +35,6 @@ import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; -import android.graphics.Insets; import android.graphics.MaskFilter; import android.graphics.Matrix; import android.graphics.Paint; @@ -60,17 +59,16 @@ import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.GridLayout; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.Toast; import com.android.launcher.R; import com.android.launcher2.DropTarget.DragObject; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.lang.ref.WeakReference; /** * A simple callback interface which also provides the results of the task. @@ -267,7 +265,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Caching private Canvas mCanvas; - private Drawable mDefaultWidgetBackground; private IconCache mIconCache; // Dimens @@ -336,7 +333,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Save the default widget preview background Resources resources = context.getResources(); - mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo); mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0); @@ -529,20 +525,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } public void onPackagesUpdated() { - // TODO: this isn't ideal, but we actually need to delay here. This call is triggered - // by a broadcast receiver, and in order for it to work correctly, we need to know that - // the AppWidgetService has already received and processed the same broadcast. Since there - // is no guarantee about ordering of broadcast receipt, we just delay here. This is a - // workaround until we add a callback from AppWidgetService to AppWidgetHost when widget - // packages are added, updated or removed. - postDelayed(new Runnable() { - public void run() { - updatePackages(); - } - }, 1500); - } - - public void updatePackages() { // Get the list of widgets and shortcuts mWidgets.clear(); List<AppWidgetProviderInfo> widgets = @@ -1240,7 +1222,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_right); int scaledIconWidth = (maxWidth - paddingLeft - paddingRight); - float scaleSize = scaledIconWidth / (float) mAppIconSize; renderDrawableToBitmap( icon, tempBitmap, paddingLeft, paddingTop, scaledIconWidth, scaledIconWidth); @@ -1328,7 +1309,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen (int) ((previewDrawableHeight - mAppIconSize * iconScale) / 2); if (iconId > 0) icon = mIconCache.getFullResIcon(packageName, iconId); - Resources resources = mLauncher.getResources(); if (icon != null) { renderDrawableToBitmap(icon, defaultPreview, hoffset, yoffset, (int) (mAppIconSize * iconScale), diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 9fa2f3237..a2cab5322 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -58,8 +58,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona private boolean mResetAfterTransition; private Runnable mRelayoutAndMakeVisible; - private Launcher mLauncher; - public AppsCustomizeTabHost(Context context, AttributeSet attrs) { super(context, attrs); mLayoutInflater = LayoutInflater.from(context); @@ -71,10 +69,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona }; } - public void setup(Launcher launcher) { - mLauncher = launcher; - } - /** * Convenience methods to select specific tabs. We want to set the content type immediately * in these cases, but we note that we still call setCurrentTabByTag() so that the tab view diff --git a/src/com/android/launcher2/Cling.java b/src/com/android/launcher2/Cling.java index c83ee2fde..33cb26f0a 100644 --- a/src/com/android/launcher2/Cling.java +++ b/src/com/android/launcher2/Cling.java @@ -31,7 +31,6 @@ import android.util.DisplayMetrics; import android.view.FocusFinder; import android.view.MotionEvent; import android.view.View; -import android.view.accessibility.AccessibilityManager; import android.widget.FrameLayout; import com.android.launcher.R; @@ -83,6 +82,8 @@ public class Cling extends FrameLayout { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Cling, defStyle, 0); mDrawIdentifier = a.getString(R.styleable.Cling_drawIdentifier); a.recycle(); + + setClickable(true); } void init(Launcher l, int[] positionData) { @@ -138,16 +139,8 @@ public class Cling extends FrameLayout { } @Override - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { - if (descendant.includeForAccessibility()) { - return descendant; - } - return null; - } - - @Override public View focusSearch(int direction) { - return this.focusSearch(null, direction); + return this.focusSearch(this, direction); } @Override diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java index 949c035ea..39a0b09c7 100644 --- a/src/com/android/launcher2/DeleteDropTarget.java +++ b/src/com/android/launcher2/DeleteDropTarget.java @@ -25,7 +25,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.util.AttributeSet; import android.view.View; diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 4be1914e0..0bcd64c41 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -24,8 +24,6 @@ import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; @@ -446,7 +444,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang public void animateViewIntoPosition(DragView dragView, final View child, int duration, final Runnable onFinishAnimationRunnable, View anchorView) { ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent(); - CellLayout parent = (CellLayout) (CellLayout) parentChildren.getParent(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); parentChildren.measureChild(child); diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index de2e4359a..53c304609 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -57,8 +57,6 @@ import java.util.Comparator; public class Folder extends LinearLayout implements DragSource, View.OnClickListener, View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener, View.OnFocusChangeListener { - - @SuppressWarnings("unused") private static final String TAG = "Launcher.Folder"; protected DragController mDragController; @@ -110,6 +108,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private static String sHintText; private ObjectAnimator mOpenCloseAnimator; + private boolean mDestroyed; + /** * Used to inflate the Workspace from XML. * @@ -945,34 +945,45 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private void replaceFolderWithFinalItem() { - ItemInfo finalItem = null; + // Add the last remaining child to the workspace in place of the folder + Runnable onCompleteRunnable = new Runnable() { + @Override + public void run() { + CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screen); + + if (getItemCount() <= 1) { + // Remove the folder + LauncherModel.deleteItemFromDatabase(mLauncher, mInfo); + cellLayout.removeView(mFolderIcon); + if (mFolderIcon instanceof DropTarget) { + mDragController.removeDropTarget((DropTarget) mFolderIcon); + } + mLauncher.removeFolder(mInfo); + } - if (getItemCount() == 1) { - finalItem = mInfo.contents.get(0); - } + // Move the item from the folder to the workspace, in the position of the folder + if (getItemCount() == 1) { + ShortcutInfo finalItem = mInfo.contents.get(0); - // Remove the folder completely - CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screen); - cellLayout.removeView(mFolderIcon); - if (mFolderIcon instanceof DropTarget) { - mDragController.removeDropTarget((DropTarget) mFolderIcon); - } - mLauncher.removeFolder(mInfo); + final View child = mLauncher.createShortcut(R.layout.application, cellLayout, + finalItem); + LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem, mInfo.container, + mInfo.screen, mInfo.cellX, mInfo.cellY); + mLauncher.getWorkspace().addInScreen(child, mInfo.container, mInfo.screen, + mInfo.cellX, mInfo.cellY, mInfo.spanX, mInfo.spanY); + } - if (finalItem != null) { - LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem, mInfo.container, - mInfo.screen, mInfo.cellX, mInfo.cellY); + } + }; + View finalChild = getItemAt(0); + if (finalChild != null) { + mFolderIcon.performDestroyAnimation(finalChild, onCompleteRunnable); } - LauncherModel.deleteItemFromDatabase(mLauncher, mInfo); - - // Add the last remaining child to the workspace in place of the folder - if (finalItem != null) { - View child = mLauncher.createShortcut(R.layout.application, cellLayout, - (ShortcutInfo) finalItem); + mDestroyed = true; + } - mLauncher.getWorkspace().addInScreen(child, mInfo.container, mInfo.screen, mInfo.cellX, - mInfo.cellY, mInfo.spanX, mInfo.spanY); - } + boolean isDestroyed() { + return mDestroyed; } // This method keeps track of the last item in the folder for the purposes diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java index 4919b57f0..76f31143c 100644 --- a/src/com/android/launcher2/FolderIcon.java +++ b/src/com/android/launcher2/FolderIcon.java @@ -50,8 +50,8 @@ import java.util.ArrayList; */ public class FolderIcon extends LinearLayout implements FolderListener { private Launcher mLauncher; - Folder mFolder; - FolderInfo mInfo; + private Folder mFolder; + private FolderInfo mInfo; private static boolean sStaticValuesDirty = true; private CheckLongPressHelper mLongPressHelper; @@ -61,6 +61,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { private static final int CONSUMPTION_ANIMATION_DURATION = 100; private static final int DROP_IN_ANIMATION_DURATION = 400; private static final int INITIAL_ITEM_ANIMATION_DURATION = 350; + private static final int FINAL_ITEM_ANIMATION_DURATION = 200; // The degree to which the inner ring grows when accepting drop private static final float INNER_RING_GROWTH_FACTOR = 0.15f; @@ -93,8 +94,10 @@ public class FolderIcon extends LinearLayout implements FolderListener { private int mPreviewOffsetY; private float mMaxPerspectiveShift; boolean mAnimating = false; + private PreviewItemDrawingParams mParams = new PreviewItemDrawingParams(0, 0, 0, 0); private PreviewItemDrawingParams mAnimParams = new PreviewItemDrawingParams(0, 0, 0, 0); + private ArrayList<ShortcutInfo> mHiddenItems = new ArrayList<ShortcutInfo>(); public FolderIcon(Context context, AttributeSet attrs) { super(context, attrs); @@ -278,6 +281,14 @@ public class FolderIcon extends LinearLayout implements FolderListener { } } + Folder getFolder() { + return mFolder; + } + + FolderInfo getFolderInfo() { + return mInfo; + } + private boolean willAcceptItem(ItemInfo item) { final int itemType = item.itemType; return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || @@ -287,7 +298,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { public boolean acceptDrop(Object dragInfo) { final ItemInfo item = (ItemInfo) dragInfo; - return willAcceptItem(item); + return !mFolder.isDestroyed() && willAcceptItem(item); } public void addItem(ShortcutInfo item) { @@ -296,7 +307,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { } public void onDragEnter(Object dragInfo) { - if (!willAcceptItem((ItemInfo) dragInfo)) return; + if (mFolder.isDestroyed() || !willAcceptItem((ItemInfo) dragInfo)) return; CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams(); CellLayout layout = (CellLayout) getParent().getParent(); mFolderRingAnimator.setCell(lp.cellX, lp.cellY); @@ -312,16 +323,29 @@ public class FolderIcon extends LinearLayout implements FolderListener { final ShortcutInfo srcInfo, final DragView srcView, Rect dstRect, float scaleRelativeToDragLayer, Runnable postAnimationRunnable) { + // These correspond two the drawable and view that the icon was dropped _onto_ Drawable animateDrawable = ((TextView) destView).getCompoundDrawables()[1]; - computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(), destView.getMeasuredWidth()); + computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(), + destView.getMeasuredWidth()); + + // This will animate the first item from it's position as an icon into its + // position as the first item in the preview + animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION, false, null); + addItem(destInfo); // This will animate the dragView (srcView) into the new folder onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable, null); + } + + public void performDestroyAnimation(final View finalView, Runnable onCompleteRunnable) { + Drawable animateDrawable = ((TextView) finalView).getCompoundDrawables()[1]; + computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(), + finalView.getMeasuredWidth()); // This will animate the first item from it's position as an icon into its // position as the first item in the preview - animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION); - addItem(destInfo); + animateFirstItem(animateDrawable, FINAL_ITEM_ANIMATION_DURATION, true, + onCompleteRunnable); } public void onDragExit(Object dragInfo) { @@ -377,9 +401,12 @@ public class FolderIcon extends LinearLayout implements FolderListener { 1, 1, finalScale, finalScale, DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2), new AccelerateInterpolator(2), postAnimationRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null); + addItem(item); + mHiddenItems.add(item); postDelayed(new Runnable() { public void run() { - addItem(item); + mHiddenItems.remove(item); + invalidate(); } }, DROP_IN_ANIMATION_DURATION); } else { @@ -526,19 +553,20 @@ public class FolderIcon extends LinearLayout implements FolderListener { if (!mAnimating) { for (int i = nItemsInPreview - 1; i >= 0; i--) { v = (TextView) items.get(i); - d = v.getCompoundDrawables()[1]; - - mParams = computePreviewItemDrawingParams(i, mParams); - mParams.drawable = d; - drawPreviewItem(canvas, mParams); + if (!mHiddenItems.contains(v.getTag())) { + d = v.getCompoundDrawables()[1]; + mParams = computePreviewItemDrawingParams(i, mParams); + mParams.drawable = d; + drawPreviewItem(canvas, mParams); + } } } else { drawPreviewItem(canvas, mAnimParams); } } - private void animateFirstItem(final Drawable d, int duration) { - computePreviewDrawingParams(d); + private void animateFirstItem(final Drawable d, int duration, final boolean reverse, + final Runnable onCompleteRunnable) { final PreviewItemDrawingParams finalParams = computePreviewItemDrawingParams(0, null); final float scale0 = 1.0f; @@ -550,6 +578,10 @@ public class FolderIcon extends LinearLayout implements FolderListener { va.addUpdateListener(new AnimatorUpdateListener(){ public void onAnimationUpdate(ValueAnimator animation) { float progress = (Float) animation.getAnimatedValue(); + if (reverse) { + progress = 1 - progress; + mPreviewBackground.setAlpha(progress); + } mAnimParams.transX = transX0 + progress * (finalParams.transX - transX0); mAnimParams.transY = transY0 + progress * (finalParams.transY - transY0); @@ -565,6 +597,9 @@ public class FolderIcon extends LinearLayout implements FolderListener { @Override public void onAnimationEnd(Animator animation) { mAnimating = false; + if (onCompleteRunnable != null) { + onCompleteRunnable.run(); + } } }); va.setDuration(duration); diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java index a525d00ee..20a19660e 100644 --- a/src/com/android/launcher2/InstallShortcutReceiver.java +++ b/src/com/android/launcher2/InstallShortcutReceiver.java @@ -22,7 +22,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; -import android.os.Debug; import android.widget.Toast; import com.android.launcher.R; diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index f4180cd00..415ccacfb 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -61,7 +61,6 @@ import android.os.Handler; import android.os.Message; import android.os.StrictMode; import android.os.SystemClock; -import android.os.SystemProperties; import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.Selection; @@ -99,6 +98,7 @@ import com.android.launcher2.DropTarget.DragObject; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileDescriptor; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -145,7 +145,8 @@ public final class Launcher extends Activity static final int DEFAULT_SCREEN = 2; private static final String PREFERENCES = "launcher.preferences"; - static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher.force_enable_rotation"; + static final String FORCE_ENABLE_ROTATION_PROPERTY = "debug.force_enable_rotation"; + static final String DUMP_STATE_PROPERTY = "debug.dumpstate"; // The Intent extra that defines whether to ignore the launch animation static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION = @@ -308,6 +309,20 @@ public final class Launcher extends Activity int cellY; } + + private boolean doesFileExist(String filename) { + FileInputStream fis = null; + try { + fis = openFileInput(filename); + fis.close(); + return true; + } catch (java.io.FileNotFoundException e) { + return false; + } catch (java.io.IOException e) { + return true; + } + } + @Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { @@ -901,7 +916,6 @@ public final class Launcher extends Activity findViewById(R.id.apps_customize_pane); mAppsCustomizeContent = (AppsCustomizePagedView) mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content); - mAppsCustomizeTabHost.setup(this); mAppsCustomizeContent.setup(this, dragController); // Get the all apps button @@ -1745,7 +1759,7 @@ public final class Launcher extends Activity case KeyEvent.KEYCODE_HOME: return true; case KeyEvent.KEYCODE_VOLUME_DOWN: - if (SystemProperties.getInt("debug.launcher2.dumpstate", 0) != 0) { + if (doesFileExist(DUMP_STATE_PROPERTY)) { dumpState(); return true; } @@ -1988,7 +2002,7 @@ public final class Launcher extends Activity } private void handleFolderClick(FolderIcon folderIcon) { - final FolderInfo info = folderIcon.mInfo; + final FolderInfo info = folderIcon.getFolderInfo(); Folder openFolder = mWorkspace.getFolderForTag(info); // If the folder info reports that the associated folder is open, then verify that @@ -1999,7 +2013,7 @@ public final class Launcher extends Activity info.opened = false; } - if (!info.opened) { + if (!info.opened && !folderIcon.getFolder().isDestroyed()) { // Close any open folder closeFolder(); // Open the requested folder @@ -2056,9 +2070,9 @@ public final class Launcher extends Activity mFolderIconCanvas.drawColor(0, PorterDuff.Mode.CLEAR); fi.draw(mFolderIconCanvas); mFolderIconImageView.setImageBitmap(mFolderIconBitmap); - if (fi.mFolder != null) { - mFolderIconImageView.setPivotX(fi.mFolder.getPivotXForIconAnimation()); - mFolderIconImageView.setPivotY(fi.mFolder.getPivotYForIconAnimation()); + if (fi.getFolder() != null) { + mFolderIconImageView.setPivotX(fi.getFolder().getPivotXForIconAnimation()); + mFolderIconImageView.setPivotY(fi.getFolder().getPivotYForIconAnimation()); } // Just in case this image view is still in the drag layer from a previous animation, // we remove it and re-add it. @@ -2066,8 +2080,8 @@ public final class Launcher extends Activity mDragLayer.removeView(mFolderIconImageView); } mDragLayer.addView(mFolderIconImageView, lp); - if (fi.mFolder != null) { - fi.mFolder.bringToFront(); + if (fi.getFolder() != null) { + fi.getFolder().bringToFront(); } } @@ -2130,7 +2144,7 @@ public final class Launcher extends Activity * @param folderInfo The FolderInfo describing the folder to open. */ public void openFolder(FolderIcon folderIcon) { - Folder folder = folderIcon.mFolder; + Folder folder = folderIcon.getFolder(); FolderInfo info = folder.mInfo; info.opened = true; @@ -3522,8 +3536,7 @@ public final class Launcher extends Activity } public boolean isRotationEnabled() { - boolean forceEnableRotation = "true".equalsIgnoreCase(SystemProperties.get( - FORCE_ENABLE_ROTATION_PROPERTY, "false")); + boolean forceEnableRotation = doesFileExist(FORCE_ENABLE_ROTATION_PROPERTY); boolean enableRotation = forceEnableRotation || getResources().getBoolean(R.bool.allow_rotation); return enableRotation; @@ -3561,7 +3574,6 @@ public final class Launcher extends Activity cling.init(this, positionData); cling.setVisibility(View.VISIBLE); cling.setLayerType(View.LAYER_TYPE_HARDWARE, null); - cling.requestAccessibilityFocus(); if (animate) { cling.buildLayer(); cling.setAlpha(0f); diff --git a/src/com/android/launcher2/LauncherAppWidgetHost.java b/src/com/android/launcher2/LauncherAppWidgetHost.java index 68d4903da..35c60a08f 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHost.java +++ b/src/com/android/launcher2/LauncherAppWidgetHost.java @@ -27,8 +27,12 @@ import android.content.Context; * always pick up and move widgets. */ public class LauncherAppWidgetHost extends AppWidgetHost { - public LauncherAppWidgetHost(Context context, int hostId) { - super(context, hostId); + + Launcher mLauncher; + + public LauncherAppWidgetHost(Launcher launcher, int hostId) { + super(launcher, hostId); + mLauncher = launcher; } @Override @@ -42,4 +46,11 @@ public class LauncherAppWidgetHost extends AppWidgetHost { super.stopListening(); clearViews(); } + + @Override + protected void onProvidersChanged() { + // Once we get the message that widget packages are updated, we need to rebind items + // in AppsCustomize accordingly. + mLauncher.bindPackagesUpdated(); + } } diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java index 9970c7675..549d3340e 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java @@ -18,9 +18,6 @@ package com.android.launcher2; import android.appwidget.AppWidgetHostView; import android.content.Context; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.Parcel; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java index 0720259f4..ccc126a11 100644 --- a/src/com/android/launcher2/LauncherProvider.java +++ b/src/com/android/launcher2/LauncherProvider.java @@ -751,12 +751,12 @@ public class LauncherProvider extends ContentProvider { private static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException { int type; - while ((type = parser.next()) != parser.START_TAG - && type != parser.END_DOCUMENT) { + while ((type = parser.next()) != XmlPullParser.START_TAG + && type != XmlPullParser.END_DOCUMENT) { ; } - if (type != parser.START_TAG) { + if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } diff --git a/src/com/android/launcher2/PagedViewWidgetImageView.java b/src/com/android/launcher2/PagedViewWidgetImageView.java index 22db0abd8..992817786 100644 --- a/src/com/android/launcher2/PagedViewWidgetImageView.java +++ b/src/com/android/launcher2/PagedViewWidgetImageView.java @@ -18,12 +18,9 @@ package com.android.launcher2; import android.content.Context; import android.graphics.Canvas; -import android.graphics.Insets; import android.util.AttributeSet; import android.widget.ImageView; - - class PagedViewWidgetImageView extends ImageView { public boolean mAllowRequestLayout = true; @@ -39,16 +36,11 @@ class PagedViewWidgetImageView extends ImageView { @Override protected void onDraw(Canvas canvas) { - - Insets insets = Insets.NONE; - if (getBackground() != null) { - insets = getBackground().getLayoutInsets(); - } canvas.save(); - canvas.clipRect(getScrollX() + getPaddingLeft() + insets.left, - getScrollY() + getPaddingTop() + insets.top, - getScrollX() + getRight() - getLeft() - getPaddingRight() - insets.right, - getScrollY() + getBottom() - getTop() - getPaddingBottom() - insets.bottom); + canvas.clipRect(getScrollX() + getPaddingLeft(), + getScrollY() + getPaddingTop(), + getScrollX() + getRight() - getLeft() - getPaddingRight(), + getScrollY() + getBottom() - getTop() - getPaddingBottom()); super.onDraw(canvas); canvas.restore(); diff --git a/src/com/android/launcher2/PreloadReceiver.java b/src/com/android/launcher2/PreloadReceiver.java index d1bc6393d..7bec72117 100644 --- a/src/com/android/launcher2/PreloadReceiver.java +++ b/src/com/android/launcher2/PreloadReceiver.java @@ -19,7 +19,6 @@ package com.android.launcher2; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.util.Log; public class PreloadReceiver extends BroadcastReceiver { @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 0192630b6..174d23b4d 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -24,7 +24,6 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.WallpaperManager; import android.appwidget.AppWidgetHostView; -import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.Context; @@ -33,7 +32,6 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.Camera; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; @@ -62,7 +60,6 @@ import com.android.launcher2.LauncherSettings.Favorites; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; /** @@ -179,11 +176,6 @@ public class Workspace extends SmoothPagedView public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; - // Camera and Matrix used to determine the final position of a neighboring CellLayout - private final Matrix mMatrix = new Matrix(); - private final Camera mCamera = new Camera(); - private final float mTempFloat2[] = new float[2]; - enum WallpaperVerticalOffset { TOP, MIDDLE, BOTTOM }; int mWallpaperWidth; int mWallpaperHeight; @@ -1179,31 +1171,6 @@ public class Workspace extends SmoothPagedView return mBackgroundAlpha; } - /** - * Due to 3D transformations, if two CellLayouts are theoretically touching each other, - * on the xy plane, when one is rotated along the y-axis, the gap between them is perceived - * as being larger. This method computes what offset the rotated view should be translated - * in order to minimize this perceived gap. - * @param degrees Angle of the view - * @param width Width of the view - * @param height Height of the view - * @return Offset to be used in a View.setTranslationX() call - */ - private float getOffsetXForRotation(float degrees, int width, int height) { - mMatrix.reset(); - mCamera.save(); - mCamera.rotateY(Math.abs(degrees)); - mCamera.getMatrix(mMatrix); - mCamera.restore(); - - mMatrix.preTranslate(-width * 0.5f, -height * 0.5f); - mMatrix.postTranslate(width * 0.5f, height * 0.5f); - mTempFloat2[0] = width; - mTempFloat2[1] = height; - mMatrix.mapPoints(mTempFloat2); - return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f); - } - float backgroundAlphaInterpolator(float r) { float pivotA = 0.1f; float pivotB = 0.4f; @@ -2418,7 +2385,13 @@ public class Workspace extends SmoothPagedView // Here we store the final page that will be dropped to, if the workspace in fact // receives the drop if (mInScrollArea) { - mDropToLayout = mDragOverlappingLayout; + if (isPageMoving()) { + // If the user drops while the page is scrolling, we should use that page as the + // destination instead of the page that is being hovered over. + mDropToLayout = (CellLayout) getPageAt(getNextPage()); + } else { + mDropToLayout = mDragOverlappingLayout; + } } else { mDropToLayout = mDragTargetLayout; } @@ -3573,8 +3546,6 @@ public class Workspace extends SmoothPagedView } void removeItems(final ArrayList<ApplicationInfo> apps) { - final AppWidgetManager widgets = AppWidgetManager.getInstance(getContext()); - final HashSet<String> packageNames = new HashSet<String>(); final int appCount = apps.size(); for (int i = 0; i < appCount; i++) { |