OSDN Git Service

When dismissing Fast-Track, don't let touch fall through.
authorJeff Sharkey <jsharkey@android.com>
Sat, 29 Aug 2009 23:07:46 +0000 (16:07 -0700)
committerJeff Sharkey <jsharkey@android.com>
Sun, 30 Aug 2009 00:00:28 +0000 (17:00 -0700)
Instead of being NOT_TOUCH_MODAL and relying on the window
manager to mark ACTION_OUTSIDE touch events, detect the
events ourselves so we don't let them fall through to any
window behind us.

Also clean up some verbose logcat when loading resources.

src/com/android/contacts/model/HardCodedSources.java
src/com/android/contacts/ui/FastTrackWindow.java

index 7a8c30c..fb00639 100644 (file)
@@ -485,8 +485,7 @@ public class HardCodedSources {
             final boolean validString = mStringRes > 0;
             final boolean validColumn = index != -1;
 
-            final CharSequence stringValue = validString ? context.getPackageManager().getText(
-                    mPackageName, mStringRes, null) : null;
+            final CharSequence stringValue = validString ? context.getText(mStringRes) : null;
             final CharSequence columnValue = validColumn ? cursor.getString(index) : null;
 
             if (validString && validColumn) {
index 9487e15..5aadcaf 100644 (file)
@@ -101,6 +101,7 @@ public class FastTrackWindow implements Window.Callback,
     private final WindowManager mWindowManager;
     private Window mWindow;
     private View mDecor;
+    private final Rect mRect = new Rect();
 
     private boolean mQuerying = false;
     private boolean mShowing = false;
@@ -333,9 +334,7 @@ public class FastTrackWindow implements Window.Callback,
 
         }
 
-        l.flags = WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
-                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
-                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+        l.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                 | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
 
         mWindowManager.addView(mDecor, l);
@@ -1083,8 +1082,25 @@ public class FastTrackWindow implements Window.Callback,
         return false;
     }
 
+    /**
+     * Detect if the given {@link MotionEvent} is outside the boundaries of this
+     * window, which usually means we should dismiss.
+     */
+    protected void detectEventOutside(MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_DOWN) {
+            // Only try detecting outside events on down-press
+            mDecor.getHitRect(mRect);
+            final int x = (int)event.getX();
+            final int y = (int)event.getY();
+            if (!mRect.contains(x, y)) {
+                event.setAction(MotionEvent.ACTION_OUTSIDE);
+            }
+        }
+    }
+
     /** {@inheritDoc} */
     public boolean dispatchTouchEvent(MotionEvent event) {
+        detectEventOutside(event);
         if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
             dismiss();
             return true;