android.content.DialogInterface.OnClickListener Java Examples

The following examples show how to use android.content.DialogInterface.OnClickListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: XQuickEnergy   Author: pansong291   File: ChoiceDialog.java    License: Apache License 2.0 6 votes vote down vote up
private static AlertDialog getSendTypeDialog(Context c, CharSequence title)
{
 if(sendTypeDialog == null)
  sendTypeDialog = new AlertDialog.Builder(c)
   .setTitle(title)
   .setSingleChoiceItems(SendType.names, Config.sendType().ordinal(),
   new OnClickListener()
   {
    @Override
    public void onClick(DialogInterface p1, int p2)
    {
     Config.setSendType(p2);
    }
   })
   .setPositiveButton("OK", null)
   .create();
 return sendTypeDialog;
}
 
Example #2
Source Project: XQuickEnergy   Author: pansong291   File: ChoiceDialog.java    License: Apache License 2.0 6 votes vote down vote up
private static AlertDialog getRecallAnimalTypeDialog(Context c, CharSequence title)
{
 if(recallAnimalTypeDialog == null)
  recallAnimalTypeDialog = new AlertDialog.Builder(c)
   .setTitle(title)
   .setSingleChoiceItems(RecallAnimalType.names, Config.recallAnimalType().ordinal(),
   new OnClickListener()
   {
    @Override
    public void onClick(DialogInterface p1, int p2)
    {
     Config.setRecallAnimalType(p2);
    }
   })
   .setPositiveButton("OK", null)
   .create();
 return recallAnimalTypeDialog;
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: TimePickerDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void show() {
    super.show();
    getButton(BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mTimePicker.validateInput()) {
                TimePickerDialog.this.onClick(TimePickerDialog.this, BUTTON_POSITIVE);
                // Clearing focus forces the dialog to commit any pending
                // changes, e.g. typed text in a NumberPicker.
                mTimePicker.clearFocus();
                dismiss();
            }
        }
    });
}
 
Example #4
Source Project: EFRConnect-android   Author: SiliconLabs   File: Dialogs.java    License: Apache License 2.0 6 votes vote down vote up
public static Dialog showAlert(CharSequence title, CharSequence message, Context context,
                               CharSequence positiveBtnText, CharSequence negativeBtnText, OnClickListener positiveListener,
                               OnClickListener negativeListener) {

    final AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setCancelable(false);
    alert.setCanceledOnTouchOutside(false);
    if (positiveListener != null && positiveBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_POSITIVE, positiveBtnText, positiveListener);
    }
    if (negativeListener != null && negativeBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_NEGATIVE, negativeBtnText, negativeListener);
    }
    alert.setTitle(title);
    alert.setMessage(message);
    alert.show();
    return alert;
}
 
Example #5
Source Project: EFRConnect-android   Author: SiliconLabs   File: BrowserActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initLicenseDialog() {
    dialogLicense = new Dialog(this);
    dialogLicense.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialogLicense.setContentView(R.layout.dialog_about_silicon_labs_blue_gecko);
    WebView view = dialogLicense.findViewById(R.id.menu_item_license);
    Button closeButton = dialogLicense.findViewById(R.id.close_about_btn);

    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogLicense.dismiss();
        }
    });

    view.loadUrl(ABOUT_DIALOG_HTML_ASSET_FILE_PATH);
}
 
