summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/text/DynamicLayout.java6
-rw-r--r--core/java/android/text/StaticLayout.java144
-rw-r--r--core/java/android/view/ViewRootImpl.java8
-rw-r--r--core/java/android/widget/TextView.java20
4 files changed, 79 insertions, 99 deletions
diff --git a/core/java/android/text/DynamicLayout.java b/core/java/android/text/DynamicLayout.java
index f82c9c4..026af34 100644
--- a/core/java/android/text/DynamicLayout.java
+++ b/core/java/android/text/DynamicLayout.java
@@ -281,9 +281,9 @@ extends Layout
}
reflowed.generate(text, where, where + after,
- getPaint(), getWidth(), getAlignment(), getTextDirectionHeuristic(),
- getSpacingMultiplier(), getSpacingAdd(),
- false, true, mEllipsizedWidth, mEllipsizeAt);
+ getPaint(), getWidth(), getTextDirectionHeuristic(), getSpacingMultiplier(),
+ getSpacingAdd(), false,
+ true, mEllipsizedWidth, mEllipsizeAt);
int n = reflowed.getLineCount();
// If the new layout has a blank line at the end, but it is not
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 583cbe6..1dd4c8a 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -137,9 +137,9 @@ public class StaticLayout extends Layout {
mMeasured = MeasuredText.obtain();
- generate(source, bufstart, bufend, paint, outerwidth, align, textDir,
- spacingmult, spacingadd, includepad, includepad,
- ellipsizedWidth, ellipsize);
+ generate(source, bufstart, bufend, paint, outerwidth, textDir, spacingmult,
+ spacingadd, includepad, includepad, ellipsizedWidth,
+ ellipsize);
mMeasured = MeasuredText.recycle(mMeasured);
mFontMetricsInt = null;
@@ -157,10 +157,10 @@ public class StaticLayout extends Layout {
/* package */ void generate(CharSequence source, int bufStart, int bufEnd,
TextPaint paint, int outerWidth,
- Alignment align, TextDirectionHeuristic textDir,
- float spacingmult, float spacingadd,
- boolean includepad, boolean trackpad,
- float ellipsizedWidth, TextUtils.TruncateAt ellipsize) {
+ TextDirectionHeuristic textDir, float spacingmult,
+ float spacingadd, boolean includepad,
+ boolean trackpad, float ellipsizedWidth,
+ TextUtils.TruncateAt ellipsize) {
mLineCount = 0;
int v = 0;
@@ -328,9 +328,7 @@ public class StaticLayout extends Layout {
whichPaint = mWorkPaint;
}
- float wid = bm.getWidth() *
- -whichPaint.ascent() /
- bm.getHeight();
+ float wid = bm.getWidth() * -whichPaint.ascent() / bm.getHeight();
w += wid;
hasTabOrEmoji = true;
@@ -398,67 +396,49 @@ public class StaticLayout extends Layout {
okBottom = fitBottom;
}
} else {
- final boolean moreChars = (j + 1 < spanEnd);
- if (ok != here) {
- // Log.e("text", "output ok " + here + " to " +ok);
+ final boolean moreChars = (j + 1 < spanEnd);
+ int endPos;
+ int above, below, top, bottom;
+ float currentTextWidth;
- while (ok < spanEnd && chs[ok - paraStart] == CHAR_SPACE) {
- ok++;
- }
+ if (ok != here) {
+ // If it is a space that makes the length exceed width, cut here
+ if (c == CHAR_SPACE) ok = j + 1;
- v = out(source,
- here, ok,
- okAscent, okDescent, okTop, okBottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- ok == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, okWidth,
- paint, moreChars);
-
- here = ok;
- } else if (fit != here) {
- // Log.e("text", "output fit " + here + " to " +fit);
- v = out(source,
- here, fit,
- fitAscent, fitDescent,
- fitTop, fitBottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- fit == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, fitWidth,
- paint, moreChars);
-
- here = fit;
- } else {
- // Log.e("text", "output one " + here + " to " +(here + 1));
- // XXX not sure why the existing fm wasn't ok.
- // measureText(paint, mWorkPaint,
- // source, here, here + 1, fm, tab,
- // null);
-
- v = out(source,
- here, here+1,
- fm.ascent, fm.descent,
- fm.top, fm.bottom,
- v,
- spacingmult, spacingadd, chooseHt,
- chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- here + 1 == bufEnd, includepad,
- trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth,
- widths[here - paraStart], paint, moreChars);
-
- here = here + 1;
+ while (ok < spanEnd && chs[ok - paraStart] == CHAR_SPACE) {
+ ok++;
}
+ endPos = ok;
+ above = okAscent;
+ below = okDescent;
+ top = okTop;
+ bottom = okBottom;
+ currentTextWidth = okWidth;
+ } else if (fit != here) {
+ endPos = fit;
+ above = fitAscent;
+ below = fitDescent;
+ top = fitTop;
+ bottom = fitBottom;
+ currentTextWidth = fitWidth;
+ } else {
+ endPos = here + 1;
+ above = fm.ascent;
+ below = fm.descent;
+ top = fm.top;
+ bottom = fm.bottom;
+ currentTextWidth = widths[here - paraStart];
+ }
+
+ v = out(source, here, endPos,
+ above, below, top, bottom,
+ v, spacingmult, spacingadd, chooseHt,chooseHtv, fm, hasTabOrEmoji,
+ needMultiply, chdirs, dir, easy, bufEnd, includepad, trackpad,
+ chs, widths, paraStart, ellipsize, ellipsizedWidth,
+ currentTextWidth, paint, moreChars);
+ here = endPos;
+
if (here < spanStart) {
// didn't output all the text for this span
// we've measured the raw widths, though, so
@@ -501,10 +481,10 @@ public class StaticLayout extends Layout {
v,
spacingmult, spacingadd, chooseHt,
chooseHtv, fm, hasTabOrEmoji,
- needMultiply, paraStart, chdirs, dir, easy,
- paraEnd == bufEnd, includepad, trackpad,
- chs, widths, paraStart,
- ellipsize, ellipsizedWidth, w, paint, paraEnd != bufEnd);
+ needMultiply, chdirs, dir, easy, bufEnd,
+ includepad, trackpad, chs,
+ widths, paraStart, ellipsize,
+ ellipsizedWidth, w, paint, paraEnd != bufEnd);
}
paraStart = paraEnd;
@@ -525,10 +505,10 @@ public class StaticLayout extends Layout {
v,
spacingmult, spacingadd, null,
null, fm, false,
- needMultiply, bufEnd, null, DEFAULT_DIR, true,
- true, includepad, trackpad,
- null, null, bufStart,
- ellipsize, ellipsizedWidth, 0, paint, false);
+ needMultiply, null, DEFAULT_DIR, true, bufEnd,
+ includepad, trackpad, null,
+ null, bufStart, ellipsize,
+ ellipsizedWidth, 0, paint, false);
}
}
@@ -628,12 +608,12 @@ public class StaticLayout extends Layout {
float spacingmult, float spacingadd,
LineHeightSpan[] chooseHt, int[] chooseHtv,
Paint.FontMetricsInt fm, boolean hasTabOrEmoji,
- boolean needMultiply, int pstart, byte[] chdirs,
- int dir, boolean easy, boolean last,
- boolean includePad, boolean trackPad,
- char[] chs, float[] widths, int widthStart,
- TextUtils.TruncateAt ellipsize, float ellipsisWidth,
- float textWidth, TextPaint paint, boolean moreChars) {
+ boolean needMultiply, byte[] chdirs, int dir,
+ boolean easy, int bufEnd, boolean includePad,
+ boolean trackPad, char[] chs,
+ float[] widths, int widthStart, TextUtils.TruncateAt ellipsize,
+ float ellipsisWidth, float textWidth,
+ TextPaint paint, boolean moreChars) {
int j = mLineCount;
int off = j * mColumns;
int want = off + mColumns + TOP;
@@ -683,7 +663,7 @@ public class StaticLayout extends Layout {
above = top;
}
}
- if (last) {
+ if (end == bufEnd) {
if (trackPad) {
mBottomPadding = bottom - below;
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index abb5bc8..a36aecb 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -287,7 +287,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
final AccessibilityManager mAccessibilityManager;
- AccessibilityInteractionController mAccessibilityInteractionContrtoller;
+ AccessibilityInteractionController mAccessibilityInteractionController;
AccessibilityInteractionConnectionManager mAccessibilityInteractionConnectionManager;
@@ -3526,10 +3526,10 @@ public final class ViewRootImpl extends Handler implements ViewParent,
throw new IllegalStateException("getAccessibilityInteractionController"
+ " called when there is no mView");
}
- if (mAccessibilityInteractionContrtoller == null) {
- mAccessibilityInteractionContrtoller = new AccessibilityInteractionController();
+ if (mAccessibilityInteractionController == null) {
+ mAccessibilityInteractionController = new AccessibilityInteractionController();
}
- return mAccessibilityInteractionContrtoller;
+ return mAccessibilityInteractionController;
}
private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility,
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 55e49ea..5a300e8 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -359,7 +359,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private SpellChecker mSpellChecker;
- private boolean mShowSoftInputOnFocus = true;
+ private boolean mSoftInputShownOnFocus = true;
// The alignment to pass to Layout, or null if not resolved.
private Layout.Alignment mLayoutAlignment;
@@ -2381,23 +2381,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* Sets whether the soft input method will be made visible when this
* TextView gets focused. The default is true.
*
- * @attr ref android.R.styleable#TextView_showSoftInputOnFocus
+ * @attr ref android.R.styleable#TextView_softInputShownOnFocus
* @hide
*/
@android.view.RemotableViewMethod
- public final void setShowSoftInputOnFocus(boolean show) {
- mShowSoftInputOnFocus = show;
+ public final void setSoftInputShownOnFocus(boolean show) {
+ mSoftInputShownOnFocus = show;
}
/**
* Returns whether the soft input method will be made visible when this
* TextView gets focused. The default is true.
*
- * @attr ref android.R.styleable#TextView_showSoftInputOnFocus
+ * @attr ref android.R.styleable#TextView_softInputShownOnFocus
* @hide
*/
- public final boolean getShowSoftInputOnFocus() {
- return mShowSoftInputOnFocus;
+ public final boolean getSoftInputShownOnFocus() {
+ return mSoftInputShownOnFocus;
}
/**
@@ -5502,7 +5502,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
&& mLayout != null && onCheckIsTextEditor()) {
InputMethodManager imm = InputMethodManager.peekInstance();
viewClicked(imm);
- if (imm != null && mShowSoftInputOnFocus) {
+ if (imm != null && mSoftInputShownOnFocus) {
imm.showSoftInput(this, 0);
}
}
@@ -8344,7 +8344,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Show the IME, except when selecting in read-only text.
final InputMethodManager imm = InputMethodManager.peekInstance();
viewClicked(imm);
- if (!mTextIsSelectable && mShowSoftInputOnFocus) {
+ if (!mTextIsSelectable && mSoftInputShownOnFocus) {
handled |= imm != null && imm.showSoftInput(this, 0);
}
@@ -10202,7 +10202,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final boolean selectionStarted = mSelectionActionMode != null ||
extractedTextModeWillBeStartedFullScreen;
- if (selectionStarted && !mTextIsSelectable && imm != null && mShowSoftInputOnFocus) {
+ if (selectionStarted && !mTextIsSelectable && imm != null && mSoftInputShownOnFocus) {
// Show the IME to be able to replace text, except when selecting non editable text.
imm.showSoftInput(this, 0, null);
}