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);
}
};
}
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;
}
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;
}
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;
}
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;
}
Aggregations