Java Code Examples for android.content.DialogInterface.OnClickListener

The following are top voted examples for showing how to use android.content.DialogInterface.OnClickListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: q-mail   File: PgpEncryptDescriptionDialog.java   View source code 7 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();

    @SuppressLint("InflateParams")
    View view = LayoutInflater.from(activity).inflate(R.layout.openpgp_encrypt_description_dialog, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setView(view);

    builder.setPositiveButton(R.string.openpgp_sign_only_ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    return builder.create();
}
 
Example 2
Project: boohee_v5.6   File: ErrorDialogFragments.java   View source code 7 votes vote down vote up
public static Dialog createDialog(Context context, Bundle arguments, OnClickListener onClickListener) {
    Builder builder = new Builder(context);
    builder.setTitle(arguments.getString(ErrorDialogManager.KEY_TITLE));
    builder.setMessage(arguments.getString(ErrorDialogManager.KEY_MESSAGE));
    if (ERROR_DIALOG_ICON != 0) {
        builder.setIcon(ERROR_DIALOG_ICON);
    }
    builder.setPositiveButton(17039370, onClickListener);
    return builder.create();
}
 
Example 3
Project: GitHub   File: MessageDialog.java   View source code 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
	View dialogView = LayoutInflater.from(getActivity())
			.inflate(R.layout.dialog_message, null);

	TextView messageView = (TextView) dialogView.findViewById(R.id.message);
	messageView.setMovementMethod(LinkMovementMethod.getInstance());
	messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));

	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
	builder.setTitle(getArguments().getString(ARG_TITLE))
			.setIcon(getArguments().getInt(ARG_ICON))
			.setView(dialogView)
			.setPositiveButton(R.string.OK, new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});

	return builder.create();
}
 
Example 4
Project: GitHub   File: PubkeyListActivity.java   View source code 6 votes vote down vote up
protected void handleAddKey(final PubkeyBean pubkey) {
	if (pubkey.isEncrypted()) {
		final View view = View.inflate(this, R.layout.dia_password, null);
		final EditText passwordField = (EditText) view.findViewById(android.R.id.text1);

		new android.support.v7.app.AlertDialog.Builder(
				PubkeyListActivity.this, R.style.AlertDialogTheme)
			.setView(view)
			.setPositiveButton(R.string.pubkey_unlock, new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					handleAddKey(pubkey, passwordField.getText().toString());
				}
			})
			.setNegativeButton(android.R.string.cancel, null).create().show();
	} else {
		handleAddKey(pubkey, null);
	}
}
 
Example 5
Project: publicProject   File: PromptManager.java   View source code 6 votes vote down vote up
/**
 * 用于回调事件提示框
 *
 * @param context
 * @param titleResId      标题资源ID -1代表无些按钮
 * @param msgResId        消息资源ID -1代表无些按钮
 * @param confirmResId    确定按钮文字资源ID -1代表无些按钮
 * @param confirmListener 确定按钮回调监听
 * @param cancelResId     取消按钮文字资源ID -1代表无些按钮
 * @param cancelListener  取消按钮回调监听
 */
public static void showResDialog(Context context, int titleResId, int msgResId, int confirmResId, OnClickListener confirmListener,
                                 int cancelResId, OnClickListener cancelListener) {
    String title = null;
    if (titleResId != -1) {
        title = context.getResources().getString(titleResId);
    }
    String msg = null;
    if (msgResId != -1) {
        msg = context.getResources().getString(msgResId);
    }
    String confirm = null;
    if (confirmResId != -1) {
        confirm = context.getResources().getString(confirmResId);
    }
    String cancel = null;
    if (cancelResId != -1) {
        cancel = context.getResources().getString(cancelResId);
    }
    showTextDialog(context, title, msg, confirm, confirmListener, cancel, cancelListener);
}
 