Example #6
Source Project: CSipSimple   Author: treasure-lau   File: ConversationsListFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void confirmDeleteThread(final String from) {
  	
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setTitle(R.string.confirm_dialog_title)
          .setIcon(android.R.drawable.ic_dialog_alert)
      .setCancelable(true)
      .setPositiveButton(R.string.delete, new OnClickListener() {
	@Override
	public void onClick(DialogInterface dialog, int which) {
		if(TextUtils.isEmpty(from)) {
		    getActivity().getContentResolver().delete(SipMessage.MESSAGE_URI, null, null);
		}else {
		    Builder threadUriBuilder = SipMessage.THREAD_ID_URI_BASE.buildUpon();
		    threadUriBuilder.appendEncodedPath(from);
		    getActivity().getContentResolver().delete(threadUriBuilder.build(), null, null);
		}
	}
})
      .setNegativeButton(R.string.no, null)
      .setMessage(TextUtils.isEmpty(from)
              ? R.string.confirm_delete_all_conversations
                      : R.string.confirm_delete_conversation)
      .show();
  }
 
Example #7
Source Project: Android-FileBrowser-FilePicker   Author: adityak368   File: UIUtils.java    License: MIT License 6 votes vote down vote up
public static void ShowError(String msg, Context context)
{
	AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(context);                      
    dlgAlert.setMessage(msg);
    dlgAlert.setTitle(context.getString(R.string.error_common));
    dlgAlert.setIcon(android.R.drawable.ic_dialog_alert);
    dlgAlert.setPositiveButton(context.getString(R.string.ok), new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example #8
Source Project: Android-FileBrowser-FilePicker   Author: adityak368   File: UIUtils.java    License: MIT License 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(context.getString(R.string.ok), new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface popup, int arg1) {
			// TODO Auto-generated method stub
			popup.dismiss();
		}
	});
    dlgAlert.setCancelable(false);
    dlgAlert.show();
}
 
Example #9
Source Project: Android-FileBrowser-FilePicker   Author: adityak368   File: UIUtils.java    License: MIT License 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 #10
Source Project: letv   Author: JackChan1999   File: UIs.java    License: Apache License 2.0 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 #11
Source Project: letv   Author: JackChan1999   File: UIs.java    License: Apache License 2.0 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 #12
Source Project: letv   Author: JackChan1999   File: UIsUtils.java    License: Apache License 2.0 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 #13
Source Project: mollyim-android   Author: mollyim   File: SaveAttachmentTask.java    License: GNU General Public License v3.0 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 #14
Source Project: DateTimePicker   Author: Gericop   File: TimePickerDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    super.show();
    getButton(BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mTimePicker.validateInput()) {
                TimePickerDialog.this.onClick(TimePickerDialog.this, BUTTON_POSITIVE);
                dismiss();
            }
        }
    });
}
 
Example #15
Source Project: KUtils-master   Author: weileng11   File: ErrorDialogFragments.java    License: Apache License 2.0 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();
}
 
Example #16
Source Project: FireFiles   Author: gigabytedevelopers   File: CreateFileFragment.java    License: Apache License 2.0 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);

    String title = getArguments().getString(EXTRA_DISPLAY_NAME);
    if(!TextUtils.isEmpty(title)) {
        text1.setText(title);
        text1.setSelection(title.length());
    }
    builder.setTitle(R.string.menu_create_file);
    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 String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
            String extension = FileUtils.getExtFromFilename(displayName);
            final DocumentsActivity activity = (DocumentsActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();
            new CreateFileTask(activity, cwd,
                    TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(
                    ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
Example #17
Source Project: FimiX8-RE   Author: wladimir-computin   File: XPermission.java    License: MIT License 5 votes vote down vote up
public static void showTipsDialog(final Context context) {
    new Builder(context).setTitle((CharSequence) "提示信息").setMessage((CharSequence) "当前应用缺少必要权限,该功能暂时无法使用。如若需要,请单击【确定】按钮前往设置中心进行权限授权。").setNegativeButton((CharSequence) "取消", null).setPositiveButton((CharSequence) "确定", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            XPermission.startAppSettings(context);
        }
    }).show();
}
 
Example #18
Source Project: AideHelper   Author: ikws4   File: MainActivity.java    License: MIT License 5 votes vote down vote up
/**
 * 更新日志对话框
 *
 * @param isShow 是否   直接显示(false就按versionCode进行判断)
 */
private void updateLogDialog(boolean isShow) {

  final SharedPreferences sharedPreferences = getSharedPreferences("app_version",
      Context.MODE_PRIVATE);
  int versionCode = sharedPreferences.getInt("versionCode", 10000);

  if (BuildConfig.VERSION_CODE > versionCode || isShow) {
    //读取raw下的update_log文件
    String updateLog = FileUtil.readTextFromRaw(this, R.raw.update_log);

    //对话框
    new AlertDialog.Builder(this)
        .setTitle(R.string.pref_update_log)
        .setMessage(updateLog)
        .setCancelable(false)
        .setNegativeButton(R.string.app_ok, new OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            Editor editor = sharedPreferences.edit();
            editor.putInt("versionCode", BuildConfig.VERSION_CODE);
            editor.apply();
            //判断是否开启模块,使用Hook改变方法内容
            showNoEnableDialog(isEnable);
          }
        })
        .show();
  } else {
    //判断是否开启模块,使用Hook改变方法内容
    showNoEnableDialog(isEnable);
  }

}
 
