Improve RTL APIs
- follow changed / reset pattern
Change-Id: I1c5e9b39196029bd78add2ab13b984da124822ca
diff --git a/api/current.txt b/api/current.txt
index 4a607cb..d683da1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -23344,10 +23344,12 @@
method protected void onLayout(boolean, int, int, int, int);
method protected void onMeasure(int, int);
method protected void onOverScrolled(int, int, boolean, boolean);
+ method public void onPaddingChanged(int);
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
- method public void onResetResolvedTextDirection();
- method public void onResolvePadding(int);
- method public void onResolveTextDirection();
+ method public void onResolvedLayoutDirectionChanged();
+ method public void onResolvedLayoutDirectionReset();
+ method public void onResolvedTextDirectionChanged();
+ method public void onResolvedTextDirectionReset();
method protected void onRestoreInstanceState(android.os.Parcelable);
method protected android.os.Parcelable onSaveInstanceState();
method protected void onScrollChanged(int, int, int, int);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 740ea12..1e6bca5 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -9598,10 +9598,19 @@
// Set to resolved
mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED;
+ onResolvedLayoutDirectionChanged();
}
/**
- * Force padding depending on layout direction.
+ * Called when layout direction has been resolved.
+ *
+ * The default implementation does nothing.
+ */
+ public void onResolvedLayoutDirectionChanged() {
+ }
+
+ /**
+ * Resolve padding depending on layout direction.
*/
public void resolvePadding() {
// If the user specified the absolute padding (either with android:padding or
@@ -9645,7 +9654,7 @@
mUserPaddingBottom = (mUserPaddingBottom >= 0) ? mUserPaddingBottom : mPaddingBottom;
recomputePadding();
- onResolvePadding(resolvedLayoutDirection);
+ onPaddingChanged(resolvedLayoutDirection);
}
/**
@@ -9656,7 +9665,7 @@
* @param layoutDirection the direction of the layout
*
*/
- public void onResolvePadding(int layoutDirection) {
+ public void onPaddingChanged(int layoutDirection) {
}
/**
@@ -9674,20 +9683,29 @@
}
/**
- * 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.
+ * Reset the resolved layout direction. Will call {@link View#onResolvedLayoutDirectionReset}
+ * when reset is done.
*/
public void resetResolvedLayoutDirection() {
// Reset the current View resolution
mPrivateFlags2 &= ~LAYOUT_DIRECTION_RESOLVED;
+ 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
@@ -14137,8 +14155,8 @@
}
/**
- * Resolve the text direction. Will call {@link View#onResolveTextDirection()} when resolution
- * is done.
+ * Resolve the text direction. Will call {@link View#onResolvedTextDirectionChanged} when
+ * resolution is done.
*/
public void resolveTextDirection() {
if (mResolvedTextDirection != TEXT_DIRECTION_INHERIT) {
@@ -14152,24 +14170,26 @@
} else {
mResolvedTextDirection = TEXT_DIRECTION_FIRST_STRONG;
}
- onResolveTextDirection();
+ onResolvedTextDirectionChanged();
}
/**
* Called when text direction has been resolved. Subclasses that care about text direction
- * resolution should override this method. The default implementation does nothing.
+ * resolution should override this method.
+ *
+ * The default implementation does nothing.
*/
- public void onResolveTextDirection() {
+ public void onResolvedTextDirectionChanged() {
}
/**
* Reset resolved text direction. Text direction can be resolved with a call to
- * getResolvedTextDirection(). Will call {@link View#onResetResolvedTextDirection()} when
+ * getResolvedTextDirection(). Will call {@link View#onResolvedTextDirectionReset} when
* reset is done.
*/
public void resetResolvedTextDirection() {
mResolvedTextDirection = TEXT_DIRECTION_INHERIT;
- onResetResolvedTextDirection();
+ onResolvedTextDirectionReset();
}
/**
@@ -14177,7 +14197,7 @@
* override this method and do a reset of the text direction of their children. The default
* implementation does nothing.
*/
- public void onResetResolvedTextDirection() {
+ public void onResolvedTextDirectionReset() {
}
//
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 7d96a19..0c63286 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -4920,9 +4920,7 @@
}
@Override
- public void resetResolvedLayoutDirection() {
- super.resetResolvedLayoutDirection();
-
+ public void onResolvedLayoutDirectionReset() {
// Take care of resetting the children resolution too
final int count = getChildCount();
for (int i = 0; i < count; i++) {
@@ -4934,7 +4932,7 @@
}
@Override
- public void onResetResolvedTextDirection() {
+ public void onResolvedTextDirectionReset() {
// Take care of resetting the children resolution too
final int count = getChildCount();
for (int i = 0; i < count; i++) {
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index dd53325..603cea1 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -143,7 +143,7 @@
}
@Override
- public void onResolvePadding(int layoutDirection) {
+ public void onPaddingChanged(int layoutDirection) {
int newPadding = (mCheckMarkDrawable != null) ?
mCheckMarkWidth + mBasePadding : mBasePadding;
mNeedRequestlayout |= (mPaddingRight != newPadding);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 385c7c7..56a0d1e 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8715,7 +8715,7 @@
}
@Override
- public void onResolveTextDirection() {
+ public void onResolvedTextDirectionChanged() {
if (hasPasswordTransformationMethod()) {
// TODO: take care of the content direction to show the password text and dots justified
// to the left or to the right