summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/util/LayoutDirection.java44
-rw-r--r--core/java/android/view/View.java9
-rw-r--r--core/java/android/widget/ImageView.java9
-rw-r--r--core/java/android/widget/TextView.java2
4 files changed, 60 insertions, 4 deletions
diff --git a/core/java/android/util/LayoutDirection.java b/core/java/android/util/LayoutDirection.java
new file mode 100644
index 0000000..e37d2f2
--- /dev/null
+++ b/core/java/android/util/LayoutDirection.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+/**
+ * An interface for defining layout directions. A layout direction can be left-to-right (LTR)
+ * or right-to-left (RTL). It can also be inherited (from a parent) or deduced from the default
+ * language script of a locale.
+ */
+public interface LayoutDirection {
+ /**
+ * Horizontal layout direction is from Left to Right.
+ */
+ public static final int LTR = 0;
+
+ /**
+ * Horizontal layout direction is from Right to Left.
+ */
+ public static final int RTL = 1;
+
+ /**
+ * Horizontal layout direction is inherited.
+ */
+ public static final int INHERIT = 2;
+
+ /**
+ * Horizontal layout direction is deduced from the default language script for the locale.
+ */
+ public static final int LOCALE = 3;
+}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 299c4a2..7624b56 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -51,6 +51,7 @@ import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.FloatProperty;
+import android.util.LayoutDirection;
import android.util.Log;
import android.util.LongSparseLongArray;
import android.util.Pools.SynchronizedPool;
@@ -1801,25 +1802,25 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* Horizontal layout direction of this view is from Left to Right.
* Use with {@link #setLayoutDirection}.
*/
- public static final int LAYOUT_DIRECTION_LTR = 0;
+ public static final int LAYOUT_DIRECTION_LTR = LayoutDirection.LTR;
/**
* Horizontal layout direction of this view is from Right to Left.
* Use with {@link #setLayoutDirection}.
*/
- public static final int LAYOUT_DIRECTION_RTL = 1;
+ public static final int LAYOUT_DIRECTION_RTL = LayoutDirection.RTL;
/**
* Horizontal layout direction of this view is inherited from its parent.
* Use with {@link #setLayoutDirection}.
*/
- public static final int LAYOUT_DIRECTION_INHERIT = 2;
+ public static final int LAYOUT_DIRECTION_INHERIT = LayoutDirection.INHERIT;
/**
* Horizontal layout direction of this view is from deduced from the default language
* script for the locale. Use with {@link #setLayoutDirection}.
*/
- public static final int LAYOUT_DIRECTION_LOCALE = 3;
+ public static final int LAYOUT_DIRECTION_LOCALE = LayoutDirection.LOCALE;
/**
* Bit shift to get the horizontal layout direction. (bits after DRAG_HOVERED)
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 33fd8ce..3e53b91 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -732,6 +732,15 @@ public class ImageView extends View {
}
}
+ @Override
+ public void onRtlPropertiesChanged(int layoutDirection) {
+ super.onRtlPropertiesChanged(layoutDirection);
+
+ if (mDrawable != null) {
+ mDrawable.setLayoutDirection(layoutDirection);
+ }
+ }
+
private static final Matrix.ScaleToFit[] sS2FArray = {
Matrix.ScaleToFit.FILL,
Matrix.ScaleToFit.START,
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 816bb18..3181164 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -2042,6 +2042,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
dr.mDrawableRightInitial = right;
}
+ resetResolvedDrawables();
+ resolveDrawables();
invalidate();
requestLayout();
}