Asset updates
- Change how default widget previews look (5509429) - Improve antialiasing in portal assets Change-Id: I9993aec46a9a9ab8a732b4fc150120c935523f02
|
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 115 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 864 B |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 185 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 6.4 KiB |
@@ -32,8 +32,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/widget_info_bg">
|
||||
android:orientation="vertical">
|
||||
<!-- The name of the widget. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_name"
|
||||
@@ -54,7 +53,7 @@
|
||||
|
||||
<!-- The original dimensions of the widget (can't be the same text as above due to different
|
||||
style. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<TextView
|
||||
android:id="@+id/widget_dims"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/widget_info_bg">
|
||||
android:orientation="horizontal">
|
||||
<!-- The name of the widget. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_name"
|
||||
|
||||
@@ -32,10 +32,13 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.MaskFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.TableMaskFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Process;
|
||||
@@ -552,10 +555,20 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
createItemInfo.spanX = createItemInfo.spanY = 1;
|
||||
}
|
||||
|
||||
// We use a custom alpha clip table for the default widget previews
|
||||
Paint alphaClipPaint = null;
|
||||
if (createItemInfo instanceof PendingAddWidgetInfo) {
|
||||
if (((PendingAddWidgetInfo) createItemInfo).hasDefaultPreview) {
|
||||
MaskFilter alphaClipTable = TableMaskFilter.CreateClipTable(0, 255);
|
||||
alphaClipPaint = new Paint();
|
||||
alphaClipPaint.setMaskFilter(alphaClipTable);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the drag
|
||||
mLauncher.lockScreenOrientationOnLargeUI();
|
||||
mLauncher.getWorkspace().onDragStartedWithItemSpans(createItemInfo.spanX,
|
||||
createItemInfo.spanY, b);
|
||||
createItemInfo.spanY, b, alphaClipPaint);
|
||||
mDragController.startDrag(image, b, this, createItemInfo,
|
||||
DragController.DRAG_ACTION_COPY, null);
|
||||
b.recycle();
|
||||
@@ -914,10 +927,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
}
|
||||
private Bitmap getShortcutPreview(ResolveInfo info, int cellWidth, int cellHeight) {
|
||||
// Render the background
|
||||
int offset = (int) (mAppIconSize * sWidgetPreviewIconPaddingPercentage);
|
||||
int bitmapSize = mAppIconSize + 2 * offset;
|
||||
int offset = 0;
|
||||
int bitmapSize = mAppIconSize;
|
||||
Bitmap preview = Bitmap.createBitmap(bitmapSize, bitmapSize, Config.ARGB_8888);
|
||||
renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, bitmapSize, bitmapSize);
|
||||
|
||||
// Render the icon
|
||||
Drawable icon = mIconCache.getFullResIcon(info, mPackageManager);
|
||||
@@ -964,41 +976,45 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
int targetHeight = mWidgetSpacingLayout.estimateCellHeight(cellVSpan);
|
||||
int bitmapWidth = targetWidth;
|
||||
int bitmapHeight = targetHeight;
|
||||
int offset = (int) (mAppIconSize * sWidgetPreviewIconPaddingPercentage);
|
||||
int minOffset = (int) (mAppIconSize * sWidgetPreviewIconPaddingPercentage);
|
||||
float iconScale = 1f;
|
||||
|
||||
// Determine the size of the bitmap we want to draw
|
||||
if (cellHSpan == cellVSpan) {
|
||||
// For square widgets, we just have a fixed size for 1x1 and larger-than-1x1
|
||||
if (cellHSpan <= 1) {
|
||||
bitmapWidth = bitmapHeight = mAppIconSize + 2 * offset;
|
||||
bitmapWidth = bitmapHeight = mAppIconSize + 2 * minOffset;
|
||||
} else {
|
||||
bitmapWidth = bitmapHeight = mAppIconSize + 4 * offset;
|
||||
bitmapWidth = bitmapHeight = mAppIconSize + 4 * minOffset;
|
||||
}
|
||||
} else {
|
||||
// Otherwise, ensure that we are properly sized within the cellWidth/Height
|
||||
if (targetWidth > targetHeight) {
|
||||
bitmapWidth = Math.min(targetWidth, cellWidth);
|
||||
bitmapHeight = (int) (targetHeight * ((float) bitmapWidth / targetWidth));
|
||||
iconScale = Math.min((float) bitmapHeight / (mAppIconSize + 2 * offset), 1f);
|
||||
iconScale = Math.min((float) bitmapHeight / (mAppIconSize + 2 * minOffset), 1f);
|
||||
} else {
|
||||
bitmapHeight = Math.min(targetHeight, cellHeight);
|
||||
bitmapWidth = (int) (targetWidth * ((float) bitmapHeight / targetHeight));
|
||||
iconScale = Math.min((float) bitmapWidth / (mAppIconSize + 2 * offset), 1f);
|
||||
iconScale = Math.min((float) bitmapWidth / (mAppIconSize + 2 * minOffset), 1f);
|
||||
}
|
||||
}
|
||||
preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
|
||||
renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, bitmapWidth,
|
||||
bitmapWidth);
|
||||
if (cellHSpan != 1 || cellVSpan != 1) {
|
||||
renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, bitmapWidth,
|
||||
bitmapHeight);
|
||||
}
|
||||
|
||||
// Draw the icon in the top left corner
|
||||
try {
|
||||
Drawable icon = null;
|
||||
int hoffset = (int) (bitmapWidth / 2 - mAppIconSize * iconScale / 2);
|
||||
int yoffset = (int) (bitmapHeight / 2 - mAppIconSize * iconScale / 2);
|
||||
if (info.icon > 0) icon = mPackageManager.getDrawable(packageName, info.icon, null);
|
||||
if (icon == null) icon = resources.getDrawable(R.drawable.ic_launcher_application);
|
||||
|
||||
renderDrawableToBitmap(icon, preview, (int) (offset * iconScale),
|
||||
(int) (offset * iconScale), (int) (mAppIconSize * iconScale),
|
||||
renderDrawableToBitmap(icon, preview, hoffset, yoffset,
|
||||
(int) (mAppIconSize * iconScale),
|
||||
(int) (mAppIconSize * iconScale));
|
||||
} catch (Resources.NotFoundException e) {}
|
||||
}
|
||||
|
||||
@@ -122,10 +122,18 @@ public class HolographicOutlineHelper {
|
||||
*/
|
||||
void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
|
||||
int outlineColor, int thickness) {
|
||||
applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, mAlphaClipPaint,
|
||||
thickness);
|
||||
}
|
||||
void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
|
||||
int outlineColor, Paint alphaClipPaint, int thickness) {
|
||||
|
||||
// We start by removing most of the alpha channel so as to ignore shadows, and
|
||||
// other types of partial transparency when defining the shape of the object
|
||||
Bitmap glowShape = srcDst.extractAlpha(mAlphaClipPaint, mTempOffset);
|
||||
if (alphaClipPaint == null) {
|
||||
alphaClipPaint = mAlphaClipPaint;
|
||||
}
|
||||
Bitmap glowShape = srcDst.extractAlpha(alphaClipPaint, mTempOffset);
|
||||
|
||||
// calculate the outer blur first
|
||||
BlurMaskFilter outerBlurMaskFilter;
|
||||
@@ -216,6 +224,12 @@ public class HolographicOutlineHelper {
|
||||
applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, THICK);
|
||||
}
|
||||
|
||||
void applyMediumExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
|
||||
int outlineColor, Paint alphaClipPaint) {
|
||||
applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, alphaClipPaint,
|
||||
MEDIUM);
|
||||
}
|
||||
|
||||
void applyMediumExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color,
|
||||
int outlineColor) {
|
||||
applyExpensiveOutlineWithBlur(srcDst, srcDstCanvas, color, outlineColor, MEDIUM);
|
||||
|
||||
@@ -33,6 +33,7 @@ class PendingAddItemInfo extends ItemInfo {
|
||||
class PendingAddWidgetInfo extends PendingAddItemInfo {
|
||||
int minWidth;
|
||||
int minHeight;
|
||||
boolean hasDefaultPreview;
|
||||
|
||||
// Any configuration data that we want to pass to a configuration activity when
|
||||
// starting up a widget
|
||||
@@ -44,6 +45,7 @@ class PendingAddWidgetInfo extends PendingAddItemInfo {
|
||||
componentName = i.provider;
|
||||
minWidth = i.minWidth;
|
||||
minHeight = i.minHeight;
|
||||
hasDefaultPreview = i.previewImage <= 0;
|
||||
if (dataMimeType != null && data != null) {
|
||||
mimeType = dataMimeType;
|
||||
configurationData = data;
|
||||
|
||||
@@ -1464,6 +1464,10 @@ public class Workspace extends SmoothPagedView
|
||||
}
|
||||
|
||||
public void onDragStartedWithItemSpans(int spanX, int spanY, Bitmap b) {
|
||||
onDragStartedWithItemSpans(spanX, spanY, b, null);
|
||||
}
|
||||
|
||||
public void onDragStartedWithItemSpans(int spanX, int spanY, Bitmap b, Paint alphaClipPaint) {
|
||||
final Canvas canvas = new Canvas();
|
||||
|
||||
// We need to add extra padding to the bitmap to make room for the glow effect
|
||||
@@ -1474,7 +1478,7 @@ public class Workspace extends SmoothPagedView
|
||||
int[] size = cl.cellSpansToSize(spanX, spanY);
|
||||
|
||||
// The outline is used to visualize where the item will land if dropped
|
||||
mDragOutline = createDragOutline(b, canvas, bitmapPadding, size[0], size[1]);
|
||||
mDragOutline = createDragOutline(b, canvas, bitmapPadding, size[0], size[1], alphaClipPaint);
|
||||
}
|
||||
|
||||
// we call this method whenever a drag and drop in Launcher finishes, even if Workspace was
|
||||
@@ -1817,6 +1821,10 @@ public class Workspace extends SmoothPagedView
|
||||
* Responsibility for the bitmap is transferred to the caller.
|
||||
*/
|
||||
private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h) {
|
||||
return createDragOutline(orig, canvas, padding, w, h, null);
|
||||
}
|
||||
private Bitmap createDragOutline(Bitmap orig, Canvas canvas, int padding, int w, int h,
|
||||
Paint alphaClipPaint) {
|
||||
final int outlineColor = getResources().getColor(android.R.color.holo_blue_light);
|
||||
final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||
canvas.setBitmap(b);
|
||||
@@ -1834,7 +1842,8 @@ public class Workspace extends SmoothPagedView
|
||||
Paint p = new Paint();
|
||||
p.setFilterBitmap(true);
|
||||
canvas.drawBitmap(orig, src, dst, p);
|
||||
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
|
||||
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor,
|
||||
alphaClipPaint);
|
||||
canvas.setBitmap(null);
|
||||
|
||||
return b;
|
||||
|
||||