Loading core/java/android/widget/Editor.java +13 −3 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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() { Loading core/java/android/widget/WidgetFlags.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -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). Loading services/core/java/com/android/server/am/CoreSettingsObserver.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading Loading
core/java/android/widget/Editor.java +13 −3 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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() { Loading
core/java/android/widget/WidgetFlags.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -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). Loading
services/core/java/com/android/server/am/CoreSettingsObserver.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading