diff options
author | Winson Chung <winsonc@google.com> | 2011-07-27 10:53:39 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-07-27 14:34:03 -0700 |
commit | a6427b15c18d5b8f3078f553d78f8432de9f46e9 (patch) | |
tree | ed68bedc3480ecd3212242bcba61f6af9e7a533e /src | |
parent | 2f84ef259314b0bef20f6e7e503377212fadc88c (diff) | |
download | packages_apps_trebuchet-a6427b15c18d5b8f3078f553d78f8432de9f46e9.zip packages_apps_trebuchet-a6427b15c18d5b8f3078f553d78f8432de9f46e9.tar.gz packages_apps_trebuchet-a6427b15c18d5b8f3078f553d78f8432de9f46e9.tar.bz2 |
Fixing minor bugs (5085316, 5082963, 5042828)
- Adding separator between qsb and workspace content
- Adding a bit of spacing between drawables and text in all apps
- Making the drop target area smaller...
Change-Id: I1bebe7dff20fc30e4896de1dcf23d23b62a31a07
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/ButtonDropTarget.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher2/DeleteDropTarget.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher2/InfoDropTarget.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 56 | ||||
-rw-r--r-- | src/com/android/launcher2/SearchDropTargetBar.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 64 |
6 files changed, 91 insertions, 79 deletions
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java index 138770a..868ede8 100644 --- a/src/com/android/launcher2/ButtonDropTarget.java +++ b/src/com/android/launcher2/ButtonDropTarget.java @@ -29,7 +29,7 @@ import com.android.launcher.R; /** * Implements a DropTarget. */ -public class ButtonDropTarget extends FrameLayout implements DropTarget, DragController.DragListener { +public class ButtonDropTarget extends TextView implements DropTarget, DragController.DragListener { protected final int mTransitionDuration; diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java index e76ab31..1553d3c 100644 --- a/src/com/android/launcher2/DeleteDropTarget.java +++ b/src/com/android/launcher2/DeleteDropTarget.java @@ -26,9 +26,8 @@ import android.graphics.Rect; import android.graphics.drawable.TransitionDrawable; import android.util.AttributeSet; import android.view.View; -import android.view.animation.AccelerateInterpolator; +import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; -import android.widget.TextView; import com.android.launcher.R; @@ -52,22 +51,21 @@ public class DeleteDropTarget extends ButtonDropTarget { super.onFinishInflate(); // Get the drawable - mText = (TextView) findViewById(R.id.delete_target_text); - mOriginalTextColor = mText.getTextColors(); + mOriginalTextColor = getTextColors(); // Get the hover color Resources r = getResources(); mHoverColor = r.getColor(R.color.delete_target_hover_tint); mHoverPaint.setColorFilter(new PorterDuffColorFilter( mHoverColor, PorterDuff.Mode.SRC_ATOP)); - mDrawable = (TransitionDrawable) mText.getCompoundDrawables()[0]; + mDrawable = (TransitionDrawable) getCompoundDrawables()[0]; mDrawable.setCrossFadeEnabled(true); // Remove the text in the Phone UI in landscape int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!LauncherApplication.isScreenLarge()) { - mText.setText(""); + setText(""); } } } @@ -120,10 +118,10 @@ public class DeleteDropTarget extends ButtonDropTarget { mActive = isVisible; mDrawable.resetTransition(); - mText.setTextColor(mOriginalTextColor); - setVisibility(isVisible ? View.VISIBLE : View.GONE); - if (mText.getText().length() > 0) { - mText.setText(isUninstall ? R.string.delete_target_uninstall_label + setTextColor(mOriginalTextColor); + ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE); + if (getText().length() > 0) { + setText(isUninstall ? R.string.delete_target_uninstall_label : R.string.delete_target_label); } } @@ -138,7 +136,7 @@ public class DeleteDropTarget extends ButtonDropTarget { super.onDragEnter(d); mDrawable.startTransition(mTransitionDuration); - mText.setTextColor(mHoverColor); + setTextColor(mHoverColor); } public void onDragExit(DragObject d) { @@ -146,7 +144,7 @@ public class DeleteDropTarget extends ButtonDropTarget { if (!d.dragComplete) { mDrawable.resetTransition(); - mText.setTextColor(mOriginalTextColor); + setTextColor(mOriginalTextColor); } } @@ -155,11 +153,12 @@ public class DeleteDropTarget extends ButtonDropTarget { Rect from = new Rect(); Rect to = new Rect(); dragLayer.getViewRectRelativeToSelf(d.dragView, from); - dragLayer.getViewRectRelativeToSelf(mText, to); + dragLayer.getViewRectRelativeToSelf(this, to); int width = mDrawable.getIntrinsicWidth(); int height = mDrawable.getIntrinsicHeight(); - to.set(to.left, to.top, to.left + width, to.bottom); + to.set(to.left + getPaddingLeft(), to.top + getPaddingTop(), + to.left + getPaddingLeft() + width, to.bottom); // Center the destination rect about the trash icon int xOffset = (int) -(d.dragView.getMeasuredWidth() - width) / 2; diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java index 3507181..dba845b 100644 --- a/src/com/android/launcher2/InfoDropTarget.java +++ b/src/com/android/launcher2/InfoDropTarget.java @@ -26,7 +26,7 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.TransitionDrawable; import android.util.AttributeSet; import android.view.View; -import android.widget.TextView; +import android.view.ViewGroup; import com.android.launcher.R; @@ -48,22 +48,21 @@ public class InfoDropTarget extends ButtonDropTarget { protected void onFinishInflate() { super.onFinishInflate(); - mText = (TextView) findViewById(R.id.info_target_text); - mOriginalTextColor = mText.getTextColors(); + mOriginalTextColor = getTextColors(); // Get the hover color Resources r = getResources(); mHoverColor = r.getColor(R.color.info_target_hover_tint); mHoverPaint.setColorFilter(new PorterDuffColorFilter( mHoverColor, PorterDuff.Mode.SRC_ATOP)); - mDrawable = (TransitionDrawable) mText.getCompoundDrawables()[0]; + mDrawable = (TransitionDrawable) getCompoundDrawables()[0]; mDrawable.setCrossFadeEnabled(true); // Remove the text in the Phone UI in landscape int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { if (!LauncherApplication.isScreenLarge()) { - mText.setText(""); + setText(""); } } } @@ -100,8 +99,8 @@ public class InfoDropTarget extends ButtonDropTarget { mActive = isVisible; mDrawable.resetTransition(); - mText.setTextColor(mOriginalTextColor); - setVisibility(isVisible ? View.VISIBLE : View.GONE); + setTextColor(mOriginalTextColor); + ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE); } @Override @@ -114,7 +113,7 @@ public class InfoDropTarget extends ButtonDropTarget { super.onDragEnter(d); mDrawable.startTransition(mTransitionDuration); - mText.setTextColor(mHoverColor); + setTextColor(mHoverColor); } public void onDragExit(DragObject d) { @@ -122,7 +121,7 @@ public class InfoDropTarget extends ButtonDropTarget { if (!d.dragComplete) { mDrawable.resetTransition(); - mText.setTextColor(mOriginalTextColor); + setTextColor(mOriginalTextColor); } } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 596ef50..292ccd7 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -163,14 +163,13 @@ public abstract class PagedView extends ViewGroup { // Scrolling indicator private ValueAnimator mScrollIndicatorAnimator; - private android.animation.ValueAnimator mDockDividerAnimator; private ImageView mScrollIndicator; private int mScrollIndicatorPaddingLeft; private int mScrollIndicatorPaddingRight; private boolean mHasScrollIndicator = true; - private static final int sScrollIndicatorFadeInDuration = 150; - private static final int sScrollIndicatorFadeOutDuration = 650; - private static final int sScrollIndicatorFlashDuration = 650; + protected static final int sScrollIndicatorFadeInDuration = 150; + protected static final int sScrollIndicatorFadeOutDuration = 650; + protected static final int sScrollIndicatorFlashDuration = 650; // If set, will defer loading associated pages until the scrolling settles private boolean mDeferLoadAssociatedPagesUntilScrollCompletes; @@ -1740,55 +1739,6 @@ public abstract class PagedView extends ViewGroup { } } - void showDockDivider(boolean immediately) { - final ViewGroup parent = (ViewGroup) getParent(); - final View divider = (ImageView) (parent.findViewById(R.id.dock_divider)); - if (divider != null) { - divider.setVisibility(View.VISIBLE); - if (mDockDividerAnimator != null) { - mDockDividerAnimator.cancel(); - } - if (immediately) { - divider.setAlpha(1f); - } else { - mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 1f); - mDockDividerAnimator.setDuration(sScrollIndicatorFadeInDuration); - mDockDividerAnimator.start(); - } - } - } - - void hideDockDivider(boolean immediately) { - final ViewGroup parent = (ViewGroup) getParent(); - final View divider = (ImageView) (parent.findViewById(R.id.dock_divider)); - if (divider != null) { - if (mDockDividerAnimator != null) { - mDockDividerAnimator.cancel(); - } - if (immediately) { - divider.setVisibility(View.GONE); - divider.setAlpha(0f); - } else { - mDockDividerAnimator = ObjectAnimator.ofFloat(divider, "alpha", 0f); - mDockDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration); - mDockDividerAnimator.addListener(new AnimatorListenerAdapter() { - private boolean cancelled = false; - @Override - public void onAnimationCancel(android.animation.Animator animation) { - cancelled = true; - } - @Override - public void onAnimationEnd(android.animation.Animator animation) { - if (!cancelled) { - divider.setVisibility(View.GONE); - } - } - }); - mDockDividerAnimator.start(); - } - } - } - /** * To be overridden by subclasses to determine whether the scroll indicator should stretch to * fill its space on the track or not. diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java index ee3ab18..69a1213 100644 --- a/src/com/android/launcher2/SearchDropTargetBar.java +++ b/src/com/android/launcher2/SearchDropTargetBar.java @@ -77,8 +77,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 = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target); - mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target); + mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text); + mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target_text); mBarHeight = getResources().getDimensionPixelSize(R.dimen.qsb_bar_height); mInfoDropTarget.setSearchDropTargetBar(this); diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 23b8c2d..e4865c2 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -58,6 +58,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.DecelerateInterpolator; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -109,6 +110,7 @@ public class Workspace extends SmoothPagedView private float mBackgroundAlpha = 0; private float mOverScrollMaxBackgroundAlpha = 0.0f; private int mOverScrollPageIndex = -1; + private AnimatorSet mDividerAnimator; private final WallpaperManager mWallpaperManager; private IBinder mWindowToken; @@ -3542,4 +3544,66 @@ public class Workspace extends SmoothPagedView protected boolean hasElasticScrollIndicator() { return true; } + + void showDockDivider(boolean immediately) { + final ViewGroup parent = (ViewGroup) getParent(); + final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider)); + final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider)); + if (qsbDivider != null && dockDivider != null) { + qsbDivider.setVisibility(View.VISIBLE); + dockDivider.setVisibility(View.VISIBLE); + if (mDividerAnimator != null) { + mDividerAnimator.cancel(); + mDividerAnimator = null; + } + if (immediately) { + qsbDivider.setAlpha(1f); + dockDivider.setAlpha(1f); + } else { + mDividerAnimator = new AnimatorSet(); + mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 1f), + ObjectAnimator.ofFloat(dockDivider, "alpha", 1f)); + mDividerAnimator.setDuration(sScrollIndicatorFadeInDuration); + mDividerAnimator.start(); + } + } + } + + void hideDockDivider(boolean immediately) { + final ViewGroup parent = (ViewGroup) getParent(); + final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider)); + final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider)); + if (qsbDivider != null && dockDivider != null) { + if (mDividerAnimator != null) { + mDividerAnimator.cancel(); + mDividerAnimator = null; + } + if (immediately) { + qsbDivider.setVisibility(View.GONE); + dockDivider.setVisibility(View.GONE); + qsbDivider.setAlpha(0f); + dockDivider.setAlpha(0f); + } else { + mDividerAnimator = new AnimatorSet(); + mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 0f), + ObjectAnimator.ofFloat(dockDivider, "alpha", 0f)); + mDividerAnimator.addListener(new AnimatorListenerAdapter() { + private boolean cancelled = false; + @Override + public void onAnimationCancel(android.animation.Animator animation) { + cancelled = true; + } + @Override + public void onAnimationEnd(android.animation.Animator animation) { + if (!cancelled) { + qsbDivider.setVisibility(View.GONE); + dockDivider.setVisibility(View.GONE); + } + } + }); + mDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration); + mDividerAnimator.start(); + } + } + } } |