summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/AllAppsPagedView.java
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2010-09-22 15:04:29 -0700
committerPatrick Dubroy <dubroy@google.com>2010-09-22 16:23:09 -0700
commitdea9e93e4a7b78ae48f27ac0d5d117f6b393bba0 (patch)
treea73ca564f85b0b8eff3fd542659c55c0d1965297 /src/com/android/launcher2/AllAppsPagedView.java
parent097b49c86eb0952f3febe28cc59743915a09a5e2 (diff)
downloadandroid_packages_apps_Trebuchet-dea9e93e4a7b78ae48f27ac0d5d117f6b393bba0.tar.gz
android_packages_apps_Trebuchet-dea9e93e4a7b78ae48f27ac0d5d117f6b393bba0.tar.bz2
android_packages_apps_Trebuchet-dea9e93e4a7b78ae48f27ac0d5d117f6b393bba0.zip
Fix misaligned drop targets in the all apps CAB
Diffstat (limited to 'src/com/android/launcher2/AllAppsPagedView.java')
-rw-r--r--src/com/android/launcher2/AllAppsPagedView.java49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index a9e4dfe85..a2a3793dd 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -21,14 +21,13 @@ import com.android.launcher.R;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.Log;
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;
@@ -72,6 +71,12 @@ 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);
}
@@ -400,10 +405,28 @@ public class AllAppsPagedView extends PagedView
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(R.string.cab_selection_text);
- menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info)
- .setIcon(R.drawable.info_button);
- menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app)
- .setIcon(R.drawable.delete_zone_selector);
+ // 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);
+
+ 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);
+
+ menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton);
+ menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app).setActionView(deleteZone);
+
return true;
}
@@ -415,6 +438,20 @@ public class AllAppsPagedView extends PagedView
@Override
public void onDestroyActionMode(ActionMode mode) {
+ // Re-parent the drop targets into the toolbar, and restore their layout params
+ ApplicationInfoDropTarget infoButton =
+ (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.info_button);
+ ((ViewGroup) infoButton.getParent()).removeView(infoButton);
+ mOrigInfoButtonParent.addView(infoButton, mOrigInfoButtonLayoutParams);
+ infoButton.setVisibility(View.GONE);
+ infoButton.setManageVisibility(true);
+
+ DeleteZone deleteZone = (DeleteZone) mLauncher.findViewById(R.id.delete_zone);
+ ((ViewGroup) deleteZone.getParent()).removeView(deleteZone);
+ mOrigDeleteZoneParent.addView(deleteZone, mOrigDeleteZoneLayoutParams);
+ deleteZone.setVisibility(View.GONE);
+ deleteZone.setManageVisibility(true);
+
mDragController.removeDropTarget(this);
endChoiceMode();
}