List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper
public ContextThemeWrapper(Context base, Resources.Theme theme)
From source file:android.support.v7ox.app.ToolbarActionBar.java
private void ensureListMenuPresenter(Menu menu) { if (mListMenuPresenter == null && (menu instanceof MenuBuilder)) { MenuBuilder mb = (MenuBuilder) menu; Context context = mDecorToolbar.getContext(); final TypedValue outValue = new TypedValue(); final Resources.Theme widgetTheme = context.getResources().newTheme(); widgetTheme.setTo(context.getTheme()); // First apply the actionBarPopupTheme widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme_ox, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); }/* ww w . ja v a2 s .c o m*/ // Apply the panelMenuListTheme widgetTheme.resolveAttribute(R.attr.panelMenuListTheme_ox, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); } else { widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true); } context = new ContextThemeWrapper(context, 0); context.getTheme().setTo(widgetTheme); // Finally create the list menu presenter mListMenuPresenter = new ListMenuPresenter(context, R.layout.abc_list_menu_item_layout); mListMenuPresenter.setCallback(new PanelMenuPresenterCallback()); mb.addMenuPresenter(mListMenuPresenter); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static Context getActionBarContext(final Context context) { final TypedArray a = context.obtainStyledAttributes( new int[] { android.R.attr.actionBarTheme, android.R.attr.actionBarWidgetTheme }); final int resId; try {/*from www .j a va 2s . c o m*/ resId = a.hasValue(0) ? a.getResourceId(0, 0) : a.getResourceId(1, 0); } finally { a.recycle(); } if (resId == 0) return context; return new ContextThemeWrapper(context, resId); }
From source file:com.gh4a.IssueListActivity.java
private void showAssigneesDialog() { final String[] assignees = new String[mAssignees.size() + 1]; assignees[0] = getResources().getString(R.string.issue_filter_by_any_assignee); String checkedAssignee = mFilterData.get("assignee"); int checkedItem = 0; for (int i = 1; i <= mAssignees.size(); i++) { User u = mAssignees.get(i - 1);//from w w w . j av a 2 s. com assignees[i] = u.getLogin(); if (u.getLogin().equalsIgnoreCase(checkedAssignee)) { checkedItem = i; } } int dialogTheme = Gh4Application.THEME == R.style.DefaultTheme ? R.style.Theme_Sherlock_Dialog : R.style.Theme_Sherlock_Light_Dialog; AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, dialogTheme)); builder.setCancelable(true); builder.setTitle(R.string.issue_filter_by_assignee); builder.setSingleChoiceItems(assignees, checkedItem, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { mFilterData.remove("assignee"); } else { mFilterData.put("assignee", assignees[which]); } } }); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); reloadIssueList(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); builder.show(); }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
private void updateButtonOpenLink() { final View btnOpenLink = menu.findViewById(R.id.BtnOpenLink); btnOpenLink.setOnClickListener(new OnClickListener() { @Override/*from w ww. ja v a 2s .c o m*/ public void onClick(final View view) { if (listener != null) { final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr); switch (setting.getData()) { case SettingBrowserChoice.BROWSER_CHOICE_UNKNOWN: final LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Dialog)); final View popupView = inflater.inflate(R.layout.browser_choice_popup, null); final CheckBox checkBox = (CheckBox) popupView.findViewById(R.id.CheckBoxDontShowAgain); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { popupView.findViewById(R.id.Hint).setVisibility(View.VISIBLE); } }); final String items[] = new String[3]; items[0] = context.getString(R.string.TxtBuiltInMobilized); items[1] = context.getString(R.string.TxtBuiltInOriginal); items[2] = context.getString(R.string.TxtExternalOriginal); builder.setTitle(R.string.TxtChooseBrowser); builder.setView(popupView); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { switch (which) { case 0: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED); } dialog.dismiss(); break; case 1: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL); } dialog.dismiss(); break; case 2: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL); } dialog.dismiss(); break; default: break; } } }); builder.setNegativeButton(context.getString(R.string.TxtCancel), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); builder.show(); break; case SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); break; case SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } break; case SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } break; default: break; } } } }); }
From source file:com.tr4android.support.extension.widget.FloatingActionMenu.java
private void createLabels() { Context context = new ContextThemeWrapper(getContext(), mLabelsStyle); for (int i = 0; i < mButtonsCount; i++) { FloatingActionButton button = (FloatingActionButton) getChildAt(i); CharSequence title = button.getContentDescription(); if (button == mMainButton || title == null || button.getTag(R.id.fab_label) != null) continue; LabelView label = new LabelView(context); label.setAnimationOffset(mMaxButtonWidth / 2f + mLabelsMargin); label.setTextAppearance(getContext(), mLabelsStyle); label.setText(title);//w w w . j av a2 s .c o m addView(label); button.setTag(R.id.fab_label, label); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static Context getDialogThemedContext(final Context context) { return new ContextThemeWrapper(context, getDialogThemeResource(context)); }
From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java
@Override public Context getThemedContext() { if (mThemedContext != null) return mThemedContext; final Context context = getActivity(); final int themeResource = ThemeUtils.getDrawerThemeResource(context); return mThemedContext = new ContextThemeWrapper(context, themeResource); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
@SuppressLint("NewApi") private static View createMessageDialogContentsView(Activity activity, MessageDescription messageDescription) { Context context = activity;/*from w ww . jav a 2 s .co m*/ final AlertDialog.Builder builder; // Workaround for dialog theme problems if (android.os.Build.VERSION.SDK_INT > 10) { builder = new AlertDialog.Builder(context); context = builder.getContext(); } else { context = new ContextThemeWrapper(context, android.R.style.Theme_Dialog); builder = new AlertDialog.Builder(context); } builder.setTitle("Send feedback"); final LayoutInflater inflater = LayoutInflater.from(context); final View dialogContentsView = inflater.inflate(R.layout.updater_dialog_message, null, false); final TextView textView = (TextView) dialogContentsView.findViewById(R.id.dialog_update_message_text); final ImageView imageView = (ImageView) dialogContentsView.findViewById(R.id.dialog_update_message_image); final ViewSwitcher switcher = (ViewSwitcher) dialogContentsView .findViewById(R.id.dialog_update_message_switcher); String messageText = null; String imageUrl = null; if (messageDescription != null) { messageText = messageDescription.get(MessageDescription.KEY_MESSAGE); imageUrl = messageDescription.get(MessageDescription.KEY_IMAGE_URL); } if (Utilities.isNullOrEmpty(messageText)) { textView.setVisibility(View.GONE); } else { textView.setText(messageText); } if (Utilities.isNullOrEmpty(imageUrl)) { switcher.setVisibility(View.GONE); } else { URI uri; try { uri = new URI(imageUrl); } catch (URISyntaxException e) { uri = null; } if (uri != null) { DownloadRequest request = new DownloadRequest(); request.setUri(uri); request.setDownloadHandler(new DownloadHandler() { @Override public void onSuccess(byte[] result) { // Load image from byte array final Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length); imageView.setImageBitmap(bitmap); // Hide progress bar and display image if (switcher != null) { switcher.setDisplayedChild(1); } } @Override public void onProgress(Integer percent) { } @Override public void onFail(Exception ex) { Log.e("Message image couldn't be loaded", ex); } @Override public void onCancelled() { } }); HttpClient client = Utilities.createClient("Turkcell Updater/1.0 ", false); try { request.executeAsync(client); } catch (Exception e) { Log.e("Message image couldn't be loaded", e); } } else { switcher.setVisibility(View.GONE); } } return dialogContentsView; }
From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java
private boolean initializePanelMenu() { Context context = mActivity;//getContext(); // 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); }//from w w w. ja v a2s . c o m } mMenu = new MenuBuilder(context); mMenu.setCallback(this); return true; }
From source file:com.yattatech.dbtc.activity.MainScreen.java
private void showRestoreMessage() { new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom)) .setTitle(R.string.lab_confirm).setMessage(R.string.lab_data_lost).setCancelable(false) .setPositiveButton(R.string.lab_yes, new DialogInterface.OnClickListener() { /*/*from w w w . j a v a 2s . com*/ * (non-Javadoc) * @see android.content.DialogInterface.OnClickListener#onClick(android.content.DialogInterface, int) */ @Override public void onClick(DialogInterface dialog, int buttonId) { startRestoreAsync(); } }).setNegativeButton(R.string.lab_no, new DialogInterface.OnClickListener() { /* * (non-Javadoc) * @see android.content.DialogInterface.OnClickListener#onClick(android.content.DialogInterface, int) */ @Override public void onClick(DialogInterface dialog, int buttonId) { } }).create().show(); }