Example 6
Project: publicProject   File: PromptManager.java   View source code 6 votes vote down vote up
/**
 * 最终调用提示框
 *
 * @param context
 * @param title           标题字符串
 * @param msg             消息体字符串
 * @param confirm         确定按钮文字
 * @param confirmListener 确定按钮监听
 * @param cancel          取消按钮文字
 * @param cancelListener  取消按钮监听
 */
public static void showTextDialog(Context context, String title, String msg, String confirm, OnClickListener confirmListener,
                                  String cancel, OnClickListener cancelListener) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
    if (!TextUtils.isEmpty(title)) {
        alertDialog.setTitle(title);
    }
    if (!TextUtils.isEmpty(msg)) {
        alertDialog.setMessage(msg);
    }
    if (!TextUtils.isEmpty(confirm) || confirmListener != null) {
        alertDialog.setPositiveButton(confirm, confirmListener);
    }
    if (!TextUtils.isEmpty(cancel) || cancelListener != null) {
        alertDialog.setNegativeButton(cancel, cancelListener);
    }
    alertDialog.show();
}
 
Example 7
Project: civify-app   File: LocationAdapter.java   View source code 6 votes vote down vote up
private void setLocationUpdateTimeout() {
    if (!isLocationUpdateTimeoutSet()) {
        mOnUpdateTimeout = Timeout.schedule("LocationUpdateTimeout", new Runnable() {
            @Override
            public void run() {
                if (!mLowConnectionWarning && isConnected()) {
                    checkForPermissions();
                    if (hasPermissions()) {
                        mLowConnectionWarning = true;
                        ConfirmDialog.show(mContext,
                                mContext.getString(R.string.cannot_retrieve_location_title),
                                mContext.getString(R.string.cannot_retrieve_location),
                                new OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface d, int w) {
                                        checkForPermissions();
                                    }
                                }, null);
                    }
                }
            }
        }, getLocationUpdateTimeoutTime(LOCATION_FIRST_UPDATE_TIMEOUT_MULTIPLIER));
    }
}
 
Example 8
Project: aos-Video   File: PlayerActivity.java   View source code 6 votes vote down vote up
/**
 * @return null if there is no update needed
 */
private Dialog getPluginNeedUpdateDialog() {
    if (LibAvos.pluginNeedUpdate(this)) {
        Log.d(TAG, "pluginNeedUpdate returns true");
        return new AlertDialog.Builder(this)
        .setTitle(R.string.plugin_update_required_title)
        .setMessage(R.string.plugin_update_required_message)
        .setNegativeButton(android.R.string.cancel, null)
        .setPositiveButton(R.string.player_plugin_purchase_google_play_button,  new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                try {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=archos+video+plugins")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    finish(); // probably safer to "quit" AVP now
                } catch (ActivityNotFoundException e) {}
            }
        })
        .setCancelable(true)
        .create();
    }
    else {
        return null;
    }
}
 
Example 9
Project: Android-FileBrowser-FilePicker   File: UIUtils.java   View source code 6 votes vote down vote up
public static void ShowMsg(String msg, String title,Context context)
{
	AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(context);                      
    dlgAlert.setMessage(msg);
    dlgAlert.setTitle(title);
    dlgAlert.setIcon(android.R.drawable.ic_dialog_info);
    dlgAlert.setPositiveButton("OK", new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example 10
Project: Android-FileBrowser-FilePicker   File: UIUtils.java   View source code 6 votes vote down vote up
public static void showEditTextDialog(Context mContext, String title, String initialText, final IFuncPtr functionToBeRun) {

		LayoutInflater inflater = (LayoutInflater)mContext.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.dialog_with_text, null);

		// custom dialog
		final Dialog dialog = new AlertDialog.Builder(mContext)
				.setTitle(title)
				.setView(v)
				.create();

		BootstrapButton okButton = (BootstrapButton) v.findViewById(R.id.okbutton);
		final BootstrapEditText insertedText = (BootstrapEditText) v.findViewById(R.id.addedText);
		insertedText.setText(initialText);
		okButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				functionToBeRun.execute(insertedText.getText().toString());
				dialog.dismiss();
			}
		});

		dialog.show();
	}
 