Example #19
Source Project: openboard   Author: dslul   File: LatinIME.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void showSubtypeSelectorAndSettings() {
    final CharSequence title = getString(R.string.english_ime_input_options);
    // TODO: Should use new string "Select active input modes".
    final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
    final CharSequence[] items = new CharSequence[] {
            languageSelectionTitle,
            getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
    };
    final String imeId = mRichImm.getInputMethodIdOfThisIme();
    final OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface di, int position) {
            di.dismiss();
            switch (position) {
            case 0:
                final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
                        imeId,
                        Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
                startActivity(intent);
                break;
            case 1:
                launchSettings();
                break;
            }
        }
    };
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            DialogUtils.getPlatformDialogThemeContext(this));
    builder.setItems(items, listener).setTitle(title);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true /* cancelable */);
    dialog.setCanceledOnTouchOutside(true /* cancelable */);
    showOptionDialog(dialog);
}
 
Example #20
Source Project: Android-Keyboard   Author: NlptechProduct   File: LatinIME.java    License: Apache License 2.0 5 votes vote down vote up
private void showSubtypeSelectorAndSettings() {
        final CharSequence title = getString(R.string.english_ime_input_options);
        // TODO: Should use new string "Select active input modes".
        final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
        final CharSequence[] items = new CharSequence[] {
                languageSelectionTitle,
                getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
        };
        final String imeId = mRichImm.getInputMethodIdOfThisIme();
        final OnClickListener listener = new OnClickListener() {
            @Override
            public void onClick(DialogInterface di, int position) {
                di.dismiss();
                switch (position) {
                case 0:
//                    final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
//                            imeId,
//                            Intent.FLAG_ACTIVITY_NEW_TASK
//                                    | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
//                                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
//                    intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
//                    startActivity(intent);
                    final Intent intent = new Intent(LatinIME.this, LanguageAddedActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    break;
                case 1:
                    launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA);
                    break;
                }
            }
        };
        final AlertDialog.Builder builder = new AlertDialog.Builder(
                DialogUtils.getPlatformDialogThemeContext(this));
        builder.setItems(items, listener).setTitle(title);
        final AlertDialog dialog = builder.create();
        dialog.setCancelable(true /* cancelable */);
        dialog.setCanceledOnTouchOutside(true /* cancelable */);
        showOptionDialog(dialog);
    }
 
