Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab928932 authored by Maryam Garrett's avatar Maryam Garrett
Browse files

Allows users to scroll while in select mode.

This change allows the user to select-n-scroll. While a user
is in select mode, and they try to scroll, the textbox will
scroll in the direction of the selection, and expand the selection.
parent 159f0015
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -254,6 +254,12 @@ implements MovementMethod

                  buffer.setSpan(LAST_TAP_DOWN, offset, offset,
                                 Spannable.SPAN_POINT_POINT);

                  // Disallow intercepting of the touch events, so that
                  // users can scroll and select at the same time.
                  // without this, users would get booted out of select
                  // mode once the view detected it needed to scroll.
                  widget.getParent().requestDisallowInterceptTouchEvent(true);
              }
            } else if (event.getAction() == MotionEvent.ACTION_MOVE ) {
              boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
@@ -277,7 +283,7 @@ implements MovementMethod
                int spanstart;
                int spanend;
                if (offset >= lastDownOffset) {
                  // expand to from word start of the original tap to new word
                  // Expand from word start of the original tap to new word
                  // end, since we are selecting "forwards"
                  spanstart = findWordStart(buffer, lastDownOffset);
                  spanend = findWordEnd(buffer, offset);
+16 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.TextView;
import android.view.KeyEvent;

public class Touch {
    private Touch() { }
@@ -139,10 +140,21 @@ public class Touch {

                if (ds[0].mFarEnough) {
                    ds[0].mUsed = true;

                    float dx = ds[0].mX - event.getX();
                    float dy = ds[0].mY - event.getY();

                    boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
                                   KeyEvent.META_SHIFT_ON) == 1) ||
                                   (MetaKeyKeyListener.getMetaState(buffer,
                                    MetaKeyKeyListener.META_SELECTING) != 0);
                    float dx;
                    float dy;
                    if (cap) {
                        // if we're selecting, we want the scroll to go in
                        // the direction of the drag
                        dx = event.getX() - ds[0].mX;
                        dy = event.getY() - ds[0].mY;
                    } else {
                        dx = ds[0].mX - event.getX();
                        dy = ds[0].mY - event.getY();
                    }
                    ds[0].mX = event.getX();
                    ds[0].mY = event.getY();