Example 11
Project: boohee_v5.6   File: ViewUtils.java   View source code 6 votes vote down vote up
public static void showTimeDialog(Context context, Alarm alarm, AlarmDao alarmDao, TextView
        text_view) {
    final TimePickerWheelView timePickerView = new TimePickerWheelView(context, alarm.hour,
            alarm.minute);
    final Alarm alarm2 = alarm;
    final TextView textView = text_view;
    final AlarmDao alarmDao2 = alarmDao;
    final Context context2 = context;
    new Builder(context).setView(timePickerView).setPositiveButton(R.string.y8, new
            OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            alarm2.hour = timePickerView.getHour();
            alarm2.minute = timePickerView.getMinute();
            textView.setText(alarm2.formatTime());
            alarmDao2.update(alarm2);
            if (alarm2.is_open()) {
                RemindService.start(alarm2, context2);
            }
        }
    }).show();
}
 
Example 12
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void showDialog(Activity context, CharSequence title, CharSequence centerText, OnClickListener centerListener) {
    if (mCommonDialog != null && mCommonDialog.isShowing()) {
        mCommonDialog.dismiss();
    }
    mCommonDialog = new LetvCommonDialog(context);
    mCommonDialog.setTitle(title);
    mCommonDialog.setButtonText(centerText);
    if (centerListener != null) {
        mCommonDialog.setCenterOnClickListener(centerListener);
    }
    if (!context.isFinishing() && !context.isRestricted()) {
        try {
            mCommonDialog.show();
        } catch (Exception e) {
        }
    }
}
 
