Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8415f4b authored by Amith Yamasani's avatar Amith Yamasani
Browse files

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
parent 7a605df3
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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;
+6 −0
Original line number Diff line number Diff line
@@ -5623,6 +5623,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.
+6 −2
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -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;