Merge "Makes the finger-to-cursor distance configurable via DeviceConfig." into rvc-dev
This commit is contained in:
@@ -4589,7 +4589,7 @@ public class Editor {
|
||||
private float mTouchOffsetY;
|
||||
// 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.
|
||||
private float mIdealVerticalOffset;
|
||||
private final float mIdealVerticalOffset;
|
||||
// Parent's (TextView) previous position in window
|
||||
private int mLastParentX, mLastParentY;
|
||||
// Parent's (TextView) previous position on screen
|
||||
@@ -4638,8 +4638,18 @@ public class Editor {
|
||||
|
||||
final int handleHeight = getPreferredHeight();
|
||||
mTouchOffsetY = -0.3f * handleHeight;
|
||||
mIdealVerticalOffset = 0.7f * handleHeight;
|
||||
mIdealFingerToCursorOffset = (int)(mIdealVerticalOffset - mTouchOffsetY);
|
||||
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;
|
||||
mIdealFingerToCursorOffset = (int)(mIdealVerticalOffset - mTouchOffsetY);
|
||||
} else {
|
||||
mIdealFingerToCursorOffset = (int) TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, distance,
|
||||
mTextView.getContext().getResources().getDisplayMetrics());
|
||||
mIdealVerticalOffset = mIdealFingerToCursorOffset + mTouchOffsetY;
|
||||
}
|
||||
}
|
||||
|
||||
public float getIdealVerticalOffset() {
|
||||
|
||||
@@ -40,6 +40,25 @@ public final class WidgetFlags {
|
||||
*/
|
||||
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.
|
||||
* long-press or double-tap on the handle to trigger selection).
|
||||
|
||||
@@ -115,6 +115,10 @@ final class CoreSettingsObserver extends ContentObserver {
|
||||
DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE,
|
||||
WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE, boolean.class,
|
||||
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>(
|
||||
DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES,
|
||||
WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES, boolean.class,
|
||||
|
||||
Reference in New Issue
Block a user