Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

In this page you can find the example usage for android.app Dialog Dialog.

Prototype

public Dialog(@NonNull Context context, @StyleRes int themeResId) 

Source Link

Document

Creates a dialog window that uses a custom dialog style.

Usage

From source file:com.kkbox.toolkit.dialog.KKDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
        @Override//ww  w  . j  av a 2 s . com
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onPositive();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNeutral();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNegative();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    switch (dialogType) {
    case Type.PROGRESSING_DIALOG:
        ProgressDialog progressDialog;
        if (theme != -1) {
            progressDialog = new ProgressDialog(getActivity(), theme);
        } else {
            progressDialog = new ProgressDialog(getActivity());
        }
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage(message);
        progressDialog.setIndeterminate(true);
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(listener != null);
        return progressDialog;
    case Type.ALERT_DIALOG:
        AlertDialog.Builder builder;
        AlertDialog alertDialog;
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.THREE_CHOICE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNeutralButton(neutralButtonText, neutralListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.YES_OR_NO_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.SELECT_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setSingleChoiceItems(entries, selectedIndex, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (!isDismissed) {
                    if (listener != null) {
                        listener.onEvent(id);
                    }
                    dismiss();
                    onDialogFinishedByUser();
                    isDismissed = true;
                }
            }
        });
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        builder.setView(customizeView);

        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }
        if (!TextUtils.isEmpty(positiveButtonText)) {
            builder.setPositiveButton(positiveButtonText, positiveListener);
        }
        if (!TextUtils.isEmpty(neutralButtonText)) {
            builder.setNeutralButton(neutralButtonText, neutralListener);
        }
        if (!TextUtils.isEmpty(negativeButtonText)) {
            builder.setNegativeButton(negativeButtonText, negativeListener);
        }
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_FULLSCREEN_DIALOG:
        Dialog dialog;
        if (theme != -1) {
            dialog = new Dialog(getActivity(), theme);
        } else {
            dialog = new Dialog(getActivity(), android.R.style.Theme_NoTitleBar);
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        dialog.setContentView(customizeView);
        return dialog;
    }
    return null;
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

/**
 * Dialog ???//from ww w.  java 2 s . co  m
 * @param mContext
 * @return
 */
private Dialog showLicenseChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_license_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.mystyle);

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.layout_rule:
                if (isAgree) {
                    isAgree = false;
                    ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose);
                    //                            TextView textView = (TextView)v.findViewById(R.id.tv_rule);
                    imageView.setImageResource(R.drawable.icon_choose);
                    //                            textView.setBackgroundColor(getResources().getColor(R.color.bg_gray_color_level_0));
                    //                            textView.setTextColor(getResources().getColor(R.color.tv_gray_color_level_3));
                } else {
                    isAgree = true;
                    ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose);
                    //                            TextView textView = (TextView)v.findViewById(R.id.tv_rule);
                    imageView.setImageResource(R.drawable.icon_choose_selected);
                    //                            textView.setBackgroundResource(R.drawable.btn_select_base_shape_0);
                    //                            textView.setTextColor(getResources().getColor(R.color.white_color));
                }
                break;
            }
            if (onLicenseDialogClickListener != null) {
                onLicenseDialogClickListener.onClick(v, isAgree);
            }
        }
    };

    TitleBar titleBar;
    SwipeRefreshLayout swipeLayout;
    final WebView webView;
    ProgressBar progressBar;
    LinearLayout layoutRule;
    LinearLayout layoutConfirm;

    titleBar = (TitleBar) convertView.findViewById(R.id.title_bar);
    swipeLayout = (SwipeRefreshLayout) convertView.findViewById(R.id.swipe_layout);
    webView = (WebView) convertView.findViewById(R.id.webView);
    progressBar = (ProgressBar) convertView.findViewById(R.id.progress_bar);
    layoutRule = (LinearLayout) convertView.findViewById(R.id.layout_rule);
    layoutConfirm = (LinearLayout) convertView.findViewById(R.id.layout_confirm);

    WebChromeClient client = new AppChromeWebClient(titleBar, progressBar, swipeLayout);
    webView.setWebChromeClient(client);
    webView.setWebViewClient(new AppWebClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(webViewURL);
    webView.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
                    webView.goBack(); //?
                    return true; //?
                }
            }
            return false;
        }
    });

    titleBar.initTitleBarInfo("", R.drawable.arrow_left, -1, "", "");
    titleBar.setOnTitleBarClickListener(new TitleBar.OnTitleBarClickListener() {
        @Override
        public void onLeftButtonClick(View v) {
            if (webView.canGoBack()) {
                webView.goBack(); //?
                return; //?
            }

            if (onLicenseDialogClickListener != null) {
                onLicenseDialogClickListener.onClick(v, isAgree);
                dismiss();
            }
        }

        @Override
        public void onRightButtonClick(View v) {

        }
    });
    UIUtils.initSwipeRefreshLayout(swipeLayout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            webView.reload();
        }
    });

    layoutConfirm.setOnClickListener(listener);
    layoutRule.setOnClickListener(listener);

    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java