Example #21
Source Project: LokiBoard-Android-Keylogger   Author: IceWreck   File: LatinIME.java    License: Apache License 2.0 5 votes vote down vote up
private void showSubtypeSelectorAndSettings() {
    final CharSequence title = getString(R.string.english_ime_input_options);
    // TODO: Should use new string "Select active input modes".
    final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
    final CharSequence[] items = new CharSequence[] {
            languageSelectionTitle,
            getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
    };
    final String imeId = mRichImm.getInputMethodIdOfThisIme();
    final OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface di, int position) {
            di.dismiss();
            switch (position) {
            case 0:
                final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
                        imeId,
                        Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
                startActivity(intent);
                break;
            case 1:
                launchSettings();
                break;
            }
        }
    };
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            DialogUtils.getPlatformDialogThemeContext(this));
    builder.setItems(items, listener).setTitle(title);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true /* cancelable */);
    dialog.setCanceledOnTouchOutside(true /* cancelable */);
    showOptionDialog(dialog);
}
 
Example #22
Source Project: StockChart-MPAndroidChart   Author: LambdaXiao   File: SimpleChartDemo.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_awesomedesign);

    setTitle("SimpleChartDemo");

    ViewPager pager = findViewById(R.id.pager);
    pager.setOffscreenPageLimit(3);

    PageAdapter a = new PageAdapter(getSupportFragmentManager());
    pager.setAdapter(a);


    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle("This is a ViewPager.");
    b.setMessage("Swipe left and right for more awesome design examples!");
    b.setPositiveButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    b.show();
}
 
Example #23
Source Project: FireFiles   Author: gigabytedevelopers   File: CreateDirectoryFragment.java    License: Apache License 2.0 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 #24
Source Project: letv   Author: JackChan1999   File: DialogUtil.java    License: Apache License 2.0 5 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()) {
            dialog.show();
        }
    }
}
 
Example #25
Source Project: stynico   Author: stytooldex   File: jni_string.java    License: MIT License 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 #26
Source Project: weex-uikit   Author: erguotou520   File: WXModalUIModule.java    License: MIT License 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 #27
Source Project: CSipSimple   Author: treasure-lau   File: DtmfDialogFragment.java    License: GNU General Public License v3.0 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 #28
Source Project: simple-keyboard   Author: rkkr   File: LatinIME.java    License: Apache License 2.0 5 votes vote down vote up
private void showSubtypeSelectorAndSettings() {
    final CharSequence title = getString(R.string.english_ime_input_options);
    // TODO: Should use new string "Select active input modes".
    final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
    final CharSequence[] items = new CharSequence[] {
            languageSelectionTitle,
            getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
    };
    final String imeId = mRichImm.getInputMethodIdOfThisIme();
    final OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface di, int position) {
            di.dismiss();
            switch (position) {
            case 0:
                final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
                        imeId,
                        Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
                startActivity(intent);
                break;
            case 1:
                launchSettings();
                break;
            }
        }
    };
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            DialogUtils.getPlatformDialogThemeContext(this));
    builder.setItems(items, listener).setTitle(title);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true /* cancelable */);
    dialog.setCanceledOnTouchOutside(true /* cancelable */);
    showOptionDialog(dialog);
}
 
Example #29
Source Project: ucar-weex-core   Author: weexext   File: WXModalUIModule.java    License: Apache License 2.0 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 #30
Source Project: AOSP-Kayboard-7.1.2   Author: sergchil   File: LatinIME.java    License: Apache License 2.0 5 votes vote down vote up
private void showSubtypeSelectorAndSettings() {
    final CharSequence title = getString(R.string.english_ime_input_options);
    // TODO: Should use new string "Select active input modes".
    final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
    final CharSequence[] items = new CharSequence[] {
            languageSelectionTitle,
            getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
    };
    final String imeId = mRichImm.getInputMethodIdOfThisIme();
    final OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface di, int position) {
            di.dismiss();
            switch (position) {
            case 0:
                final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
                        imeId,
                        Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
                startActivity(intent);
                break;
            case 1:
                launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA);
                break;
            }
        }
    };
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            DialogUtils.getPlatformDialogThemeContext(this));
    builder.setItems(items, listener).setTitle(title);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true /* cancelable */);
    dialog.setCanceledOnTouchOutside(true /* cancelable */);
    showOptionDialog(dialog);
}