Example 13
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void call(Context activity, String title, String message, int yes, int no, OnClickListener yesListener, OnClickListener noListener, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(message).setCancelable(cancelable).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if ((activity instanceof Activity) && !((Activity) activity).isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 14
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void call(Activity activity, int messageId, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(R.string.dialog_default_title).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(R.string.dialog_default_ok, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 15
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void call(Activity activity, String messageId, OnClickListener yes, OnClickListener no) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setIcon(R.drawable.dialog_icon).setMessage(messageId).setPositiveButton(R.string.dialog_default_ok, yes).setNegativeButton(R.string.dialog_default_no, no).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 16
Project: letv   File: UIs.java   View source code 6 votes vote down vote up
public static void call(Context context, Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    if (activity != null) {
        String title = context.getString(2131100003);
        String msg = context.getString(messageId);
        String y = context.getString(yes);
        Dialog dialog = new Builder(activity).setTitle(title).setMessage(msg).setPositiveButton(y, yesListener).setNegativeButton(context.getString(no), noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 17
Project: letv   File: UIs.java   View source code 6 votes vote down vote up
public static void call(Activity activity, int messageId, OnClickListener yes) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(2131100003).setIcon(2130837921).setMessage(messageId).setPositiveButton(2131100002, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 18
Project: letv   File: UIs.java   View source code 6 votes vote down vote up
public static void callDialogMsgPositiveButton(Activity activity, String msgId, OnClickListener yes) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(2131100003);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setPositiveButton(2131100002, yes).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 19
Project: letv   File: UIs.java   View source code 6 votes vote down vote up
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(2131100003);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 20
Project: letv   File: UIsUtils.java   View source code 6 votes vote down vote up
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
    TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
    if (activity != null && dialogMsgByMsg != null) {
        CharSequence string;
        Builder builder = new Builder(activity);
        if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
            string = activity.getString(R.string.dialog_default_title);
        } else {
            string = dialogMsgByMsg.title;
        }
        Dialog dialog = builder.setTitle(string).setIcon(R.drawable.dialog_icon).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if (!activity.isFinishing() && !activity.isRestricted()) {
            try {
                dialog.show();
            } catch (Exception e) {
            }
        }
    }
}
 
Example 21
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void showDialog(Activity context, CharSequence title, CharSequence content, CharSequence leftText, CharSequence rightText, OnClickListener leftListener, OnClickListener rightListener) {
    if (mCommonDialog != null && mCommonDialog.isShowing()) {
        mCommonDialog.dismiss();
    }
    mCommonDialog = new CommonDialog(context);
    mCommonDialog.setTitle(title);
    mCommonDialog.setContent(content.toString());
    mCommonDialog.setButtonText(leftText, rightText);
    if (leftListener != null) {
        mCommonDialog.setLeftOnClickListener(leftListener);
    }
    if (rightListener != null) {
        mCommonDialog.setRightOnClickListener(rightListener);
    }
    if (!context.isFinishing() && !context.isRestricted()) {
        mCommonDialog.show();
    }
}
 
Example 22
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void showDialog(Activity context, CharSequence title, CharSequence content, CharSequence leftText, CharSequence rightText, OnClickListener leftListener, OnClickListener rightListener, int layoutId) {
    if (mCommonDialog != null && mCommonDialog.isShowing()) {
        mCommonDialog.dismiss();
    }
    mCommonDialog = new CommonDialog(context, layoutId);
    mCommonDialog.setTitle(title);
    mCommonDialog.setContent(content.toString());
    mCommonDialog.setButtonText(leftText, rightText);
    if (leftListener != null) {
        mCommonDialog.setLeftOnClickListener(leftListener);
    }
    if (rightListener != null) {
        mCommonDialog.setRightOnClickListener(rightListener);
    }
    if (!context.isFinishing() && !context.isRestricted()) {
        mCommonDialog.show();
    }
}
 
Example 23
Project: letv   File: DialogUtil.java   View source code 6 votes vote down vote up
public static void call(Context activity, String title, String message, int yes, int no, OnClickListener yesListener, OnClickListener noListener, boolean cancelable) {
    if (activity != null) {
        Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(message).setCancelable(cancelable).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
        if ((activity instanceof Activity) && !((Activity) activity).isFinishing() && !activity.isRestricted()) {
            dialog.show();
        }
    }
}
 
Example 24
Project: Cable-Android   File: SaveAttachmentTask.java   View source code 5 votes vote down vote up
public static void showWarningDialog(Context context, OnClickListener onAcceptListener, int count) {
  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  builder.setTitle(R.string.ConversationFragment_save_to_sd_card);
  builder.setIconAttribute(R.attr.dialog_alert_icon);
  builder.setCancelable(true);
  builder.setMessage(context.getResources().getQuantityString(R.plurals.ConversationFragment_saving_n_media_to_storage_warning,
                                                              count, count));
  builder.setPositiveButton(R.string.yes, onAcceptListener);
  builder.setNegativeButton(R.string.no, null);
  builder.show();
}
 
Example 25
Project: boohee_v5.6   File: UserSettingActivity.java   View source code 5 votes vote down vote up
public void cleanPictureCache() {
    LightAlertDialog.create((Context) this, (int) R.string.fn).setNegativeButton((int) R
            .string.eq, null).setPositiveButton((int) R.string.y8, new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            ImageLoader.getInstance().clearDiskCache();
            UserSettingActivity.this.cacheLine.setIndicateText("0.0M");
        }
    }).show();
}
 
Example 26
Project: aos-Video   File: TorrentBlocklistDialogPreference.java   View source code 5 votes vote down vote up
private void setup() {
	
	mProgress = new ProgressDialog(getContext());
	mProgress.setMessage(getContext().getString(R.string.blocklist_downloading));
	mProgress.setCancelable(false);
	
	if((mCurrentBlockList=getSharedPreferences().getString(getKey(), defaultBlocklist))!=null){
           File file = getContext().getFileStreamPath(TorrentObserverService.BLOCKLIST);
		if(file.exists()) {
               setSummary(mCurrentBlockList);
               mView.findViewById(R.id.button).setVisibility(View.VISIBLE);
           }
		else {
               setSummary(R.string.blocklist_not_loaded);
               mView.findViewById(R.id.button).setVisibility(View.GONE);
           }
	}
	else
		mView.findViewById(R.id.button).setVisibility(View.GONE);
	
	mView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

           @Override
           public void onClick(View v) {
               startDownload(getSharedPreferences().getString(getKey(), defaultBlocklist));
           }
       });
}
 
Example 27
Project: aos-Video   File: Browser.java   View source code 5 votes vote down vote up
/**
 *  ask user to check is the selected file has to be deleted
 *
 * @param isParentFolder if we are deleting a parent folder of a video file previously deleted
 * @param uri needed to delete a parent folder, other wise, can be null
 */
public void showConfirmDeleteDialog(final boolean isParentFolder, final List<Uri> uri) {

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity()).setTitle("");
    if(!isParentFolder)
        b.setIcon(R.drawable.filetype_new_video);
    else
        b.setIcon(R.drawable.filetype_new_folder);

    if(!isParentFolder)
        b.setMessage(R.string.confirm_delete);
    else
        b.setMessage(R.string.confirm_delete_parent_folder);
    mDialogDelete =b.setNegativeButton(R.string.no, null)
            .setPositiveButton(R.string.yes, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (mActionModeManager != null) {
                        mActionModeManager.destroyActionBar();
                    }
                    if (!isParentFolder)
                        startDeletingDialog(uri);
                    else {
                        Delete delete = new Delete(Browser.this, getActivity());
                        delete.deleteFolder(uri.get(0));
                    }

                }
            }).create();
    mDialogDelete.show();
}
 