private void initProtection() {

    if (authenticated || !SettingsActivity.isPinEnabled(this)) {
        return;//from   w ww . j  a va  2 s . c  om
    }
    final Dialog d = new Dialog(this, R.style.Theme_DailogPIN);
    d.setContentView(
            new PinViewHelper((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE), null, null) {
                public void onEnter(String password) {
                    super.onEnter(password);
                    if (SettingsActivity.checkPin(DocumentsActivity.this, password)) {
                        authenticated = true;
                        d.dismiss();
                    } else {
                        Toast.makeText(DocumentsActivity.this, getString(R.string.incorrect_pin),
                                Toast.LENGTH_SHORT).show();
                    }
                };

                public void onCancel() {
                    super.onCancel();
                    finish();
                    d.dismiss();
                };
            }.getView(), new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    PINDialogFragment pinFragment = new PINDialogFragment();
    pinFragment.setDialog(d);
    pinFragment.setCancelable(false);
    pinFragment.show(getFragmentManager(), "PIN Dialog");
}

From source file:com.stupid.method.app.DialogFragment.java

/**
 * Override to build your own custom Dialog container. This is typically
 * used to show an AlertDialog instead of a generic Dialog; when doing so,
 * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} does not need to
 * be implemented since the AlertDialog takes care of its own content.
 * /*from w ww .  j a  va 2 s  .com*/
 * <p>
 * This method will be called after {@link #onCreate(Bundle)} and before
 * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. The default
 * implementation simply instantiates and returns a {@link Dialog} class.
 * 
 * <p>
 * <em>Note: DialogFragment own the {@link Dialog#setOnCancelListener
 * Dialog.setOnCancelListener} and {@link Dialog#setOnDismissListener
 * Dialog.setOnDismissListener} callbacks.  You must not set them yourself.</em>
 * To find out about these events, override
 * {@link #onCancel(DialogInterface)} and
 * {@link #onDismiss(DialogInterface)}.
 * </p>
 * 
 * @param savedInstanceState
 *            The last saved instance state of the Fragment, or null if this
 *            is a freshly created Fragment.
 * 
 * @return Return a new Dialog instance to be displayed by the Fragment.
 */
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new Dialog(getActivity(), getTheme());
}

From source file:com.cloverstudio.spika.CreateGroupActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case GET_IMAGE_DIALOG:
        mGetImageDialog = new Dialog(CreateGroupActivity.this, R.style.TransparentDialogTheme);
        mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM);
        mGetImageDialog.setContentView(R.layout.dialog_get_image);

        // Grab the window of the dialog, and change the width
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        Window window = mGetImageDialog.getWindow();
        lp.copyFrom(window.getAttributes());
        // This makes the dialog take up the full width
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);/*from w  w  w . j av  a2s .  co m*/

        final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery);
        btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
        btnGallery.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent galleryIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                galleryIntent.putExtra("type", "gallery");
                galleryIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(galleryIntent);
                mGetImageDialog.dismiss();

            }
        });

        final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera);
        btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
        btnCamera.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent cameraIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                cameraIntent.putExtra("type", "camera");
                cameraIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(cameraIntent);
                mGetImageDialog.dismiss();

            }
        });

        final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto);
        btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
        btnRemovePhoto.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                mGroupAvatarId = "";
                gGroupImage = null;
                Utils.displayImage(mGroupAvatarId, mIvGroupImage, ImageLoader.LARGE,
                        R.drawable.group_stub_large, false);
                mGetImageDialog.dismiss();

            }
        });

        return mGetImageDialog;
    default:
        return null;
    }
}

From source file:info.hl.mediam.CreateGroupActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case GET_IMAGE_DIALOG:
        mGetImageDialog = new Dialog(CreateGroupActivity.this, R.style.TransparentDialogTheme);
        mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM);
        mGetImageDialog.setContentView(R.layout.dialog_get_image);

        // Grab the window of the dialog, and change the width
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        Window window = mGetImageDialog.getWindow();
        lp.copyFrom(window.getAttributes());
        // This makes the dialog take up the full width
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);/*w w  w  . ja  v  a2  s  . c om*/

        final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery);
        btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
        btnGallery.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent galleryIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                galleryIntent.putExtra("type", "gallery");
                galleryIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(galleryIntent);
                mGetImageDialog.dismiss();

            }
        });

        final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera);
        btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
        btnCamera.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent cameraIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class);
                cameraIntent.putExtra("type", "camera");
                cameraIntent.putExtra("createGroup", true);
                CreateGroupActivity.this.startActivity(cameraIntent);
                mGetImageDialog.dismiss();

            }
        });

        final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto);
        btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
        btnRemovePhoto.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                mGroupAvatarId = "";
                gGroupImage = null;
                Utils.displayImage(mGroupAvatarId, mIvGroupImage, ImageLoader.LARGE,
                        R.drawable.group_stub_large, false);
                mGetImageDialog.dismiss();

            }
        });

        return mGetImageDialog;
    default:
        return null;
    }
}

