Merge "Fix typos related to sortSelectionIndices" am: 5247f04147 am: 7a42f1c980
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1355842 Change-Id: Iec31622cc351a635b8d590b2509523167141d32c
This commit is contained in:
@@ -108,7 +108,7 @@ public final class SelectionActionModeHelper {
|
|||||||
*
|
*
|
||||||
* @return the swap result, index 0 is the start index and index 1 is the end index.
|
* @return the swap result, index 0 is the start index and index 1 is the end index.
|
||||||
*/
|
*/
|
||||||
private static int[] sortSelctionIndices(int selectionStart, int selectionEnd) {
|
private static int[] sortSelectionIndices(int selectionStart, int selectionEnd) {
|
||||||
if (selectionStart < selectionEnd) {
|
if (selectionStart < selectionEnd) {
|
||||||
return new int[]{selectionStart, selectionEnd};
|
return new int[]{selectionStart, selectionEnd};
|
||||||
}
|
}
|
||||||
@@ -122,11 +122,11 @@ public final class SelectionActionModeHelper {
|
|||||||
* @param textView the selected TextView.
|
* @param textView the selected TextView.
|
||||||
* @return the swap result, index 0 is the start index and index 1 is the end index.
|
* @return the swap result, index 0 is the start index and index 1 is the end index.
|
||||||
*/
|
*/
|
||||||
private static int[] sortSelctionIndicesFromTextView(TextView textView) {
|
private static int[] sortSelectionIndicesFromTextView(TextView textView) {
|
||||||
int selectionStart = textView.getSelectionStart();
|
int selectionStart = textView.getSelectionStart();
|
||||||
int selectionEnd = textView.getSelectionEnd();
|
int selectionEnd = textView.getSelectionEnd();
|
||||||
|
|
||||||
return sortSelctionIndices(selectionStart, selectionEnd);
|
return sortSelectionIndices(selectionStart, selectionEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,7 +135,7 @@ public final class SelectionActionModeHelper {
|
|||||||
public void startSelectionActionModeAsync(boolean adjustSelection) {
|
public void startSelectionActionModeAsync(boolean adjustSelection) {
|
||||||
// Check if the smart selection should run for editable text.
|
// Check if the smart selection should run for editable text.
|
||||||
adjustSelection &= getTextClassificationSettings().isSmartSelectionEnabled();
|
adjustSelection &= getTextClassificationSettings().isSmartSelectionEnabled();
|
||||||
int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
|
|
||||||
mSelectionTracker.onOriginalSelection(
|
mSelectionTracker.onOriginalSelection(
|
||||||
getText(mTextView),
|
getText(mTextView),
|
||||||
@@ -165,7 +165,7 @@ public final class SelectionActionModeHelper {
|
|||||||
* Starts Link ActionMode.
|
* Starts Link ActionMode.
|
||||||
*/
|
*/
|
||||||
public void startLinkActionModeAsync(int start, int end) {
|
public void startLinkActionModeAsync(int start, int end) {
|
||||||
int[] indexResult = sortSelctionIndices(start, end);
|
int[] indexResult = sortSelectionIndices(start, end);
|
||||||
mSelectionTracker.onOriginalSelection(getText(mTextView), indexResult[0], indexResult[1],
|
mSelectionTracker.onOriginalSelection(getText(mTextView), indexResult[0], indexResult[1],
|
||||||
true /*isLink*/);
|
true /*isLink*/);
|
||||||
cancelAsyncTask();
|
cancelAsyncTask();
|
||||||
@@ -201,21 +201,21 @@ public final class SelectionActionModeHelper {
|
|||||||
|
|
||||||
/** Reports a selection action event. */
|
/** Reports a selection action event. */
|
||||||
public void onSelectionAction(int menuItemId, @Nullable String actionLabel) {
|
public void onSelectionAction(int menuItemId, @Nullable String actionLabel) {
|
||||||
int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
mSelectionTracker.onSelectionAction(
|
mSelectionTracker.onSelectionAction(
|
||||||
sortedSelectionIndices[0], sortedSelectionIndices[1],
|
sortedSelectionIndices[0], sortedSelectionIndices[1],
|
||||||
getActionType(menuItemId), actionLabel, mTextClassification);
|
getActionType(menuItemId), actionLabel, mTextClassification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSelectionDrag() {
|
public void onSelectionDrag() {
|
||||||
int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
mSelectionTracker.onSelectionAction(
|
mSelectionTracker.onSelectionAction(
|
||||||
sortedSelectionIndices[0], sortedSelectionIndices[1],
|
sortedSelectionIndices[0], sortedSelectionIndices[1],
|
||||||
SelectionEvent.ACTION_DRAG, /* actionLabel= */ null, mTextClassification);
|
SelectionEvent.ACTION_DRAG, /* actionLabel= */ null, mTextClassification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTextChanged(int start, int end) {
|
public void onTextChanged(int start, int end) {
|
||||||
int[] sortedSelectionIndices = sortSelctionIndices(start, end);
|
int[] sortedSelectionIndices = sortSelectionIndices(start, end);
|
||||||
mSelectionTracker.onTextChanged(sortedSelectionIndices[0], sortedSelectionIndices[1],
|
mSelectionTracker.onTextChanged(sortedSelectionIndices[0], sortedSelectionIndices[1],
|
||||||
mTextClassification);
|
mTextClassification);
|
||||||
}
|
}
|
||||||
@@ -334,7 +334,7 @@ public final class SelectionActionModeHelper {
|
|||||||
startSelectionActionMode(startSelectionResult);
|
startSelectionActionMode(startSelectionResult);
|
||||||
};
|
};
|
||||||
// TODO do not trigger the animation if the change included only non-printable characters
|
// TODO do not trigger the animation if the change included only non-printable characters
|
||||||
int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
final boolean didSelectionChange =
|
final boolean didSelectionChange =
|
||||||
result != null && (sortedSelectionIndices[0] != result.mStart
|
result != null && (sortedSelectionIndices[0] != result.mStart
|
||||||
|| sortedSelectionIndices[1] != result.mEnd);
|
|| sortedSelectionIndices[1] != result.mEnd);
|
||||||
@@ -486,7 +486,7 @@ public final class SelectionActionModeHelper {
|
|||||||
if (actionMode != null) {
|
if (actionMode != null) {
|
||||||
actionMode.invalidate();
|
actionMode.invalidate();
|
||||||
}
|
}
|
||||||
final int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
final int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
mSelectionTracker.onSelectionUpdated(
|
mSelectionTracker.onSelectionUpdated(
|
||||||
sortedSelectionIndices[0], sortedSelectionIndices[1], mTextClassification);
|
sortedSelectionIndices[0], sortedSelectionIndices[1], mTextClassification);
|
||||||
mTextClassificationAsyncTask = null;
|
mTextClassificationAsyncTask = null;
|
||||||
@@ -495,7 +495,7 @@ public final class SelectionActionModeHelper {
|
|||||||
private void resetTextClassificationHelper(int selectionStart, int selectionEnd) {
|
private void resetTextClassificationHelper(int selectionStart, int selectionEnd) {
|
||||||
if (selectionStart < 0 || selectionEnd < 0) {
|
if (selectionStart < 0 || selectionEnd < 0) {
|
||||||
// Use selection indices
|
// Use selection indices
|
||||||
int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(mTextView);
|
int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(mTextView);
|
||||||
selectionStart = sortedSelectionIndices[0];
|
selectionStart = sortedSelectionIndices[0];
|
||||||
selectionEnd = sortedSelectionIndices[1];
|
selectionEnd = sortedSelectionIndices[1];
|
||||||
}
|
}
|
||||||
@@ -637,7 +637,7 @@ public final class SelectionActionModeHelper {
|
|||||||
mAllowReset = false;
|
mAllowReset = false;
|
||||||
boolean selected = editor.selectCurrentWord();
|
boolean selected = editor.selectCurrentWord();
|
||||||
if (selected) {
|
if (selected) {
|
||||||
final int[] sortedSelectionIndices = sortSelctionIndicesFromTextView(textView);
|
final int[] sortedSelectionIndices = sortSelectionIndicesFromTextView(textView);
|
||||||
mSelectionStart = sortedSelectionIndices[0];
|
mSelectionStart = sortedSelectionIndices[0];
|
||||||
mSelectionEnd = sortedSelectionIndices[1];
|
mSelectionEnd = sortedSelectionIndices[1];
|
||||||
mLogger.logSelectionAction(
|
mLogger.logSelectionAction(
|
||||||
@@ -1215,7 +1215,7 @@ public final class SelectionActionModeHelper {
|
|||||||
|
|
||||||
SelectionResult(int start, int end,
|
SelectionResult(int start, int end,
|
||||||
@Nullable TextClassification classification, @Nullable TextSelection selection) {
|
@Nullable TextClassification classification, @Nullable TextSelection selection) {
|
||||||
int[] sortedIndices = sortSelctionIndices(start, end);
|
int[] sortedIndices = sortSelectionIndices(start, end);
|
||||||
mStart = sortedIndices[0];
|
mStart = sortedIndices[0];
|
||||||
mEnd = sortedIndices[1];
|
mEnd = sortedIndices[1];
|
||||||
mClassification = classification;
|
mClassification = classification;
|
||||||
|
|||||||
Reference in New Issue
Block a user