use of android.view.ContextThemeWrapper in project ActionBarSherlock by JakeWharton.
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 u2020 by JakeWharton.
the class DebugViewContainer method forActivity.
@Override
public ViewGroup forActivity(final Activity activity) {
activity.setContentView(R.layout.debug_activity_frame);
final ViewHolder viewHolder = new ViewHolder();
ButterKnife.bind(viewHolder, activity);
final Context drawerContext = new ContextThemeWrapper(activity, R.style.Theme_U2020_Debug);
final DebugView debugView = new DebugView(drawerContext);
viewHolder.debugDrawer.addView(debugView);
// Set up the contextual actions to watch views coming in and out of the content area.
ContextualDebugActions contextualActions = debugView.getContextualDebugActions();
contextualActions.setActionClickListener(v -> viewHolder.drawerLayout.closeDrawers());
viewHolder.content.setOnHierarchyChangeListener(HierarchyTreeChangeListener.wrap(contextualActions));
viewHolder.drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, GravityCompat.END);
viewHolder.drawerLayout.setDrawerListener(new DebugDrawerLayout.SimpleDrawerListener() {
@Override
public void onDrawerOpened(View drawerView) {
debugView.onDrawerOpened();
}
});
// Clean up any old screenshots.
TelescopeLayout.cleanUp(activity);
viewHolder.telescopeLayout.setLens(new BugReportLens(activity, lumberYard));
// If you have not seen the debug drawer before, show it with a message
if (!seenDebugDrawer.get()) {
viewHolder.drawerLayout.postDelayed(() -> {
viewHolder.drawerLayout.openDrawer(GravityCompat.END);
Toast.makeText(drawerContext, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show();
}, 1000);
seenDebugDrawer.set(true);
}
final CompositeSubscription subscriptions = new CompositeSubscription();
setupMadge(viewHolder, subscriptions);
setupScalpel(viewHolder, subscriptions);
final Application app = activity.getApplication();
app.registerActivityLifecycleCallbacks(new EmptyActivityLifecycleCallbacks() {
@Override
public void onActivityDestroyed(Activity lifecycleActivity) {
if (lifecycleActivity == activity) {
subscriptions.unsubscribe();
app.unregisterActivityLifecycleCallbacks(this);
}
}
});
riseAndShine(activity);
return viewHolder.content;
}
use of android.view.ContextThemeWrapper in project AndroidChromium by JackyAndroid.
the class AboutChromePreferences method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setTitle(R.string.prefs_about_chrome);
addPreferencesFromResource(R.xml.about_chrome_preferences);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
ChromeBasePreference deprecationWarning = new ChromeBasePreference(new ContextThemeWrapper(getActivity(), R.style.DeprecationWarningPreferenceTheme));
deprecationWarning.setOrder(-1);
deprecationWarning.setTitle(R.string.deprecation_warning);
deprecationWarning.setIcon(R.drawable.exclamation_triangle);
getPreferenceScreen().addPreference(deprecationWarning);
}
PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
Preference p = findPreference(PREF_APPLICATION_VERSION);
p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
p = findPreference(PREF_OS_VERSION);
p.setSummary(versionStrings.getOSVersion());
p = findPreference(PREF_LEGAL_INFORMATION);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
p.setSummary(getString(R.string.legal_information_summary, currentYear));
}
use of android.view.ContextThemeWrapper in project Ushahidi_Android by ushahidi.
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 Ushahidi_Android by ushahidi.
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;
}
Aggregations