Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-09-28 06:44:11 -07:00
16 changed files with 388 additions and 59 deletions
+2 -1
View File
@@ -66,7 +66,8 @@
android:name="com.android.launcher2.LauncherApplication"
android:process="@string/process"
android:label="@string/application_name"
android:icon="@drawable/ic_launcher_home">
android:icon="@drawable/ic_launcher_home"
android:hardwareAccelerated="@integer/config_hardwareAccelerated">
<activity
android:name="com.android.launcher2.Launcher"
@@ -23,7 +23,7 @@
launcher:checkedBlurColor="#FFBBE83C"
launcher:checkedOutlineColor="#FF8CD2FF"
android:id="@+id/name"
android:id="@+id/application_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
@@ -14,8 +14,16 @@
limitations under the License.
-->
<com.android.launcher2.PagedViewIcon xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/name"
<com.android.launcher2.PagedViewIcon
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF"
launcher:checkedBlurColor="#FFBBE83C"
launcher:checkedOutlineColor="#FF8CD2FF"
android:id="@+id/customize_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
@@ -14,8 +14,10 @@
limitations under the License.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/name"
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wallpaper_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
@@ -13,7 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.android.launcher2.PagedViewWidgetIcon
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="12.5dp"
@@ -21,11 +24,14 @@
android:paddingTop="40dp"
android:paddingBottom="50dp"
android:gravity="top"
android:orientation="vertical">
android:orientation="vertical"
launcher:checkedBlurColor="#FFDAFF71"
launcher:checkedOutlineColor="#FFCFFF9C">
<!-- The icon of the widget. -->
<ImageView
android:id="@+id/icon"
android:id="@+id/widget_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
@@ -42,7 +48,7 @@
<!-- The name of the widget. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/name"
android:id="@+id/widget_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
@@ -60,7 +66,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"
android:id="@+id/dims"
android:id="@+id/widget_dims"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
@@ -71,4 +77,4 @@
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0" />
</LinearLayout>
</com.android.launcher2.PagedViewWidgetIcon>
+9
View File
@@ -68,6 +68,15 @@
<attr name="checkedOutlineColor" format="color" />
</declare-styleable>
<!-- PagedViewWidgetIcon specific attributes. These attributes are used to
customize a PagedViewWidgetIcon view in XML files. -->
<declare-styleable name="PagedViewWidgetIcon">
<!-- The checked blur color of the holographic outline -->
<attr name="checkedBlurColor" />
<!-- The checked outline color of the holographic outline -->
<attr name="checkedOutlineColor" />
</declare-styleable>
<!-- PagedView specific attributes. These attributes are used to customize
a PagedView view in XML files. -->
<declare-styleable name="PagedView">
+1
View File
@@ -3,4 +3,5 @@
<integer name="config_allAppsFadeOutTime">700</integer>
<integer name="config_allAppsBatchLoadDelay">0</integer>
<integer name="config_allAppsBatchSize">0</integer>
<integer name="config_hardwareAccelerated">0</integer>
</resources>
+8 -2
View File
@@ -147,8 +147,14 @@
<!-- Describes the button for getting details/info about currently selected application.
Text is not displayed, but provided for accessibility. [CHAR_LIMIT=none] -->
<string name="cab_menu_app_info">Application details</string>
<!-- Appears in the CAB when an app is selected in All Apps. [CHAR_LIMIT=50] -->
<string name="cab_selection_text">1 application selected</string>
<!-- Appears in the CAB when an app is selected in All Apps or Customize mode. [CHAR_LIMIT=50] -->
<string name="cab_app_selection_text">1 application selected</string>
<!-- Appears in the CAB when a widget is selected in Customize mode. [CHAR_LIMIT=50] -->
<string name="cab_widget_selection_text">1 widget selected</string>
<!-- Appears in the CAB when a folder is selected in Customize mode. [CHAR_LIMIT=50] -->
<string name="cab_folder_selection_text">1 folder selected</string>
<!-- Appears in the CAB when a shortcut is selected in Customize mode. [CHAR_LIMIT=50] -->
<string name="cab_shortcut_selection_text">1 shortcut selected</string>
<!-- Permissions: -->
<skip />
@@ -417,7 +417,7 @@ public class AllAppsPagedView extends PagedView
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(R.string.cab_selection_text);
mode.setTitle(R.string.cab_app_selection_text);
// Until the workspace has a selection mode and the CAB supports drag-and-drop, we
// take a hybrid approach: grab the views from the workspace and stuff them into the CAB.
+26 -1
View File
@@ -698,8 +698,30 @@ public class CellLayout extends ViewGroup {
* @return The X, Y cell of a vacant area that can contain this object,
* nearest the requested location.
*/
int[] findNearestVacantArea(int pixelX, int pixelY, int spanX, int spanY, int[] recycle) {
int[] findNearestVacantArea(
int pixelX, int pixelY, int spanX, int spanY, int[] recycle) {
return findNearestVacantArea(pixelX, pixelY, spanX, spanY, null, recycle);
}
/**
* Find a vacant area that will fit the given bounds nearest the requested
* cell location. Uses Euclidean distance to score multiple vacant areas.
*
* @param pixelX The X location at which you want to search for a vacant area.
* @param pixelY The Y location at which you want to search for a vacant area.
* @param spanX Horizontal span of the object.
* @param spanY Vertical span of the object.
* @param vacantCells Pre-computed set of vacant cells to search.
* @param recycle Previously returned value to possibly recycle.
* @param ignoreView Considers space occupied by this view as unoccupied
* @return The X, Y cell of a vacant area that can contain this object,
* nearest the requested location.
*/
int[] findNearestVacantArea(
int pixelX, int pixelY, int spanX, int spanY, View ignoreView, int[] recycle) {
if (ignoreView != null) {
markCellsAsUnoccupiedForView(ignoreView);
}
// Keep track of best-scoring drop area
final int[] bestXY = recycle != null ? recycle : new int[2];
double bestDistance = Double.MAX_VALUE;
@@ -729,6 +751,9 @@ public class CellLayout extends ViewGroup {
}
}
}
if (ignoreView != null) {
markCellsAsOccupiedForView(ignoreView);
}
// Return null if no suitable location found
if (bestDistance < Double.MAX_VALUE) {
+137 -28
View File
@@ -36,10 +36,15 @@ import android.graphics.drawable.Drawable;
import android.provider.LiveFolders;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -51,7 +56,7 @@ import java.util.List;
public class CustomizePagedView extends PagedView
implements View.OnLongClickListener, View.OnClickListener,
DragSource {
DragSource, ActionMode.Callback {
public enum CustomizationType {
WidgetCustomization,
@@ -119,6 +124,8 @@ public class CustomizePagedView extends PagedView
private static final int sMinWidgetCellHSpan = 2;
private static final int sMaxWidgetCellHSpan = 4;
private int mChoiceModeTitleText;
// The scale factor for widget previews inside the widget drawer
private static final float sScaleFactor = 0.75f;
@@ -313,6 +320,9 @@ public class CustomizePagedView extends PagedView
mCustomizationType = filterType;
setCurrentPage(0);
invalidatePageData();
// End the current choice mode so that we don't carry selections across tabs
endChoiceMode();
}
@Override
@@ -326,15 +336,58 @@ public class CustomizePagedView extends PagedView
return;
}
final View animView = v;
// On certain pages, we allow single tap to mark items as selected so that they can be
// dropped onto the mini workspaces
boolean enterChoiceMode = false;
switch (mCustomizationType) {
case WidgetCustomization:
mChoiceModeTitleText = R.string.cab_widget_selection_text;
enterChoiceMode = true;
break;
case ApplicationCustomization:
mChoiceModeTitleText = R.string.cab_app_selection_text;
enterChoiceMode = true;
break;
case FolderCustomization:
mChoiceModeTitleText = R.string.cab_folder_selection_text;
enterChoiceMode = true;
break;
case ShortcutCustomization:
mChoiceModeTitleText = R.string.cab_shortcut_selection_text;
enterChoiceMode = true;
break;
default:
break;
}
if (enterChoiceMode) {
if (v instanceof Checkable) {
final Checkable c = (Checkable) v;
final boolean wasChecked = c.isChecked();
resetCheckedGrandchildren();
c.setChecked(!wasChecked);
// End the current choice mode when we have no items selected
if (!c.isChecked()) {
endChoiceMode();
} else if (isChoiceMode(CHOICE_MODE_NONE)) {
endChoiceMode();
startChoiceMode(CHOICE_MODE_SINGLE, this);
}
}
return;
}
// Otherwise, we just handle the single click here
switch (mCustomizationType) {
case WallpaperCustomization:
// animate some feedback to the long press
final View clickView = v;
animateClickFeedback(v, new Runnable() {
@Override
public void run() {
// add the shortcut
ResolveInfo info = (ResolveInfo) animView.getTag();
ResolveInfo info = (ResolveInfo) clickView.getTag();
Intent createWallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
ComponentName name = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
@@ -342,6 +395,9 @@ public class CustomizePagedView extends PagedView
mLauncher.processWallpaper(createWallpapersIntent);
}
});
break;
default:
break;
}
}
@@ -351,46 +407,43 @@ public class CustomizePagedView extends PagedView
return false;
}
final View animView = v;
PendingAddItemInfo createItemInfo = new PendingAddItemInfo();
// End the current choice mode before we start dragging anything
if (isChoiceMode(CHOICE_MODE_SINGLE)) {
endChoiceMode();
}
PendingAddItemInfo createItemInfo;
switch (mCustomizationType) {
case WidgetCustomization:
// Get the icon as the drag representation
final LinearLayout l = (LinearLayout) animView;
final Drawable icon = ((ImageView) l.findViewById(R.id.icon)).getDrawable();
final LinearLayout l = (LinearLayout) v;
final Drawable icon = ((ImageView) l.findViewById(R.id.widget_preview)).getDrawable();
Bitmap b = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
icon.draw(c);
AppWidgetProviderInfo appWidgetInfo = (AppWidgetProviderInfo) v.getTag();
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
createItemInfo.componentName = appWidgetInfo.provider;
mDragController.startDrag(v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
createItemInfo = (PendingAddItemInfo) v.getTag();
mDragController.startDrag(v, b, this, createItemInfo, DragController.DRAG_ACTION_COPY,
null);
// Cleanup the icon
b.recycle();
return true;
case FolderCustomization:
ResolveInfo resolveInfo = (ResolveInfo) animView.getTag();
if (resolveInfo.labelRes == R.string.group_folder) {
UserFolderInfo folderInfo = new UserFolderInfo();
folderInfo.title = getResources().getText(R.string.folder_name);
if (v.getTag() instanceof UserFolderInfo) {
// The UserFolderInfo tag is only really used for live folders
UserFolderInfo folderInfo = (UserFolderInfo) v.getTag();
mDragController.startDrag(
v, this, folderInfo, DragController.DRAG_ACTION_COPY, null);
} else {
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER;
createItemInfo.componentName = new ComponentName(
resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
createItemInfo = (PendingAddItemInfo) v.getTag();
mDragController.startDrag(
v, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
}
return true;
case ShortcutCustomization:
ResolveInfo info = (ResolveInfo) animView.getTag();
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(
info.activityInfo.packageName, info.activityInfo.name);
createItemInfo = (PendingAddItemInfo) v.getTag();
mDragController.startDrag(
v, this, createItemInfo, DragController.DRAG_ACTION_COPY, null);
return true;
@@ -550,21 +603,26 @@ public class CustomizePagedView extends PagedView
layout.removeAllViews();
for (int i = 0; i < count; ++i) {
AppWidgetProviderInfo info = (AppWidgetProviderInfo) list.get(i);
PendingAddItemInfo createItemInfo = new PendingAddItemInfo();
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
createItemInfo.componentName = info.provider;
LinearLayout l = (LinearLayout) mInflater.inflate(
R.layout.customize_paged_view_widget, layout, false);
l.setTag(info);
l.setTag(createItemInfo);
l.setOnClickListener(this);
l.setOnLongClickListener(this);
final Drawable icon = getWidgetIcon(info);
final int hSpan = mWorkspaceWidgetLayout.estimateCellHSpan(info.minWidth);
final int vSpan = mWorkspaceWidgetLayout.estimateCellHSpan(info.minHeight);
ImageView image = (ImageView) l.findViewById(R.id.icon);
ImageView image = (ImageView) l.findViewById(R.id.widget_preview);
image.setMaxWidth(mMaxWidgetWidth);
image.setImageDrawable(icon);
TextView name = (TextView) l.findViewById(R.id.name);
TextView name = (TextView) l.findViewById(R.id.widget_name);
name.setText(info.label);
TextView dims = (TextView) l.findViewById(R.id.dims);
TextView dims = (TextView) l.findViewById(R.id.widget_dims);
dims.setText(mContext.getString(R.string.widget_dims_format, hSpan, vSpan));
layout.addView(l);
@@ -594,13 +652,39 @@ public class CustomizePagedView extends PagedView
layout.removeAllViews();
for (int i = startIndex; i < endIndex; ++i) {
ResolveInfo info = list.get(i);
PendingAddItemInfo createItemInfo = new PendingAddItemInfo();
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.customize_paged_view_item, layout, false);
icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache);
if (mCustomizationType == CustomizationType.WallpaperCustomization) {
switch (mCustomizationType) {
case WallpaperCustomization:
icon.setOnClickListener(this);
break;
case FolderCustomization:
if (info.labelRes != R.string.group_folder) {
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_LIVE_FOLDER;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
icon.setTag(createItemInfo);
} else {
UserFolderInfo folderInfo = new UserFolderInfo();
folderInfo.title = getResources().getText(R.string.folder_name);
icon.setTag(folderInfo);
}
icon.setOnClickListener(this);
} else {
icon.setOnLongClickListener(this);
break;
case ShortcutCustomization:
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
icon.setTag(createItemInfo);
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
break;
default:
break;
}
final int index = i - startIndex;
@@ -641,6 +725,7 @@ public class CustomizePagedView extends PagedView
PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
R.layout.all_apps_paged_view_application, layout, false);
icon.applyFromApplicationInfo(info, mPageViewIconCache);
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
final int index = i - startIndex;
@@ -719,10 +804,34 @@ public class CustomizePagedView extends PagedView
}
}
@Override
protected int getAssociatedLowerPageBound(int page) {
return 0;
}
@Override
protected int getAssociatedUpperPageBound(int page) {
return getChildCount();
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(mChoiceModeTitleText);
return true;
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return true;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
endChoiceMode();
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
}
@@ -35,8 +35,6 @@ public class HolographicOutlineHelper {
private static final BlurMaskFilter mThickInnerBlurMaskFilter = new BlurMaskFilter(4.0f,
BlurMaskFilter.Blur.NORMAL);
public static float DEFAULT_STROKE_WIDTH = 6.0f;
HolographicOutlineHelper() {
mHolographicPaint.setFilterBitmap(true);
mHolographicPaint.setAntiAlias(true);
+15 -7
View File
@@ -1473,9 +1473,9 @@ public final class Launcher extends Activity
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startActivityForResult(pickIntent, REQUEST_PICK_APPLICATION);
startActivityForResultSafely(pickIntent, REQUEST_PICK_APPLICATION);
} else {
startActivityForResult(intent, REQUEST_CREATE_SHORTCUT);
startActivityForResultSafely(intent, REQUEST_CREATE_SHORTCUT);
}
}
@@ -1502,7 +1502,7 @@ public final class Launcher extends Activity
if (folderName != null && folderName.equals(shortcutName)) {
addFolder(mAddScreen, mAddIntersectCellX, mAddIntersectCellY);
} else {
startActivityForResult(intent, REQUEST_CREATE_LIVE_FOLDER);
startActivityForResultSafely(intent, REQUEST_CREATE_LIVE_FOLDER);
}
}
@@ -3003,7 +3003,9 @@ public final class Launcher extends Activity
*/
public void bindAllApplications(ArrayList<ApplicationInfo> apps) {
mAllAppsGrid.setApps(apps);
mCustomizePagedView.setApps(apps);
if (mCustomizePagedView != null) {
mCustomizePagedView.setApps(apps);
}
updateAppMarketIcon();
}
@@ -3015,7 +3017,9 @@ public final class Launcher extends Activity
public void bindAppsAdded(ArrayList<ApplicationInfo> apps) {
removeDialog(DIALOG_CREATE_SHORTCUT);
mAllAppsGrid.addApps(apps);
mCustomizePagedView.addApps(apps);
if (mCustomizePagedView != null) {
mCustomizePagedView.addApps(apps);
}
updateAppMarketIcon();
}
@@ -3028,7 +3032,9 @@ public final class Launcher extends Activity
removeDialog(DIALOG_CREATE_SHORTCUT);
mWorkspace.updateShortcuts(apps);
mAllAppsGrid.updateApps(apps);
mCustomizePagedView.updateApps(apps);
if (mCustomizePagedView != null) {
mCustomizePagedView.updateApps(apps);
}
updateAppMarketIcon();
}
@@ -3043,7 +3049,9 @@ public final class Launcher extends Activity
mWorkspace.removeItems(apps);
}
mAllAppsGrid.removeApps(apps);
mCustomizePagedView.removeApps(apps);
if (mCustomizePagedView != null) {
mCustomizePagedView.removeApps(apps);
}
updateAppMarketIcon();
}
+2 -2
View File
@@ -1097,7 +1097,7 @@ public abstract class PagedView extends ViewGroup {
ArrayList<Checkable> checked = new ArrayList<Checkable>();
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
final PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(i);
final ViewGroup layout = (ViewGroup) getChildAt(i);
final int grandChildCount = layout.getChildCount();
for (int j = 0; j < grandChildCount; ++j) {
final View v = layout.getChildAt(j);
@@ -1117,7 +1117,7 @@ public abstract class PagedView extends ViewGroup {
if (mChoiceMode == CHOICE_MODE_SINGLE) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
final PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(i);
final ViewGroup layout = (ViewGroup) getChildAt(i);
final int grandChildCount = layout.getChildCount();
for (int j = 0; j < grandChildCount; ++j) {
final View v = layout.getChildAt(j);
@@ -0,0 +1,156 @@
/*
* Copyright (C) 2010 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 android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.LinearLayout;
import com.android.launcher.R;
/**
* An widget icon for use specifically in the CustomizePagedView. In class form so that
* we can add logic for how it will look when checked/unchecked.
*/
public class PagedViewWidgetIcon extends LinearLayout implements Checkable {
private static final String TAG = "PagedViewIcon";
// Holographic outline
private final Paint mPaint = new Paint();
private static HolographicOutlineHelper sHolographicOutlineHelper;
private final Paint mErasePaint = new Paint();
private Bitmap mCheckedOutline;
private Canvas mHolographicOutlineCanvas;
private boolean mIsHolographicUpdatePass;
private int mAlpha;
private boolean mIsChecked;
// Highlight colours
private int mCheckedBlurColor;
private int mCheckedOutlineColor;
public PagedViewWidgetIcon(Context context) {
this(context, null);
}
public PagedViewWidgetIcon(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PagedViewWidgetIcon(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewWidgetIcon,
defStyle, 0);
mCheckedBlurColor = a.getColor(R.styleable.PagedViewWidgetIcon_checkedBlurColor, 0);
mCheckedOutlineColor = a.getColor(R.styleable.PagedViewWidgetIcon_checkedOutlineColor, 0);
mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
mErasePaint.setFilterBitmap(true);
a.recycle();
if (sHolographicOutlineHelper == null) {
sHolographicOutlineHelper = new HolographicOutlineHelper();
}
setWillNotDraw(false);
}
public void invalidateCheckedImage() {
if (mCheckedOutline != null) {
mCheckedOutline.recycle();
mCheckedOutline = null;
}
}
@Override
protected void onDraw(Canvas canvas) {
// Draw the view itself
if (mIsHolographicUpdatePass) {
canvas.save();
final float alpha = getAlpha();
super.setAlpha(1.0f);
super.onDraw(canvas);
super.setAlpha(alpha);
canvas.restore();
} else {
if (mAlpha > 0) {
super.onDraw(canvas);
}
}
// Draw the holographic checked overlay if necessary
if (!mIsHolographicUpdatePass) {
if (mCheckedOutline != null) {
mPaint.setAlpha(255);
canvas.drawBitmap(mCheckedOutline, 0, 0, mPaint);
}
}
}
@Override
public boolean isChecked() {
return mIsChecked;
}
@Override
public void setChecked(boolean checked) {
if (mIsChecked != checked) {
mIsChecked = checked;
if (mIsChecked) {
// set a flag to indicate that we are going to draw the view at full alpha
mIsHolographicUpdatePass = true;
final int width = getMeasuredWidth();
final int height = getMeasuredHeight();
mCheckedOutline = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mHolographicOutlineCanvas = new Canvas(mCheckedOutline);
mHolographicOutlineCanvas.concat(getMatrix());
draw(mHolographicOutlineCanvas);
sHolographicOutlineHelper.applyExpensiveOutlineWithBlur(mCheckedOutline,
mHolographicOutlineCanvas, mCheckedBlurColor, mCheckedOutlineColor);
// Unlike PagedViewIcon, we can't seem to properly set the clip rect for all the
// children to respect when drawing... so for now, we erase over those parts in the
// checked highlight image
mHolographicOutlineCanvas.drawRect(0, findViewById(R.id.divider).getTop(),
width, height, mErasePaint);
mIsHolographicUpdatePass = false;
mHolographicOutlineCanvas = null;
} else {
invalidateCheckedImage();
}
invalidate();
}
}
@Override
public void toggle() {
setChecked(!mIsChecked);
}
}
+4 -4
View File
@@ -788,7 +788,7 @@ public class Workspace extends SmoothPagedView
mDragInfo.spanX, mDragInfo.spanY);
}
mTargetCell = estimateDropCell(originX, originY,
mTargetCell = findNearestVacantArea(originX, originY,
mDragInfo.spanX, mDragInfo.spanY, cell, cellLayout,
mTargetCell);
cellLayout.onDropChild(cell);
@@ -1085,7 +1085,7 @@ public class Workspace extends SmoothPagedView
if (view == null) {
cellLayout.onDragExit();
} else {
mTargetCell = estimateDropCell(x, y, 1, 1, view, cellLayout, mTargetCell);
mTargetCell = findNearestVacantArea(x, y, 1, 1, view, cellLayout, mTargetCell);
addInScreen(view, indexOfChild(cellLayout), mTargetCell[0],
mTargetCell[1], info.spanX, info.spanY, insertAtFirst);
cellLayout.onDropChild(view);
@@ -1148,7 +1148,7 @@ public class Workspace extends SmoothPagedView
/**
* Calculate the nearest cell where the given object would be dropped.
*/
private int[] estimateDropCell(int pixelX, int pixelY,
private int[] findNearestVacantArea(int pixelX, int pixelY,
int spanX, int spanY, View ignoreView, CellLayout layout, int[] recycle) {
final int[] cellXY = mTempCell;
@@ -1159,7 +1159,7 @@ public class Workspace extends SmoothPagedView
// Find the best target drop location
return layout.findNearestVacantArea(
mTempEstimate[0], mTempEstimate[1], spanX, spanY, recycle);
mTempEstimate[0], mTempEstimate[1], spanX, spanY, ignoreView, recycle);
}
/**