am e3f2ac9e: Merge "Fix bug #6427629 Clean up layout direction APIs" into jb-mr1-dev

* commit 'e3f2ac9e526e5b4de4d2ae113e644c1cb14b1ce6':
  Fix bug #6427629 Clean up layout direction APIs
This commit is contained in:
Fabrice Di Meglio
2012-09-24 09:28:36 -07:00
committed by Android Git Automerger
10 changed files with 127 additions and 176 deletions

View File

@ -28704,8 +28704,6 @@ package android.widget {
method protected void onTextChanged(java.lang.CharSequence, int, int, int); method protected void onTextChanged(java.lang.CharSequence, int, int, int);
method public boolean onTextContextMenuItem(int); method public boolean onTextContextMenuItem(int);
method public void removeTextChangedListener(android.text.TextWatcher); method public void removeTextChangedListener(android.text.TextWatcher);
method protected void resetResolvedDrawables();
method protected void resolveDrawables();
method public void setAllCaps(boolean); method public void setAllCaps(boolean);
method public final void setAutoLinkMask(int); method public final void setAutoLinkMask(int);
method public void setCompoundDrawablePadding(int); method public void setCompoundDrawablePadding(int);

View File

@ -24830,9 +24830,6 @@ package android.view {
method public void buildDrawingCache(boolean); method public void buildDrawingCache(boolean);
method public void buildLayer(); method public void buildLayer();
method public boolean callOnClick(); method public boolean callOnClick();
method public boolean canResolveLayoutDirection();
method public boolean canResolveTextAlignment();
method public boolean canResolveTextDirection();
method public boolean canScrollHorizontally(int); method public boolean canScrollHorizontally(int);
method public boolean canScrollVertically(int); method public boolean canScrollVertically(int);
method public void cancelLongPress(); method public void cancelLongPress();
@ -25033,7 +25030,6 @@ package android.view {
method public boolean isHovered(); method public boolean isHovered();
method public boolean isInEditMode(); method public boolean isInEditMode();
method public boolean isInTouchMode(); method public boolean isInTouchMode();
method protected static boolean isLayoutDirectionRtl(java.util.Locale);
method public boolean isLayoutRequested(); method public boolean isLayoutRequested();
method public boolean isLayoutRtl(); method public boolean isLayoutRtl();
method public boolean isLongClickable(); method public boolean isLongClickable();
@ -25089,14 +25085,8 @@ package android.view {
method protected void onOverScrolled(int, int, boolean, boolean); method protected void onOverScrolled(int, int, boolean, boolean);
method public void onPaddingChanged(int); method public void onPaddingChanged(int);
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent); method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public void onResolveDrawables(int);
method public void onResolvedLayoutDirectionChanged();
method public void onResolvedLayoutDirectionReset();
method public void onResolvedTextAlignmentChanged();
method public void onResolvedTextAlignmentReset();
method public void onResolvedTextDirectionChanged();
method public void onResolvedTextDirectionReset();
method protected void onRestoreInstanceState(android.os.Parcelable); method protected void onRestoreInstanceState(android.os.Parcelable);
method public void onRtlPropertiesChanged();
method protected android.os.Parcelable onSaveInstanceState(); method protected android.os.Parcelable onSaveInstanceState();
method public void onScreenStateChanged(int); method public void onScreenStateChanged(int);
method protected void onScrollChanged(int, int, int, int); method protected void onScrollChanged(int, int, int, int);
@ -25138,16 +25128,8 @@ package android.view {
method public void requestLayout(); method public void requestLayout();
method public boolean requestRectangleOnScreen(android.graphics.Rect); method public boolean requestRectangleOnScreen(android.graphics.Rect);
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean); method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
method public void resetResolvedLayoutDirection();
method public void resetResolvedTextAlignment();
method public void resetResolvedTextDirection();
method public void resolveDrawables();
method public void resolveLayoutDirection();
method public void resolvePadding();
method public static int resolveSize(int, int); method public static int resolveSize(int, int);
method public static int resolveSizeAndState(int, int, int); method public static int resolveSizeAndState(int, int, int);
method public void resolveTextAlignment();
method public void resolveTextDirection();
method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void restoreHierarchyState(android.util.SparseArray<android.os.Parcelable>);
method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>); method public void saveHierarchyState(android.util.SparseArray<android.os.Parcelable>);
method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long); method public void scheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable, long);

View File

