Search in sources :

Example 11 with Theme

use of android.content.res.Resources.Theme in project android_frameworks_base by crdroidandroid.

the class ActivityThread method handleConfigurationChanged.

final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {
    int configDiff = 0;
    synchronized (mResourcesManager) {
        if (mPendingConfiguration != null) {
            if (!mPendingConfiguration.isOtherSeqNewer(config)) {
                config = mPendingConfiguration;
                mCurDefaultDisplayDpi = config.densityDpi;
                updateDefaultDensity();
            }
            mPendingConfiguration = null;
        }
        if (config == null) {
            return;
        }
        if (DEBUG_CONFIGURATION)
            Slog.v(TAG, "Handle configuration changed: " + config);
        mResourcesManager.applyConfigurationToResourcesLocked(config, compat);
        updateLocaleListFromAppContext(mInitialApplication.getApplicationContext(), mResourcesManager.getConfiguration().getLocales());
        if (mConfiguration == null) {
            mConfiguration = new Configuration();
        }
        if (!mConfiguration.isOtherSeqNewer(config) && compat == null) {
            return;
        }
        configDiff = mConfiguration.updateFrom(config);
        config = applyCompatConfiguration(mCurDefaultDisplayDpi);
        final Theme systemTheme = getSystemContext().getTheme();
        if ((systemTheme.getChangingConfigurations() & configDiff) != 0) {
            systemTheme.rebase();
        }
    }
    ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config);
    freeTextLayoutCachesIfNeeded(configDiff);
    if (callbacks != null) {
        final int N = callbacks.size();
        for (int i = 0; i < N; i++) {
            ComponentCallbacks2 cb = callbacks.get(i);
            if (cb instanceof Activity) {
                // If callback is an Activity - call corresponding method to consider override
                // config and avoid onConfigurationChanged if it hasn't changed.
                Activity a = (Activity) cb;
                performConfigurationChangedForActivity(mActivities.get(a.getActivityToken()), config, REPORT_TO_ACTIVITY);
            } else {
                performConfigurationChanged(cb, null, config, null, REPORT_TO_ACTIVITY);
            }
        }
    }
}
Also used : Configuration(android.content.res.Configuration) Theme(android.content.res.Resources.Theme) ComponentCallbacks2(android.content.ComponentCallbacks2)

Example 12 with Theme

use of android.content.res.Resources.Theme in project android_frameworks_base by AOSPA.

the class ActivityThread method handleConfigurationChanged.

final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {
    int configDiff = 0;
    synchronized (mResourcesManager) {
        if (mPendingConfiguration != null) {
            if (!mPendingConfiguration.isOtherSeqNewer(config)) {
                config = mPendingConfiguration;
                mCurDefaultDisplayDpi = config.densityDpi;
                updateDefaultDensity();
            }
            mPendingConfiguration = null;
        }
        if (config == null) {
            return;
        }
        if (DEBUG_CONFIGURATION)
            Slog.v(TAG, "Handle configuration changed: " + config);
        mResourcesManager.applyConfigurationToResourcesLocked(config, compat);
        updateLocaleListFromAppContext(mInitialApplication.getApplicationContext(), mResourcesManager.getConfiguration().getLocales());
        if (mConfiguration == null) {
            mConfiguration = new Configuration();
        }
        if (!mConfiguration.isOtherSeqNewer(config) && compat == null) {
            return;
        }
        configDiff = mConfiguration.updateFrom(config);
        config = applyCompatConfiguration(mCurDefaultDisplayDpi);
        final Theme systemTheme = getSystemContext().getTheme();
        if ((systemTheme.getChangingConfigurations() & configDiff) != 0) {
            systemTheme.rebase();
        }
    }
    ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config);
    freeTextLayoutCachesIfNeeded(configDiff);
    if (callbacks != null) {
        final int N = callbacks.size();
        for (int i = 0; i < N; i++) {
            ComponentCallbacks2 cb = callbacks.get(i);
            if (cb instanceof Activity) {
                // If callback is an Activity - call corresponding method to consider override
                // config and avoid onConfigurationChanged if it hasn't changed.
                Activity a = (Activity) cb;
                performConfigurationChangedForActivity(mActivities.get(a.getActivityToken()), config, REPORT_TO_ACTIVITY);
            } else {
                performConfigurationChanged(cb, null, config, null, REPORT_TO_ACTIVITY);
            }
        }
    }
}
Also used : Configuration(android.content.res.Configuration) Theme(android.content.res.Resources.Theme) ComponentCallbacks2(android.content.ComponentCallbacks2)

Example 13 with Theme

use of android.content.res.Resources.Theme in project android_frameworks_base by AOSPA.