From source file:com.amaze.filemanager.fragments.preference_fragments.Preffrag.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.reset();//from  w  w  w .  j a  va2 s . c o  m
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    final int th1 = Integer.parseInt(sharedPref.getString("theme", "0"));
    theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1;
    findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).donate();
            return false;
        }
    });
    findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final String[] sort = getResources().getStringArray(R.array.columns);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.gridcolumnno);
            int current = Integer.parseInt(sharedPref.getString("columns", "-1"));
            current = current == -1 ? 0 : current;
            if (current != 0)
                current = current - 1;
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.theme);
            int current = Integer.parseInt(sharedPref.getString("theme", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("theme", "" + which).commit();
                    dialog.dismiss();
                    restartPC(getActivity());
                    return true;
                }
            });
            a.title(R.string.theme);
            a.build().show();
            return true;
        }
    });
    findPreference("colors").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).selectItem(1);
            return true;
        }
    });

    final CheckBx rootmode = (CheckBx) findPreference("rootmode");
    rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            boolean b = sharedPref.getBoolean("rootmode", false);
            if (b) {
                if (RootTools.isAccessGiven()) {
                    rootmode.setChecked(true);

                } else {
                    rootmode.setChecked(false);

                    Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                rootmode.setChecked(false);

            }

            return false;
        }
    });

    // Authors
    Preference preference4 = (Preference) findPreference("authors");
    preference4.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            skin = PreferenceUtils.getPrimaryColorString(sharedPref);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            if (theme == 1)
                a.theme(Theme.DARK);

            a.positiveText(R.string.close);
            a.positiveColor(fab_skin);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.authors, null);
            a.customView(view, true);
            a.title(R.string.authors);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                }
            });
            /*a.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
            });*/
            a.build().show();

            final Intent intent = new Intent(Intent.ACTION_VIEW);

            TextView googlePlus1 = (TextView) view.findViewById(R.id.googlePlus1);
            googlePlus1.setTextColor(Color.parseColor(skin));
            TextView googlePlus2 = (TextView) view.findViewById(R.id.googlePlus2);
            googlePlus2.setTextColor(Color.parseColor(skin));
            TextView git1 = (TextView) view.findViewById(R.id.git1);
            git1.setTextColor(Color.parseColor(skin));
            TextView git2 = (TextView) view.findViewById(R.id.git2);
            git2.setTextColor(Color.parseColor(skin));

            googlePlus1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/u/0/110424067388738907251/"));
                    startActivity(intent);
                }
            });
            googlePlus2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/+VishalNehra/"));
                    startActivity(intent);
                }
            });
            git1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/arpitkh96"));
                    startActivity(intent);
                }
            });
            git2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/vishal0071"));
                    startActivity(intent);
                }
            });

            // icon credits
            TextView textView = (TextView) view.findViewById(R.id.icon_credits);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setLinksClickable(true);
            textView.setText(Html.fromHtml(getActivity().getString(R.string.icon_credits)));

            return false;
        }
    });

    // Changelog
    Preference preference1 = (Preference) findPreference("changelog");
    preference1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.changelog);
            a.content(Html.fromHtml(getActivity().getString(R.string.changelog_version_9)
                    + getActivity().getString(R.string.changelog_change_9)
                    + getActivity().getString(R.string.changelog_version_8)
                    + getActivity().getString(R.string.changelog_change_8)
                    + getActivity().getString(R.string.changelog_version_7)
                    + getActivity().getString(R.string.changelog_change_7)
                    + getActivity().getString(R.string.changelog_version_6)
                    + getActivity().getString(R.string.changelog_change_6)
                    + getActivity().getString(R.string.changelog_version_5)
                    + getActivity().getString(R.string.changelog_change_5)
                    + getActivity().getString(R.string.changelog_version_4)
                    + getActivity().getString(R.string.changelog_change_4)
                    + getActivity().getString(R.string.changelog_version_3)
                    + getActivity().getString(R.string.changelog_change_3)
                    + getActivity().getString(R.string.changelog_version_2)
                    + getActivity().getString(R.string.changelog_change_2)
                    + getActivity().getString(R.string.changelog_version_1)
                    + getActivity().getString(R.string.changelog_change_1)));
            a.negativeText(R.string.close);
            a.positiveText(R.string.fullChangelog);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            a.positiveColor(fab_skin);
            a.negativeColor(fab_skin);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://github.com/arpitkh96/AmazeFileManager/commits/master"));
                    startActivity(intent);
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }
            }).build().show();
            return false;
        }
    });

    // Open Source Licenses
    Preference preference2 = (Preference) findPreference("os");
    //Defining dialog layout
    final Dialog dialog = new Dialog(getActivity(),
            android.R.style.Theme_Holo_Light_DialogWhenLarge_NoActionBar);
    //dialog.setTitle("Open-Source Licenses");
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final View dialog_view = inflater.inflate(R.layout.open_source_licenses, null);
    dialog.setContentView(dialog_view);

    preference2.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {

            WebView wv = (WebView) dialog_view.findViewById(R.id.webView1);
            PreferenceUtils preferenceUtils = new PreferenceUtils();
            wv.loadData(PreferenceUtils.LICENCE_TERMS, "text/html", null);
            dialog.show();
            return false;
        }
    });

    // Feedback
    Preference preference3 = (Preference) findPreference("feedback");
    preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "arpitkh96@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : Amaze File Manager");
            Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show();
            File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt");
            if (f.exists()) {
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
            }
            startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback)));
            return false;
        }
    });

    // rate
    Preference preference5 = (Preference) findPreference("rate");
    preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse("market://details?id=com.amaze.filemanager"));
            startActivity(intent1);
            return false;
        }
    });

    // studio
    Preference studio = findPreference("studio");
    studio.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            COUNT++;
            if (COUNT >= 5) {
                if (toast != null)
                    toast.cancel();
                toast = Toast.makeText(getActivity(), "Studio Mode : " + COUNT, Toast.LENGTH_SHORT);
                toast.show();

                sharedPref.edit().putInt("studio", Integer.parseInt(Integer.toString(COUNT) + "000")).apply();
            } else {
                sharedPref.edit().putInt("studio", 0).apply();
            }
            return false;
        }
    });

    // G+
    gplus = (CheckBx) findPreference("plus_pic");
    gplus.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (gplus.isChecked()) {
                boolean b = checkGplusPermission();
                if (!b)
                    requestGplusPermission();
            }
            return false;
        }
    });
    if (BuildConfig.IS_VERSION_FDROID)
        gplus.setEnabled(false);

    // Colored navigation bar
}

