Search in sources :

Example 71 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project CoCoin by Nightonke.

the class AccountBookSettingActivity method changeAccountBookName.

// Change account book name/////////////////////////////////////////////////////////////////////////
private void changeAccountBookName() {
    new MaterialDialog.Builder(this).theme(Theme.LIGHT).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).title(R.string.set_account_book_dialog_title).inputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS).inputRange(1, 16).positiveText(R.string.submit).input(SettingManager.getInstance().getAccountBookName(), null, new MaterialDialog.InputCallback() {

        @Override
        public void onInput(MaterialDialog dialog, CharSequence input) {
            // local change
            SettingManager.getInstance().setAccountBookName(input.toString());
            SettingManager.getInstance().setTodayViewTitleShouldChange(true);
            SettingManager.getInstance().setMainViewTitleShouldChange(true);
            accountBookName.setText(input.toString());
            // update change
            User user = getCurrentUser();
            if (user != null) {
                updateSettingsToServer(UPDATE_ACCOUNT_BOOK_NAME);
            } else {
                // the new account book name is changed successfully
                showToast(2, "");
            }
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User)

Example 72 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project CoCoin by Nightonke.

the class AccountBookSettingActivity method changeLogo.

// change the user logo/////////////////////////////////////////////////////////////////////////////
private void changeLogo() {
    User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
    if (user == null) {
        new MaterialDialog.Builder(this).iconRes(R.drawable.cocoin_logo).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).limitIconToDefaultSize().title(R.string.login_first_title).content(R.string.login_first_content).positiveText(R.string.ok).neutralText(R.string.cancel).onAny(new MaterialDialog.SingleButtonCallback() {

            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                if (which == DialogAction.POSITIVE) {
                    userOperator();
                }
            }
        }).show();
        return;
    }
    new MaterialDialog.Builder(this).iconRes(R.drawable.cocoin_logo).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).limitIconToDefaultSize().title(R.string.change_logo_title).content(R.string.change_logo_content).positiveText(R.string.from_gallery).negativeText(R.string.from_camera).neutralText(R.string.cancel).onAny(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            if (which == DialogAction.POSITIVE) {
                Intent intent1 = new Intent(Intent.ACTION_PICK, null);
                intent1.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
                startActivityForResult(intent1, 1);
            } else if (which == DialogAction.NEGATIVE) {
                Intent intent2 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent2.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME)));
                startActivityForResult(intent2, 2);
            }
        }
    }).show();
}
Also used : BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) Intent(android.content.Intent) BmobFile(cn.bmob.v3.datatype.BmobFile) File(java.io.File)

Example 73 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project Timber by naman14.

the class LastFmLoginDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new MaterialDialog.Builder(getActivity()).positiveText("Login").negativeText("Cancel").title("Login to LastFM").customView(R.layout.dialog_lastfm_login, false).onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            String username = ((EditText) dialog.findViewById(R.id.lastfm_username)).getText().toString();
            String password = ((EditText) dialog.findViewById(R.id.lastfm_password)).getText().toString();
            if (username.length() == 0 || password.length() == 0)
                return;
            final ProgressDialog progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage("Logging in..");
            progressDialog.show();
            LastFmClient.getInstance(getActivity()).getUserLoginInfo(new UserLoginQuery(username, password), new UserListener() {

                @Override
                public void userSuccess() {
                    progressDialog.dismiss();
                    if (getTargetFragment() instanceof SettingsFragment) {
                        ((SettingsFragment) getTargetFragment()).updateLastFM();
                    }
                }

                @Override
                public void userInfoFailed() {
                    progressDialog.dismiss();
                    Toast.makeText(getTargetFragment().getActivity(), "Failed to Login", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }).build();
}
Also used : SettingsFragment(com.naman14.timber.fragments.SettingsFragment) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) UserLoginQuery(com.naman14.timber.lastfmapi.models.UserLoginQuery) ProgressDialog(android.app.ProgressDialog) UserListener(com.naman14.timber.lastfmapi.callbacks.UserListener)

Example 74 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project Hummingbird-for-Android by xiprox.

the class NavigationDrawerFragment method showLogoutDialog.

public void showLogoutDialog() {
    new MaterialDialog.Builder(context).title(R.string.content_log_out).positiveText(R.string.yes).negativeText(R.string.no).positiveColorRes(R.color.text_dialog_action).negativeColorRes(R.color.text_dialog_action).content(R.string.content_are_you_sure_logout).callback(new MaterialDialog.ButtonCallback() {

        @Override
        public void onPositive(MaterialDialog materialDialog) {
            prefMan.logout();
            startActivity(new Intent(getActivity(), LoginActivity.class));
            getActivity().finish();
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Intent(android.content.Intent)

Example 75 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project AisenWeiBo by wangdan.

the class OtherItemFragment method checkPhotoPermission.

//	private void setLanguage(int value) {
//		String[] valueTitleArr = getResources().getStringArray(R.array.pLanguage);
//
//		pLanguage.setSummary(valueTitleArr[value]);
//	}
public static void checkPhotoPermission(final BaseActivity activity, final boolean shownever) {
    APermissionsAction permissionsAction = new APermissionsAction(activity, null, activity.getActivityHelper(), Manifest.permission.CALL_PHONE) {

        @Override
        protected void onPermissionDenied(boolean alwaysDenied) {
            if (alwaysDenied) {
                if (shownever && ActivityHelper.getBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", false)) {
                    return;
                }
                MaterialDialog.Builder builder = new MaterialDialog.Builder(activity).forceStacking(true).content(R.string.crash_hint).negativeText(R.string.crash_settings).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        ActivityHelper.putBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", true);
                    }
                }).onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        AisenUtils.gotoSettings(activity);
                    }
                });
                if (shownever)
                    builder.positiveText(R.string.donnot_remind);
                builder.show();
            }
        }
    };
    // 开启日志上报
    new IAction(activity, permissionsAction) {

        @Override
        public void doAction() {
            Log.d("Main", "setupCrash");
            ((MyApplication) GlobalContext.getInstance()).setupCrash();
        }
    }.run();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IAction(org.aisen.android.support.action.IAction) DialogAction(com.afollestad.materialdialogs.DialogAction) APermissionsAction(org.aisen.android.support.permissions.APermissionsAction)

Aggregations

MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)90 View (android.view.View)57 DialogAction (com.afollestad.materialdialogs.DialogAction)45 TextView (android.widget.TextView)36 NonNull (android.support.annotation.NonNull)33 Intent (android.content.Intent)21 File (java.io.File)21 RecyclerView (android.support.v7.widget.RecyclerView)20 ImageView (android.widget.ImageView)19 SuppressLint (android.annotation.SuppressLint)18 List (java.util.List)16 LayoutInflater (android.view.LayoutInflater)14 MenuItem (android.view.MenuItem)14 Context (android.content.Context)13 PopupMenu (android.widget.PopupMenu)12 Activity (android.app.Activity)11 ListView (android.widget.ListView)11 Toast (android.widget.Toast)11 ArrayList (java.util.ArrayList)11 Bundle (android.os.Bundle)8