diff options
author | Winson Chung <winsonc@google.com> | 2010-12-21 11:31:54 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2010-12-21 16:04:02 -0800 |
commit | 59e1f9a07eef87b1d287956d21b8d9c5b27faf9c (patch) | |
tree | d37b7b49e34a28608ecffce7b24d92ef927b8b53 /src/com/android/launcher2/PagedViewWidget.java | |
parent | 577d017732abf9969e9a5c1b6aa3ffb5b8fdae7f (diff) | |
download | android_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.tar.gz android_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.tar.bz2 android_packages_apps_Trebuchet-59e1f9a07eef87b1d287956d21b8d9c5b27faf9c.zip |
Adding fade when dragging items outside of the customization tray.
Change-Id: Ie8dad00bc0278053707f81d948528929e6bb6f5c
Diffstat (limited to 'src/com/android/launcher2/PagedViewWidget.java')
-rw-r--r-- | src/com/android/launcher2/PagedViewWidget.java | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index 5f5844f44..8c729b1ca 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -16,34 +16,34 @@ package com.android.launcher2; +import android.animation.ObjectAnimator; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.PorterDuffXfermode; import android.graphics.PorterDuff.Mode; -import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.util.AttributeSet; import android.view.MotionEvent; +import android.widget.Checkable; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.launcher.R; -import com.android.launcher2.PagedView.PagedViewIconCache; /** * The linear layout used strictly for the widget/wallpaper tab of the customization tray */ -public class PagedViewWidget extends LinearLayout { +public class PagedViewWidget extends LinearLayout implements Checkable { static final String TAG = "PagedViewWidgetLayout"; private final Paint mPaint = new Paint(); @@ -59,6 +59,12 @@ public class PagedViewWidget extends LinearLayout { private int mHoloBlurColor; private int mHoloOutlineColor; + private boolean mIsChecked; + private ObjectAnimator mCheckedAlphaAnimator; + private float mCheckedAlpha = 1.0f; + private int mCheckedFadeInDuration; + private int mCheckedFadeOutDuration; + private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewwidget-helper"); static { sWorkerThread.start(); @@ -118,6 +124,15 @@ public class PagedViewWidget extends LinearLayout { sHolographicOutlineHelper = new HolographicOutlineHelper(); } + // Set up fade in/out constants + final Resources r = context.getResources(); + final int alpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha); + if (alpha > 0) { + mCheckedAlpha = r.getInteger(R.integer.icon_allAppsCustomizeFadeAlpha) / 256.0f; + mCheckedFadeInDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeInTime); + mCheckedFadeOutDuration = r.getInteger(R.integer.icon_allAppsCustomizeFadeOutTime); + } + setFocusable(true); setWillNotDraw(false); setClipToPadding(false); @@ -219,4 +234,41 @@ public class PagedViewWidget extends LinearLayout { super.onDetachedFromWindow(); sWorker.removeMessages(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE, this); } + + @Override + public void setChecked(boolean checked) { + if (mIsChecked != checked) { + mIsChecked = checked; + + float alpha; + int duration; + if (mIsChecked) { + alpha = mCheckedAlpha; + duration = mCheckedFadeInDuration; + } else { + alpha = 1.0f; + duration = mCheckedFadeOutDuration; + } + + // Initialize the animator + if (mCheckedAlphaAnimator != null) { + mCheckedAlphaAnimator.cancel(); + } + mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha); + mCheckedAlphaAnimator.setDuration(duration); + mCheckedAlphaAnimator.start(); + + invalidate(); + } + } + + @Override + public boolean isChecked() { + return mIsChecked; + } + + @Override + public void toggle() { + setChecked(!mIsChecked); + } } |