Merge "Fixing crash in Wallpaper picker. (3392415)" into honeycomb
diff --git a/res/drawable/wallpaper_picker_preview.png b/res/drawable-hdpi/wallpaper_picker_preview.png
similarity index 63%
rename from res/drawable/wallpaper_picker_preview.png
rename to res/drawable-hdpi/wallpaper_picker_preview.png
index 926a99c..300ea4a 100644
--- a/res/drawable/wallpaper_picker_preview.png
+++ b/res/drawable-hdpi/wallpaper_picker_preview.png
Binary files differ
diff --git a/res/drawable/wallpaper_picker_preview.png b/res/drawable-mdpi/wallpaper_picker_preview.png
similarity index 63%
copy from res/drawable/wallpaper_picker_preview.png
copy to res/drawable-mdpi/wallpaper_picker_preview.png
index 926a99c..300ea4a 100644
--- a/res/drawable/wallpaper_picker_preview.png
+++ b/res/drawable-mdpi/wallpaper_picker_preview.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/search_button_normal.png b/res/drawable-xlarge-hdpi/search_button_normal.png
deleted file mode 100644
index b1df556..0000000
--- a/res/drawable-xlarge-hdpi/search_button_normal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/search_button_pressed.png b/res/drawable-xlarge-hdpi/search_button_pressed.png
deleted file mode 100644
index 1013383..0000000
--- a/res/drawable-xlarge-hdpi/search_button_pressed.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/textfield_home_end.9.png b/res/drawable-xlarge-hdpi/textfield_home_end.9.png
deleted file mode 100644
index 4e79920..0000000
--- a/res/drawable-xlarge-hdpi/textfield_home_end.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/textfield_home_start.9.png b/res/drawable-xlarge-hdpi/textfield_home_start.9.png
deleted file mode 100644
index a338c69..0000000
--- a/res/drawable-xlarge-hdpi/textfield_home_start.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/homescreen_large_blue_strong.9.png b/res/drawable-xlarge-mdpi/homescreen_large_blue_strong.9.png
deleted file mode 100644
index f4913e5..0000000
--- a/res/drawable-xlarge-mdpi/homescreen_large_blue_strong.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/ic_generic_search.png b/res/drawable-xlarge-mdpi/ic_generic_search.png
new file mode 100644
index 0000000..d92071b
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/ic_generic_search.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/search_button_normal.png b/res/drawable-xlarge-mdpi/search_button_normal.png
deleted file mode 100644
index b172074..0000000
--- a/res/drawable-xlarge-mdpi/search_button_normal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/search_button_pressed.png b/res/drawable-xlarge-mdpi/search_button_pressed.png
deleted file mode 100644
index c2926c8..0000000
--- a/res/drawable-xlarge-mdpi/search_button_pressed.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/textfield_home_end.9.png b/res/drawable-xlarge-mdpi/textfield_home_end.9.png
deleted file mode 100644
index 753514f..0000000
--- a/res/drawable-xlarge-mdpi/textfield_home_end.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/textfield_home_start.9.png b/res/drawable-xlarge-mdpi/textfield_home_start.9.png
deleted file mode 100644
index 11ee7ca..0000000
--- a/res/drawable-xlarge-mdpi/textfield_home_start.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xlarge/search_button_generic.xml b/res/drawable-xlarge/search_button_generic.xml
deleted file mode 100644
index 8f18e67..0000000
--- a/res/drawable-xlarge/search_button_generic.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:drawable="@drawable/search_button_pressed" />
- <item android:drawable="@drawable/search_button_normal" />
-</selector>
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 93d19dc..c76516e 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -54,54 +54,51 @@
android:layout_height="?android:attr/actionBarSize"
android:layout_gravity="top">
- <LinearLayout android:id="@+id/search_button_cluster"
+ <!-- Global search icon -->
+ <ImageView
+ android:id="@+id/search_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
+ android:paddingRight="@dimen/toolbar_button_horizontal_padding"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
+ android:src="@drawable/ic_generic_search"
+ android:background="@drawable/button_bg"
+ android:onClick="onClickSearchButton"
+ android:focusable="true"
+ android:clickable="true" />
+
+ <ImageView
+ android:id="@+id/search_divider"
+ android:src="@drawable/divider_launcher_holo"
android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:gravity="bottom"
- >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="16dp"
- android:background="@drawable/textfield_home_start"
- android:orientation="horizontal">
- <!-- Global search icon -->
- <ImageView
- android:id="@+id/search_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingLeft="8dp"
- android:paddingRight="32dp"
- android:paddingTop="12dp"
- android:src="@drawable/search_button_generic"
- android:background="@drawable/button_bg"
- android:onClick="onClickSearchButton"
- android:focusable="true"
- android:clickable="true"/>
- </LinearLayout>
+ android:layout_height="@dimen/toolbar_divider_height"
+ android:layout_toRightOf="@id/search_button"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/textfield_home_end"
- android:orientation="horizontal">
- <!-- Voice search icon -->
- <ImageView
- android:id="@+id/voice_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingLeft="24dp"
- android:paddingRight="24dp"
- android:paddingTop="12dp"
- android:src="@drawable/ic_voice_search"
- android:background="@drawable/button_bg"
- android:onClick="onClickVoiceButton"
- android:focusable="true"
- android:clickable="true"/>
- </LinearLayout>
- </LinearLayout>
+ android:onClick="onClickAllAppsButton"
+ android:focusable="true"
+ android:clickable="true" />
+
+ <!-- Voice search icon -->
+ <ImageView
+ android:id="@+id/voice_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/search_divider"
+ android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
+ android:paddingRight="@dimen/toolbar_button_horizontal_padding"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
+ android:src="@drawable/ic_voice_search"
+ android:background="@drawable/button_bg"
+ android:onClick="onClickVoiceButton"
+ android:focusable="true"
+ android:clickable="true"/>
<ImageView
android:id="@+id/configure_button"
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index 6ad5d9c..3b499d9 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -54,54 +54,51 @@
android:layout_height="?android:attr/actionBarSize"
android:layout_gravity="top">
- <LinearLayout android:id="@+id/search_button_cluster"
+ <!-- Global search icon -->
+ <ImageView
+ android:id="@+id/search_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
+ android:paddingRight="@dimen/toolbar_button_horizontal_padding"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
+ android:src="@drawable/ic_generic_search"
+ android:background="@drawable/button_bg"
+ android:onClick="onClickSearchButton"
+ android:focusable="true"
+ android:clickable="true" />
+
+ <ImageView
+ android:id="@+id/search_divider"
+ android:src="@drawable/divider_launcher_holo"
android:layout_width="wrap_content"
- android:layout_height="48dp"
- android:gravity="bottom"
- >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="16dp"
- android:background="@drawable/textfield_home_start"
- android:orientation="horizontal">
- <!-- Global search icon -->
- <ImageView
- android:id="@+id/search_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingLeft="8dp"
- android:paddingRight="32dp"
- android:paddingTop="12dp"
- android:src="@drawable/search_button_generic"
- android:background="@drawable/button_bg"
- android:onClick="onClickSearchButton"
- android:focusable="true"
- android:clickable="true"/>
- </LinearLayout>
+ android:layout_height="@dimen/toolbar_divider_height"
+ android:layout_toRightOf="@id/search_button"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:background="@drawable/textfield_home_end"
- android:orientation="horizontal">
- <!-- Voice search icon -->
- <ImageView
- android:id="@+id/voice_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingLeft="24dp"
- android:paddingRight="24dp"
- android:paddingTop="12dp"
- android:src="@drawable/ic_voice_search"
- android:background="@drawable/button_bg"
- android:onClick="onClickVoiceButton"
- android:focusable="true"
- android:clickable="true"/>
- </LinearLayout>
- </LinearLayout>
+ android:onClick="onClickAllAppsButton"
+ android:focusable="true"
+ android:clickable="true" />
+
+ <!-- Voice search icon -->
+ <ImageView
+ android:id="@+id/voice_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/search_divider"
+ android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
+ android:paddingRight="@dimen/toolbar_button_horizontal_padding"
+ android:paddingTop="@dimen/toolbar_button_vertical_padding"
+ android:paddingBottom="@dimen/toolbar_button_vertical_padding"
+ android:src="@drawable/ic_voice_search"
+ android:background="@drawable/button_bg"
+ android:onClick="onClickVoiceButton"
+ android:focusable="true"
+ android:clickable="true"/>
<ImageView
android:id="@+id/configure_button"
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 9c629ee..de75fd3 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -84,7 +84,6 @@
private float mBackgroundAlphaMultiplier = 1.0f;
private Drawable mNormalBackground;
- private Drawable mNormalGlowBackground;
private Drawable mActiveBackground;
private Drawable mActiveGlowBackground;
private Drawable mNormalBackgroundMini;
@@ -169,7 +168,6 @@
if (LauncherApplication.isScreenXLarge()) {
mNormalBackground = res.getDrawable(R.drawable.homescreen_large_blue);
- mNormalGlowBackground = res.getDrawable(R.drawable.homescreen_large_blue_strong);
mActiveBackground = res.getDrawable(R.drawable.homescreen_large_green);
mActiveGlowBackground = res.getDrawable(R.drawable.homescreen_large_green_strong);
@@ -179,7 +177,6 @@
mActiveGlowBackgroundMini = res.getDrawable(R.drawable.homescreen_small_green_strong);
mNormalBackground.setFilterBitmap(true);
- mNormalGlowBackground.setFilterBitmap(true);
mActiveBackground.setFilterBitmap(true);
mActiveGlowBackground.setFilterBitmap(true);
mNormalBackgroundMini.setFilterBitmap(true);
@@ -308,6 +305,9 @@
if (scaleFactor != mGlowBackgroundScale) {
mGlowBackgroundScale = scaleFactor;
updateGlowRect();
+ if (getParent() != null) {
+ ((View) getParent()).invalidate();
+ }
}
}
@@ -380,8 +380,8 @@
bg = mini ? mActiveBackgroundMini : mActiveGlowBackground;
} else if (mIsDragOccuring && mAcceptsDrops) {
bg = mini ? mActiveBackgroundMini : mActiveBackground;
- } else if (mIsDragOccuring && mIsDefaultDropTarget) {
- bg = mini ? mNormalGlowBackgroundMini : mNormalGlowBackground;
+ } else if (mIsDefaultDropTarget && mini) {
+ bg = mNormalGlowBackgroundMini;
} else {
bg = mini ? mNormalBackgroundMini : mNormalBackground;
}
@@ -1245,6 +1245,13 @@
return result;
}
+ public int[] cellSpansToSize(int hSpans, int vSpans) {
+ int[] size = new int[2];
+ size[0] = hSpans * mCellWidth + (hSpans - 1) * mWidthGap;
+ size[1] = vSpans * mCellHeight + (vSpans - 1) * mHeightGap;
+ return size;
+ }
+
/**
* Calculate the grid spans needed to fit given item
*/
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index c74e5f4..e934efa 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -479,8 +479,9 @@
}
}
- Bitmap drawableToBitmap(Drawable d, View v) {
- Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
+ Bitmap drawableToBitmap(Drawable d, View v, boolean clipHeight) {
+ int height = clipHeight ? v.getPaddingTop() + d.getIntrinsicHeight() : v.getHeight();
+ Bitmap b = Bitmap.createBitmap(v.getWidth(), height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.translate((v.getWidth() - d.getIntrinsicWidth()) / 2, v.getPaddingTop());
d.draw(c);
@@ -508,8 +509,7 @@
// Get the widget preview as the drag representation
final LinearLayout l = (LinearLayout) v;
final ImageView i = (ImageView) l.findViewById(R.id.widget_preview);
- final Drawable icon = i.getDrawable();
- Bitmap b = drawableToBitmap(icon, i);
+ Bitmap b = drawableToBitmap(i.getDrawable(), i, true);
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
int[] spanXY = CellLayout.rectToCell(
@@ -529,7 +529,7 @@
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
- Bitmap b = drawableToBitmap(icon, tv);
+ Bitmap b = drawableToBitmap(icon, tv, false);
PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
@@ -546,7 +546,7 @@
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
- Bitmap b = drawableToBitmap(icon, tv);
+ Bitmap b = drawableToBitmap(icon, tv, false);
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 433dab8..c0776a9 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -48,7 +48,6 @@
private int mDragRegionHeight;
ValueAnimator mAnim;
- private float mScale = 1.0f;
private float mOffsetX = 0.0f;
private float mOffsetY = 0.0f;
@@ -144,22 +143,6 @@
mOnDrawRunnable = r;
}
- public int getScaledDragRegionXOffset() {
- return -(int)((mScale - 1.0f) * mDragRegionWidth / 2);
- }
-
- public int getScaledDragRegionWidth() {
- return (int)(mScale * mDragRegionWidth);
- }
-
- public int getScaledDragRegionYOffset() {
- return -(int)((mScale - 1.0f) * mDragRegionHeight / 2);
- }
-
- public int getScaledDragRegionHeight() {
- return (int)(mScale * mDragRegionWidth);
- }
-
public int getDragRegionLeft() {
return mDragRegionLeft;
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index dabc42a..966f2e7 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1148,10 +1148,7 @@
final int[] cellXY = mTmpAddItemCellCoordinates;
final CellLayout layout = (CellLayout) mWorkspace.getChildAt(screen);
- int[] touchXY = null;
- if (mAddDropPosition != null && mAddDropPosition[0] > -1 && mAddDropPosition[1] > -1) {
- touchXY = mAddDropPosition;
- }
+ int[] touchXY = mAddDropPosition;
boolean foundCellSpan = false;
if (touchXY != null) {
// when dragging and dropping, just find the closest free spot
@@ -1196,13 +1193,7 @@
// if we are placing widgets on a "spring-loaded" screen
final int[] cellXY = mTmpAddItemCellCoordinates;
- // For now, we don't save the coordinate where we dropped the icon because we're not
- // supporting spring-loaded mini-screens; however, leaving the ability to directly place
- // a widget on the home screen in case we want to add it in the future
- int[] touchXY = null;
- if (mAddDropPosition != null && mAddDropPosition[0] > -1 && mAddDropPosition[1] > -1) {
- touchXY = mAddDropPosition;
- }
+ int[] touchXY = mAddDropPosition;
boolean foundCellSpan = false;
if (touchXY != null) {
// when dragging and dropping, just find the closest free spot
@@ -2607,7 +2598,9 @@
* @param hideSeq AnimatorSet in which to put "hide" animations, or null.
*/
private void hideAndShowToolbarButtons(State newState, AnimatorSet showSeq, AnimatorSet hideSeq) {
- final View searchButton = findViewById(R.id.search_button_cluster);
+ final View searchButton = findViewById(R.id.search_button);
+ final View searchDivider = findViewById(R.id.search_divider);
+ final View voiceSearchButton = findViewById(R.id.voice_button);
final View allAppsButton = findViewById(R.id.all_apps_button);
final View divider = findViewById(R.id.divider);
final View configureButton = findViewById(R.id.configure_button);
@@ -2615,6 +2608,8 @@
switch (newState) {
case WORKSPACE:
hideOrShowToolbarButton(true, searchButton, showSeq);
+ hideOrShowToolbarButton(true, searchDivider, showSeq);
+ hideOrShowToolbarButton(true, voiceSearchButton, showSeq);
hideOrShowToolbarButton(true, allAppsButton, showSeq);
hideOrShowToolbarButton(true, divider, showSeq);
hideOrShowToolbarButton(true, configureButton, showSeq);
@@ -2624,7 +2619,9 @@
break;
case ALL_APPS:
hideOrShowToolbarButton(false, configureButton, hideSeq);
+ hideOrShowToolbarButton(false, searchDivider, hideSeq);
hideOrShowToolbarButton(false, searchButton, hideSeq);
+ hideOrShowToolbarButton(false, voiceSearchButton, hideSeq);
hideOrShowToolbarButton(false, divider, hideSeq);
hideOrShowToolbarButton(false, allAppsButton, hideSeq);
mDeleteZone.setDragAndDropEnabled(false);
@@ -2632,7 +2629,9 @@
break;
case CUSTOMIZE:
hideOrShowToolbarButton(false, allAppsButton, hideSeq);
+ hideOrShowToolbarButton(false, searchDivider, hideSeq);
hideOrShowToolbarButton(false, searchButton, hideSeq);
+ hideOrShowToolbarButton(false, voiceSearchButton, hideSeq);
hideOrShowToolbarButton(false, divider, hideSeq);
hideOrShowToolbarButton(false, configureButton, hideSeq);
mDeleteZone.setDragAndDropEnabled(false);
@@ -3115,7 +3114,7 @@
ComponentName activityName = searchManager.getGlobalSearchActivity();
if (activityName != null) {
sGlobalSearchIcon = updateButtonWithIconFromExternalActivity(
- R.id.search_button, activityName, R.drawable.search_button_generic);
+ R.id.search_button, activityName, R.drawable.ic_generic_search);
} else {
findViewById(R.id.search_button).setVisibility(View.GONE);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index e7fb0fd..270027b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -125,7 +125,6 @@
private int mDefaultPage;
- private boolean mPageMoving = false;
private boolean mIsDragInProcess = false;
/**
@@ -549,7 +548,6 @@
enableChildrenCache(mCurrentPage - 1, mCurrentPage + 1);
}
showOutlines();
- mPageMoving = true;
}
protected void onPageEndMoving() {
@@ -560,7 +558,6 @@
}
mOverScrollMaxBackgroundAlpha = 0.0f;
mOverScrollPageIndex = -1;
- mPageMoving = false;
}
@Override
@@ -1491,8 +1488,10 @@
// We need to add extra padding to the bitmap to make room for the glow effect
final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
+ CellLayout cl = (CellLayout) getChildAt(0);
+ int[] desiredSize = cl.cellSpansToSize(spanX, spanY);
// The outline is used to visualize where the item will land if dropped
- mDragOutline = createDragOutline(b, canvas, bitmapPadding);
+ mDragOutline = createDragOutline(b, canvas, bitmapPadding, desiredSize[0], desiredSize[1]);
updateWhichPagesAcceptDropsDuringDrag(mShrinkState, spanX, spanY);
}
@@ -1688,13 +1687,24 @@
* Returns a new bitmap to be used as the object outline, e.g. to visualize the drop location.
* Responsibility for the bitmap is transferred to the caller.
*/
- private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding) {
+ private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h) {
final int outlineColor = getResources().getColor(R.color.drag_outline_color);
- final Bitmap b = Bitmap.createBitmap(
- orig.getWidth() + padding, orig.getHeight() + padding, Bitmap.Config.ARGB_8888);
-
+ final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
- canvas.drawBitmap(orig, 0, 0, new Paint());
+
+ Rect src = new Rect(0, 0, orig.getWidth(), orig.getHeight());
+ float scaleFactor = Math.min((w - padding) / (float) orig.getWidth(),
+ (h - padding) / (float) orig.getHeight());
+ int scaledWidth = (int) (scaleFactor * orig.getWidth());
+ int scaledHeight = (int) (scaleFactor * orig.getHeight());
+ Rect dst = new Rect(0, 0, scaledWidth, scaledHeight);
+
+ // center the image
+ dst.offset((w - scaledWidth) / 2, (h - scaledHeight) / 2);
+
+ Paint p = new Paint();
+ p.setFilterBitmap(true);
+ canvas.drawBitmap(orig, src, dst, p);
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
return b;
@@ -2232,11 +2242,11 @@
int dragViewX, int dragViewY, Matrix cachedInverseMatrix) {
// Transform the coordinates of the item being dragged to the CellLayout's coordinates
final float[] draggedItemTopLeft = mTempDragCoordinates;
- draggedItemTopLeft[0] = dragViewX + dragView.getScaledDragRegionXOffset();
- draggedItemTopLeft[1] = dragViewY + dragView.getScaledDragRegionYOffset();
+ draggedItemTopLeft[0] = dragViewX;
+ draggedItemTopLeft[1] = dragViewY;
final float[] draggedItemBottomRight = mTempDragBottomRightCoordinates;
- draggedItemBottomRight[0] = draggedItemTopLeft[0] + dragView.getScaledDragRegionWidth();
- draggedItemBottomRight[1] = draggedItemTopLeft[1] + dragView.getScaledDragRegionHeight();
+ draggedItemBottomRight[0] = draggedItemTopLeft[0] + dragView.getDragRegionWidth();
+ draggedItemBottomRight[1] = draggedItemTopLeft[1] + dragView.getDragRegionHeight();
// Transform the dragged item's top left coordinates
// to the CellLayout's local coordinates