Example 28
Project: ss-android   File: MainActivity.java   View source code 5 votes vote down vote up
private void showProxyUrlInputDialog() {
    final EditText editText = new EditText(this);
    editText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    editText.setHint(getString(R.string.config_url_hint));
    editText.setText(readProxyUrl());

    new AlertDialog.Builder(this)
            .setTitle(R.string.config_url)
            .setView(editText)
            .setPositiveButton(R.string.btn_ok, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (editText.getText() == null) {
                        return;
                    }

                    String ProxyUrl = editText.getText().toString().trim();
                    if (isValidUrl(ProxyUrl)) {
                        setProxyUrl(ProxyUrl);
                        textViewProxyUrl.setText(ProxyUrl);
                    } else {
                        Toast.makeText(MainActivity.this, R.string.err_invalid_url, Toast.LENGTH_SHORT).show();
                    }
                }
            })
            .setNegativeButton(R.string.btn_cancel, null)
            .show();
}
 
Example 29
Project: stynico   File: jni_string.java   View source code 5 votes vote down vote up
@TargetApi(21)
   public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked)
   {
       if (isChecked && compoundButton == mCompoundButton
    && getResources().getBoolean(R.bool.use_accessibility_service)
    && WatchingAccessibilityService.getInstance() == null)
{
           new Builder(this).setMessage(R.string.dialog_enable_accessibility_msg)
	.setPositiveButton(R.string.dialog_enable_accessibility_positive_btn, new OnClickListener() {

	    @Override
	    public void onClick(DialogInterface dialog, int which)
	    {
		Intent intent = new Intent();
		intent.setAction("android.settings.ACCESSIBILITY_SETTINGS");
		startActivity(intent);

	    }
	}).setNegativeButton(R.string.dialog_enable_accessibility_Nagetive_btn, this).setOnCancelListener(this).create().show();
           DefaultSharedPreferences.save(this, isChecked);
       }
else if (compoundButton == mCompoundButton)
{
           DefaultSharedPreferences.save(this, isChecked);
           if (isChecked)
    {
               ViewWindow.showView(this, getPackageName() + "\n" + getClass().getName());
           }
    else
    {
               ViewWindow.removeView();
           }
       }
   }
 