the class PhoneWindow method initializePanelMenu.

/**
     * Initializes the menu associated with the given panel feature state. You
     * must at the very least set PanelFeatureState.menu to the Menu to be
     * associated with the given panel state. The default implementation creates
     * a new menu for the panel state.
     *
     * @param st The panel whose menu is being initialized.
     * @return Whether the initialization was successful.
     */
protected boolean initializePanelMenu(final PanelFeatureState st) {
    Context context = getContext();
    // If we have an action bar, initialize the menu with the right theme.
    if ((st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR) && mDecorContentParent != null) {
        final TypedValue outValue = new TypedValue();
        final Theme baseTheme = context.getTheme();
        baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
        Theme widgetTheme = null;
        if (outValue.resourceId != 0) {
            widgetTheme = context.getResources().newTheme();
            widgetTheme.setTo(baseTheme);
            widgetTheme.applyStyle(outValue.resourceId, true);
            widgetTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        } else {
            baseTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        }
        if (outValue.resourceId != 0) {
            if (widgetTheme == null) {
                widgetTheme = context.getResources().newTheme();
                widgetTheme.setTo(baseTheme);
            }
            widgetTheme.applyStyle(outValue.resourceId, true);
        }
        if (widgetTheme != null) {
            context = new ContextThemeWrapper(context, 0);
            context.getTheme().setTo(widgetTheme);
        }
    }
    final MenuBuilder menu = new MenuBuilder(context);
    menu.setCallback(this);
    st.setMenu(menu);
    return true;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) Theme(android.content.res.Resources.Theme) ContextMenuBuilder(com.android.internal.view.menu.ContextMenuBuilder) MenuBuilder(com.android.internal.view.menu.MenuBuilder) TypedValue(android.util.TypedValue)

Example 14 with Theme

use of android.content.res.Resources.Theme in project k-9 by k9mail.

the class FoldableLinearLayout method processAttributes.

/**
     * Load given attributes to inner variables,
     * 
     * @param context
     * @param attrs
     */
private void processAttributes(Context context, AttributeSet attrs) {
    Theme theme = context.getTheme();
    TypedValue outValue = new TypedValue();
    boolean found = theme.resolveAttribute(R.attr.iconActionCollapse, outValue, true);
    if (found) {
        mIconActionCollapseId = outValue.resourceId;
    }
    found = theme.resolveAttribute(R.attr.iconActionExpand, outValue, true);
    if (found) {
        mIconActionExpandId = outValue.resourceId;
    }
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FoldableLinearLayout, 0, 0);
        mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
        mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
        a.recycle();
    }
    // If any attribute isn't found then set a default one
    mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel;
    mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel;
}
Also used : TypedArray(android.content.res.TypedArray) Theme(android.content.res.Resources.Theme) TypedValue(android.util.TypedValue)

Example 15 with Theme

use of android.content.res.Resources.Theme in project GreenDroid by cyrilmottier.

the class ActionBarDrawable method getColorFromTheme.

private static int getColorFromTheme(Context context, int attr, int defaultColor) {
    synchronized (sTypedValue) {
        final TypedValue value = sTypedValue;
        final Theme theme = context.getTheme();
        if (theme != null) {
            theme.resolveAttribute(attr, value, true);
            if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) {
                return value.data;
            }
        }
        return defaultColor;
    }
}
Also used : Theme(android.content.res.Resources.Theme) TypedValue(android.util.TypedValue)

Aggregations

Theme (android.content.res.Resources.Theme)33 Resources (android.content.res.Resources)11 Context (android.content.Context)10 Configuration (android.content.res.Configuration)9 TypedValue (android.util.TypedValue)9 Method (java.lang.reflect.Method)7 ComponentCallbacks2 (android.content.ComponentCallbacks2)5 NotFoundException (android.content.res.Resources.NotFoundException)5 XmlResourceParser (android.content.res.XmlResourceParser)5 ContextThemeWrapper (android.view.ContextThemeWrapper)5 ContextMenuBuilder (com.android.internal.view.menu.ContextMenuBuilder)5 MenuBuilder (com.android.internal.view.menu.MenuBuilder)5 INotificationManager (android.app.INotificationManager)4 RemoteException (android.os.RemoteException)4 IMountService (android.os.storage.IMountService)4 DisplayMetrics (android.util.DisplayMetrics)4 WindowManager (android.view.WindowManager)4 ILockSettings (com.android.internal.widget.ILockSettings)4 AccessibilityManagerService (com.android.server.accessibility.AccessibilityManagerService)4 AudioService (com.android.server.audio.AudioService)4