summaryrefslogtreecommitdiff
path: root/android/widget
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2017-10-19 09:30:56 -0400
committerJason Monk <jmonk@google.com>2017-10-19 09:30:56 -0400
commitd439404c9988df6001e4ff8bce31537e2692660e (patch)
treeb1462a7177b8a2791140964761eb49d173cdc878 /android/widget
parent93b7ee4fce01df52a6607f0b1965cbafdfeaf1a6 (diff)
downloadandroid-28-d439404c9988df6001e4ff8bce31537e2692660e.tar.gz
Import Android SDK Platform P [4402356]
/google/data/ro/projects/android/fetch_artifact \ --bid 4386628 \ --target sdk_phone_armv7-win_sdk \ sdk-repo-linux-sources-4402356.zip AndroidVersion.ApiLevel has been modified to appear as 28 Change-Id: Ie49e24e1f4ae9dc96306111e953d3db1e1495b53
Diffstat (limited to 'android/widget')
-rw-r--r--android/widget/Editor.java21
-rw-r--r--android/widget/RemoteViews.java6
-rw-r--r--android/widget/SelectionActionModeHelper.java30
-rw-r--r--android/widget/TextView.java41
4 files changed, 82 insertions, 16 deletions
diff --git a/android/widget/Editor.java b/android/widget/Editor.java
index afd11881..d4be7e57 100644
--- a/android/widget/Editor.java
+++ b/android/widget/Editor.java
@@ -165,7 +165,7 @@ public class Editor {
private static final int MENU_ITEM_ORDER_PASTE_AS_PLAIN_TEXT = 11;
private static final int MENU_ITEM_ORDER_PROCESS_TEXT_INTENT_ACTIONS_START = 100;
- private static final float MAGNIFIER_ZOOM = 1.5f;
+ private static final float MAGNIFIER_ZOOM = 1.25f;
@IntDef({MagnifierHandleTrigger.SELECTION_START,
MagnifierHandleTrigger.SELECTION_END,
MagnifierHandleTrigger.INSERTION})
@@ -476,6 +476,17 @@ public class Editor {
stopTextActionModeWithPreservingSelection();
}
+ void invalidateMagnifier() {
+ final DisplayMetrics dm = mTextView.getResources().getDisplayMetrics();
+ invalidateMagnifier(0, 0, dm.widthPixels, dm.heightPixels);
+ }
+
+ void invalidateMagnifier(final float l, final float t, final float r, final float b) {
+ if (mMagnifier != null) {
+ mTextView.post(() -> mMagnifier.invalidate(new RectF(l, t, r, b)));
+ }
+ }
+
private void discardTextDisplayLists() {
if (mTextRenderNodes != null) {
for (int i = 0; i < mTextRenderNodes.length; i++) {
@@ -4545,17 +4556,17 @@ public class Editor {
+ mTextView.getLayout().getLineBottom(lineNumber)) / 2.0f;
final int[] coordinatesOnScreen = new int[2];
mTextView.getLocationOnScreen(coordinatesOnScreen);
- final float centerXOnScreen = xPosInView + mTextView.getTotalPaddingLeft()
- - mTextView.getScrollX() + coordinatesOnScreen[0];
- final float centerYOnScreen = yPosInView + mTextView.getTotalPaddingTop()
- - mTextView.getScrollY() + coordinatesOnScreen[1];
+ final float centerXOnScreen = mTextView.convertViewToScreenCoord(xPosInView, true);
+ final float centerYOnScreen = mTextView.convertViewToScreenCoord(yPosInView, false);
+ suspendBlink();
mMagnifier.show(centerXOnScreen, centerYOnScreen, MAGNIFIER_ZOOM);
}
protected final void dismissMagnifier() {
if (mMagnifier != null) {
mMagnifier.dismiss();
+ resumeBlink();
}
}
diff --git a/android/widget/RemoteViews.java b/android/widget/RemoteViews.java
index 1b26f8e2..199b596a 100644
--- a/android/widget/RemoteViews.java
+++ b/android/widget/RemoteViews.java
@@ -2653,7 +2653,11 @@ public class RemoteViews implements Parcelable, Filter {
/**
* Equivalent to calling
* {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
- * to launch the provided {@link PendingIntent}.
+ * to launch the provided {@link PendingIntent}. The source bounds
+ * ({@link Intent#getSourceBounds()}) of the intent will be set to the bounds of the clicked
+ * view in screen space.
+ * Note that any activity options associated with the pendingIntent may get overridden
+ * before starting the intent.
*
* When setting the on-click action of items within collections (eg. {@link ListView},
* {@link StackView} etc.), this method will not work. Instead, use {@link
diff --git a/android/widget/SelectionActionModeHelper.java b/android/widget/SelectionActionModeHelper.java
index 3be42a5b..5e22650a 100644
--- a/android/widget/SelectionActionModeHelper.java
+++ b/android/widget/SelectionActionModeHelper.java
@@ -95,11 +95,15 @@ public final class SelectionActionModeHelper {
}
public void startActionModeAsync(boolean adjustSelection) {
+ // Check if the smart selection should run for editable text.
+ adjustSelection &= !mTextView.isTextEditable()
+ || mTextView.getTextClassifier().getSettings()
+ .isSuggestSelectionEnabledForEditableText();
+
mSelectionTracker.onOriginalSelection(
getText(mTextView),
mTextView.getSelectionStart(),
- mTextView.getSelectionEnd(),
- mTextView.isTextEditable());
+ mTextView.getSelectionEnd());
cancelAsyncTask();
if (skipTextClassification()) {
startActionMode(null);
@@ -196,7 +200,10 @@ public final class SelectionActionModeHelper {
private void startActionMode(@Nullable SelectionResult result) {
final CharSequence text = getText(mTextView);
if (result != null && text instanceof Spannable) {
- Selection.setSelection((Spannable) text, result.mStart, result.mEnd);
+ // Do not change the selection if TextClassifier should be dark launched.
+ if (!mTextView.getTextClassifier().getSettings().isDarkLaunch()) {
+ Selection.setSelection((Spannable) text, result.mStart, result.mEnd);
+ }
mTextClassification = result.mClassification;
} else {
mTextClassification = null;
@@ -377,7 +384,7 @@ public final class SelectionActionModeHelper {
}
private void resetTextClassificationHelper() {
- mTextClassificationHelper.reset(
+ mTextClassificationHelper.init(
mTextView.getTextClassifier(),
getText(mTextView),
mTextView.getSelectionStart(), mTextView.getSelectionEnd(),
@@ -415,8 +422,7 @@ public final class SelectionActionModeHelper {
/**
* Called when the original selection happens, before smart selection is triggered.
*/
- public void onOriginalSelection(
- CharSequence text, int selectionStart, int selectionEnd, boolean editableText) {
+ public void onOriginalSelection(CharSequence text, int selectionStart, int selectionEnd) {
// If we abandoned a selection and created a new one very shortly after, we may still
// have a pending request to log ABANDON, which we flush here.
mDelayedLogAbandon.flush();
@@ -812,11 +818,11 @@ public final class SelectionActionModeHelper {
TextClassificationHelper(TextClassifier textClassifier,
CharSequence text, int selectionStart, int selectionEnd, LocaleList locales) {
- reset(textClassifier, text, selectionStart, selectionEnd, locales);
+ init(textClassifier, text, selectionStart, selectionEnd, locales);
}
@UiThread
- public void reset(TextClassifier textClassifier,
+ public void init(TextClassifier textClassifier,
CharSequence text, int selectionStart, int selectionEnd, LocaleList locales) {
mTextClassifier = Preconditions.checkNotNull(textClassifier);
mText = Preconditions.checkNotNull(text).toString();
@@ -839,8 +845,12 @@ public final class SelectionActionModeHelper {
trimText();
final TextSelection selection = mTextClassifier.suggestSelection(
mTrimmedText, mRelativeStart, mRelativeEnd, mLocales);
- mSelectionStart = Math.max(0, selection.getSelectionStartIndex() + mTrimStart);
- mSelectionEnd = Math.min(mText.length(), selection.getSelectionEndIndex() + mTrimStart);
+ // Do not classify new selection boundaries if TextClassifier should be dark launched.
+ if (!mTextClassifier.getSettings().isDarkLaunch()) {
+ mSelectionStart = Math.max(0, selection.getSelectionStartIndex() + mTrimStart);
+ mSelectionEnd = Math.min(
+ mText.length(), selection.getSelectionEndIndex() + mTrimStart);
+ }
return performClassification(selection);
}
diff --git a/android/widget/TextView.java b/android/widget/TextView.java
index 24ae03c3..ce805526 100644
--- a/android/widget/TextView.java
+++ b/android/widget/TextView.java
@@ -9219,6 +9219,36 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
+ @Override
+ public void invalidate() {
+ super.invalidate();
+
+ if (mEditor != null) {
+ mEditor.invalidateMagnifier();
+ }
+ }
+
+ @Override
+ public void invalidate(int l, int t, int r, int b) {
+ super.invalidate(l, t, r, b);
+
+ if (mEditor != null) {
+ mEditor.invalidateMagnifier(
+ convertViewToScreenCoord(l, true /* isHorizontal */),
+ convertViewToScreenCoord(t, false /* isHorizontal */),
+ convertViewToScreenCoord(r, true /* isHorizontal */),
+ convertViewToScreenCoord(b, false /* isHorizontal */));
+ }
+ }
+
+ float convertViewToScreenCoord(float viewCoord, boolean isHorizontal) {
+ final int[] coordinatesOnScreen = new int[2];
+ getLocationOnScreen(coordinatesOnScreen);
+ return isHorizontal
+ ? viewCoord + getTotalPaddingLeft() - getScrollX() + coordinatesOnScreen[0]
+ : viewCoord + getTotalPaddingTop() - getScrollY() + coordinatesOnScreen[1];
+ }
+
/**
* @return whether or not the cursor is visible (assuming this TextView is editable)
*
@@ -10338,6 +10368,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// of the View (and can be any drawable) or a BackgroundColorSpan inside the text.
structure.setTextStyle(getTextSize(), getCurrentTextColor(),
AssistStructure.ViewNode.TEXT_COLOR_UNDEFINED /* bgColor */, style);
+ } else {
+ structure.setMinTextEms(getMinEms());
+ structure.setMaxTextEms(getMaxEms());
+ int maxLength = -1;
+ for (InputFilter filter: getFilters()) {
+ if (filter instanceof InputFilter.LengthFilter) {
+ maxLength = ((InputFilter.LengthFilter) filter).getMax();
+ break;
+ }
+ }
+ structure.setMaxTextLength(maxLength);
}
}
structure.setHint(getHint());