Example usage for android.view ContextThemeWrapper ContextThemeWrapper

List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper

Introduction

In this page you can find the example usage for android.view ContextThemeWrapper ContextThemeWrapper.

Prototype

public ContextThemeWrapper(Context base, Resources.Theme theme) 

Source Link

Document

Creates a new context wrapper with the specified theme.

Usage

From source file:pl.mrwojtek.sensrec.app.NetworkDialog.java

@NonNull
@Override/*w  w  w . j a v a  2s. c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), R.style.DialogTheme);
    LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(context);
    View view = inflater.inflate(R.layout.network_dialog, null);

    initializePortEdit(view);
    networkSwitch = (SwitchCompat) view.findViewById(R.id.network_switch);
    protocolSpinner = (Spinner) view.findViewById(R.id.protocol_spinner);
    hostEdit = (EditText) view.findViewById(R.id.host_edit);
    portEdit = (EditText) view.findViewById(R.id.port_edit);

    TextView protocolCaption = (TextView) view.findViewById(R.id.protocol_caption);
    MaterialUtils.transformForSpinner(protocolCaption);

    if (savedInstanceState == null) {
        setFromPreferences();
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTheme);
    //builder.setTitle(R.string.network_title);
    builder.setView(view);
    builder.setNegativeButton(R.string.action_cancel, null);
    builder.setPositiveButton(R.string.action_ok, this);
    return MaterialUtils.fixTitle(context, builder.create(), null);
}

From source file:com.uprayzner.mediator.fragments.common.ActionFragment.java

private LayoutInflater getCustomInflater(@StyleRes int style) {
    final Context contextWrapper = new ContextThemeWrapper(getActivity(), style);
    return LayoutInflater.from(contextWrapper);

}

From source file:com.tortel.deploytrack.dialog.AboutDialog.java

@NonNull
@Override//from   w w  w  .j a  v a  2  s . c o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context wrappedContext = new ContextThemeWrapper(getActivity(), R.style.Theme_DeployThemeLight);

    MaterialDialog.Builder builder = new MaterialDialog.Builder(wrappedContext);

    LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(wrappedContext);
    @SuppressLint("InflateParams")
    View view = inflater.inflate(R.layout.dialog_about, null);
    TextView text = (TextView) view.findViewById(R.id.about_view);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        text.setText(Html.fromHtml(readRawTextFile(getContent()), Html.FROM_HTML_MODE_LEGACY));
    } else {
        //noinspection deprecation
        text.setText(Html.fromHtml(readRawTextFile(getContent())));
    }
    Linkify.addLinks(text, Linkify.ALL);
    text.setMovementMethod(LinkMovementMethod.getInstance());

    builder.customView(view, false);
    builder.title(getTitleString());
    builder.positiveText(R.string.close);

    return builder.build();
}

From source file:com.innoc.secureline.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {// w w  w  . j  ava 2 s . c  o  m
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), SecureLineService.class);
            intent.setAction(SecureLineService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), SecureLine.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.mindprotectionkit.freephone.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {//from ww w.  jav  a2 s . com
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}

From source file:com.example.spellingcoach.tabs.students.StudentsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // create ContextThemeWrapper from the original Activity Context with the custom theme
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.studentsListViewTheme);

    // clone the inflater using the ContextThemeWrapper
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

    return localInflater.inflate(R.layout.fragment_tab_students, container, false);
}

From source file:butter.droid.fragments.dialog.LoadingDetailDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return LayoutInflater.from(new ContextThemeWrapper(getActivity(), R.style.Theme_Butter))
            .inflate(R.layout.fragment_loading_detail, container, false);
}

From source file:pct.droid.fragments.dialog.LoadingDetailDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return LayoutInflater.from(new ContextThemeWrapper(getActivity(), R.style.Theme_PopcornTime))
            .inflate(R.layout.fragment_loading_detail, container, false);
}

From source file:com.monmonja.library.utils.ViewUtils.java

public static AlertDialog.Builder buildAlertDialogWithStyle(Context context, int styleResId) {
    final AlertDialog.Builder builder;
    // 11 is honeycomb where builder(context, resId) is allowed
    if (Build.VERSION.SDK_INT >= 11) {
        builder = new AlertDialog.Builder(context, styleResId);
    } else {//from  w w w . ja va 2  s  .c  om
        builder = new AlertDialog.Builder(new ContextThemeWrapper(context, styleResId));
    }
    return builder;
}

From source file:com.securecomcode.voice.ui.UpgradeCallDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(
                new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog));
    } else {//from  w  ww .j  ava 2  s. co  m
        builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog);
    }

    builder.setIcon(R.drawable.red_call);

    final String upgradeString = getActivity().getResources()
            .getString(R.string.RedPhoneChooser_upgrade_to_redphone);
    SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString);
    titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(),
            Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    builder.setTitle(titleBuilder);

    builder.setMessage(
            R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call);

    builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(getActivity(), RedPhoneService.class);
            intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL);
            intent.putExtra(Constants.REMOTE_NUMBER, number);
            getActivity().startService(intent);

            Intent activityIntent = new Intent();
            activityIntent.setClass(getActivity(), RedPhone.class);
            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(activityIntent);

            getActivity().finish();
        }
    });

    builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            CallChooserCache.getInstance().addInsecureChoice(number);

            Intent intent = new Intent("android.intent.action.CALL",
                    Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    AlertDialog alert = builder.create();

    alert.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });

            ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    getActivity().finish();
                }
            });
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);

            Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
        }
    });

    return alert;
}