Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -22387,6 +22387,7 @@ package android.view { method public void requestDisallowInterceptTouchEvent(boolean); method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent); method public void requestTransparentRegion(android.view.View); method protected void resetLayoutDirectionResolution(); method public void scheduleLayoutAnimation(); method public void setAddStatesFromChildren(boolean); method public void setAlwaysDrawnWithCacheEnabled(boolean); Loading Loading @@ -26053,6 +26054,7 @@ package android.widget { method protected void onTextChanged(java.lang.CharSequence, int, int, int); method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); method protected void resetLayoutDirectionResolution(); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); method public void setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable); core/java/android/text/Layout.java +34 −10 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ public abstract class Layout { } } Alignment align = mAlignment; Alignment paraAlign = mAlignment; TabStops tabStops = null; boolean tabStopsIsInitialized = false; Loading Loading @@ -310,10 +310,10 @@ public abstract class Layout { ParagraphStyle.class); spans = getParagraphSpans(sp, start, spanEnd, ParagraphStyle.class); align = mAlignment; paraAlign = mAlignment; for (int n = spans.length-1; n >= 0; n--) { if (spans[n] instanceof AlignmentSpan) { align = ((AlignmentSpan) spans[n]).getAlignment(); paraAlign = ((AlignmentSpan) spans[n]).getAlignment(); break; } } Loading Loading @@ -360,6 +360,16 @@ public abstract class Layout { tabStopsIsInitialized = true; } // Determine whether the line aligns to normal, opposite, or center. Alignment align = paraAlign; if (align == Alignment.ALIGN_LEFT) { align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE; } else if (align == Alignment.ALIGN_RIGHT) { align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL; } int x; if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_LEFT_TO_RIGHT) { Loading Loading @@ -411,7 +421,9 @@ public abstract class Layout { int dir = getParagraphDirection(line); int x; if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { x = left; } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_LEFT_TO_RIGHT) { x = left; } else { Loading @@ -430,7 +442,9 @@ public abstract class Layout { } } int max = (int)getLineExtent(line, tabStops, false); if (align == Alignment.ALIGN_OPPOSITE) { if (align == Alignment.ALIGN_RIGHT) { x = right - max; } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_LEFT_TO_RIGHT) { x = right - max; } else { Loading Loading @@ -738,11 +752,15 @@ public abstract class Layout { int dir = getParagraphDirection(line); Alignment align = getParagraphAlignment(line); if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { return 0; } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_RIGHT_TO_LEFT) return getParagraphRight(line) - getLineMax(line); else return 0; } else if (align == Alignment.ALIGN_RIGHT) { return mWidth - getLineMax(line); } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_RIGHT_TO_LEFT) return 0; Loading @@ -765,11 +783,15 @@ public abstract class Layout { int dir = getParagraphDirection(line); Alignment align = getParagraphAlignment(line); if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { return getParagraphLeft(line) + getLineMax(line); } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_RIGHT_TO_LEFT) return mWidth; else return getParagraphLeft(line) + getLineMax(line); } else if (align == Alignment.ALIGN_RIGHT) { return mWidth; } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_RIGHT_TO_LEFT) return getLineMax(line); Loading Loading @@ -1765,8 +1787,10 @@ public abstract class Layout { ALIGN_NORMAL, ALIGN_OPPOSITE, ALIGN_CENTER, // XXX ALIGN_LEFT, // XXX ALIGN_RIGHT, /** @hide */ ALIGN_LEFT, /** @hide */ ALIGN_RIGHT, } private static final int TAB_INCREMENT = 20; Loading core/java/android/view/View.java +8 −2 Original line number Diff line number Diff line Loading @@ -9038,9 +9038,15 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit } /** * Reset the resolved layout direction by clearing the corresponding flag * Reset the resolved layout direction. * * Subclasses need to override this method to clear cached information that depends on the * resolved layout direction, or to inform child views that inherit their layout direction. * Overrides must also call the superclass implementation at the start of their implementation. * * @hide */ void resetLayoutDirectionResolution() { protected void resetLayoutDirectionResolution() { // Reset the current View resolution mPrivateFlags2 &= ~LAYOUT_DIRECTION_RESOLVED; } Loading core/java/android/view/ViewGroup.java +1 −5 Original line number Diff line number Diff line Loading @@ -4997,12 +4997,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager viewAncestor.requestTransitionStart(transition); } /** * This method will be called when we need to reset the layout direction resolution flag * */ @Override void resetLayoutDirectionResolution() { protected void resetLayoutDirectionResolution() { super.resetLayoutDirectionResolution(); // Take care of resetting the children resolution too Loading core/java/android/widget/TextView.java +78 −19 Original line number Diff line number Diff line Loading @@ -340,6 +340,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private WordIterator mWordIterator; // The alignment to pass to Layout, or null if not resolved. private Layout.Alignment mLayoutAlignment; // The default value for mTextAlign. private TextAlign mTextAlign = TextAlign.INHERIT; private static enum TextAlign { INHERIT, GRAVITY, TEXT_START, TEXT_END, CENTER, VIEW_START, VIEW_END; } /* * Kick-start the font cache for the zygote process (to pay the cost of * initializing freetype for our default font only once). Loading Loading @@ -5529,6 +5539,73 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener physicalWidth, false); } @Override protected void resetLayoutDirectionResolution() { super.resetLayoutDirectionResolution(); if (mLayoutAlignment != null && (mTextAlign == TextAlign.VIEW_START || mTextAlign == TextAlign.VIEW_END)) { mLayoutAlignment = null; } } private Layout.Alignment getLayoutAlignment() { if (mLayoutAlignment == null) { Layout.Alignment alignment; TextAlign textAlign = mTextAlign; switch (textAlign) { case INHERIT: // fall through to gravity temporarily // intention is to inherit value through view hierarchy. case GRAVITY: switch (mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.START: alignment = Layout.Alignment.ALIGN_NORMAL; break; case Gravity.END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case Gravity.LEFT: alignment = Layout.Alignment.ALIGN_LEFT; break; case Gravity.RIGHT: alignment = Layout.Alignment.ALIGN_RIGHT; break; case Gravity.CENTER_HORIZONTAL: alignment = Layout.Alignment.ALIGN_CENTER; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; break; } break; case TEXT_START: alignment = Layout.Alignment.ALIGN_NORMAL; break; case TEXT_END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case CENTER: alignment = Layout.Alignment.ALIGN_CENTER; break; case VIEW_START: alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ? Layout.Alignment.ALIGN_RIGHT : Layout.Alignment.ALIGN_LEFT; break; case VIEW_END: alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ? Layout.Alignment.ALIGN_LEFT : Layout.Alignment.ALIGN_RIGHT; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; break; } mLayoutAlignment = alignment; } return mLayoutAlignment; } /** * The width passed in is now the desired layout width, * not the full view width with padding. Loading @@ -5549,25 +5626,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener hintWidth = 0; } final int layoutDirection = getResolvedLayoutDirection(); final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection); Layout.Alignment alignment; switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: alignment = Layout.Alignment.ALIGN_CENTER; break; case Gravity.RIGHT: // Note, Layout resolves ALIGN_OPPOSITE to left or // right based on the paragraph direction. alignment = Layout.Alignment.ALIGN_OPPOSITE; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; } Layout.Alignment alignment = getLayoutAlignment(); boolean shouldEllipsize = mEllipsize != null && mInput == null; if (mText instanceof Spannable) { Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -22387,6 +22387,7 @@ package android.view { method public void requestDisallowInterceptTouchEvent(boolean); method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent); method public void requestTransparentRegion(android.view.View); method protected void resetLayoutDirectionResolution(); method public void scheduleLayoutAnimation(); method public void setAddStatesFromChildren(boolean); method public void setAlwaysDrawnWithCacheEnabled(boolean); Loading Loading @@ -26053,6 +26054,7 @@ package android.widget { method protected void onTextChanged(java.lang.CharSequence, int, int, int); method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); method protected void resetLayoutDirectionResolution(); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); method public void setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
core/java/android/text/Layout.java +34 −10 Original line number Diff line number Diff line Loading @@ -266,7 +266,7 @@ public abstract class Layout { } } Alignment align = mAlignment; Alignment paraAlign = mAlignment; TabStops tabStops = null; boolean tabStopsIsInitialized = false; Loading Loading @@ -310,10 +310,10 @@ public abstract class Layout { ParagraphStyle.class); spans = getParagraphSpans(sp, start, spanEnd, ParagraphStyle.class); align = mAlignment; paraAlign = mAlignment; for (int n = spans.length-1; n >= 0; n--) { if (spans[n] instanceof AlignmentSpan) { align = ((AlignmentSpan) spans[n]).getAlignment(); paraAlign = ((AlignmentSpan) spans[n]).getAlignment(); break; } } Loading Loading @@ -360,6 +360,16 @@ public abstract class Layout { tabStopsIsInitialized = true; } // Determine whether the line aligns to normal, opposite, or center. Alignment align = paraAlign; if (align == Alignment.ALIGN_LEFT) { align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE; } else if (align == Alignment.ALIGN_RIGHT) { align = (dir == DIR_LEFT_TO_RIGHT) ? Alignment.ALIGN_OPPOSITE : Alignment.ALIGN_NORMAL; } int x; if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_LEFT_TO_RIGHT) { Loading Loading @@ -411,7 +421,9 @@ public abstract class Layout { int dir = getParagraphDirection(line); int x; if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { x = left; } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_LEFT_TO_RIGHT) { x = left; } else { Loading @@ -430,7 +442,9 @@ public abstract class Layout { } } int max = (int)getLineExtent(line, tabStops, false); if (align == Alignment.ALIGN_OPPOSITE) { if (align == Alignment.ALIGN_RIGHT) { x = right - max; } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_LEFT_TO_RIGHT) { x = right - max; } else { Loading Loading @@ -738,11 +752,15 @@ public abstract class Layout { int dir = getParagraphDirection(line); Alignment align = getParagraphAlignment(line); if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { return 0; } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_RIGHT_TO_LEFT) return getParagraphRight(line) - getLineMax(line); else return 0; } else if (align == Alignment.ALIGN_RIGHT) { return mWidth - getLineMax(line); } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_RIGHT_TO_LEFT) return 0; Loading @@ -765,11 +783,15 @@ public abstract class Layout { int dir = getParagraphDirection(line); Alignment align = getParagraphAlignment(line); if (align == Alignment.ALIGN_NORMAL) { if (align == Alignment.ALIGN_LEFT) { return getParagraphLeft(line) + getLineMax(line); } else if (align == Alignment.ALIGN_NORMAL) { if (dir == DIR_RIGHT_TO_LEFT) return mWidth; else return getParagraphLeft(line) + getLineMax(line); } else if (align == Alignment.ALIGN_RIGHT) { return mWidth; } else if (align == Alignment.ALIGN_OPPOSITE) { if (dir == DIR_RIGHT_TO_LEFT) return getLineMax(line); Loading Loading @@ -1765,8 +1787,10 @@ public abstract class Layout { ALIGN_NORMAL, ALIGN_OPPOSITE, ALIGN_CENTER, // XXX ALIGN_LEFT, // XXX ALIGN_RIGHT, /** @hide */ ALIGN_LEFT, /** @hide */ ALIGN_RIGHT, } private static final int TAB_INCREMENT = 20; Loading
core/java/android/view/View.java +8 −2 Original line number Diff line number Diff line Loading @@ -9038,9 +9038,15 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit } /** * Reset the resolved layout direction by clearing the corresponding flag * Reset the resolved layout direction. * * Subclasses need to override this method to clear cached information that depends on the * resolved layout direction, or to inform child views that inherit their layout direction. * Overrides must also call the superclass implementation at the start of their implementation. * * @hide */ void resetLayoutDirectionResolution() { protected void resetLayoutDirectionResolution() { // Reset the current View resolution mPrivateFlags2 &= ~LAYOUT_DIRECTION_RESOLVED; } Loading
core/java/android/view/ViewGroup.java +1 −5 Original line number Diff line number Diff line Loading @@ -4997,12 +4997,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager viewAncestor.requestTransitionStart(transition); } /** * This method will be called when we need to reset the layout direction resolution flag * */ @Override void resetLayoutDirectionResolution() { protected void resetLayoutDirectionResolution() { super.resetLayoutDirectionResolution(); // Take care of resetting the children resolution too Loading
core/java/android/widget/TextView.java +78 −19 Original line number Diff line number Diff line Loading @@ -340,6 +340,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private WordIterator mWordIterator; // The alignment to pass to Layout, or null if not resolved. private Layout.Alignment mLayoutAlignment; // The default value for mTextAlign. private TextAlign mTextAlign = TextAlign.INHERIT; private static enum TextAlign { INHERIT, GRAVITY, TEXT_START, TEXT_END, CENTER, VIEW_START, VIEW_END; } /* * Kick-start the font cache for the zygote process (to pay the cost of * initializing freetype for our default font only once). Loading Loading @@ -5529,6 +5539,73 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener physicalWidth, false); } @Override protected void resetLayoutDirectionResolution() { super.resetLayoutDirectionResolution(); if (mLayoutAlignment != null && (mTextAlign == TextAlign.VIEW_START || mTextAlign == TextAlign.VIEW_END)) { mLayoutAlignment = null; } } private Layout.Alignment getLayoutAlignment() { if (mLayoutAlignment == null) { Layout.Alignment alignment; TextAlign textAlign = mTextAlign; switch (textAlign) { case INHERIT: // fall through to gravity temporarily // intention is to inherit value through view hierarchy. case GRAVITY: switch (mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.START: alignment = Layout.Alignment.ALIGN_NORMAL; break; case Gravity.END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case Gravity.LEFT: alignment = Layout.Alignment.ALIGN_LEFT; break; case Gravity.RIGHT: alignment = Layout.Alignment.ALIGN_RIGHT; break; case Gravity.CENTER_HORIZONTAL: alignment = Layout.Alignment.ALIGN_CENTER; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; break; } break; case TEXT_START: alignment = Layout.Alignment.ALIGN_NORMAL; break; case TEXT_END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case CENTER: alignment = Layout.Alignment.ALIGN_CENTER; break; case VIEW_START: alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ? Layout.Alignment.ALIGN_RIGHT : Layout.Alignment.ALIGN_LEFT; break; case VIEW_END: alignment = (getResolvedLayoutDirection() == LAYOUT_DIRECTION_RTL) ? Layout.Alignment.ALIGN_LEFT : Layout.Alignment.ALIGN_RIGHT; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; break; } mLayoutAlignment = alignment; } return mLayoutAlignment; } /** * The width passed in is now the desired layout width, * not the full view width with padding. Loading @@ -5549,25 +5626,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener hintWidth = 0; } final int layoutDirection = getResolvedLayoutDirection(); final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection); Layout.Alignment alignment; switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: alignment = Layout.Alignment.ALIGN_CENTER; break; case Gravity.RIGHT: // Note, Layout resolves ALIGN_OPPOSITE to left or // right based on the paragraph direction. alignment = Layout.Alignment.ALIGN_OPPOSITE; break; default: alignment = Layout.Alignment.ALIGN_NORMAL; } Layout.Alignment alignment = getLayoutAlignment(); boolean shouldEllipsize = mEllipsize != null && mInput == null; if (mText instanceof Spannable) { Loading