android:layout_height="match_parent"
launcher:wallpaperCellSpanX="3"
launcher:wallpaperCellCountX="9"
- launcher:widgetCellCountX="10"
+ launcher:widgetCellCountX="9"
launcher:cellCountX="5"
launcher:cellCountY="3"
launcher:pageLayoutWidthGap="36dp"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
- android:layout_height="365dp"
- android:paddingLeft="12.5dp"
- android:paddingRight="12.5dp"
- android:paddingBottom="50dp"
- android:gravity="top"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
android:orientation="vertical"
+ android:paddingRight="25dp"
+ android:paddingBottom="50dp"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF">
android:id="@+id/wallpaper_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1.0"
+ android:layout_weight="1"
+ android:adjustViewBounds="true"
android:scaleType="fitStart" />
<!-- The divider image. -->
android:id="@+id/divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="0"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:src="@drawable/widget_divider" />
android:id="@+id/wallpaper_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="0"
android:gravity="left"
android:textColor="#FFFFFFFF"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
- android:layout_height="365dp"
- android:paddingLeft="12.5dp"
- android:paddingTop="12.5dp"
- android:paddingRight="12.5dp"
- android:paddingBottom="50dp"
- android:gravity="top"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
android:orientation="vertical"
+ android:paddingRight="25dp"
+ android:paddingBottom="50dp"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF">
android:id="@+id/widget_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1.0"
+ android:layout_weight="1"
+ android:adjustViewBounds="true"
android:scaleType="fitStart" />
<!-- The divider image. -->
android:id="@+id/divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="0"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:src="@drawable/widget_divider" />
android:id="@+id/widget_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="0"
android:gravity="left"
android:textColor="#FFFFFFFF"
android:id="@+id/widget_dims"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="0"
android:gravity="left"
android:textColor="#FF999999"
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="@dimen/customization_drawer_content_height">
</FrameLayout>
</LinearLayout>
</TabHost>
<dimen name="workspace_page_spacing">50dp</dimen>
<dimen name="customization_drawer_height">480dp</dimen>
+ <dimen name="customization_drawer_content_height">420dp</dimen>
+ <dimen name="customization_drawer_content_min_width">952dp</dimen>
<dimen name="customization_drawer_tab_widget_width">952dp</dimen>
</resources>
\ No newline at end of file
<dimen name="workspace_page_spacing">64dp</dimen>
<dimen name="customization_drawer_height">800dp</dimen>
+ <dimen name="customization_drawer_content_height">420dp</dimen>
+ <dimen name="customization_drawer_content_min_width">640dp</dimen>
<dimen name="customization_drawer_tab_widget_width">700dp</dimen>
</resources>
\ No newline at end of file
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
// The mapping between the pages and the widgets that will be laid out on them
private ArrayList<ArrayList<AppWidgetProviderInfo>> mWidgetPages;
+ // This is used if we want to set a min width on pages so that things inside them left align to
+ // a fixed size
+ private int mMinPageWidth;
+
// The max dimensions for the ImageView we use for displaying a widget
private int mMaxWidgetWidth;
final Resources r = context.getResources();
setDragSlopeThreshold(
r.getInteger(R.integer.config_customizationDrawerDragSlopeThreshold) / 100.0f);
+ mMinPageWidth = r.getDimensionPixelSize(R.dimen.customization_drawer_content_min_width);
setVisibility(View.GONE);
setSoundEffectsEnabled(false);
}
}
- private Bitmap drawableToBitmap(Drawable d) {
+ private Bitmap drawableToBitmap(Drawable d, float scaleX, float scaleY) {
final Rect bounds = d.getBounds();
final int w = bounds.width();
final int h = bounds.height();
Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- renderDrawableToBitmap(d, b, 0, 0, w, h);
+ renderDrawableToBitmap(d, b, 0, 0, w, h, scaleX, scaleY);
return b;
}
// Get the widget preview as the drag representation
final LinearLayout l = (LinearLayout) v;
final ImageView i = (ImageView) l.findViewById(R.id.widget_preview);
- mDragBitmap = drawableToBitmap(i.getDrawable());
+
+ // Calculate how much to scale the drag preview
+ RectF tmpScaleRect = new RectF(0,0,1,1);
+ i.getImageMatrix().mapRect(tmpScaleRect);
+
+ mDragBitmap = drawableToBitmap(i.getDrawable(), tmpScaleRect.right,
+ tmpScaleRect.bottom);
i.getLocationOnScreen(mDragViewOrigin);
PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
- mDragBitmap = drawableToBitmap(icon);
+ mDragBitmap = drawableToBitmap(icon, 1.0f, 1.0f);
Object dragInfo = v.getTag();
if (mCustomizationType == CustomizationType.ApplicationCustomization) {
/**
* Helper function to draw a drawable to the specified canvas with the specified bounds.
*/
- private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h) {
+ private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
+ float scaleX, float scaleY) {
if (bitmap != null) mCanvas.setBitmap(bitmap);
mCanvas.save();
+ mCanvas.scale(scaleX, scaleY);
final Rect oldBounds = d.copyBounds();
d.setBounds(x, y, x + w, y + h);
d.draw(mCanvas);
background = resources.getDrawable(R.drawable.default_widget_preview);
}
- renderDrawableToBitmap(background, bitmap, 0, 0, width, height);
+ renderDrawableToBitmap(background, bitmap, 0, 0, width, height, 1.0f, 1.0f);
// If we don't have a custom icon, we use the app icon on the default background
if (!foundCustomDrawable) {
final int iconSize = minDim / 2;
final int offset = iconSize / 4;
- renderDrawableToBitmap(icon, null, offset, offset, iconSize, iconSize);
+ renderDrawableToBitmap(icon, null, offset, offset, iconSize, iconSize, 1.0f, 1.0f);
} catch (Resources.NotFoundException e) {
// if we can't find the icon, then just don't draw it
}
int height = (int) (Math.max(minDim, Math.min(maxDim, info.minHeight)) * sScaleFactor);
final Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
final Drawable background = resources.getDrawable(R.drawable.default_widget_preview);
- renderDrawableToBitmap(background, bitmap, 0, 0, width, height);
+ renderDrawableToBitmap(background, bitmap, 0, 0, width, height, 1.0f, 1.0f);
// Draw the icon flush left
try {
final int iconSize = minDim / 2;
final int offset = iconSize / 4;
- renderDrawableToBitmap(icon, null, offset, offset, iconSize, iconSize);
+ renderDrawableToBitmap(icon, null, offset, offset, iconSize, iconSize, 1.0f, 1.0f);
} catch (Resources.NotFoundException e) {
// if we can't find the icon, then just don't draw it
}
}
final Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- renderDrawableToBitmap(drawable, bitmap, 0, 0, width, height);
+ renderDrawableToBitmap(drawable, bitmap, 0, 0, width, height, 1.0f, 1.0f);
newDrawable = new FastBitmapDrawable(bitmap);
}
PagedViewWidget l = (PagedViewWidget) mInflater.inflate(
R.layout.customize_paged_view_widget, layout, false);
+
l.applyFromAppWidgetProviderInfo(info, icon, mMaxWidgetWidth, cellSpans,
mPageViewIconCache, (numPages > 1));
l.setTag(createItemInfo);
@Override
public void syncPages() {
+ boolean enforceMinimumPagedWidths = false;
boolean centerPagedViewCellLayouts = false;
switch (mCustomizationType) {
case WidgetCustomization:
syncWidgetPages();
+ enforceMinimumPagedWidths = true;
break;
case ShortcutCustomization:
syncListPages(mShortcutList);
break;
case WallpaperCustomization:
syncWallpaperPages();
+ enforceMinimumPagedWidths = true;
break;
case ApplicationCustomization:
syncAppPages();
}
}
- // bound the current page
+ // Set a min page width for PagedView layout if we have more than a single page
+ if (enforceMinimumPagedWidths) {
+ setMinimumWidthOverride((childCount > 1) ? mMinPageWidth : 0);
+ }
+
+ // Bound the current page index
requestLayout();
post(new Runnable() {
@Override
private final Paint mAlphaClipPaint = new Paint();
public static final int MAX_OUTER_BLUR_RADIUS;
+ public static final int MIN_OUTER_BLUR_RADIUS;
private static final BlurMaskFilter sExtraThickOuterBlurMaskFilter;
private static final BlurMaskFilter sThickOuterBlurMaskFilter;
static {
final float scale = LauncherApplication.getScreenDensity();
+ MIN_OUTER_BLUR_RADIUS = (int) (scale * 1.0f);
MAX_OUTER_BLUR_RADIUS = (int) (scale * 12.0f);
sExtraThickOuterBlurMaskFilter = new BlurMaskFilter(scale * 12.0f, BlurMaskFilter.Blur.OUTER);
protected int mTouchSlop;
private int mPagingTouchSlop;
private int mMaximumVelocity;
+ private int mMinimumWidth;
protected int mPageSpacing;
protected int mPageLayoutPaddingTop;
protected int mPageLayoutPaddingBottom;
R.styleable.PagedView, defStyle, 0);
mPageSpacing = a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0);
mPageLayoutPaddingTop = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutPaddingTop, 10);
+ R.styleable.PagedView_pageLayoutPaddingTop, 0);
mPageLayoutPaddingBottom = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutPaddingBottom, 10);
+ R.styleable.PagedView_pageLayoutPaddingBottom, 0);
mPageLayoutPaddingLeft = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutPaddingLeft, 10);
+ R.styleable.PagedView_pageLayoutPaddingLeft, 0);
mPageLayoutPaddingRight = a.getDimensionPixelSize(
- R.styleable.PagedView_pageLayoutPaddingRight, 10);
+ R.styleable.PagedView_pageLayoutPaddingRight, 0);
mPageLayoutWidthGap = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutWidthGap, -1);
mPageLayoutHeightGap = a.getDimensionPixelSize(
return -1;
}
+ protected void setMinimumWidthOverride(int minimumWidth) {
+ mMinimumWidth = minimumWidth;
+ }
+
+ protected int getChildWidth(int index) {
+ return Math.max(mMinimumWidth, getChildAt(index).getMeasuredWidth());
+ }
+
protected int getRelativeChildOffset(int index) {
- return (getMeasuredWidth() - getChildAt(index).getMeasuredWidth()) / 2;
+ return (getMeasuredWidth() - getChildWidth(index)) / 2;
}
protected int getChildOffset(int index) {
}
protected int getScaledMeasuredWidth(View child) {
- return (int) (child.getMeasuredWidth() * mLayoutScale + 0.5f);
+ return (int) (Math.max(mMinimumWidth, child.getMeasuredWidth()) * mLayoutScale + 0.5f);
}
int getPageNearestToCenterOfScreen() {
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
private Bitmap mHolographicOutline;
private final Canvas mHolographicOutlineCanvas = new Canvas();
private FastBitmapDrawable mPreview;
+ private ImageView mPreviewImageView;
+ private final RectF mTmpScaleRect = new RectF();
+ private final Rect mEraseStrokeRect = new Rect();
+ private final Paint mEraseStrokeRectPaint = new Paint();
private PagedViewIconCache.Key mIconCacheKey;
private PagedViewIconCache mIconCache;
public void handleMessage(Message msg) {
final PagedViewWidget widget = (PagedViewWidget) msg.obj;
final int prevAlpha = widget.mPreview.getAlpha();
- final Bitmap outline = Bitmap.createBitmap(widget.getWidth(), widget.getHeight(),
- Bitmap.Config.ARGB_8888);
+ final int width = Math.max(widget.mPreview.getIntrinsicWidth(),
+ widget.getMeasuredWidth());
+ final int height = Math.max(widget.mPreview.getIntrinsicHeight(),
+ widget.getMeasuredHeight());
+ final Bitmap outline = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
widget.mHolographicOutlineCanvas.setBitmap(outline);
widget.mHolographicOutlineCanvas.save();
widget.mHolographicOutlineCanvas.drawColor(Color.argb(156, 0, 0, 0), Mode.SRC_OVER);
widget.mHolographicOutlineCanvas.restore();
+ // To account for the fact that some previews run up straight to the edge (we subtract
+ // the edge from the holographic preview (before we apply the holograph)
+ widget.mEraseStrokeRect.set(0, 0, width, height);
+ widget.mHolographicOutlineCanvas.drawRect(widget.mEraseStrokeRect,
+ widget.mEraseStrokeRectPaint);
+
sHolographicOutlineHelper.applyThickExpensiveOutlineWithBlur(outline,
widget.mHolographicOutlineCanvas, widget.mHoloBlurColor,
widget.mHoloOutlineColor);
defStyle, 0);
mHoloBlurColor = a.getColor(R.styleable.PagedViewWidget_blurColor, 0);
mHoloOutlineColor = a.getColor(R.styleable.PagedViewWidget_outlineColor, 0);
+ mEraseStrokeRectPaint.setStyle(Paint.Style.STROKE);
+ mEraseStrokeRectPaint.setStrokeWidth(HolographicOutlineHelper.MIN_OUTER_BLUR_RADIUS);
+ mEraseStrokeRectPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
+ mEraseStrokeRectPaint.setFilterBitmap(true);
+ mEraseStrokeRectPaint.setAntiAlias(true);
a.recycle();
if (sHolographicOutlineHelper == null) {
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
image.setMaxWidth(maxWidth);
image.setImageDrawable(preview);
+ mPreviewImageView = image;
final TextView name = (TextView) findViewById(R.id.widget_name);
name.setText(info.label);
name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
ImageView image = (ImageView) findViewById(R.id.wallpaper_preview);
image.setMaxWidth(maxWidth);
image.setImageDrawable(preview);
+ mPreviewImageView = image;
TextView name = (TextView) findViewById(R.id.wallpaper_name);
name.setText(info.loadLabel(packageManager));
name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
// draw any blended overlays
if (mHolographicOutline != null && mHolographicAlpha > 0) {
+ // Calculate how much to scale the holographic preview
+ mTmpScaleRect.set(0,0,1,1);
+ mPreviewImageView.getImageMatrix().mapRect(mTmpScaleRect);
+
mPaint.setAlpha(mHolographicAlpha);
+ canvas.save();
+ canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom);
canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
+ canvas.restore();
}
}