summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-06-12 15:15:29 -0700
committerWinson Chung <winsonc@google.com>2011-06-13 11:51:18 -0700
commit61fa4197c4316bb0f9b05fcefb676f86197a2273 (patch)
treef65b772ab5f47288734edab35fdb5d8f0fabf7b9
parentf0ea4d3378be7b962c8e0bce2392df5e82491fb8 (diff)
downloadandroid_packages_apps_Trebuchet-61fa4197c4316bb0f9b05fcefb676f86197a2273.tar.gz
android_packages_apps_Trebuchet-61fa4197c4316bb0f9b05fcefb676f86197a2273.tar.bz2
android_packages_apps_Trebuchet-61fa4197c4316bb0f9b05fcefb676f86197a2273.zip
Fixing drop target area, and adding bg color indicators.
- Merging wallpaper fix and PagedViewIconCache key fix Change-Id: I2a65bc4b642f020dfc4d2223a36d3ebcf41de5f5
-rw-r--r--res/layout-large/qsb_bar.xml28
-rw-r--r--res/layout/qsb_bar.xml28
-rw-r--r--res/values-large/styles.xml8
-rw-r--r--res/values/colors.xml4
-rw-r--r--res/values/config.xml3
-rw-r--r--res/values/styles.xml8
-rw-r--r--src/com/android/launcher2/ButtonDropTarget.java93
-rw-r--r--src/com/android/launcher2/DeleteDropTarget.java34
-rw-r--r--src/com/android/launcher2/InfoDropTarget.java20
-rw-r--r--src/com/android/launcher2/PagedViewIconCache.java4
-rw-r--r--src/com/android/launcher2/SearchDropTargetBar.java12
-rw-r--r--src/com/android/launcher2/Workspace.java12
12 files changed, 176 insertions, 78 deletions
diff --git a/res/layout-large/qsb_bar.xml b/res/layout-large/qsb_bar.xml
index 57e4eeb14..421ace2e1 100644
--- a/res/layout-large/qsb_bar.xml
+++ b/res/layout-large/qsb_bar.xml
@@ -104,32 +104,28 @@
android:layout_height="match_parent"
android:alpha="0">
- <FrameLayout
+ <com.android.launcher2.DeleteDropTarget
style="@style/DropTargetButtonContainer"
+ android:id="@+id/delete_target"
android:layout_weight="1">
<!-- Delete target -->
- <com.android.launcher2.DeleteDropTarget
+ <TextView
style="@style/DropTargetButton"
- android:id="@+id/delete_target"
+ android:id="@+id/delete_target_text"
android:text="@string/delete_zone_label_workspace"
- android:drawableLeft="@drawable/delete_zone_selector"
- launcher:strokeColor="#991e3157"
- launcher:strokeTextColor="#DDFFFFFF"
- launcher:strokeWidth="2.5" />
- </FrameLayout>
+ android:drawableLeft="@drawable/delete_zone_selector" />
+ </com.android.launcher2.DeleteDropTarget>
- <FrameLayout
+ <com.android.launcher2.InfoDropTarget
style="@style/DropTargetButtonContainer"
+ android:id="@+id/info_target"
android:layout_weight="1">
<!-- Info target -->
- <com.android.launcher2.InfoDropTarget
+ <TextView
style="@style/DropTargetButton"
- android:id="@+id/info_target"
+ android:id="@+id/info_target_text"
android:text="@string/info_target_label"
- android:drawableLeft="@drawable/ic_home_info_holo_dark"
- launcher:strokeColor="#991e3157"
- launcher:strokeTextColor="#DDFFFFFF"
- launcher:strokeWidth="2.5" />
- </FrameLayout>
+ android:drawableLeft="@drawable/ic_home_info_holo_dark" />
+ </com.android.launcher2.InfoDropTarget>
</LinearLayout>
</com.android.launcher2.SearchDropTargetBar>
diff --git a/res/layout/qsb_bar.xml b/res/layout/qsb_bar.xml
index 6e1d98c38..68ee8b6d5 100644
--- a/res/layout/qsb_bar.xml
+++ b/res/layout/qsb_bar.xml
@@ -67,32 +67,28 @@
android:layout_height="match_parent"
android:alpha="0">
- <FrameLayout
+ <com.android.launcher2.DeleteDropTarget
style="@style/DropTargetButtonContainer"
+ android:id="@+id/delete_target"
android:layout_weight="1">
<!-- Delete target -->
- <com.android.launcher2.DeleteDropTarget
+ <TextView
style="@style/DropTargetButton"
- android:id="@+id/delete_target"
+ android:id="@+id/delete_target_text"
android:text="@string/delete_zone_label_workspace"
- android:drawableLeft="@drawable/delete_zone_selector"
- launcher:strokeColor="#991e3157"
- launcher:strokeTextColor="#DDFFFFFF"
- launcher:strokeWidth="2.5" />
- </FrameLayout>
+ android:drawableLeft="@drawable/delete_zone_selector" />
+ </com.android.launcher2.DeleteDropTarget>
- <FrameLayout
+ <com.android.launcher2.InfoDropTarget
style="@style/DropTargetButtonContainer"
+ android:id="@+id/info_target"
android:layout_weight="1">
<!-- Info target -->
- <com.android.launcher2.InfoDropTarget
+ <TextView
style="@style/DropTargetButton"
- android:id="@+id/info_target"
+ android:id="@+id/info_target_text"
android:text="@string/info_target_label"
- android:drawableLeft="@drawable/ic_home_info_holo_dark"
- launcher:strokeColor="#991e3157"
- launcher:strokeTextColor="#DDFFFFFF"
- launcher:strokeWidth="2.5" />
- </FrameLayout>
+ android:drawableLeft="@drawable/ic_home_info_holo_dark" />
+ </com.android.launcher2.InfoDropTarget>
</LinearLayout>
</com.android.launcher2.SearchDropTargetBar>
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
index 42b85f652..9c1532aa0 100644
--- a/res/values-large/styles.xml
+++ b/res/values-large/styles.xml
@@ -80,12 +80,12 @@
</style>
<style name="DropTargetButton">
<item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">match_parent</item>
- <item name="android:layout_gravity">center_horizontal</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical</item>
<item name="android:drawablePadding">7.5dp</item>
- <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
- <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
+ <item name="android:textColor">#FFFFFFFF</item>
+ <item name="android:textSize">16sp</item>
</style>
<style name="config_orientation">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e14fbfe37..fd7b21c35 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -20,8 +20,8 @@
<resources>
<!-- The color tints to apply to the text and drag view when hovering
over the delete target or the info target -->
- <color name="delete_target_hover_tint">#A5FF0000</color>
- <color name="info_target_hover_tint">#A50000FE</color>
+ <color name="delete_target_hover_tint">#D4FF3600</color>
+ <color name="info_target_hover_tint">#D40078FF</color>
<color name="window_background">#FF191919</color>
<color name="grid_dark_background">#EB191919</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index 394ff8afa..06e8fdad8 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -43,6 +43,9 @@
<integer name="config_allAppsBatchSize">0</integer>
<!-- Workspace -->
+ <!-- The transition duration for the background of the drop targets -->
+ <integer name="config_dropTargetBgTransitionDuration">100</integer>
+
<integer name="config_crosshairsFadeInTime">600</integer>
<!-- When dragging an item on the workspace, how much bigger (in pixels) the dragged view
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 176bab572..5c458b408 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -93,12 +93,12 @@
</style>
<style name="DropTargetButton">
<item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">match_parent</item>
- <item name="android:layout_gravity">center_horizontal</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical</item>
<item name="android:drawablePadding">7.5dp</item>
- <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
- <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
+ <item name="android:textColor">#FFFFFFFF</item>
+ <item name="android:textSize">16sp</item>
</style>
<style name="TabIndicator">
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
new file mode 100644
index 000000000..e3da860cc
--- /dev/null
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -0,0 +1,93 @@
+/*
+ * 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.graphics.Paint;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import com.android.launcher.R;
+
+
+/**
+ * Implements a DropTarget.
+ */
+public class ButtonDropTarget extends FrameLayout implements DropTarget, DragController.DragListener {
+
+ protected final int mTransitionDuration;
+
+ protected Launcher mLauncher;
+
+ /** Whether this drop target is active for the current drag */
+ protected boolean mActive;
+
+ /** The paint applied to the drag view on hover */
+ protected final Paint mHoverPaint = new Paint();
+
+ public ButtonDropTarget(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ mTransitionDuration =
+ context.getResources().getInteger(R.integer.config_dropTargetBgTransitionDuration);
+ }
+
+ void setLauncher(Launcher launcher) {
+ mLauncher = launcher;
+ }
+
+ public boolean acceptDrop(DragObject d) {
+ return false;
+ }
+
+ public void onDrop(DragObject d) {
+ // Do nothing
+ }
+
+ public void onDragEnter(DragObject d) {
+ d.dragView.setPaint(mHoverPaint);
+ }
+
+ public void onDragOver(DragObject d) {
+ // Do nothing
+ }
+
+ public void onDragExit(DragObject d) {
+ d.dragView.setPaint(null);
+ }
+
+ public void onDragStart(DragSource source, Object info, int dragAction) {
+ // Do nothing
+ }
+
+ public boolean isDropEnabled() {
+ return mActive;
+ }
+
+ public void onDragEnd() {
+ // Do nothing
+ }
+
+ @Override
+ public DropTarget getDropTargetDelegate(DragObject d) {
+ return null;
+ }
+}
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index a474c27e1..5b3fd1e16 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -16,23 +16,22 @@
package com.android.launcher2;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
-import android.graphics.drawable.TransitionDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.TextView;
import com.android.launcher.R;
-public class DeleteDropTarget extends IconDropTarget {
+public class DeleteDropTarget extends ButtonDropTarget {
- private static final int sTransitionDuration = 0;
-
- private TransitionDrawable mIcon;
- private int mDefaultTextColor;
+ private TextView mText;
private int mHoverColor = 0xFFFF0000;
public DeleteDropTarget(Context context, AttributeSet attrs) {
@@ -48,14 +47,15 @@ public class DeleteDropTarget extends IconDropTarget {
super.onFinishInflate();
// Get the drawable
- mIcon = (TransitionDrawable) getCompoundDrawables()[0];
+ mText = (TextView) findViewById(R.id.delete_target_text);
// Get the hover color
Resources r = getResources();
- mDefaultTextColor = getTextColors().getDefaultColor();
mHoverColor = r.getColor(R.color.delete_target_hover_tint);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(
mHoverColor, PorterDuff.Mode.SRC_ATOP));
+ setBackgroundColor(mHoverColor);
+ getBackground().setAlpha(0);
}
private boolean isAllAppsApplication(DragSource source, Object info) {
@@ -82,7 +82,6 @@ public class DeleteDropTarget extends IconDropTarget {
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
- ItemInfo item = (ItemInfo) info;
boolean isVisible = true;
boolean isUninstall = false;
@@ -103,9 +102,9 @@ public class DeleteDropTarget extends IconDropTarget {
}
mActive = isVisible;
- ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
- if (getText().length() > 0) {
- setText(isUninstall ? R.string.delete_target_uninstall_label
+ setVisibility(isVisible ? View.VISIBLE : View.GONE);
+ if (mText.getText().length() > 0) {
+ mText.setText(isUninstall ? R.string.delete_target_uninstall_label
: R.string.delete_target_label);
}
}
@@ -119,15 +118,18 @@ public class DeleteDropTarget extends IconDropTarget {
public void onDragEnter(DragObject d) {
super.onDragEnter(d);
- mIcon.startTransition(sTransitionDuration);
- setTextColor(mHoverColor);
+ ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha",
+ Color.alpha(mHoverColor));
+ anim.setDuration(mTransitionDuration);
+ anim.start();
}
public void onDragExit(DragObject d) {
super.onDragExit(d);
- mIcon.resetTransition();
- setTextColor(mDefaultTextColor);
+ ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha", 0);
+ anim.setDuration(mTransitionDuration);
+ anim.start();
}
public void onDrop(DragObject d) {
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java
index bbde2b846..7e6b700df 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/android/launcher2/InfoDropTarget.java
@@ -16,20 +16,20 @@
package com.android.launcher2;
+import android.animation.ObjectAnimator;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.util.AttributeSet;
import android.view.View;
-import android.view.ViewGroup;
import com.android.launcher.R;
-public class InfoDropTarget extends IconDropTarget {
+public class InfoDropTarget extends ButtonDropTarget {
- private int mDefaultTextColor;
private int mHoverColor = 0xFF0000FF;
public InfoDropTarget(Context context, AttributeSet attrs) {
@@ -46,10 +46,11 @@ public class InfoDropTarget extends IconDropTarget {
// Get the hover color
Resources r = getResources();
- mDefaultTextColor = getTextColors().getDefaultColor();
mHoverColor = r.getColor(R.color.info_target_hover_tint);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(
mHoverColor, PorterDuff.Mode.SRC_ATOP));
+ setBackgroundColor(mHoverColor);
+ getBackground().setAlpha(0);
}
private boolean isApplication(Object info) {
@@ -85,7 +86,7 @@ public class InfoDropTarget extends IconDropTarget {
}
mActive = isVisible;
- ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
+ setVisibility(isVisible ? View.VISIBLE : View.GONE);
}
@Override
@@ -97,12 +98,17 @@ public class InfoDropTarget extends IconDropTarget {
public void onDragEnter(DragObject d) {
super.onDragEnter(d);
- setTextColor(mHoverColor);
+ ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha",
+ Color.alpha(mHoverColor));
+ anim.setDuration(mTransitionDuration);
+ anim.start();
}
public void onDragExit(DragObject d) {
super.onDragExit(d);
- setTextColor(mDefaultTextColor);
+ ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha", 0);
+ anim.setDuration(mTransitionDuration);
+ anim.start();
}
}
diff --git a/src/com/android/launcher2/PagedViewIconCache.java b/src/com/android/launcher2/PagedViewIconCache.java
index de05ff1ac..d65f68baf 100644
--- a/src/com/android/launcher2/PagedViewIconCache.java
+++ b/src/com/android/launcher2/PagedViewIconCache.java
@@ -48,11 +48,11 @@ public class PagedViewIconCache {
final ComponentInfo ci = info.activityInfo != null ? info.activityInfo :
info.serviceInfo;
mComponentName = new ComponentName(ci.packageName, ci.name);
- mType = Type.AppWidgetProviderInfoKey;
+ mType = Type.ResolveInfoKey;
}
public Key(AppWidgetProviderInfo info) {
mComponentName = info.provider;
- mType = Type.ResolveInfoKey;
+ mType = Type.AppWidgetProviderInfoKey;
}
private ComponentName getComponentName() {
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index 5ab28ea4a..d00e2103f 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -17,9 +17,6 @@
package com.android.launcher2;
import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
@@ -38,8 +35,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
private boolean mIsSearchBarHidden;
private View mQSBSearchBar;
private View mDropTargetBar;
- private IconDropTarget mInfoDropTarget;
- private IconDropTarget mDeleteDropTarget;
+ private ButtonDropTarget mInfoDropTarget;
+ private ButtonDropTarget mDeleteDropTarget;
public SearchDropTargetBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -57,6 +54,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
dragController.addDropTarget(mDeleteDropTarget);
mInfoDropTarget.setLauncher(launcher);
mDeleteDropTarget.setLauncher(launcher);
+ mDropTargetBar.setBackgroundColor(0x33000000);
}
@Override
@@ -66,8 +64,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Get the individual components
mQSBSearchBar = findViewById(R.id.qsb_search_bar);
mDropTargetBar = findViewById(R.id.drag_target_bar);
- mInfoDropTarget = (IconDropTarget) mDropTargetBar.findViewById(R.id.info_target);
- mDeleteDropTarget = (IconDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
+ mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target);
+ mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
}
/*
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index b6e4f563d..ff2dede6e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -45,6 +45,7 @@ import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region.Op;
@@ -61,8 +62,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
-import android.widget.TabHost;
-import android.widget.TabWidget;
import android.widget.TextView;
import android.widget.Toast;
@@ -720,8 +719,13 @@ public class Workspace extends SmoothPagedView
protected void setWallpaperDimension() {
Display display = mLauncher.getWindowManager().getDefaultDisplay();
- final int maxDim = Math.max(display.getWidth(), display.getHeight());
- final int minDim = Math.min(display.getWidth(), display.getHeight());
+ Point displaySize = new Point();
+ display.getSize(displaySize);
+ if (LauncherApplication.isScreenLarge()) {
+ displaySize.y += (int) getResources().getDimension(R.dimen.status_bar_height);
+ }
+ final int maxDim = Math.max(displaySize.x, displaySize.y);
+ final int minDim = Math.min(displaySize.x, displaySize.y);
// We need to ensure that there is enough extra space in the wallpaper for the intended
// parallax effects