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

Commit c1d52792 authored by Alan Viverette's avatar Alan Viverette
Browse files

Add API for obtaining changing configurations bitmask from Theme

Required to know when to reload the system context's theme in response
to configuration changes, and thus needed to support the DayNight theme.

Bug: 20267825
Change-Id: I7df5e28b7a6d8b611ea030032544cf4800788514
parent 5551aca2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9833,6 +9833,7 @@ package android.content.res {
  public final class Resources.Theme {
    method public void applyStyle(int, boolean);
    method public void dump(int, java.lang.String, java.lang.String);
    method public int getChangingConfigurations();
    method public android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException;
    method public android.content.res.Resources getResources();
    method public android.content.res.TypedArray obtainStyledAttributes(int[]);
+1 −0
Original line number Diff line number Diff line
@@ -10127,6 +10127,7 @@ package android.content.res {
  public final class Resources.Theme {
    method public void applyStyle(int, boolean);
    method public void dump(int, java.lang.String, java.lang.String);
    method public int getChangingConfigurations();
    method public android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException;
    method public android.content.res.Resources getResources();
    method public android.content.res.TypedArray obtainStyledAttributes(int[]);
+21 −3
Original line number Diff line number Diff line
@@ -570,8 +570,11 @@ public class ActivityInfo extends ComponentInfo
        Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
        Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
    };
    /** @hide

    /**
     * Convert Java change bits to native.
     *
     * @hide
     */
    public static int activityInfoConfigToNative(int input) {
        int output = 0;
@@ -583,6 +586,21 @@ public class ActivityInfo extends ComponentInfo
        return output;
    }

    /**
     * Convert native change bits to Java.
     *
     * @hide
     */
    public static int activityInfoConfigNativeToJava(int input) {
        int output = 0;
        for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
            if ((input & CONFIG_NATIVE_BITS[i]) != 0) {
                output |= (1 << i);
            }
        }
        return output;
    }

    /**
     * @hide
     * Unfortunately some developers (OpenFeint I am looking at you) have
+1 −0
Original line number Diff line number Diff line
@@ -789,6 +789,7 @@ public final class AssetManager implements AutoCloseable {
                                                                TypedValue outValue,
                                                                boolean resolve);
    /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix);
    /*package*/ native static final int getThemeChangingConfigurations(long theme);

    private native final long openXmlAssetNative(int cookie, String fileName);

+13 −0
Original line number Diff line number Diff line
@@ -1730,6 +1730,19 @@ public class Resources {
            return Resources.this.getDrawable(id, this);
        }

        /**
         * Returns a bit mask of configuration changes that will impact this
         * theme (and thus require completely reloading it).
         *
         * @return a bit mask of configuration changes, as defined by
         *         {@link ActivityInfo}
         * @see ActivityInfo
         */
        public int getChangingConfigurations() {
            final int nativeChangingConfig = AssetManager.getThemeChangingConfigurations(mTheme);
            return ActivityInfo.activityInfoConfigNativeToJava(nativeChangingConfig);
        }

        /**
         * Print contents of this theme out to the log.  For debugging only.
         * 
Loading