diff options
author | Winson Chung <winsonc@google.com> | 2011-06-12 15:15:29 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-06-13 11:51:18 -0700 |
commit | 61fa4197c4316bb0f9b05fcefb676f86197a2273 (patch) | |
tree | f65b772ab5f47288734edab35fdb5d8f0fabf7b9 /src | |
parent | f0ea4d3378be7b962c8e0bce2392df5e82491fb8 (diff) | |
download | android_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
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/ButtonDropTarget.java | 93 | ||||
-rw-r--r-- | src/com/android/launcher2/DeleteDropTarget.java | 34 | ||||
-rw-r--r-- | src/com/android/launcher2/InfoDropTarget.java | 20 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewIconCache.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/SearchDropTargetBar.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 12 |
6 files changed, 139 insertions, 36 deletions
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 |