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

Commit 5b00f558 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am b3bffa80: Merge "Follow up on issue #8159072: Spinner widget should be...

am b3bffa80: Merge "Follow up on issue #8159072: Spinner widget should be RTL\'ized" into jb-mr2-dev

* commit 'b3bffa80':
  Follow up on issue #8159072: Spinner widget should be RTL'ized
parents 70f30d21 b3bffa80
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1219,12 +1219,12 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     * Return the layout direction. Will be either {@link View#LAYOUT_DIRECTION_LTR} or
     * Return the layout direction. Will be either {@link View#LAYOUT_DIRECTION_LTR} or
     * {@link View#LAYOUT_DIRECTION_RTL}.
     * {@link View#LAYOUT_DIRECTION_RTL}.
     *
     *
     * @return the layout direction
     * @return Returns {@link View#LAYOUT_DIRECTION_RTL} if the configuration
     * is {@link #SCREENLAYOUT_LAYOUTDIR_RTL}, otherwise {@link View#LAYOUT_DIRECTION_LTR}.
     */
     */
    public int getLayoutDirection() {
    public int getLayoutDirection() {
        // We need to substract one here as the configuration values are using "0" as undefined thus
        return (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) == SCREENLAYOUT_LAYOUTDIR_RTL
        // having LRT set to "1" and RTL set to "2"
                ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR;
        return ((screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK) >> SCREENLAYOUT_LAYOUTDIR_SHIFT) - 1;
    }
    }


    /**
    /**
+39 −18
Original line number Original line Diff line number Diff line
@@ -1985,13 +1985,14 @@ public class Resources {
        }
        }
    }
    }


    static private final int VARYING_CONFIGS = ActivityInfo.activityInfoConfigToNative(
    private boolean verifyPreloadConfig(int changingConfigurations, int allowVarying,
            ActivityInfo.CONFIG_LAYOUT_DIRECTION);
            int resourceId, String name) {

        // We allow preloading of resources even if they vary by font scale (which
    private boolean verifyPreloadConfig(int changingConfigurations, int resourceId, String name) {
        // doesn't impact resource selection) or density (which we handle specially by
        // We dont want to preloadd a Drawable when there is both a LTR and RTL version of it
        // simply turning off all preloading), as well as any other configs specified
        // by the caller.
        if (((changingConfigurations&~(ActivityInfo.CONFIG_FONT_SCALE |
        if (((changingConfigurations&~(ActivityInfo.CONFIG_FONT_SCALE |
                ActivityInfo.CONFIG_DENSITY)) & VARYING_CONFIGS) != 0) {
                ActivityInfo.CONFIG_DENSITY)) & ~allowVarying) != 0) {
            String resName;
            String resName;
            try {
            try {
                resName = getResourceName(resourceId);
                resName = getResourceName(resourceId);
@@ -2017,6 +2018,9 @@ public class Resources {
        return true;
        return true;
    }
    }


    static private final int LAYOUT_DIR_CONFIG = ActivityInfo.activityInfoConfigToNative(
            ActivityInfo.CONFIG_LAYOUT_DIRECTION);

    /*package*/ Drawable loadDrawable(TypedValue value, int id)
    /*package*/ Drawable loadDrawable(TypedValue value, int id)
            throws NotFoundException {
            throws NotFoundException {


@@ -2041,11 +2045,12 @@ public class Resources {
        if (dr != null) {
        if (dr != null) {
            return dr;
            return dr;
        }
        }
        final int layoutDirection = mConfiguration.getLayoutDirection();
        Drawable.ConstantState cs;
        Drawable.ConstantState cs = isColorDrawable
        if (isColorDrawable) {
                ? sPreloadedColorDrawables.get(key)
            cs = sPreloadedColorDrawables.get(key);
                : (sPreloadedDensity == mConfiguration.densityDpi
        } else {
                        ? sPreloadedDrawables[layoutDirection].get(key) : null);
            cs = sPreloadedDrawables[mConfiguration.getLayoutDirection()].get(key);
        }
        if (cs != null) {
        if (cs != null) {
            dr = cs.newDrawable(this);
            dr = cs.newDrawable(this);
        } else {
        } else {
@@ -2119,12 +2124,26 @@ public class Resources {
            cs = dr.getConstantState();
            cs = dr.getConstantState();
            if (cs != null) {
            if (cs != null) {
                if (mPreloading) {
                if (mPreloading) {
                    if (verifyPreloadConfig(cs.getChangingConfigurations(), value.resourceId,
                    final int changingConfigs = cs.getChangingConfigurations();
                            "drawable")) {
                    if (isColorDrawable) {
                    if (isColorDrawable) {
                        if (verifyPreloadConfig(changingConfigs, 0, value.resourceId,
                                "drawable")) {
                            sPreloadedColorDrawables.put(key, cs);
                            sPreloadedColorDrawables.put(key, cs);
                        }
                    } else {
                        if (verifyPreloadConfig(changingConfigs,
                                LAYOUT_DIR_CONFIG, value.resourceId, "drawable")) {
                            if ((changingConfigs&LAYOUT_DIR_CONFIG) == 0) {
                                // If this resource does not vary based on layout direction,
                                // we can put it in all of the preload maps.
                                sPreloadedDrawables[0].put(key, cs);
                                sPreloadedDrawables[1].put(key, cs);
                            } else {
                            } else {
                            sPreloadedDrawables[layoutDirection].put(key, cs);
                                // Otherwise, only in the layout dir we loaded it for.
                                final LongSparseArray<Drawable.ConstantState> preloads
                                        = sPreloadedDrawables[mConfiguration.getLayoutDirection()];
                                preloads.put(key, cs);
                            }
                        }
                        }
                    }
                    }
                } else {
                } else {
@@ -2190,7 +2209,8 @@ public class Resources {


            csl = ColorStateList.valueOf(value.data);
            csl = ColorStateList.valueOf(value.data);
            if (mPreloading) {
            if (mPreloading) {
                if (verifyPreloadConfig(value.changingConfigurations, value.resourceId, "color")) {
                if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId,
                        "color")) {
                    sPreloadedColorStateLists.put(key, csl);
                    sPreloadedColorStateLists.put(key, csl);
                }
                }
            }
            }
@@ -2239,7 +2259,8 @@ public class Resources {


        if (csl != null) {
        if (csl != null) {
            if (mPreloading) {
            if (mPreloading) {
                if (verifyPreloadConfig(value.changingConfigurations, value.resourceId, "color")) {
                if (verifyPreloadConfig(value.changingConfigurations, 0, value.resourceId,
                        "color")) {
                    sPreloadedColorStateLists.put(key, csl);
                    sPreloadedColorStateLists.put(key, csl);
                }
                }
            } else {
            } else {