Removing CAB from AllApps
-Removed CAB and single selection mode -Replaced it with trash and appinfo drag targets at the top right of the tab view Change-Id: Ic4acaaef7fc71dc2ca0bffd516da31e85af1be69
This commit is contained in:
@@ -31,12 +31,36 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:tabStripEnabled="false" />
|
||||
<ImageView
|
||||
android:id="@+id/market_button"
|
||||
<FrameLayout
|
||||
android:id="@+id/market_info_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="onClickAppMarketButton" />
|
||||
android:layout_centerVertical="true">
|
||||
<com.android.launcher2.ApplicationInfoDropTarget
|
||||
android:id="@+id/all_apps_info_target"
|
||||
android:src="@drawable/info_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="invisible"/>
|
||||
<ImageView
|
||||
android:id="@+id/market_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:onClick="onClickAppMarketButton"/>
|
||||
</FrameLayout>
|
||||
<com.android.launcher2.DeleteZone
|
||||
android:id="@+id/all_apps_delete_zone"
|
||||
android:src="@drawable/delete_zone_selector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/market_info_frame"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible"
|
||||
android:paddingRight="22dp"
|
||||
launcher:direction="horizontal" />
|
||||
</RelativeLayout>
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
|
||||
@@ -31,12 +31,36 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:tabStripEnabled="false" />
|
||||
<ImageView
|
||||
android:id="@+id/market_button"
|
||||
<FrameLayout
|
||||
android:id="@+id/market_info_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:onClick="onClickAppMarketButton" />
|
||||
android:layout_centerVertical="true">
|
||||
<com.android.launcher2.ApplicationInfoDropTarget
|
||||
android:id="@+id/all_apps_info_target"
|
||||
android:src="@drawable/info_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="invisible"/>
|
||||
<ImageView
|
||||
android:id="@+id/market_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:onClick="onClickAppMarketButton"/>
|
||||
</FrameLayout>
|
||||
<com.android.launcher2.DeleteZone
|
||||
android:id="@+id/all_apps_delete_zone"
|
||||
android:src="@drawable/delete_zone_selector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/market_info_frame"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible"
|
||||
android:paddingRight="22dp"
|
||||
launcher:direction="horizontal" />
|
||||
</RelativeLayout>
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
|
||||
<!-- height & width of the drop rectangle for the trash icon -->
|
||||
<dimen name="delete_zone_size">50dip</dimen>
|
||||
<dimen name="delete_zone_min_padding">10dip</dimen>
|
||||
<dimen name="delete_zone_max_padding">20dip</dimen>
|
||||
<dimen name="delete_zone_padding">20dip</dimen>
|
||||
|
||||
<!-- dimensions for the wallpaper picker wallpaper thumbnail width -->
|
||||
<dimen name="wallpaper_small_width">170dp</dimen>
|
||||
|
||||
@@ -24,12 +24,8 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ActionMode;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Checkable;
|
||||
import android.widget.TextView;
|
||||
@@ -42,7 +38,7 @@ import com.android.launcher.R;
|
||||
*/
|
||||
public class AllAppsPagedView extends PagedView
|
||||
implements AllAppsView, View.OnClickListener, View.OnLongClickListener, DragSource,
|
||||
DropTarget, ActionMode.Callback {
|
||||
DropTarget {
|
||||
|
||||
private static final String TAG = "AllAppsPagedView";
|
||||
private static final boolean DEBUG = false;
|
||||
@@ -69,11 +65,6 @@ public class AllAppsPagedView extends PagedView
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
private ViewGroup mOrigInfoButtonParent;
|
||||
private LayoutParams mOrigInfoButtonLayoutParams;
|
||||
|
||||
private ViewGroup mOrigDeleteZoneParent;
|
||||
private LayoutParams mOrigDeleteZoneLayoutParams;
|
||||
|
||||
public AllAppsPagedView(Context context) {
|
||||
this(context, null);
|
||||
@@ -207,6 +198,47 @@ public class AllAppsPagedView extends PagedView
|
||||
}
|
||||
}
|
||||
|
||||
private void setupDragMode() {
|
||||
mLauncher.getWorkspace().shrinkToBottomVisible();
|
||||
|
||||
ApplicationInfoDropTarget infoButton =
|
||||
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
|
||||
infoButton.setDragAndDropEnabled(false);
|
||||
DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
|
||||
deleteZone.setDragAndDropEnabled(false);
|
||||
|
||||
ApplicationInfoDropTarget allAppsInfoButton =
|
||||
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
|
||||
allAppsInfoButton.setDragAndDropEnabled(true);
|
||||
DeleteZone allAppsDeleteZone = (DeleteZone)
|
||||
mLauncher.findViewById(R.id.all_apps_delete_zone);
|
||||
allAppsDeleteZone.setDragAndDropEnabled(true);
|
||||
}
|
||||
|
||||
private void tearDownDragMode() {
|
||||
post(new Runnable() {
|
||||
// Once the drag operation has fully completed, hence the post, we want to disable the
|
||||
// deleteZone and the appInfoButton in all apps, and re-enable the instance which
|
||||
// live in the workspace
|
||||
public void run() {
|
||||
ApplicationInfoDropTarget infoButton =
|
||||
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
|
||||
infoButton.setDragAndDropEnabled(true);
|
||||
DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
|
||||
deleteZone.setDragAndDropEnabled(true);
|
||||
|
||||
ApplicationInfoDropTarget allAppsInfoButton =
|
||||
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
|
||||
allAppsInfoButton.setDragAndDropEnabled(false);
|
||||
DeleteZone allAppsDeleteZone =
|
||||
(DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
|
||||
allAppsDeleteZone.setDragAndDropEnabled(false);
|
||||
}
|
||||
});
|
||||
resetCheckedGrandchildren();
|
||||
mDragController.removeDropTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (!v.isInTouchMode()) {
|
||||
@@ -223,10 +255,8 @@ public class AllAppsPagedView extends PagedView
|
||||
c.toggle();
|
||||
}
|
||||
|
||||
// Start choice mode AFTER the item is selected
|
||||
if (isChoiceMode(CHOICE_MODE_NONE)) {
|
||||
startChoiceMode(CHOICE_MODE_SINGLE, this);
|
||||
}
|
||||
// Start drag mode after the item is selected
|
||||
setupDragMode();
|
||||
|
||||
ApplicationInfo app = (ApplicationInfo) v.getTag();
|
||||
app = new ApplicationInfo(app);
|
||||
@@ -246,6 +276,7 @@ public class AllAppsPagedView extends PagedView
|
||||
if (target != this) {
|
||||
endChoiceMode();
|
||||
}
|
||||
tearDownDragMode();
|
||||
mLauncher.getWorkspace().onDragStopped();
|
||||
}
|
||||
|
||||
@@ -467,83 +498,6 @@ public class AllAppsPagedView extends PagedView
|
||||
new PagedViewCellLayout.LayoutParams(0, 0, 2, 1));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
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.
|
||||
// When the action mode is done, restore the views to their original place in the toolbar.
|
||||
|
||||
ApplicationInfoDropTarget infoButton =
|
||||
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
|
||||
mOrigInfoButtonParent = (ViewGroup) infoButton.getParent();
|
||||
mOrigInfoButtonLayoutParams = infoButton.getLayoutParams();
|
||||
mOrigInfoButtonParent.removeView(infoButton);
|
||||
infoButton.setManageVisibility(false);
|
||||
infoButton.setVisibility(View.VISIBLE);
|
||||
infoButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
|
||||
mLauncher.startApplicationDetailsActivity(appInfo.componentName);
|
||||
}
|
||||
});
|
||||
|
||||
DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
|
||||
mOrigDeleteZoneParent = (ViewGroup) deleteZone.getParent();
|
||||
mOrigDeleteZoneLayoutParams = deleteZone.getLayoutParams();
|
||||
mOrigDeleteZoneParent.removeView(deleteZone);
|
||||
deleteZone.setManageVisibility(false);
|
||||
deleteZone.setVisibility(View.VISIBLE);
|
||||
deleteZone.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
final ApplicationInfo appInfo = (ApplicationInfo) getChosenItem();
|
||||
mLauncher.startApplicationUninstallActivity(appInfo);
|
||||
}
|
||||
});
|
||||
|
||||
menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app).setActionView(deleteZone);
|
||||
menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton);
|
||||
|
||||
mLauncher.getWorkspace().shrinkToBottomVisible();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
mDragController.addDropTarget(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
final Menu menu = mode.getMenu();
|
||||
|
||||
// Re-parent the drop targets into the toolbar, and restore their layout params
|
||||
|
||||
ApplicationInfoDropTarget infoButton =
|
||||
(ApplicationInfoDropTarget) menu.findItem(MENU_APP_INFO).getActionView();
|
||||
((ViewGroup) infoButton.getParent()).removeView(infoButton);
|
||||
mOrigInfoButtonParent.addView(infoButton, mOrigInfoButtonLayoutParams);
|
||||
infoButton.setVisibility(View.GONE);
|
||||
infoButton.setManageVisibility(true);
|
||||
|
||||
DeleteZone deleteZone = (DeleteZone) menu.findItem(MENU_DELETE_APP).getActionView();
|
||||
((ViewGroup) deleteZone.getParent()).removeView(deleteZone);
|
||||
mOrigDeleteZoneParent.addView(deleteZone, mOrigDeleteZoneLayoutParams);
|
||||
deleteZone.setVisibility(View.GONE);
|
||||
deleteZone.setManageVisibility(true);
|
||||
|
||||
mDragController.removeDropTarget(this);
|
||||
endChoiceMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
// This is never called. Because we use setActionView(), we handle our own click events.
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't actually use AllAppsPagedView as a drop target... it's only used to intercept a drop
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
@@ -28,6 +26,8 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
/**
|
||||
* Implements a DropTarget which allows applications to be dropped on it,
|
||||
* in order to launch the application info for that app.
|
||||
@@ -41,7 +41,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
* This is generally the case, but it will be set to false when this is part of the
|
||||
* Contextual Action Bar.
|
||||
*/
|
||||
private boolean mManageVisibility = true;
|
||||
private boolean mDragAndDropEnabled = true;
|
||||
|
||||
/** The view that this view should appear in the place of. */
|
||||
private View mHandle = null;
|
||||
@@ -69,6 +69,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
// acceptDrop is called just before onDrop. We do the work here, rather than
|
||||
// in onDrop, because it allows us to reject the drop (by returning false)
|
||||
// so that the object being dragged isn't removed from the home screen.
|
||||
if (getVisibility() != VISIBLE) return false;
|
||||
|
||||
ComponentName componentName = null;
|
||||
if (dragInfo instanceof ApplicationInfo) {
|
||||
@@ -87,6 +88,7 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
|
||||
public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
|
||||
DragView dragView, Object dragInfo) {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
dragView.setPaint(mPaint);
|
||||
}
|
||||
|
||||
@@ -96,18 +98,20 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
|
||||
public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
|
||||
DragView dragView, Object dragInfo) {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
dragView.setPaint(null);
|
||||
}
|
||||
|
||||
public void onDragStart(DragSource source, Object info, int dragAction) {
|
||||
if (info != null) {
|
||||
if (info != null && mDragAndDropEnabled) {
|
||||
final int itemType = ((ItemInfo)info).itemType;
|
||||
mActive = (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION);
|
||||
if (mManageVisibility) {
|
||||
// Only show the info icon when an application is selected
|
||||
if (mActive) {
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
// Only show the info icon when an application is selected
|
||||
if (mActive) {
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
if (mHandle != null) {
|
||||
mHandle.setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -118,11 +122,13 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
}
|
||||
|
||||
public void onDragEnd() {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
|
||||
if (mActive) {
|
||||
mActive = false;
|
||||
}
|
||||
if (mManageVisibility) {
|
||||
setVisibility(GONE);
|
||||
setVisibility(GONE);
|
||||
if (mHandle != null) {
|
||||
mHandle.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -131,16 +137,10 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
public void getHitRect(Rect outRect) {
|
||||
super.getHitRect(outRect);
|
||||
if (LauncherApplication.isScreenXLarge()) {
|
||||
// TODO: This is a temporary hack. mManageVisiblity = false when you're in CAB mode.
|
||||
// In that case, this icon is more tightly spaced next to the delete icon so we want
|
||||
// it to have a smaller drag region. When the new drag&drop system comes in, we'll
|
||||
// dispatch the drag/drop by calculating what target you're overlapping
|
||||
final int minPadding = R.dimen.delete_zone_min_padding;
|
||||
final int maxPadding = R.dimen.delete_zone_max_padding;
|
||||
final int padding = R.dimen.delete_zone_padding;
|
||||
final int outerDragPadding =
|
||||
getResources().getDimensionPixelSize(R.dimen.delete_zone_size);
|
||||
final int innerDragPadding = getResources().getDimensionPixelSize(
|
||||
mManageVisibility ? maxPadding : minPadding);
|
||||
final int innerDragPadding = getResources().getDimensionPixelSize(padding);
|
||||
outRect.top -= outerDragPadding;
|
||||
outRect.left -= innerDragPadding;
|
||||
outRect.bottom += outerDragPadding;
|
||||
@@ -156,8 +156,8 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget,
|
||||
mHandle = view;
|
||||
}
|
||||
|
||||
void setManageVisibility(boolean value) {
|
||||
mManageVisibility = value;
|
||||
void setDragAndDropEnabled(boolean enabled) {
|
||||
mDragAndDropEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Paint;
|
||||
@@ -35,6 +33,8 @@ import android.view.animation.AnimationSet;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.launcher.R;
|
||||
|
||||
public class DeleteZone extends ImageView implements DropTarget, DragController.DragListener {
|
||||
private static final int ORIENTATION_HORIZONTAL = 1;
|
||||
private static final int TRANSITION_DURATION = 250;
|
||||
@@ -50,7 +50,7 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
* This is generally the case, but it will be set to false when this is part of the
|
||||
* Contextual Action Bar.
|
||||
*/
|
||||
private boolean mManageVisibility = true;
|
||||
private boolean mDragAndDropEnabled = true;
|
||||
|
||||
private AnimationSet mInAnimation;
|
||||
private AnimationSet mOutAnimation;
|
||||
@@ -81,7 +81,6 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0);
|
||||
mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL);
|
||||
a.recycle();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,6 +96,8 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
|
||||
public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
|
||||
DragView dragView, Object dragInfo) {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
|
||||
final ItemInfo item = (ItemInfo) dragInfo;
|
||||
|
||||
// On x-large screens, you can uninstall an app by dragging from all apps
|
||||
@@ -142,6 +143,7 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
|
||||
public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
|
||||
DragView dragView, Object dragInfo) {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
mTransition.reverseTransition(TRANSITION_DURATION);
|
||||
dragView.setPaint(mTrashPaint);
|
||||
}
|
||||
@@ -152,13 +154,14 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
|
||||
public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
|
||||
DragView dragView, Object dragInfo) {
|
||||
if (!mDragAndDropEnabled) return;
|
||||
mTransition.reverseTransition(TRANSITION_DURATION);
|
||||
dragView.setPaint(null);
|
||||
}
|
||||
|
||||
public void onDragStart(DragSource source, Object info, int dragAction) {
|
||||
final ItemInfo item = (ItemInfo) info;
|
||||
if (item != null) {
|
||||
if (item != null && mDragAndDropEnabled) {
|
||||
mTrashMode = true;
|
||||
getHitRect(mRegion);
|
||||
mRegionF.set(mRegion);
|
||||
@@ -175,26 +178,25 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
// Make sure the icon is set to the default drawable, not the hover drawable
|
||||
mTransition.resetTransition();
|
||||
|
||||
if (mManageVisibility) {
|
||||
createAnimations();
|
||||
startAnimation(mInAnimation);
|
||||
createAnimations();
|
||||
startAnimation(mInAnimation);
|
||||
if (mHandle != null) {
|
||||
mHandle.startAnimation(mHandleOutAnimation);
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDragEnd() {
|
||||
if (mTrashMode) {
|
||||
if (mTrashMode && mDragAndDropEnabled) {
|
||||
mTrashMode = false;
|
||||
mDragController.setDeleteRegion(null);
|
||||
|
||||
if (mOutAnimation != null) startAnimation(mOutAnimation);
|
||||
if (mHandleInAnimation != null) mHandle.startAnimation(mHandleInAnimation);
|
||||
|
||||
if (mManageVisibility) {
|
||||
setVisibility(GONE);
|
||||
if (mHandleInAnimation != null && mHandle != null) {
|
||||
mHandle.startAnimation(mHandleInAnimation);
|
||||
}
|
||||
setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,12 +212,10 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
// In that case, this icon is more tightly spaced next to the delete icon so we want
|
||||
// it to have a smaller drag region. When the new drag&drop system comes in, we'll
|
||||
// dispatch the drag/drop by calculating what target you're overlapping
|
||||
final int minPadding = R.dimen.delete_zone_min_padding;
|
||||
final int maxPadding = R.dimen.delete_zone_max_padding;
|
||||
final int padding = R.dimen.delete_zone_padding;
|
||||
final int outerDragPadding =
|
||||
getResources().getDimensionPixelSize(R.dimen.delete_zone_size);
|
||||
final int innerDragPadding = getResources().getDimensionPixelSize(
|
||||
mManageVisibility ? maxPadding : minPadding);
|
||||
final int innerDragPadding = getResources().getDimensionPixelSize(padding);
|
||||
outRect.top -= outerDragPadding;
|
||||
outRect.left -= innerDragPadding;
|
||||
outRect.bottom += outerDragPadding;
|
||||
@@ -290,8 +290,8 @@ public class DeleteZone extends ImageView implements DropTarget, DragController.
|
||||
mHandle = view;
|
||||
}
|
||||
|
||||
void setManageVisibility(boolean value) {
|
||||
mManageVisibility = value;
|
||||
void setDragAndDropEnabled(boolean enabled) {
|
||||
mDragAndDropEnabled = enabled;
|
||||
}
|
||||
|
||||
private static class FastTranslateAnimation extends TranslateAnimation {
|
||||
|
||||
@@ -59,6 +59,7 @@ import android.content.res.TypedArray;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -90,8 +91,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Advanceable;
|
||||
import android.widget.EditText;
|
||||
@@ -960,6 +959,29 @@ public final class Launcher extends Activity
|
||||
deleteZone.setHandle(findViewById(deleteZoneHandleId));
|
||||
dragController.addDragListener(deleteZone);
|
||||
|
||||
DeleteZone allAppsDeleteZone = (DeleteZone) findViewById(R.id.all_apps_delete_zone);
|
||||
if (allAppsDeleteZone != null) {
|
||||
allAppsDeleteZone.setLauncher(this);
|
||||
allAppsDeleteZone.setDragController(dragController);
|
||||
allAppsDeleteZone.setDragAndDropEnabled(false);
|
||||
dragController.addDragListener(allAppsDeleteZone);
|
||||
dragController.addDropTarget(allAppsDeleteZone);
|
||||
}
|
||||
|
||||
ApplicationInfoDropTarget allAppsInfoTarget = (ApplicationInfoDropTarget)
|
||||
findViewById(R.id.all_apps_info_target);
|
||||
if (allAppsInfoTarget != null) {
|
||||
allAppsInfoTarget.setLauncher(this);
|
||||
dragController.addDragListener(allAppsInfoTarget);
|
||||
allAppsInfoTarget.setDragColor(getResources().getColor(R.color.app_info_filter));
|
||||
allAppsInfoTarget.setDragAndDropEnabled(false);
|
||||
View marketButton = findViewById(R.id.market_button);
|
||||
if (marketButton != null) {
|
||||
marketButton.setBackgroundColor(Color.RED);
|
||||
allAppsInfoTarget.setHandle(marketButton);
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationInfoDropTarget infoButton = (ApplicationInfoDropTarget)findViewById(R.id.info_button);
|
||||
if (infoButton != null) {
|
||||
infoButton.setLauncher(this);
|
||||
@@ -978,6 +1000,12 @@ public final class Launcher extends Activity
|
||||
if (infoButton != null) {
|
||||
dragController.addDropTarget(infoButton);
|
||||
}
|
||||
if (allAppsInfoTarget != null) {
|
||||
dragController.addDropTarget(allAppsInfoTarget);
|
||||
}
|
||||
if (allAppsDeleteZone != null) {
|
||||
dragController.addDropTarget(allAppsDeleteZone);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
|
||||
Reference in New Issue
Block a user