Merge "Adding support for app widgets in the InstallQueue" into ub-launcher3-master
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 9eaef90..866d239 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -1041,7 +1041,7 @@
// Offsets due to the size difference between the View and the dragOutline.
// There is a size difference to account for the outer blur, which may lie
// outside the bounds of the view.
- top += (v.getHeight() - dragOutline.getHeight()) / 2;
+ top += ((mCellHeight * spanY) - dragOutline.getHeight()) / 2;
// We center about the x axis
left += ((mCellWidth * spanX) - dragOutline.getWidth()) / 2;
} else {
diff --git a/src/com/android/launcher3/PreloadIconDrawable.java b/src/com/android/launcher3/PreloadIconDrawable.java
index efc0eac..973e688 100644
--- a/src/com/android/launcher3/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/PreloadIconDrawable.java
@@ -177,8 +177,9 @@
// Set the paint color only when the level changes, so that the dominant color
// is only calculated when needed.
mPaint.setColor(getIndicatorColor());
- } else if (mIcon instanceof FastBitmapDrawable) {
- ((FastBitmapDrawable) mIcon).setIsDisabled(true);
+ }
+ if (mIcon instanceof FastBitmapDrawable) {
+ ((FastBitmapDrawable) mIcon).setIsDisabled(level < 100);
}
invalidateSelf();
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 54d9b2e..10680b4 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3461,14 +3461,14 @@
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(layout, loc, true);
resetTransitionTransform(layout);
- float dragViewScaleX;
- float dragViewScaleY;
+ float dragViewScaleX = 1f;
+ float dragViewScaleY = 1f;
if (scale) {
- dragViewScaleX = (1.0f * r.width()) / dragView.getMeasuredWidth();
- dragViewScaleY = (1.0f * r.height()) / dragView.getMeasuredHeight();
- } else {
- dragViewScaleX = 1f;
- dragViewScaleY = 1f;
+ float width = info.spanX * layout.mCellWidth;
+ float height = info.spanY * layout.mCellHeight;
+
+ dragViewScaleX = r.width() / width;
+ dragViewScaleY = r.height() / height;
}
// The animation will scale the dragView about its center, so we need to center about
diff --git a/src/com/android/launcher3/graphics/DragPreviewProvider.java b/src/com/android/launcher3/graphics/DragPreviewProvider.java
index a7d4c63..e205c42 100644
--- a/src/com/android/launcher3/graphics/DragPreviewProvider.java
+++ b/src/com/android/launcher3/graphics/DragPreviewProvider.java
@@ -24,7 +24,9 @@
import android.view.View;
import android.widget.TextView;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PreloadIconDrawable;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.ProviderConfig;
@@ -100,20 +102,31 @@
* Responsibility for the bitmap is transferred to the caller.
*/
public Bitmap createDragBitmap(Canvas canvas) {
- Bitmap b;
+ float scale = 1f;
+ int width = mView.getWidth();
+ int height = mView.getHeight();
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
- b = Bitmap.createBitmap(bounds.width() + DRAG_BITMAP_PADDING,
- bounds.height() + DRAG_BITMAP_PADDING, Bitmap.Config.ARGB_8888);
- } else {
- b = Bitmap.createBitmap(mView.getWidth() + DRAG_BITMAP_PADDING,
- mView.getHeight() + DRAG_BITMAP_PADDING, Bitmap.Config.ARGB_8888);
+ width = bounds.width();
+ height = bounds.height();
+ } else if (mView instanceof LauncherAppWidgetHostView) {
+ DeviceProfile profile = Launcher.getLauncher(mView.getContext()).getDeviceProfile();
+ scale = Math.min(profile.appWidgetScale.x, profile.appWidgetScale.y);
+ width = (int) (mView.getWidth() * scale);
+ height = (int) (mView.getHeight() * scale);
}
+ Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
+
+ canvas.save();
+ canvas.scale(scale, scale);
drawDragView(canvas);
+ canvas.restore();
+
canvas.setBitmap(null);
return b;
@@ -132,12 +145,29 @@
* Responsibility for the bitmap is transferred to the caller.
*/
public Bitmap createDragOutline(Canvas canvas) {
- final Bitmap b = Bitmap.createBitmap(mView.getWidth() + DRAG_BITMAP_PADDING,
- mView.getHeight() + DRAG_BITMAP_PADDING, Bitmap.Config.ALPHA_8);
+ float scale = 1f;
+ int width = mView.getWidth();
+ int height = mView.getHeight();
+
+ if (mView instanceof LauncherAppWidgetHostView) {
+ DeviceProfile profile = Launcher.getLauncher(mView.getContext()).getDeviceProfile();
+ scale = Math.min(profile.appWidgetScale.x, profile.appWidgetScale.y);
+ width = (int) Math.floor(mView.getWidth() * scale);
+ height = (int) Math.floor(mView.getHeight() * scale);
+ }
+
+ Bitmap b = Bitmap.createBitmap(width + DRAG_BITMAP_PADDING, height + DRAG_BITMAP_PADDING,
+ Bitmap.Config.ALPHA_8);
canvas.setBitmap(b);
+
+ canvas.save();
+ canvas.scale(scale, scale);
drawDragView(canvas);
+ canvas.restore();
+
HolographicOutlineHelper.getInstance(mView.getContext())
.applyExpensiveOutlineWithBlur(b, canvas);
+
canvas.setBitmap(null);
return b;
}
@@ -160,8 +190,17 @@
public float getScaleAndPosition(Bitmap preview, int[] outPos) {
float scale = Launcher.getLauncher(mView.getContext())
.getDragLayer().getLocationInDragLayer(mView, outPos);
- outPos[0] = Math.round(outPos[0] - (preview.getWidth() - scale * mView.getWidth()) / 2);
- outPos[1] = Math.round(outPos[1] - (1 - scale) * preview.getHeight() / 2 - previewPadding / 2);
+ DeviceProfile profile = Launcher.getLauncher(mView.getContext()).getDeviceProfile();
+ if (mView instanceof LauncherAppWidgetHostView) {
+ // App widgets are technically scaled, but are drawn at their expected size -- so the
+ // app widget scale should not affect the scale of the preview.
+ scale /= Math.min(profile.appWidgetScale.x, profile.appWidgetScale.y);
+ }
+
+ outPos[0] = Math.round(outPos[0] -
+ (preview.getWidth() - scale * mView.getWidth() * mView.getScaleX()) / 2);
+ outPos[1] = Math.round(outPos[1] - (1 - scale) * preview.getHeight() / 2
+ - previewPadding / 2);
return scale;
}
}
diff --git a/tests/Android.mk b/tests/Android.mk
index 5103ced..466146e 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -17,9 +17,9 @@
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator mockito-target-minus-junit4
+#LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator mockito-target-minus-junit4
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+#LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_MIN_SDK_VERSION := 21