Merge "Fixing long-press issue due to child hit-rect offset."
This commit is contained in:
commit
60c787a301
|
@ -25,8 +25,8 @@ import android.util.AttributeSet;
|
|||
import android.view.View;
|
||||
|
||||
/**
|
||||
* An implementation of PagedView that populates the pages of the workspace
|
||||
* with all of the user's applications.
|
||||
* The background for AllApps which moves independently of the AllApps tray (for example, when we
|
||||
* transition between AllApps and the Workspace while in spring-loaded mode).
|
||||
*/
|
||||
public class AllAppsBackground extends View {
|
||||
private Drawable mBackground;
|
||||
|
|
|
@ -71,7 +71,7 @@ public class CellLayout extends ViewGroup {
|
|||
|
||||
// These are temporary variables to prevent having to allocate a new object just to
|
||||
// return an (x, y) value from helper functions. Do NOT use them to maintain other state.
|
||||
private final int[] mTmpCellXY = new int[2];
|
||||
private final int[] mTmpXY = new int[2];
|
||||
private final int[] mTmpPoint = new int[2];
|
||||
private final PointF mTmpPointF = new PointF();
|
||||
|
||||
|
@ -694,6 +694,14 @@ public class CellLayout extends ViewGroup {
|
|||
if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
|
||||
lp.isLockedToGrid) {
|
||||
child.getHitRect(frame);
|
||||
|
||||
// The child hit rect is relative to the CellLayoutChildren parent, so we need to
|
||||
// offset that by this CellLayout's padding to test an (x,y) point that is relative
|
||||
// to this view.
|
||||
final int tmpXY[] = mTmpXY;
|
||||
child.getLocationOnScreen(tmpXY);
|
||||
frame.offset(mLeftPadding, mTopPadding);
|
||||
|
||||
if (frame.contains(x, y)) {
|
||||
cellInfo.cell = child;
|
||||
cellInfo.cellX = lp.cellX;
|
||||
|
@ -708,7 +716,7 @@ public class CellLayout extends ViewGroup {
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
final int cellXY[] = mTmpCellXY;
|
||||
final int cellXY[] = mTmpXY;
|
||||
pointToCellExact(x, y, cellXY);
|
||||
|
||||
cellInfo.cell = null;
|
||||
|
@ -1161,7 +1169,7 @@ public class CellLayout extends ViewGroup {
|
|||
}
|
||||
}
|
||||
}
|
||||
final int[] cellXY = mTmpCellXY;
|
||||
final int[] cellXY = mTmpXY;
|
||||
cellToCenterPoint(x, y, cellXY);
|
||||
|
||||
double distance = Math.sqrt(Math.pow(cellXY[0] - pixelX, 2)
|
||||
|
|
|
@ -31,7 +31,6 @@ import android.os.HandlerThread;
|
|||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Checkable;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 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.
|
||||
*/
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
/**
|
||||
* GridView adapter to show the list of applications and shortcuts
|
||||
*/
|
||||
public class ShortcutsAdapter extends ArrayAdapter<ShortcutInfo> {
|
||||
private final LayoutInflater mInflater;
|
||||
private final IconCache mIconCache;
|
||||
|
||||
public ShortcutsAdapter(Context context, ArrayList<ShortcutInfo> apps) {
|
||||
super(context, 0, apps);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final ShortcutInfo info = getItem(position);
|
||||
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.application_boxed, parent, false);
|
||||
}
|
||||
|
||||
final TextView textView = (TextView) convertView;
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null,
|
||||
new FastBitmapDrawable(info.getIcon(mIconCache)), null, null);
|
||||
textView.setText(info.title);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
|
@ -68,28 +68,6 @@ final class Utilities {
|
|||
sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
|
||||
Paint.FILTER_BITMAP_FLAG));
|
||||
}
|
||||
|
||||
static Bitmap centerToFit(Bitmap bitmap, int width, int height, Context context) {
|
||||
final int bitmapWidth = bitmap.getWidth();
|
||||
final int bitmapHeight = bitmap.getHeight();
|
||||
|
||||
if (bitmapWidth < width || bitmapHeight < height) {
|
||||
int color = context.getResources().getColor(R.color.window_background);
|
||||
|
||||
Bitmap centered = Bitmap.createBitmap(bitmapWidth < width ? width : bitmapWidth,
|
||||
bitmapHeight < height ? height : bitmapHeight, Bitmap.Config.RGB_565);
|
||||
centered.setDensity(bitmap.getDensity());
|
||||
Canvas canvas = new Canvas(centered);
|
||||
canvas.drawColor(color);
|
||||
canvas.drawBitmap(bitmap, (width - bitmapWidth) / 2.0f, (height - bitmapHeight) / 2.0f,
|
||||
null);
|
||||
|
||||
bitmap = centered;
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
|
||||
static int sColorIndex = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue