When would ACTION_OUTSIDE be triggered? - android

I don't understand when ACTION_OUTSIDE is triggered. Please give me an example.
The doc's give this cryptic description:
Constant for getAction(): A movement
has happened outside of the normal
bounds of the UI element. This does
not provide a full gesture, but only
the initial location of the
movement/touch.
http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_OUTSIDE

I believe it is only used for clicking outside of the current activity (for example a dialog). Check out WindowManager.LayoutParams

Related

How to lock the UI?

I'm looking for a way to lock the user interface, for example when I select "Lock" from the options menu, the UI will be block from touches. It's sort of adding an overlay with some kind of lock icon over the UI.
Do you guys have any suggestions? Thanks!
To make the entire window of the activity untouchable, call this:
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
to make it touchable again, call
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
Though this may cause an ANR...if you can get around that then this is the easiest method, otherwise what bitbox said may be the apropriate solution
Do you need to do that on multiple activities or just one ?
If it's just one, then add a transparent ViewGroup(MatchParent,Parent) to the top of your view hierarchy. Make it Gone by default.
Then in OnCreate(), add a OnTouchListener that always returns true (meaning that it took into account the touch);
Then when you need it, just make it "Visible".
Explanation : adding it to the top will make it the top-most "layer" in the view hierarchy. So it will be first to receive touch events which you then veto by returning true to the listener's caller.

Getting all MotionEvents with WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH

My question refers directly to this question. The answer to that question shows how one can create a ViewGroup, embed it inside a WindowManager, and allow the WindowManager to catch MotionEvents through onTouchEvent(MotionEvent event). WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH is the flag that allows this this ViewGroup to receive MotionEvents. However, according to documentation, this flag
...will not receive the full down/move/up gesture
I want to know if there's a work-around or a way so that I can get all touch events including down, move, and up. A proof of concept is in the app Wave Launcher which uses the same concept but is able to receive more than just a single ACTION_OUTSIDE event.
No you can not, and that is very much by design.
Wave Launcher doesn't do this, it has a UI element where you start your touch gesture and then as with standard even dispatching all touch events are delivered to the window of the first down point until the final up.
I realize this is an old question, but I've stumbled across it while trying to accomplish something similar. I've also found this, hopefully it is helpful to someone: http://www.section465.com/code_OverlayView/
To create an overlay view, when setting up the LayoutParams you need
to set the type to TYPE_SYSTEM_OVERLAY and use the flag
FLAG_WATCH_OUTSIDE_TOUCH. This presents a problem because as the
Android documentation states: "you will not receive the full
down/move/up gesture, only the location of the first down as an
ACTION_OUTSIDE." In order to receive the full array of touch events
you need to use the TYPE_SYSTEM_ALERT type, but this causes the
overlay to take over the screen and stop interaction with other
elements. The solution is to use both TYPE_SYSTEM_OVERLAY and
TYPE_SYSTEM_ALERT and switch between them by changing the type of the
LayoutParams as needed.

Android: Is it possible to get notified when enter/quit TouchMode?

When system enters into TouchMode, I'd like to know which widget will lose focus. When system quits TouchMode, I'd also like to know which widget will get focus. Overriding onFocusChange() didn't satisfy me, since it couldn't tell TouchMode change, since it could happen in every mode, touch, trackball, key navigation, etc.
SDK said only one API View.isInTouchMode() there it is. So, is it possible to detect TouchMode change?
Long shot but you probably need to maintain states manually. So you keep a a flag , lets say isTouchMode which you can set every time any of the widgets are touched and unset when something gets focus.
Use ViewTreeObserver.addOnTouchModeChangeListener(). It will tell you when the mode changes.
http://developer.android.com/reference/android/view/ViewTreeObserver.html

Does multi-tap fires evnets as a single tap?

Does multi-tap fires events as single-tap?
Events such:
click
pressed
released
and maybe more, because it uses another finger to create variations?
Thank You.
Yes, multitouch is detected the same way as simple touch: via onTouch(). The difference is in the supplied MotionEvent. You can check which point has been changed by getPointerId(int).
For a complete example take a look at: http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-3-understanding-touch-events/1775

When to use Android PopupWindow vs Dialog

I'm unclear about when to use PopupWindow vs Dialog. Any insight would be much appreciated. Thanks.
They both use the addView() method along with various windowManager methods. The two are similar in that regard.
Dialogs seem to come with more built-in features for interaction, such as handlers and buttons already included in the base class, while PopupWindows come with more built-in methods for positioning them about the screen.
I think that each of them can do exactly the same as the other, but choosing between the two will be a matter of convenience to the programmer with regards to how you want to use the Object. I'm not a phD in computer science, but I do not think there is a significant difference in processing time between the two based on what I saw in their respective class definitions.
My advice: If you want to have greater control over where your View appears on the display, use a PopupWindow. If you want to add more control and feedback between your View then use a Dialog. If you, like me, want master control over everything, I would suggest a PopupWindow since it has fewer user-evident default methods to override.
I think, that you should use Dialog for simple user interaction (YES,NO).
I usually use Dialog for simple user interaction and WindowPopup for a little bit more complex view.
One example of WindowPopup is AutoCompleteTextView.
Hope it helps.
I think Dialog should use when you need to take action before proceed to continue next. It never cover the screen and always adjust center aligned as modal event.
On other side, PopupWindow has flexibility to adjust information anywhere in the screen as position wise like sticky footer, sticky header, on left, right, center etc. as per location set.
For Showing Information it's good option as there is facility to animate also.
In short, For Showing Information with minimal action go with PopupWindow and for controlled action to proceed next go with Dialog.

Categories

Resources