Example 30
Project: PeSanKita-android   File: SaveAttachmentTask.java   View source code 5 votes vote down vote up
public static void showWarningDialog(Context context, OnClickListener onAcceptListener, int count) {
  AlertDialog.Builder builder = new AlertDialog.Builder(context);
  builder.setTitle(R.string.ConversationFragment_save_to_sd_card);
  builder.setIconAttribute(R.attr.dialog_alert_icon);
  builder.setCancelable(true);
  builder.setMessage(context.getResources().getQuantityString(R.plurals.ConversationFragment_saving_n_media_to_storage_warning,
                                                              count, count));
  builder.setPositiveButton(R.string.yes, onAcceptListener);
  builder.setNegativeButton(R.string.no, null);
  builder.show();
}
 
Example 31
Project: CSipSimple   File: DtmfDialogFragment.java   View source code 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    
    return new AlertDialog.Builder(getActivity())
            .setView(getCustomView(getActivity().getLayoutInflater(), null, savedInstanceState))
            .setCancelable(true)
            .setNeutralButton(R.string.done, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                }
            })
            .create();
}
 
Example 32
Project: OSchina_resources_android   File: TeamNewActiveActivity.java   View source code 5 votes vote down vote up
private void handleSelectPicture() {
    DialogHelper.getSelectDialog(this, getResources().getStringArray(R.array.choose_picture), "取消",
            new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    goToSelectPicture(i);
                }
            }).show();
}
 
Example 33
Project: boohee_v5.6   File: BecomeTeamLeaderActivity.java   View source code 5 votes vote down vote up
private void showSelector() {
    if (this.mSelector == null) {
        LinearLayout view = (LinearLayout) LayoutInflater.from(this.ctx).inflate(R.layout.o2,
                null);
        this.mSelector = new PopupWindow(view, -1, -2, true);
        this.mSelector.setOutsideTouchable(true);
        this.mSelector.setAnimationStyle(R.style.f0);
        this.mSelector.setBackgroundDrawable(new BitmapDrawable(getResources()));
        View.OnClickListener click = new View.OnClickListener() {
            public void onClick(View v) {
                BecomeTeamLeaderActivity.this.dismissSelector();
                switch (v.getId()) {
                    case R.id.cancel:
                        BecomeTeamLeaderActivity.this.dismissSelector();
                        return;
                    case R.id.select_photos:
                        PhotoPickerHelper.show(BecomeTeamLeaderActivity.this.activity, 2);
                        return;
                    default:
                        return;
                }
            }
        };
        view.findViewById(R.id.select_photos).setOnClickListener(click);
        view.findViewById(R.id.cancel).setOnClickListener(click);
    }
    this.mSelector.showAtLocation(this.iv_icon, 80, 0, 0);
}
 
Example 34
Project: easyfilemanager   File: CreateDirectoryFragment.java   View source code 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());

    final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
    final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
    Utils.tintWidget(text1);

    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String displayName = text1.getText().toString();

            final BaseActivity activity = (BaseActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();

            if(TextUtils.isEmpty(displayName)){
                activity.showError(R.string.create_error);
                return;
            }
            new CreateDirectoryTask(activity, cwd, displayName).executeOnExecutor(
                    ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
Example 35
Project: Nird2   File: ForumActivity.java   View source code 5 votes vote down vote up
private void showUnsubscribeDialog() {
	OnClickListener okListener = new OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
			deleteForum();
		}
	};
	AlertDialog.Builder builder = new AlertDialog.Builder(this,
			R.style.BriarDialogTheme);
	builder.setTitle(getString(R.string.dialog_title_leave_forum));
	builder.setMessage(getString(R.string.dialog_message_leave_forum));
	builder.setNegativeButton(R.string.dialog_button_leave, okListener);
	builder.setPositiveButton(R.string.cancel, null);
	builder.show();
}
 
