am b2ff3bd4: am 88e76d88: am e46094c4: am 84005b40: Merge "Use hint text to position handle / floating tool bar popups" into mnc-dev
* commit 'b2ff3bd42b06ea8c1a95b830f96d6ffee92d1a3a': Use hint text to position handle / floating tool bar popups
This commit is contained in:
@@ -1683,8 +1683,7 @@ public class Editor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout layout = mTextView.getLayout();
|
Layout layout = getActiveLayout();
|
||||||
Layout hintLayout = mTextView.getHintLayout();
|
|
||||||
final int offset = mTextView.getSelectionStart();
|
final int offset = mTextView.getSelectionStart();
|
||||||
final int line = layout.getLineForOffset(offset);
|
final int line = layout.getLineForOffset(offset);
|
||||||
final int top = layout.getLineTop(line);
|
final int top = layout.getLineTop(line);
|
||||||
@@ -1699,8 +1698,7 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean clamped = layout.shouldClampCursor(line);
|
boolean clamped = layout.shouldClampCursor(line);
|
||||||
updateCursorPosition(0, top, middle,
|
updateCursorPosition(0, top, middle, layout.getPrimaryHorizontal(offset, clamped));
|
||||||
getPrimaryHorizontal(layout, hintLayout, offset, clamped));
|
|
||||||
|
|
||||||
if (mCursorCount == 2) {
|
if (mCursorCount == 2) {
|
||||||
updateCursorPosition(1, middle, bottom,
|
updateCursorPosition(1, middle, bottom,
|
||||||
@@ -1708,17 +1706,6 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getPrimaryHorizontal(Layout layout, Layout hintLayout, int offset,
|
|
||||||
boolean clamped) {
|
|
||||||
if (TextUtils.isEmpty(layout.getText()) &&
|
|
||||||
hintLayout != null &&
|
|
||||||
!TextUtils.isEmpty(hintLayout.getText())) {
|
|
||||||
return hintLayout.getPrimaryHorizontal(offset, clamped);
|
|
||||||
} else {
|
|
||||||
return layout.getPrimaryHorizontal(offset, clamped);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an Insertion action mode.
|
* Start an Insertion action mode.
|
||||||
*/
|
*/
|
||||||
@@ -3311,14 +3298,15 @@ public class Editor {
|
|||||||
+ mHandleHeight);
|
+ mHandleHeight);
|
||||||
} else {
|
} else {
|
||||||
// We have a single cursor.
|
// We have a single cursor.
|
||||||
int line = mTextView.getLayout().getLineForOffset(mTextView.getSelectionStart());
|
Layout layout = getActiveLayout();
|
||||||
|
int line = layout.getLineForOffset(mTextView.getSelectionStart());
|
||||||
float primaryHorizontal =
|
float primaryHorizontal =
|
||||||
mTextView.getLayout().getPrimaryHorizontal(mTextView.getSelectionStart());
|
layout.getPrimaryHorizontal(mTextView.getSelectionStart());
|
||||||
mSelectionBounds.set(
|
mSelectionBounds.set(
|
||||||
primaryHorizontal,
|
primaryHorizontal,
|
||||||
mTextView.getLayout().getLineTop(line),
|
layout.getLineTop(line),
|
||||||
primaryHorizontal + 1,
|
primaryHorizontal + 1,
|
||||||
mTextView.getLayout().getLineTop(line + 1) + mHandleHeight);
|
layout.getLineTop(line + 1) + mHandleHeight);
|
||||||
}
|
}
|
||||||
// Take TextView's padding and scroll into account.
|
// Take TextView's padding and scroll into account.
|
||||||
int textHorizontalOffset = mTextView.viewportToContentHorizontalOffset();
|
int textHorizontalOffset = mTextView.viewportToContentHorizontalOffset();
|
||||||
@@ -3684,6 +3672,7 @@ public class Editor {
|
|||||||
prepareCursorControllers();
|
prepareCursorControllers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
layout = getActiveLayout();
|
||||||
|
|
||||||
boolean offsetChanged = offset != mPreviousOffset;
|
boolean offsetChanged = offset != mPreviousOffset;
|
||||||
if (offsetChanged || parentScrolled) {
|
if (offsetChanged || parentScrolled) {
|
||||||
@@ -3863,6 +3852,19 @@ public class Editor {
|
|||||||
public void onDetached() {}
|
public void onDetached() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the active layout (hint or text layout). Note that the text layout can be null.
|
||||||
|
*/
|
||||||
|
private Layout getActiveLayout() {
|
||||||
|
Layout layout = mTextView.getLayout();
|
||||||
|
Layout hintLayout = mTextView.getHintLayout();
|
||||||
|
if (TextUtils.isEmpty(layout.getText()) && hintLayout != null &&
|
||||||
|
!TextUtils.isEmpty(hintLayout.getText())) {
|
||||||
|
layout = hintLayout;
|
||||||
|
}
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
private class InsertionHandleView extends HandleView {
|
private class InsertionHandleView extends HandleView {
|
||||||
private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000;
|
private static final int DELAY_BEFORE_HANDLE_FADES_OUT = 4000;
|
||||||
private static final int RECENT_CUT_COPY_DURATION = 15 * 1000; // seconds
|
private static final int RECENT_CUT_COPY_DURATION = 15 * 1000; // seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user