From source file:com.ywesee.amiko.MainActivity.java

/**
 * Shows the splash screen over the full Activity
 *///  ww  w.  j a v a 2  s .c o  m
protected void showSplashScreen(boolean showIt, boolean dismissAuto) {
    if (showIt) {
        mSplashDialog = new Dialog(this, android.R.style.Theme_Holo /*Translucent_NoTitleBar_Fullscreen*/);
        mSplashDialog.setContentView(R.layout.splash_screen);
        mSplashDialog.setCancelable(false);
        mSplashDialog.show();

        // Enable flag (disable toast message)
        mRestoringState = true;

        mSplashDialog.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                createMainLayout();
                // Re-enable toaster once the splash screen has been removed...
                mRestoringState = false;
                //
                mSearch.requestFocus();
                // Show keyboard
                showSoftKeyboard(100);
            }
        });

        // Set Runnable to remove splash screen just in case
        if (dismissAuto) {
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (mSplashDialog != null) {
                        mSplashDialog.dismiss();
                        mSplashDialog = null;
                    }
                }
            }, 3000);
        }
    }
}

From source file:de.mrapp.android.dialog.AbstractMaterialDialogFragment.java

@NonNull
@Override// www.j ava2  s  . co  m
public final Dialog onCreateDialog(final Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getContext(), themeResourceId);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

From source file:com.cjc.activity.carManagement.CarDisassemblyTypeActivity.java

private void createDialog(final int way) {
    // 2: 3: 4://w w  w  . j  av a 2 s . c o m
    String message = "";
    if (way == 1) {
        message = "";
    } else if (way == 2) {
        message = "";
    } else if (way == 3) {
        message = "";
    } else if (way == 4) {
        message = "";
    }
    final Dialog dialog = new Dialog(context, R.style.DialogNoTitle);
    View view = View.inflate(context, R.layout.dlg_dismantling, null);
    dialog.setContentView(view);
    TextView mTvUpdateMsg = (TextView) view.findViewById(R.id.tvTypeContent);
    mTvUpdateMsg.setText(message);
    Button btnOk = (Button) view.findViewById(R.id.btnOk);
    Button btnCancel = (Button) view.findViewById(R.id.btnCancel);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadCheckTypeData(way);
            dialog.dismiss();
        }
    });
    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            dialog.dismiss();
        }
    });
    dialog.show();
}