Search in sources :

Example 11 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class Presentation method createPresentationContext.

private static Context createPresentationContext(Context outerContext, Display display, int theme) {
    if (outerContext == null) {
        throw new IllegalArgumentException("outerContext must not be null");
    }
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }
    Context displayContext = outerContext.createDisplayContext(display);
    if (theme == 0) {
        TypedValue outValue = new TypedValue();
        displayContext.getTheme().resolveAttribute(com.android.internal.R.attr.presentationTheme, outValue, true);
        theme = outValue.resourceId;
    }
    // Derive the display's window manager from the outer window manager.
    // We do this because the outer window manager have some extra information
    // such as the parent window, which is important if the presentation uses
    // an application window type.
    final WindowManagerImpl outerWindowManager = (WindowManagerImpl) outerContext.getSystemService(Context.WINDOW_SERVICE);
    final WindowManagerImpl displayWindowManager = outerWindowManager.createPresentationWindowManager(displayContext);
    return new ContextThemeWrapper(displayContext, theme) {

        @Override
        public Object getSystemService(String name) {
            if (Context.WINDOW_SERVICE.equals(name)) {
                return displayWindowManager;
            }
            return super.getSystemService(name);
        }
    };
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) WindowManagerImpl(android.view.WindowManagerImpl) TypedValue(android.util.TypedValue)

Example 12 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project Libraries-for-Android-Developers by eoecn.

the class ActionBarSherlockCompat method initializePanelMenu.

private boolean initializePanelMenu() {
    //getContext();
    Context context = mActivity;
    // If we have an action bar, initialize the menu with a context themed for it.
    if (wActionBar != null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = context.getTheme();
        currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0) /*&& context.getThemeResId() != targetThemeRes*/
        {
            context = new ContextThemeWrapper(context, targetThemeRes);
        }
    }
    mMenu = new MenuBuilder(context);
    mMenu.setCallback(this);
    return true;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) MenuBuilder(com.actionbarsherlock.internal.view.menu.MenuBuilder) TypedValue(android.util.TypedValue)

Example 13 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project Libraries-for-Android-Developers by eoecn.

the class ActionBarSherlockNative method getThemedContext.

@Override
protected Context getThemedContext() {
    Context context = mActivity;
    TypedValue outValue = new TypedValue();
    mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme, outValue, true);
    if (outValue.resourceId != 0) {
        //We are unable to test if this is the same as our current theme
        //so we just wrap it and hope that if the attribute was specified
        //then the user is intentionally specifying an alternate theme.
        context = new ContextThemeWrapper(context, outValue.resourceId);
    }
    return context;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) TypedValue(android.util.TypedValue)

Example 14 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project Libraries-for-Android-Developers by eoecn.

the class ActionBarImpl method getThemedContext.

public Context getThemedContext() {
    if (mThemedContext == null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = mContext.getTheme();
        currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0) {
            //XXX && mContext.getThemeResId() != targetThemeRes) {
            mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
        } else {
            mThemedContext = mContext;
        }
    }
    return mThemedContext;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 15 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project cw-omnibus by commonsguy.

the class ActionBarSherlockCompat method initializePanelMenu.

private boolean initializePanelMenu() {
    //getContext();
    Context context = mActivity;
    // If we have an action bar, initialize the menu with a context themed for it.
    if (wActionBar != null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = context.getTheme();
        currentTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0) /*&& context.getThemeResId() != targetThemeRes*/
        {
            context = new ContextThemeWrapper(context, targetThemeRes);
        }
    }
    mMenu = new MenuBuilder(context);
    mMenu.setCallback(this);
    return true;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) MenuBuilder(com.actionbarsherlock.internal.view.menu.MenuBuilder) TypedValue(android.util.TypedValue)

Aggregations

ContextThemeWrapper (android.view.ContextThemeWrapper)121 Context (android.content.Context)64 TypedValue (android.util.TypedValue)52 Resources (android.content.res.Resources)32 View (android.view.View)22 TypedArray (android.content.res.TypedArray)16 TextView (android.widget.TextView)16 AlertDialog (android.app.AlertDialog)15 DialogInterface (android.content.DialogInterface)13 OnClickListener (android.content.DialogInterface.OnClickListener)11 Drawable (android.graphics.drawable.Drawable)11 LayoutInflater (android.view.LayoutInflater)10 RecyclerView (android.support.v7.widget.RecyclerView)8 ImageView (android.widget.ImageView)8 MenuBuilder (com.actionbarsherlock.internal.view.menu.MenuBuilder)7 Point (android.graphics.Point)6 ViewStub (android.view.ViewStub)6 WindowManagerImpl (android.view.WindowManagerImpl)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5