stanipintjuk / Silverfish

A simple and lightweight launcher for Android.
GNU General Public License v3.0
44 stars 17 forks source link

Single tap triggers widget selection #9

Closed Lonami closed 8 years ago

Lonami commented 8 years ago

Steps to recreate

Find a widget which doesn't take all the space in the widget area or one that doesn't take any action. Perform a tap somewhere not occupied by the widget.

What happens

The widget selection triggers.

Proof

Tap bug

stanipintjuk commented 8 years ago

Can confirm. I tested this with the firefox widget

Lonami commented 8 years ago

Even when onInterceptTouchEvent(MotionEvent ev) (under LauncherAppWidgetHostView.java) returns always false, the widget selection is still triggered. So we probably need to focus on the widget_area FrameLayout instead. Maybe intercept the touch events in a custom way as we did with the widget host view? But that is currently using the default setOnLongClickListener, it should work well... Awkward.

stanipintjuk commented 8 years ago

What if we simply remove any click listeners from the widget_area after a widget has been placed there?

Lonami commented 8 years ago

That's probably a good option.

stanipintjuk commented 8 years ago

Try it. If it works make a PR

Lonami commented 8 years ago

Will play with it ASAP 👍

Lonami commented 8 years ago

It couldn't be that easy... Didn't work. I've added widget_area.setOnLongClickListener(null); on placeWidget(AppWidgetHostView hostView) here and it still fires. Even with a single tap. Isn't that supposed to prevent longClick from being fired?

The problem must be somewhere else.

Lonami commented 8 years ago

This is the responsible. But it shouldn't be the case since it is not a longClick!

Lonami commented 8 years ago

OK, ACTION_UP events are not fired for a simple reason:

If you return false from onTouch method, no further events get delivered to the listener. You should return true at least in case of event.getAction() == MotionEvent.ACTION_DOWN.

From this question. Let's see if that does the trick.