Search in sources :

Example 71 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project k-9 by k9mail.

the class MessageCompose method onCreateDialog.

@Override
public Dialog onCreateDialog(int id) {
    switch(id) {
        case DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE:
            return new AlertDialog.Builder(this).setTitle(R.string.save_or_discard_draft_message_dlg_title).setMessage(R.string.save_or_discard_draft_message_instructions_fmt).setPositiveButton(R.string.save_draft_action, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
                    checkToSaveDraftAndSave();
                }
            }).setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
                    onDiscard();
                }
            }).create();
        case DIALOG_CONFIRM_DISCARD_ON_BACK:
            return new AlertDialog.Builder(this).setTitle(R.string.confirm_discard_draft_message_title).setMessage(R.string.confirm_discard_draft_message).setPositiveButton(R.string.cancel_action, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
                }
            }).setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
                    Toast.makeText(MessageCompose.this, getString(R.string.message_discarded_toast), Toast.LENGTH_LONG).show();
                    onDiscard();
                }
            }).create();
        case DIALOG_CHOOSE_IDENTITY:
            Context context = new ContextThemeWrapper(this, (K9.getK9Theme() == K9.Theme.LIGHT) ? R.style.Theme_K9_Dialog_Light : R.style.Theme_K9_Dialog_Dark);
            Builder builder = new AlertDialog.Builder(context);
            builder.setTitle(R.string.send_as);
            final IdentityAdapter adapter = new IdentityAdapter(context);
            builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    IdentityContainer container = (IdentityContainer) adapter.getItem(which);
                    onAccountChosen(container.account, container.identity);
                }
            });
            return builder.create();
        case DIALOG_CONFIRM_DISCARD:
            {
                return new AlertDialog.Builder(this).setTitle(R.string.dialog_confirm_delete_title).setMessage(R.string.dialog_confirm_delete_message).setPositiveButton(R.string.dialog_confirm_delete_confirm_button, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        onDiscard();
                    }
                }).setNegativeButton(R.string.dialog_confirm_delete_cancel_button, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).create();
            }
    }
    return super.onCreateDialog(id);
}
Also used : AlertDialog(android.app.AlertDialog) Context(android.content.Context) IdentityAdapter(com.fsck.k9.activity.compose.IdentityAdapter) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) PgpMessageBuilder(com.fsck.k9.message.PgpMessageBuilder) SimpleMessageBuilder(com.fsck.k9.message.SimpleMessageBuilder) MessageBuilder(com.fsck.k9.message.MessageBuilder) Builder(android.app.AlertDialog.Builder) OnClickListener(android.view.View.OnClickListener) IdentityContainer(com.fsck.k9.activity.compose.IdentityAdapter.IdentityContainer) SuppressLint(android.annotation.SuppressLint)

Example 72 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project AndroidTreeView by bmelnychuk.

the class AndroidTreeView method getView.

public View getView(int style) {
    final ViewGroup view;
    if (style > 0) {
        ContextThemeWrapper newContext = new ContextThemeWrapper(mContext, style);
        view = use2dScroll ? new TwoDScrollView(newContext) : new ScrollView(newContext);
    } else {
        view = use2dScroll ? new TwoDScrollView(mContext) : new ScrollView(mContext);
    }
    Context containerContext = mContext;
    if (containerStyle != 0 && applyForRoot) {
        containerContext = new ContextThemeWrapper(mContext, containerStyle);
    }
    final LinearLayout viewTreeItems = new LinearLayout(containerContext, null, containerStyle);
    viewTreeItems.setId(R.id.tree_items);
    viewTreeItems.setOrientation(LinearLayout.VERTICAL);
    view.addView(viewTreeItems);
    mRoot.setViewHolder(new TreeNode.BaseNodeViewHolder(mContext) {

        @Override
        public View createNodeView(TreeNode node, Object value) {
            return null;
        }

        @Override
        public ViewGroup getNodeItemsView() {
            return viewTreeItems;
        }
    });
    expandNode(mRoot, false);
    return view;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) ScrollView(android.widget.ScrollView) ViewGroup(android.view.ViewGroup) TreeNode(com.unnamed.b.atv.model.TreeNode) ScrollView(android.widget.ScrollView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 73 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project AndroidTreeView by bmelnychuk.

the class TreeNodeWrapperView method init.

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    nodeContainer = new RelativeLayout(getContext());
    nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeContainer.setId(R.id.node_header);
    ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
    nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
    nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeItemsContainer.setId(R.id.node_items);
    nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
    nodeItemsContainer.setVisibility(View.GONE);
    addView(nodeContainer);
    addView(nodeItemsContainer);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) RelativeLayout(android.widget.RelativeLayout) LinearLayout(android.widget.LinearLayout)

Example 74 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project Caldroid by roomorama.

the class WeekdayArrayAdapter method getLayoutInflater.

private LayoutInflater getLayoutInflater(Context context, int themeResource) {
    Context wrapped = new ContextThemeWrapper(context, themeResource);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return inflater.cloneInContext(wrapped);
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater)

Example 75 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project Carbon by ZieIony.

the class Snackbar method initSnackbar.

private void initSnackbar(int defStyleAttr) {
    setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(android.R.color.transparent)));
    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(defStyleAttr, outValue, true);
    int theme = outValue.resourceId;
    Context themedContext = new ContextThemeWrapper(getContext(), theme);
    View.inflate(themedContext, R.layout.carbon_snackbar, this);
    content = (LinearLayout) findViewById(R.id.carbon_snackbarContent);
    content.setElevation(getResources().getDimension(R.dimen.carbon_elevationSnackbar));
    message = (TextView) content.findViewById(R.id.carbon_messageText);
    button = (Button) content.findViewById(R.id.carbon_actionButton);
    handler = new Handler();
}
Also used : Context(android.content.Context) ColorDrawable(android.graphics.drawable.ColorDrawable) ContextThemeWrapper(android.view.ContextThemeWrapper) Handler(android.os.Handler) TypedValue(android.util.TypedValue)

Aggregations

ContextThemeWrapper (android.view.ContextThemeWrapper)122 Context (android.content.Context)65 TypedValue (android.util.TypedValue)52 Resources (android.content.res.Resources)32 View (android.view.View)22 TextView (android.widget.TextView)17 TypedArray (android.content.res.TypedArray)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