diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:53 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:53 -0800 |
commit | 98baae654dc6e69eecb5ffab2f86c5ab217a762c (patch) | |
tree | c949cee572fe7424493e7b54247ce8462813f361 /src/com/android/launcher/LauncherGadgetHost.java | |
parent | 15a8880cb1b9010ce4503c10c1666568d49415b1 (diff) | |
download | android_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.tar.gz android_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.tar.bz2 android_packages_apps_Trebuchet-98baae654dc6e69eecb5ffab2f86c5ab217a762c.zip |
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'src/com/android/launcher/LauncherGadgetHost.java')
-rw-r--r-- | src/com/android/launcher/LauncherGadgetHost.java | 105 |
1 files changed, 6 insertions, 99 deletions
diff --git a/src/com/android/launcher/LauncherGadgetHost.java b/src/com/android/launcher/LauncherGadgetHost.java index 4f7e8f2f2..9bb4f0565 100644 --- a/src/com/android/launcher/LauncherGadgetHost.java +++ b/src/com/android/launcher/LauncherGadgetHost.java @@ -19,113 +19,20 @@ package com.android.launcher; import android.content.Context; import android.gadget.GadgetHost; import android.gadget.GadgetHostView; -import android.gadget.GadgetInfo; -import android.graphics.Color; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewConfiguration; -import android.widget.TextView; +import android.gadget.GadgetProviderInfo; /** - * Specific {@link GadgetHost} that creates our {@link LauncherGadgetHostView} which correctly - * captures all long-press events. This ensures that users can always pick up and move gadgets. + * Specific {@link GadgetHost} that creates our {@link LauncherGadgetHostView} + * which correctly captures all long-press events. This ensures that users can + * always pick up and move gadgets. */ public class LauncherGadgetHost extends GadgetHost { public LauncherGadgetHost(Context context, int hostId) { super(context, hostId); } - protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) { + protected GadgetHostView onCreateView(Context context, int gadgetId, + GadgetProviderInfo gadget) { return new LauncherGadgetHostView(context); } - - /** - * {@inheritDoc} - */ - public class LauncherGadgetHostView extends GadgetHostView { - static final String TAG = "LauncherGadgetHostView"; - - private boolean mHasPerformedLongPress; - - private CheckForLongPress mPendingCheckForLongPress; - - private LayoutInflater mInflater; - - public LauncherGadgetHostView(Context context) { - super(context); - - mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - // Prepare our default transition animations - setAnimateFirstView(true); - setInAnimation(context, android.R.anim.fade_in); - setOutAnimation(context, android.R.anim.fade_out); - } - - @Override - protected View getErrorView() { - return mInflater.inflate(R.layout.gadget_error, this, false); - } - - public boolean onInterceptTouchEvent(MotionEvent ev) { - - // Consume any touch events for ourselves after longpress is triggered - if (mHasPerformedLongPress) { - mHasPerformedLongPress = false; - return true; - } - - // Watch for longpress events at this level to make sure - // users can always pick up this Gadget - switch (ev.getAction()) { - case MotionEvent.ACTION_DOWN: { - postCheckForLongClick(); - break; - } - - case MotionEvent.ACTION_UP: { - mHasPerformedLongPress = false; - if (mPendingCheckForLongPress != null) { - removeCallbacks(mPendingCheckForLongPress); - } - break; - } - } - - // Otherwise continue letting touch events fall through to children - return false; - } - - class CheckForLongPress implements Runnable { - private int mOriginalWindowAttachCount; - - public void run() { - if ((mParent != null) && hasWindowFocus() - && mOriginalWindowAttachCount == getWindowAttachCount() - && !mHasPerformedLongPress) { - if (performLongClick()) { - mHasPerformedLongPress = true; - } - } - } - - public void rememberWindowAttachCount() { - mOriginalWindowAttachCount = getWindowAttachCount(); - } - } - - private void postCheckForLongClick() { - mHasPerformedLongPress = false; - - if (mPendingCheckForLongPress == null) { - mPendingCheckForLongPress = new CheckForLongPress(); - } - mPendingCheckForLongPress.rememberWindowAttachCount(); - postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout()); - } - - } - } - |