summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-05-24 13:09:28 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-24 13:09:28 -0700
commit60c787a3017714ecb176c4ccc920f036b509cf53 (patch)
tree5ae6f956bf4ec841cca4f8642ec82b77701852b6 /src
parenteffe1afd4257b31b3a3a96b3ef1fc106a50dfc49 (diff)
parent0be025d64c1f84138fe430a58875886e66aae767 (diff)
downloadandroid_packages_apps_Trebuchet-60c787a3017714ecb176c4ccc920f036b509cf53.tar.gz
android_packages_apps_Trebuchet-60c787a3017714ecb176c4ccc920f036b509cf53.tar.bz2
android_packages_apps_Trebuchet-60c787a3017714ecb176c4ccc920f036b509cf53.zip
Merge "Fixing long-press issue due to child hit-rect offset."
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllAppsBackground.java4
-rw-r--r--src/com/android/launcher2/CellLayout.java14
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java1
-rw-r--r--src/com/android/launcher2/ShortcutsAdapter.java58
-rw-r--r--src/com/android/launcher2/Utilities.java22
5 files changed, 13 insertions, 86 deletions
diff --git a/src/com/android/launcher2/AllAppsBackground.java b/src/com/android/launcher2/AllAppsBackground.java
index 5292d0ad3..51e1ee472 100644
--- a/src/com/android/launcher2/AllAppsBackground.java
+++ b/src/com/android/launcher2/AllAppsBackground.java
@@ -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;
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 5f848a8fa..f189cd58e 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -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)
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 306ff9e7b..30f0b1db2 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -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;
diff --git a/src/com/android/launcher2/ShortcutsAdapter.java b/src/com/android/launcher2/ShortcutsAdapter.java
deleted file mode 100644
index de73c3e3a..000000000
--- a/src/com/android/launcher2/ShortcutsAdapter.java
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index ba258939c..04abd77aa 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -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;