summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amith Yamasani <yamasani@google.com> 2013-08-07 20:15:10 -0700
committer Amith Yamasani <yamasani@google.com> 2013-08-08 13:42:02 -0700
commitd8415f4bf061000b049143b4f48b96b2005450bb (patch)
tree0f6b0f7deb0fbb985e6f03efa96b6df876bd870f
parent7a605df3137ee571dec855761c0cb15b28513d26 (diff)
Developer option to force RTL layout
Make sure screen layout changes are taken into account in Configuration diffs. Initialize the SystemProperty from Global settings on startup of ActivityManagerService. TextUtils checks the override flag to decide if the default layout direction should be forced to RTL. Bug: 10244047 Change-Id: I23a2583d790a355060d0d898ba44e5f7dc896b46
-rw-r--r--core/java/android/content/res/Configuration.java11
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/java/android/text/TextUtils.java8
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java8
4 files changed, 29 insertions, 4 deletions
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 6318e3893767..1c281387fce8 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -786,10 +786,14 @@ public final class Configuration implements Parcelable, Comparable<Configuration
// 2 most significant bits in screenLayout).
setLayoutDirection(locale);
}
+ if (delta.screenLayout != 0 && screenLayout != delta.screenLayout) {
+ changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
+ setLayoutDirection(locale);
+ }
if (delta.userSetLocale && (!userSetLocale || ((changed & ActivityInfo.CONFIG_LOCALE) != 0)))
{
- userSetLocale = true;
changed |= ActivityInfo.CONFIG_LOCALE;
+ userSetLocale = true;
}
if (delta.touchscreen != TOUCHSCREEN_UNDEFINED
&& touchscreen != delta.touchscreen) {
@@ -933,6 +937,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
changed |= ActivityInfo.CONFIG_LOCALE;
changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
}
+ if (delta.screenLayout != 0 && screenLayout != delta.screenLayout) {
+ changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
+ }
if (delta.touchscreen != TOUCHSCREEN_UNDEFINED
&& touchscreen != delta.touchscreen) {
changed |= ActivityInfo.CONFIG_TOUCHSCREEN;
@@ -1005,7 +1012,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
public static boolean needNewResources(int configChanges, int interestingChanges) {
return (configChanges & (interestingChanges|ActivityInfo.CONFIG_FONT_SCALE)) != 0;
}
-
+
/**
* @hide Return true if the sequence of 'other' is better than this. Assumes
* that 'this' is your current sequence and 'other' is a new one you have
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 130123fb9d2c..0f7bf9302d3d 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -5624,6 +5624,12 @@ public final class Settings {
public static final String SELINUX_STATUS = "selinux_status";
/**
+ * Developer setting to force RTL layout.
+ * @hide
+ */
+ public static final String DEVELOPMENT_FORCE_RTL = "debug.force_rtl";
+
+ /**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
*
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index e2035c2afe1f..596ca8c958ec 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -19,6 +19,8 @@ package android.text;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.SystemProperties;
+import android.provider.Settings;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.AlignmentSpan;
import android.text.style.BackgroundColorSpan;
@@ -1743,8 +1745,10 @@ public class TextUtils {
return View.LAYOUT_DIRECTION_RTL;
}
}
-
- return View.LAYOUT_DIRECTION_LTR;
+ // If forcing into RTL layout mode, return RTL as default, else LTR
+ return SystemProperties.getBoolean(Settings.Global.DEVELOPMENT_FORCE_RTL, false)
+ ? View.LAYOUT_DIRECTION_RTL
+ : View.LAYOUT_DIRECTION_LTR;
}
/**
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 3d8843e7f502..b950cd0df8a7 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -8453,9 +8453,17 @@ public final class ActivityManagerService extends ActivityManagerNative
resolver, Settings.Global.WAIT_FOR_DEBUGGER, 0) != 0;
boolean alwaysFinishActivities = Settings.Global.getInt(
resolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) != 0;
+ boolean forceRtl = Settings.Global.getInt(
+ resolver, Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0;
+ // Transfer any global setting for forcing RTL layout, into a System Property
+ SystemProperties.set(Settings.Global.DEVELOPMENT_FORCE_RTL, forceRtl ? "1":"0");
Configuration configuration = new Configuration();
Settings.System.getConfiguration(resolver, configuration);
+ if (forceRtl) {
+ // This will take care of setting the correct layout direction flags
+ configuration.setLayoutDirection(configuration.locale);
+ }
synchronized (this) {
mDebugApp = mOrigDebugApp = debugApp;