@ -5799,13 +5799,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (getLayoutDirection() != layoutDirection) { if (getLayoutDirection() != layoutDirection) {
// Reset the current layout direction and the resolved one // Reset the current layout direction and the resolved one
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_MASK; mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_MASK;
resetResolvedLayoutDirection(); resetRtlProperties();
// Reset padding resolution
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
// Set the new layout direction (filtered) // Set the new layout direction (filtered)
mPrivateFlags2 |= mPrivateFlags2 |=
((layoutDirection << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) & PFLAG2_LAYOUT_DIRECTION_MASK); ((layoutDirection << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) & PFLAG2_LAYOUT_DIRECTION_MASK);
resolveRtlProperties(); resolveRtlProperties();
// Notify changes
onRtlPropertiesChanged();
// ... and ask for a layout pass // ... and ask for a layout pass
requestLayout(); requestLayout();
} }
@ -11475,6 +11475,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
jumpDrawablesToCurrentState(); jumpDrawablesToCurrentState();
resolveRtlProperties(); resolveRtlProperties();
// Notify changes
onRtlPropertiesChanged();
clearAccessibilityFocus(); clearAccessibilityFocus();
if (isFocused()) { if (isFocused()) {
@ -11487,17 +11489,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
} }
/**
* Resolve all RTL related properties
*/
void resolveRtlProperties() { void resolveRtlProperties() {
// Order is important here: LayoutDirection MUST be resolved first... // Order is important here: LayoutDirection MUST be resolved first...
resolveLayoutDirection(); resolveLayoutDirection();
// ... then we can resolve the others properties depending on the resolved LayoutDirection. // ... then we can resolve the others properties depending on the resolved LayoutDirection.
resolvePadding();
resolveLayoutParams();
resolveTextDirection(); resolveTextDirection();
resolveTextAlignment(); resolveTextAlignment();
resolvePadding();
resolveLayoutParams();
resolveDrawables(); resolveDrawables();
} }
// Reset resolution of all RTL related properties
void resetRtlProperties() {
resetResolvedLayoutDirection();
resetResolvedTextDirection();
resetResolvedTextAlignment();
resetResolvedPadding();
}
/** /**
* @see #onScreenStateChanged(int) * @see #onScreenStateChanged(int)
*/ */
@ -11524,10 +11537,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
return mContext.getApplicationInfo().hasRtlSupport(); return mContext.getApplicationInfo().hasRtlSupport();
} }
/**
* Called when any RTL property (layout direction or text direction or text alignment) has
* been changed.
*
* Subclasses need to override this method to take care of cached information that depends on the
* resolved layout direction, or to inform child views that inherit their layout direction.
*
* The default implementation does nothing.
*/
public void onRtlPropertiesChanged() {
}
/** /**
* Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing * Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing
* that the parent directionality can and will be resolved before its children. * that the parent directionality can and will be resolved before its children.
* Will call {@link View#onResolvedLayoutDirectionChanged} when resolution is done. *
* @hide
*/ */
public void resolveLayoutDirection() { public void resolveLayoutDirection() {
// Clear any previous layout direction resolution // Clear any previous layout direction resolution
@ -11555,7 +11581,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL;
break; break;
case LAYOUT_DIRECTION_LOCALE: case LAYOUT_DIRECTION_LOCALE:
if(isLayoutDirectionRtl(Locale.getDefault())) { if((LAYOUT_DIRECTION_RTL ==
TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()))) {
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL;
} }
break; break;
@ -11566,19 +11593,38 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// Set to resolved // Set to resolved
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED;
onResolvedLayoutDirectionChanged();
} }
/** /**
* Called when layout direction has been resolved. * Check if layout direction resolution can be done.
* *
* The default implementation does nothing. * @return true if layout direction resolution can be done otherwise return false.
*
* @hide
*/ */
public void onResolvedLayoutDirectionChanged() { public boolean canResolveLayoutDirection() {
switch (getLayoutDirection()) {
case LAYOUT_DIRECTION_INHERIT:
return (mParent != null) && (mParent instanceof ViewGroup);
default:
return true;
}
}
/**
* Reset the resolved layout direction.
*
* @hide
*/
public void resetResolvedLayoutDirection() {
// Reset the current resolved bits
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK;
} }
/** /**
* Return if padding has been resolved * Return if padding has been resolved
*
* @hide
*/ */
boolean isPaddingResolved() { boolean isPaddingResolved() {
return (mPrivateFlags2 & PFLAG2_PADDING_RESOLVED) != 0; return (mPrivateFlags2 & PFLAG2_PADDING_RESOLVED) != 0;
@ -11586,6 +11632,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/** /**
* Resolve padding depending on layout direction. * Resolve padding depending on layout direction.
*
* @hide
*/ */
public void resolvePadding() { public void resolvePadding() {
final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
@ -11648,6 +11696,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mPrivateFlags2 |= PFLAG2_PADDING_RESOLVED; mPrivateFlags2 |= PFLAG2_PADDING_RESOLVED;
} }
/**
* Reset the resolved layout direction.
*
* @hide
*/
public void resetResolvedPadding() {
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
}
/** /**
* Resolve padding depending on the layout direction. Subclasses that care about * Resolve padding depending on the layout direction. Subclasses that care about
* padding resolution should override this method. The default implementation does * padding resolution should override this method. The default implementation does
@ -11661,53 +11718,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
public void onPaddingChanged(int layoutDirection) { public void onPaddingChanged(int layoutDirection) {
} }
/**
* Check if layout direction resolution can be done.
*
* @return true if layout direction resolution can be done otherwise return false.
*/
public boolean canResolveLayoutDirection() {
switch (getLayoutDirection()) {
case LAYOUT_DIRECTION_INHERIT:
return (mParent != null) && (mParent instanceof ViewGroup);
default:
return true;
}
}
/**
* Reset the resolved layout direction. Will call {@link View#onResolvedLayoutDirectionReset}
* when reset is done.
*/
public void resetResolvedLayoutDirection() {
// Reset the current resolved bits
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK;
onResolvedLayoutDirectionReset();
// Reset also the text direction
resetResolvedTextDirection();
}
/**
* Called during reset of 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.
*
* The default implementation does nothing.
*/
public void onResolvedLayoutDirectionReset() {
}
/**
* Check if a Locale uses an RTL script.
*
* @param locale Locale to check
* @return true if the Locale uses an RTL script.
*/
protected static boolean isLayoutDirectionRtl(Locale locale) {
return (LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(locale));
}
/** /**
* This is called when the view is detached from a window. At this point it * This is called when the view is detached from a window. At this point it
* no longer has a surface for drawing. * no longer has a surface for drawing.
@ -11738,10 +11748,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mCurrentAnimation = null; mCurrentAnimation = null;
resetResolvedLayoutDirection(); resetRtlProperties();
resetResolvedTextAlignment(); onRtlPropertiesChanged();
resetAccessibilityStateChanged(); resetAccessibilityStateChanged();
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
} }
/** /**
@ -14091,6 +14100,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* that the View directionality can and will be resolved before its Drawables. * that the View directionality can and will be resolved before its Drawables.
* *
* Will call {@link View#onResolveDrawables} when resolution is done. * Will call {@link View#onResolveDrawables} when resolution is done.
*
* @hide
*/ */
public void resolveDrawables() { public void resolveDrawables() {
if (mBackground != null) { if (mBackground != null) {
@ -14108,6 +14119,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* *
* @see #LAYOUT_DIRECTION_LTR * @see #LAYOUT_DIRECTION_LTR
* @see #LAYOUT_DIRECTION_RTL * @see #LAYOUT_DIRECTION_RTL
*
* @hide
*/ */
public void onResolveDrawables(int layoutDirection) { public void onResolveDrawables(int layoutDirection) {
} }
@ -14383,8 +14396,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
background.setLayoutDirection(getResolvedLayoutDirection()); background.setLayoutDirection(getResolvedLayoutDirection());
if (background.getPadding(padding)) { if (background.getPadding(padding)) {
// Reset padding resolution resetResolvedPadding();
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
switch (background.getLayoutDirection()) { switch (background.getLayoutDirection()) {
case LAYOUT_DIRECTION_RTL: case LAYOUT_DIRECTION_RTL:
mUserPaddingLeftInitial = padding.right; mUserPaddingLeftInitial = padding.right;
@ -14485,8 +14497,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @param bottom the bottom padding in pixels * @param bottom the bottom padding in pixels
*/ */
public void setPadding(int left, int top, int right, int bottom) { public void setPadding(int left, int top, int right, int bottom) {
// Reset padding resolution resetResolvedPadding();
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
mUserPaddingStart = UNDEFINED_PADDING; mUserPaddingStart = UNDEFINED_PADDING;
mUserPaddingEnd = UNDEFINED_PADDING; mUserPaddingEnd = UNDEFINED_PADDING;
@ -14575,8 +14586,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @param bottom the bottom padding in pixels * @param bottom the bottom padding in pixels
*/ */
public void setPaddingRelative(int start, int top, int end, int bottom) { public void setPaddingRelative(int start, int top, int end, int bottom) {
// Reset padding resolution resetResolvedPadding();
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED;
mUserPaddingStart = start; mUserPaddingStart = start;
mUserPaddingEnd = end; mUserPaddingEnd = end;
@ -16513,6 +16523,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
resetResolvedTextDirection(); resetResolvedTextDirection();
// Set the new text direction // Set the new text direction
mPrivateFlags2 |= ((textDirection << PFLAG2_TEXT_DIRECTION_MASK_SHIFT) & PFLAG2_TEXT_DIRECTION_MASK); mPrivateFlags2 |= ((textDirection << PFLAG2_TEXT_DIRECTION_MASK_SHIFT) & PFLAG2_TEXT_DIRECTION_MASK);
// Notify change
onRtlPropertiesChanged();
// Refresh // Refresh
requestLayout(); requestLayout();
invalidate(true); invalidate(true);
@ -16544,8 +16556,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
/** /**
* Resolve the text direction. Will call {@link View#onResolvedTextDirectionChanged} when * Resolve the text direction.
* resolution is done. *
* @hide
*/ */
public void resolveTextDirection() { public void resolveTextDirection() {
// Reset any previous text direction resolution // Reset any previous text direction resolution
@ -16598,16 +16611,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// Set to resolved // Set to resolved
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED; mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED;
onResolvedTextDirectionChanged();
}
/**
* Called when text direction has been resolved. Subclasses that care about text direction
* resolution should override this method.
*
* The default implementation does nothing.
*/
public void onResolvedTextDirectionChanged() {
} }
/** /**
@ -16615,7 +16618,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* *
* @return true if text direction resolution can be done otherwise return false. * @return true if text direction resolution can be done otherwise return false.
*/ */
public boolean canResolveTextDirection() { private boolean canResolveTextDirection() {
switch (getTextDirection()) { switch (getTextDirection()) {
case TEXT_DIRECTION_INHERIT: case TEXT_DIRECTION_INHERIT:
return (mParent != null) && (mParent instanceof ViewGroup); return (mParent != null) && (mParent instanceof ViewGroup);
@ -16626,20 +16629,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/** /**
* Reset resolved text direction. Text direction can be resolved with a call to * Reset resolved text direction. Text direction can be resolved with a call to
* getResolvedTextDirection(). Will call {@link View#onResolvedTextDirectionReset} when * getResolvedTextDirection().
* reset is done. *
* @hide
*/ */
public void resetResolvedTextDirection() { public void resetResolvedTextDirection() {
mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK); mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK);
onResolvedTextDirectionReset();
}
/**
* Called when text direction is reset. Subclasses that care about text direction reset should
* override this method and do a reset of the text direction of their children. The default
* implementation does nothing.
*/
public void onResolvedTextDirectionReset() {
} }
/** /**
@ -16691,6 +16686,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
resetResolvedTextAlignment(); resetResolvedTextAlignment();
// Set the new text alignment // Set the new text alignment
mPrivateFlags2 |= ((textAlignment << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) & PFLAG2_TEXT_ALIGNMENT_MASK); mPrivateFlags2 |= ((textAlignment << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) & PFLAG2_TEXT_ALIGNMENT_MASK);
// Notify change
onRtlPropertiesChanged();
// Refresh // Refresh
requestLayout(); requestLayout();
invalidate(true); invalidate(true);
@ -16731,8 +16728,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
/** /**
* Resolve the text alignment. Will call {@link View#onResolvedTextAlignmentChanged} when * Resolve the text alignment.
* resolution is done. *
* @hide
*/ */
public void resolveTextAlignment() { public void resolveTextAlignment() {
// Reset any previous text alignment resolution // Reset any previous text alignment resolution
@ -16744,7 +16742,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
switch (textAlignment) { switch (textAlignment) {
case TEXT_ALIGNMENT_INHERIT: case TEXT_ALIGNMENT_INHERIT:
// Check if we can resolve the text alignment // Check if we can resolve the text alignment
if (canResolveLayoutDirection() && mParent instanceof View) { if (canResolveTextAlignment() && mParent instanceof View) {
View view = (View) mParent; View view = (View) mParent;
final int parentResolvedTextAlignment = view.getResolvedTextAlignment(); final int parentResolvedTextAlignment = view.getResolvedTextAlignment();
@ -16790,7 +16788,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// Set the resolved // Set the resolved
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED; mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED;
onResolvedTextAlignmentChanged();
} }
/** /**
@ -16798,7 +16795,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* *
* @return true if text alignment resolution can be done otherwise return false. * @return true if text alignment resolution can be done otherwise return false.
*/ */
public boolean canResolveTextAlignment() { private boolean canResolveTextAlignment() {
switch (getTextAlignment()) { switch (getTextAlignment()) {
case TEXT_DIRECTION_INHERIT: case TEXT_DIRECTION_INHERIT:
return (mParent != null); return (mParent != null);
@ -16808,31 +16805,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} }
/** /**
* Called when text alignment has been resolved. Subclasses that care about text alignment * Reset resolved text alignment.
* resolution should override this method.
* *
* The default implementation does nothing. * @hide
*/
public void onResolvedTextAlignmentChanged() {
}
/**
* Reset resolved text alignment. Text alignment can be resolved with a call to
* getResolvedTextAlignment(). Will call {@link View#onResolvedTextAlignmentReset} when
* reset is done.
*/ */
public void resetResolvedTextAlignment() { public void resetResolvedTextAlignment() {
// Reset any previous text alignment resolution // Reset any previous text alignment resolution
mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK); mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK);
onResolvedTextAlignmentReset();
}
/**
* Called when text alignment is reset. Subclasses that care about text alignment reset should
* override this method and do a reset of the text alignment of their children. The default
* implementation does nothing.
*/
public void onResolvedTextAlignmentReset() {
} }
/** /**

View File

@ -5257,36 +5257,23 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
} }
} }
/**
* @hide
*/
@Override @Override
public void onResolvedLayoutDirectionReset() { public void resetResolvedLayoutDirection() {
super.resetResolvedLayoutDirection();
// Take care of resetting the children resolution too // Take care of resetting the children resolution too
final int count = getChildCount(); int count = getChildCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final View child = getChildAt(i); final View child = getChildAt(i);
if (child.getLayoutDirection() == LAYOUT_DIRECTION_INHERIT) { if (child.getLayoutDirection() == LAYOUT_DIRECTION_INHERIT) {
child.resetResolvedLayoutDirection(); child.resetResolvedLayoutDirection();
} }
}
}
@Override
public void onResolvedTextDirectionReset() {
// Take care of resetting the children resolution too
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getTextDirection() == TEXT_DIRECTION_INHERIT) { if (child.getTextDirection() == TEXT_DIRECTION_INHERIT) {
child.resetResolvedTextDirection(); child.resetResolvedTextDirection();
} }
}
}
@Override
public void onResolvedTextAlignmentReset() {
// Take care of resetting the children resolution too
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getTextAlignment() == TEXT_ALIGNMENT_INHERIT) { if (child.getTextAlignment() == TEXT_ALIGNMENT_INHERIT) {
child.resetResolvedTextAlignment(); child.resetResolvedTextAlignment();
} }

View File

@ -308,6 +308,9 @@ public abstract class AbsSeekBar extends ProgressBar {
thumb.setBounds(left, topBound, left + thumbWidth, bottomBound); thumb.setBounds(left, topBound, left + thumbWidth, bottomBound);
} }
/**
* @hide
*/
@Override @Override
public void onResolveDrawables(int layoutDirection) { public void onResolveDrawables(int layoutDirection) {
super.onResolveDrawables(layoutDirection); super.onResolveDrawables(layoutDirection);

View File

@ -680,7 +680,7 @@ public class ImageView extends View {
d.setState(getDrawableState()); d.setState(getDrawableState());
} }
d.setLevel(mLevel); d.setLevel(mLevel);
d.setLayoutDirection(getLayoutDirection()); d.setLayoutDirection(getResolvedLayoutDirection());
mDrawableWidth = d.getIntrinsicWidth(); mDrawableWidth = d.getIntrinsicWidth();
mDrawableHeight = d.getIntrinsicHeight(); mDrawableHeight = d.getIntrinsicHeight();
applyColorMod(); applyColorMod();

View File

@ -565,6 +565,9 @@ public class ProgressBar extends View {
if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState(); if (mIndeterminateDrawable != null) mIndeterminateDrawable.jumpToCurrentState();
} }
/**
* @hide
*/
@Override @Override
public void onResolveDrawables(int layoutDirection) { public void onResolveDrawables(int layoutDirection) {
final Drawable d = mCurrentDrawable; final Drawable d = mCurrentDrawable;

View File

@ -1354,7 +1354,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
}; };
@Override @Override
public void onResolvedLayoutDirectionChanged() { public void onRtlPropertiesChanged() {
mQueryTextView.setLayoutDirection(getResolvedLayoutDirection()); mQueryTextView.setLayoutDirection(getResolvedLayoutDirection());
} }

View File

@ -5635,7 +5635,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} }
@Override @Override
public void onResolvedLayoutDirectionReset() { public void onRtlPropertiesChanged() {
if (mLayoutAlignment != null) { if (mLayoutAlignment != null) {
if (mResolvedTextAlignment == TEXT_ALIGNMENT_VIEW_START || if (mResolvedTextAlignment == TEXT_ALIGNMENT_VIEW_START ||
mResolvedTextAlignment == TEXT_ALIGNMENT_VIEW_END) { mResolvedTextAlignment == TEXT_ALIGNMENT_VIEW_END) {
@ -5733,7 +5733,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} }
if (mTextDir == null) { if (mTextDir == null) {
resolveTextDirection(); mTextDir = getTextDirectionHeuristic();
} }
mLayout = makeSingleLayout(wantWidth, boring, ellipsisWidth, alignment, shouldEllipsize, mLayout = makeSingleLayout(wantWidth, boring, ellipsisWidth, alignment, shouldEllipsize,
@ -5995,7 +5995,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
BoringLayout.Metrics hintBoring = UNKNOWN_BORING; BoringLayout.Metrics hintBoring = UNKNOWN_BORING;
if (mTextDir == null) { if (mTextDir == null) {
resolveTextDirection(); getTextDirectionHeuristic();
} }
int des = -1; int des = -1;
@ -8181,13 +8181,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return mEditor.mInBatchEditControllers; return mEditor.mInBatchEditControllers;
} }
@Override TextDirectionHeuristic getTextDirectionHeuristic() {
public void onResolvedTextDirectionChanged() {
if (hasPasswordTransformationMethod()) { if (hasPasswordTransformationMethod()) {
// TODO: take care of the content direction to show the password text and dots justified // TODO: take care of the content direction to show the password text and dots justified
// to the left or to the right // to the left or to the right
mTextDir = TextDirectionHeuristics.LOCALE; return TextDirectionHeuristics.LOCALE;
return;
} }
// Always need to resolve layout direction first // Always need to resolve layout direction first
@ -8198,24 +8196,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
switch (textDir) { switch (textDir) {
default: default:
case TEXT_DIRECTION_FIRST_STRONG: case TEXT_DIRECTION_FIRST_STRONG:
mTextDir = (defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL : return (defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL :
TextDirectionHeuristics.FIRSTSTRONG_LTR); TextDirectionHeuristics.FIRSTSTRONG_LTR);
break;
case TEXT_DIRECTION_ANY_RTL: case TEXT_DIRECTION_ANY_RTL:
mTextDir = TextDirectionHeuristics.ANYRTL_LTR; return TextDirectionHeuristics.ANYRTL_LTR;
break;
case TEXT_DIRECTION_LTR: case TEXT_DIRECTION_LTR:
mTextDir = TextDirectionHeuristics.LTR; return TextDirectionHeuristics.LTR;
break;
case TEXT_DIRECTION_RTL: case TEXT_DIRECTION_RTL:
mTextDir = TextDirectionHeuristics.RTL; return TextDirectionHeuristics.RTL;
break;
case TEXT_DIRECTION_LOCALE: case TEXT_DIRECTION_LOCALE:
mTextDir = TextDirectionHeuristics.LOCALE; return TextDirectionHeuristics.LOCALE;
break;
} }
} }
/**
* @hide
*/
@Override @Override
public void onResolveDrawables(int layoutDirection) { public void onResolveDrawables(int layoutDirection) {
// No need to resolve twice // No need to resolve twice

View File

@ -161,6 +161,9 @@ public class ActionBarContainer extends FrameLayout {
} }
} }
/**
* @hide
*/
@Override @Override
public void onResolveDrawables(int layoutDirection) { public void onResolveDrawables(int layoutDirection) {
super.onResolveDrawables(layoutDirection); super.onResolveDrawables(layoutDirection);