Text selection handles correctly scroll

Bug 3416154

The origin of the problem is new display optimisations that enable
a scrollView to be scrolled without calling the onDraw method of its
children. As a result, the handles' positions were not updated on scroll.

DropDown popup menu have an integrated scroll listener that will fix the
problem. Using these indead is the first part of the solution.

The next problem is that when they get hidden, these popups try to move their
parent (the TextView in our case) which creates a scroll conflict. Fixed by
overriding findDropDownPosition.

Finally, when the handles get invisible, a new scroll listener has to be
installed that will show them back in case the view is scrolled back.

This is also an important step to fix Bug 3441308 (selectable text in list
views).

Debugging find outs:
Small optimization in PopupWindow to avoir unregistering then registering
back the listener when it is updated.

getHandle().show(); is not needed since updatePosition will do it through
moveTo().

Change-Id: I6bf6a3649538328257734ed1e651b23b889d65d9
2 files changed