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

Commit 138fa38b authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Makes the finger-to-cursor distance configurable via DeviceConfig."...

Merge "Makes the finger-to-cursor distance configurable via DeviceConfig." into rvc-dev am: 422e7ead am: 51abef39 am: 544232cd am: d000406d

Change-Id: If43fc2e2dadf3ed71f51e1b2651ba7129626c585
parents fbe23d17 d000406d
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -4604,7 +4604,7 @@ public class Editor {
        private float mTouchOffsetY;
        private float mTouchOffsetY;
        // Where the touch position should be on the handle to ensure a maximum cursor visibility.
        // Where the touch position should be on the handle to ensure a maximum cursor visibility.
        // This is the distance in pixels from the top of the handle view.
        // This is the distance in pixels from the top of the handle view.
        private float mIdealVerticalOffset;
        private final float mIdealVerticalOffset;
        // Parent's (TextView) previous position in window
        // Parent's (TextView) previous position in window
        private int mLastParentX, mLastParentY;
        private int mLastParentX, mLastParentY;
        // Parent's (TextView) previous position on screen
        // Parent's (TextView) previous position on screen
@@ -4653,8 +4653,18 @@ public class Editor {


            final int handleHeight = getPreferredHeight();
            final int handleHeight = getPreferredHeight();
            mTouchOffsetY = -0.3f * handleHeight;
            mTouchOffsetY = -0.3f * handleHeight;
            final int distance = AppGlobals.getIntCoreSetting(
                    WidgetFlags.KEY_FINGER_TO_CURSOR_DISTANCE,
                    WidgetFlags.FINGER_TO_CURSOR_DISTANCE_DEFAULT);
            if (distance < 0 || distance > 100) {
                mIdealVerticalOffset = 0.7f * handleHeight;
                mIdealVerticalOffset = 0.7f * handleHeight;
                mIdealFingerToCursorOffset = (int)(mIdealVerticalOffset - mTouchOffsetY);
                mIdealFingerToCursorOffset = (int)(mIdealVerticalOffset - mTouchOffsetY);
            } else {
                mIdealFingerToCursorOffset = (int) TypedValue.applyDimension(
                        TypedValue.COMPLEX_UNIT_DIP, distance,
                        mTextView.getContext().getResources().getDisplayMetrics());
                mIdealVerticalOffset = mIdealFingerToCursorOffset + mTouchOffsetY;
            }
        }
        }


        public float getIdealVerticalOffset() {
        public float getIdealVerticalOffset() {
+19 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,25 @@ public final class WidgetFlags {
     */
     */
    public static final boolean ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT = true;
    public static final boolean ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT = true;


    /**
     * The flag of finger-to-cursor distance in DP for cursor dragging.
     * The value unit is DP and the range is {0..100}. If the value is out of range, the legacy
     * value, which is based on handle size, will be used.
     */
    public static final String FINGER_TO_CURSOR_DISTANCE =
            "CursorControlFeature__finger_to_cursor_distance";

    /**
     * The key used in app core settings for the flag {@link #FINGER_TO_CURSOR_DISTANCE}.
     */
    public static final String KEY_FINGER_TO_CURSOR_DISTANCE =
            "widget__finger_to_cursor_distance";

    /**
     * Default value for the flag {@link #FINGER_TO_CURSOR_DISTANCE}.
     */
    public static final int FINGER_TO_CURSOR_DISTANCE_DEFAULT = -1;

    /**
    /**
     * Whether additional gestures should be enabled for the insertion cursor handle (e.g.
     * Whether additional gestures should be enabled for the insertion cursor handle (e.g.
     * long-press or double-tap on the handle to trigger selection).
     * long-press or double-tap on the handle to trigger selection).
+4 −0
Original line number Original line Diff line number Diff line
@@ -115,6 +115,10 @@ final class CoreSettingsObserver extends ContentObserver {
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE,
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE,
                WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE, boolean.class,
                WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE, boolean.class,
                WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT));
                WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT));
        sDeviceConfigEntries.add(new DeviceConfigEntry<Integer>(
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.FINGER_TO_CURSOR_DISTANCE,
                WidgetFlags.KEY_FINGER_TO_CURSOR_DISTANCE, int.class,
                WidgetFlags.FINGER_TO_CURSOR_DISTANCE_DEFAULT));
        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES,
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES,
                WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES, boolean.class,
                WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES, boolean.class,