summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 23:11:50 +0000
committercramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 23:11:50 +0000
commit0ac6a7f40cfa637f3dc9fc09b6261301234a012a (patch)
tree458e6d84987cd5f71e25af50ccf16d5cda0aa682
parent7f62364f24b0f0f16442df7d2f913d5ff2ee6ed2 (diff)
downloadchromium_src-0ac6a7f40cfa637f3dc9fc09b6261301234a012a.zip
chromium_src-0ac6a7f40cfa637f3dc9fc09b6261301234a012a.tar.gz
chromium_src-0ac6a7f40cfa637f3dc9fc09b6261301234a012a.tar.bz2
Merge 191113 "Added two ICU RTL function jni bindings."
> Added two ICU RTL function jni bindings. > > BUG=222672 > > > Review URL: https://chromiumcodereview.appspot.com/12665004 TBR=kkimlabs@chromium.org Review URL: https://codereview.chromium.org/14760003 git-svn-id: svn://svn.chromium.org/chrome/branches/1453/src@198004 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/android/java/src/org/chromium/base/LocaleUtils.java27
-rw-r--r--base/android/locale_utils.cc11
-rw-r--r--base/i18n/rtl.h7
3 files changed, 42 insertions, 3 deletions
diff --git a/base/android/java/src/org/chromium/base/LocaleUtils.java b/base/android/java/src/org/chromium/base/LocaleUtils.java
index 51dc303..e0f1829 100644
--- a/base/android/java/src/org/chromium/base/LocaleUtils.java
+++ b/base/android/java/src/org/chromium/base/LocaleUtils.java
@@ -9,8 +9,14 @@ import java.util.Locale;
/**
* This class provides the locale related methods for the native library.
*/
+@JNINamespace("base::android")
public class LocaleUtils {
+ // This is mirrored from base/i18n/rtl.h. Please keep in sync.
+ public static final int UNKNOWN_DIRECTION = 0;
+ public static final int RIGHT_TO_LEFT = 1;
+ public static final int LEFT_TO_RIGHT = 2;
+
private LocaleUtils() { /* cannot be instantiated */ }
/**
@@ -46,4 +52,25 @@ public class LocaleUtils {
private static String getDisplayNameForLocale(Locale locale, Locale displayLocale) {
return locale.getDisplayName(displayLocale);
}
+
+ /**
+ * Jni binding to base::i18n::IsRTL.
+ * @return true if the current locale is right to left.
+ */
+ public static boolean isRtl() {
+ return nativeIsRTL();
+ }
+
+ /**
+ * Jni binding to base::i18n::GetFirstStrongCharacterDirection
+ * @param string String to decide the direction.
+ * @return One of the UNKNOWN_DIRECTION, RIGHT_TO_LEFT, and LEFT_TO_RIGHT.
+ */
+ public static int getFirstStrongCharacterDirection(String string) {
+ return nativeGetFirstStrongCharacterDirection(string);
+ }
+
+ private static native boolean nativeIsRTL();
+
+ private static native int nativeGetFirstStrongCharacterDirection(String string);
}
diff --git a/base/android/locale_utils.cc b/base/android/locale_utils.cc
index f9c030d..6bf0686 100644
--- a/base/android/locale_utils.cc
+++ b/base/android/locale_utils.cc
@@ -7,6 +7,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "jni/LocaleUtils_jni.h"
@@ -15,6 +16,16 @@
namespace base {
namespace android {
+jboolean IsRTL(JNIEnv* env, jclass clazz) {
+ return base::i18n::IsRTL();
+}
+
+jint GetFirstStrongCharacterDirection(JNIEnv* env, jclass clazz,
+ jstring string) {
+ return base::i18n::GetFirstStrongCharacterDirection(
+ base::android::ConvertJavaStringToUTF16(env, string));
+}
+
std::string GetDefaultLocale() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> locale = Java_LocaleUtils_getDefaultLocale(env);
diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h
index d4e364b..6a79dbd 100644
--- a/base/i18n/rtl.h
+++ b/base/i18n/rtl.h
@@ -26,10 +26,11 @@ const char16 kPopDirectionalFormatting = 0x202C;
const char16 kLeftToRightOverride = 0x202D;
const char16 kRightToLeftOverride = 0x202E;
+// Locale.java mirrored this enum TextDirection. Please keep in sync.
enum TextDirection {
- UNKNOWN_DIRECTION,
- RIGHT_TO_LEFT,
- LEFT_TO_RIGHT,
+ UNKNOWN_DIRECTION = 0,
+ RIGHT_TO_LEFT = 1,
+ LEFT_TO_RIGHT = 2,
};
// Get the locale that the currently running process has been configured to use.