Example 36
Project: weex-3d-map   File: WXModalUIModule.java   View source code 5 votes vote down vote up
@WXModuleAnno
public void alert(String param, final JSCallback callback) {

  if (mWXSDKInstance.getContext() instanceof Activity) {

    String message = "";
    String okTitle = OK;
    if (!TextUtils.isEmpty(param)) {
      try {
        param = URLDecoder.decode(param, "utf-8");
        JSONObject jsObj = new JSONObject(param);
        message = jsObj.optString(MESSAGE);
        okTitle = jsObj.optString(OK_TITLE);
      } catch (Exception e) {
        WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
      }
    }
    if (TextUtils.isEmpty(message)) {
      message="";
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
    builder.setMessage(message);

    final String okTitle_f = TextUtils.isEmpty(okTitle) ? OK : okTitle;
    builder.setPositiveButton(okTitle_f, new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        if(callback !=null) {
          callback.invoke(okTitle_f);
        }
      }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
  } else {
    WXLogUtils.e("[WXModalUIModule] when call alert mWXSDKInstance.getContext() must instanceof Activity");
  }
}
 
Example 37
Project: ucar-weex-core   File: WXModalUIModule.java   View source code 5 votes vote down vote up
@JSMethod(uiThread = true)
public void alert(String param, final JSCallback callback) {

  if (mWXSDKInstance.getContext() instanceof Activity) {

    String message = "";
    String okTitle = OK;
    if (!TextUtils.isEmpty(param)) {
      try {
        param = URLDecoder.decode(param, "utf-8");
        JSONObject jsObj = JSON.parseObject(param);
        message = jsObj.getString(MESSAGE);
        okTitle = jsObj.getString(OK_TITLE);
      } catch (Exception e) {
        WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
      }
    }
    if (TextUtils.isEmpty(message)) {
      message = "";
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
    builder.setMessage(message);

    final String okTitle_f = TextUtils.isEmpty(okTitle) ? OK : okTitle;
    builder.setPositiveButton(okTitle_f, new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        if (callback != null) {
          callback.invoke(okTitle_f);
        }
      }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
    tracking(alertDialog);
  } else {
    WXLogUtils.e("[WXModalUIModule] when call alert mWXSDKInstance.getContext() must instanceof Activity");
  }
}
 
Example 38
Project: boohee_v5.6   File: AlertDialog.java   View source code 5 votes vote down vote up
public Builder setSingleChoiceItems(CharSequence[] items, int checkedItem, OnClickListener listener) {
    this.P.mItems = items;
    this.P.mOnClickListener = listener;
    this.P.mCheckedItem = checkedItem;
    this.P.mIsSingleChoice = true;
    return this;
}
 
Example 39
Project: boohee_v5.6   File: AlertDialog.java   View source code 5 votes vote down vote up
public Builder setSingleChoiceItems(ListAdapter adapter, int checkedItem, OnClickListener listener) {
    this.P.mAdapter = adapter;
    this.P.mOnClickListener = listener;
    this.P.mCheckedItem = checkedItem;
    this.P.mIsSingleChoice = true;
    return this;
}
 
Example 40
Project: Chidori   File: ErrorDialogFragments.java   View source code 5 votes vote down vote up
public static Dialog createDialog(Context context, Bundle arguments, OnClickListener onClickListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(arguments.getString(ErrorDialogManager.KEY_TITLE));
    builder.setMessage(arguments.getString(ErrorDialogManager.KEY_MESSAGE));
    if (ERROR_DIALOG_ICON != 0) {
        builder.setIcon(ERROR_DIALOG_ICON);
    }
    builder.setPositiveButton(android.R.string.ok, onClickListener);
    return builder.create();
}