am 59fcc1ad: Merge "Updating widget resize frame assets." into ub-launcher3-burnaby
* commit '59fcc1ad4edebd082496121a36861ae04fd073f1': Updating widget resize frame assets.
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 522 B |
Before Width: | Height: | Size: 880 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 681 B |
After Width: | Height: | Size: 896 B |
After Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 745 B |
Before Width: | Height: | Size: 762 B |
Before Width: | Height: | Size: 772 B |
Before Width: | Height: | Size: 750 B |
After Width: | Height: | Size: 486 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 953 B |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -28,7 +28,10 @@
|
|||
<dimen name="dynamic_grid_overview_bar_item_width">80dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_bar_spacer_width">20dp</dimen>
|
||||
|
||||
<!-- App Widget resize frame -->
|
||||
<dimen name="default_widget_padding">8dp</dimen>
|
||||
<dimen name="widget_handle_margin">13dp</dimen>
|
||||
<dimen name="resize_frame_background_padding">24dp</dimen>
|
||||
|
||||
<!-- Cling -->
|
||||
<dimen name="cling_migration_logo_height">240dp</dimen>
|
||||
|
|
|
@ -15,24 +15,36 @@ import android.widget.FrameLayout;
|
|||
import android.widget.ImageView;
|
||||
|
||||
public class AppWidgetResizeFrame extends FrameLayout {
|
||||
private LauncherAppWidgetHostView mWidgetView;
|
||||
private CellLayout mCellLayout;
|
||||
private DragLayer mDragLayer;
|
||||
private ImageView mLeftHandle;
|
||||
private ImageView mRightHandle;
|
||||
private ImageView mTopHandle;
|
||||
private ImageView mBottomHandle;
|
||||
private static final int SNAP_DURATION = 150;
|
||||
private static final float DIMMED_HANDLE_ALPHA = 0f;
|
||||
private static final float RESIZE_THRESHOLD = 0.66f;
|
||||
|
||||
private static Rect sTmpRect = new Rect();
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private final LauncherAppWidgetHostView mWidgetView;
|
||||
private final CellLayout mCellLayout;
|
||||
private final DragLayer mDragLayer;
|
||||
|
||||
private final ImageView mLeftHandle;
|
||||
private final ImageView mRightHandle;
|
||||
private final ImageView mTopHandle;
|
||||
private final ImageView mBottomHandle;
|
||||
|
||||
private final Rect mWidgetPadding;
|
||||
|
||||
private final int mBackgroundPadding;
|
||||
private final int mTouchTargetWidth;
|
||||
|
||||
private final int[] mDirectionVector = new int[2];
|
||||
private final int[] mLastDirectionVector = new int[2];
|
||||
private final int[] mTmpPt = new int[2];
|
||||
|
||||
private boolean mLeftBorderActive;
|
||||
private boolean mRightBorderActive;
|
||||
private boolean mTopBorderActive;
|
||||
private boolean mBottomBorderActive;
|
||||
|
||||
private int mWidgetPaddingLeft;
|
||||
private int mWidgetPaddingRight;
|
||||
private int mWidgetPaddingTop;
|
||||
private int mWidgetPaddingBottom;
|
||||
|
||||
private int mBaselineWidth;
|
||||
private int mBaselineHeight;
|
||||
private int mBaselineX;
|
||||
|
@ -48,30 +60,9 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
|||
private int mDeltaXAddOn;
|
||||
private int mDeltaYAddOn;
|
||||
|
||||
private int mBackgroundPadding;
|
||||
private int mTouchTargetWidth;
|
||||
|
||||
private int mTopTouchRegionAdjustment = 0;
|
||||
private int mBottomTouchRegionAdjustment = 0;
|
||||
|
||||
int[] mDirectionVector = new int[2];
|
||||
int[] mLastDirectionVector = new int[2];
|
||||
int[] mTmpPt = new int[2];
|
||||
|
||||
final int SNAP_DURATION = 150;
|
||||
final int BACKGROUND_PADDING = 24;
|
||||
final float DIMMED_HANDLE_ALPHA = 0f;
|
||||
final float RESIZE_THRESHOLD = 0.66f;
|
||||
|
||||
private static Rect mTmpRect = new Rect();
|
||||
|
||||
public static final int LEFT = 0;
|
||||
public static final int TOP = 1;
|
||||
public static final int RIGHT = 2;
|
||||
public static final int BOTTOM = 3;
|
||||
|
||||
private Launcher mLauncher;
|
||||
|
||||
public AppWidgetResizeFrame(Context context,
|
||||
LauncherAppWidgetHostView widgetView, CellLayout cellLayout, DragLayer dragLayer) {
|
||||
|
||||
|
@ -87,49 +78,49 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
|||
mMinHSpan = info.minSpanX;
|
||||
mMinVSpan = info.minSpanY;
|
||||
|
||||
setBackgroundResource(R.drawable.widget_resize_frame_holo);
|
||||
setBackgroundResource(R.drawable.widget_resize_shadow);
|
||||
setForeground(getResources().getDrawable(R.drawable.widget_resize_frame));
|
||||
setPadding(0, 0, 0, 0);
|
||||
|
||||
final int handleMargin = getResources().getDimensionPixelSize(R.dimen.widget_handle_margin);
|
||||
LayoutParams lp;
|
||||
mLeftHandle = new ImageView(context);
|
||||
mLeftHandle.setImageResource(R.drawable.widget_resize_handle_left);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
mLeftHandle.setImageResource(R.drawable.ic_widget_resize_handle);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
lp.leftMargin = handleMargin;
|
||||
addView(mLeftHandle, lp);
|
||||
|
||||
mRightHandle = new ImageView(context);
|
||||
mRightHandle.setImageResource(R.drawable.widget_resize_handle_right);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
mRightHandle.setImageResource(R.drawable.ic_widget_resize_handle);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.RIGHT | Gravity.CENTER_VERTICAL);
|
||||
lp.rightMargin = handleMargin;
|
||||
addView(mRightHandle, lp);
|
||||
|
||||
mTopHandle = new ImageView(context);
|
||||
mTopHandle.setImageResource(R.drawable.widget_resize_handle_top);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
mTopHandle.setImageResource(R.drawable.ic_widget_resize_handle);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
||||
lp.topMargin = handleMargin;
|
||||
addView(mTopHandle, lp);
|
||||
|
||||
mBottomHandle = new ImageView(context);
|
||||
mBottomHandle.setImageResource(R.drawable.widget_resize_handle_bottom);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
mBottomHandle.setImageResource(R.drawable.ic_widget_resize_handle);
|
||||
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
|
||||
lp.bottomMargin = handleMargin;
|
||||
addView(mBottomHandle, lp);
|
||||
|
||||
Rect p = new Rect(0, 0, 0, 0);
|
||||
if (!info.isCustomWidget) {
|
||||
p = AppWidgetHostView.getDefaultPaddingForWidget(context,
|
||||
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context,
|
||||
widgetView.getAppWidgetInfo().provider, null);
|
||||
} else {
|
||||
Resources r = context.getResources();
|
||||
int padding = r.getDimensionPixelSize(R.dimen.default_widget_padding);
|
||||
p.set(padding, padding, padding, padding);
|
||||
mWidgetPadding = new Rect(padding, padding, padding, padding);
|
||||
}
|
||||
|
||||
mWidgetPaddingLeft = p.left;
|
||||
mWidgetPaddingTop = p.top;
|
||||
mWidgetPaddingRight = p.right;
|
||||
mWidgetPaddingBottom = p.bottom;
|
||||
|
||||
if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) {
|
||||
mTopHandle.setVisibility(GONE);
|
||||
mBottomHandle.setVisibility(GONE);
|
||||
|
@ -138,8 +129,8 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
|||
mRightHandle.setVisibility(GONE);
|
||||
}
|
||||
|
||||
final float density = mLauncher.getResources().getDisplayMetrics().density;
|
||||
mBackgroundPadding = (int) Math.ceil(density * BACKGROUND_PADDING);
|
||||
mBackgroundPadding = getResources()
|
||||
.getDimensionPixelSize(R.dimen.resize_frame_background_padding);
|
||||
mTouchTargetWidth = 2 * mBackgroundPadding;
|
||||
|
||||
// When we create the resize frame, we first mark all cells as unoccupied. The appropriate
|
||||
|
@ -344,9 +335,9 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
|||
|
||||
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher,
|
||||
int spanX, int spanY) {
|
||||
getWidgetSizeRanges(launcher, spanX, spanY, mTmpRect);
|
||||
widgetView.updateAppWidgetSize(null, mTmpRect.left, mTmpRect.top,
|
||||
mTmpRect.right, mTmpRect.bottom);
|
||||
getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect);
|
||||
widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top,
|
||||
sTmpRect.right, sTmpRect.bottom);
|
||||
}
|
||||
|
||||
public static Rect getWidgetSizeRanges(Launcher launcher, int spanX, int spanY, Rect rect) {
|
||||
|
@ -404,19 +395,19 @@ public class AppWidgetResizeFrame extends FrameLayout {
|
|||
|
||||
public void snapToWidget(boolean animate) {
|
||||
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
|
||||
int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding - mWidgetPaddingLeft -
|
||||
mWidgetPaddingRight;
|
||||
int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding - mWidgetPaddingTop -
|
||||
mWidgetPaddingBottom;
|
||||
int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding
|
||||
- mWidgetPadding.left - mWidgetPadding.right;
|
||||
int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding
|
||||
- mWidgetPadding.top - mWidgetPadding.bottom;
|
||||
|
||||
mTmpPt[0] = mWidgetView.getLeft();
|
||||
mTmpPt[1] = mWidgetView.getTop();
|
||||
mDragLayer.getDescendantCoordRelativeToSelf(mCellLayout.getShortcutsAndWidgets(), mTmpPt);
|
||||
|
||||
int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPaddingLeft;
|
||||
int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPaddingTop;
|
||||
int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPadding.left;
|
||||
int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPadding.top;
|
||||
|
||||
// We need to make sure the frame's touchable regions lie fully within the bounds of the
|
||||
// We need to make sure the frame's touchable regions lie fully within the bounds of the
|
||||
// DragLayer. We allow the actual handles to be clipped, but we shift the touch regions
|
||||
// down accordingly to provide a proper touch target.
|
||||
if (newY < 0) {
|
||||
|
|