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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations