Java Code Examples for com.afollestad.materialdialogs.MaterialDialog#getInputEditText()
The following examples show how to use
com.afollestad.materialdialogs.MaterialDialog#getInputEditText() .
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 File: CommonUtil.java From homeassist with Apache License 2.0 | 6 votes |
public static void fixDialogKeyboard(final MaterialDialog dialog) { //https://github.com/afollestad/material-dialogs/issues/1105 EditText inputEditText = dialog.getInputEditText(); if (inputEditText != null) { inputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE) || (actionId == EditorInfo.IME_ACTION_SEARCH)) { View positiveButton = dialog.getActionButton(DialogAction.POSITIVE); if (dialog.getActionButton(DialogAction.POSITIVE).isEnabled()) { positiveButton.callOnClick(); } else { return true; } } return false; } }); } }
Example 2
Source File: DialogHelper.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public static void initFilenameInputDialog(MaterialDialog show) { final EditText editText = show.getInputEditText(); editText.setSingleLine(); editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); // create an initial filename to suggest to the user String filename = createLogFilename(); editText.setText(filename); // highlight everything but the .txt at the end editText.setSelection(0, filename.length() - 4); }
Example 3
Source File: RuleListFragment.java From SmsCode with GNU General Public License v3.0 | 5 votes |
private void attemptExportRuleList() { if (mRuleAdapter.getItemCount() == 0) { SnackbarHelper.makeLong(mRecyclerView, R.string.rule_list_empty_snack_prompt).show(); return; } final String defaultFilename = BackupManager.getDefaultBackupFilename(); String hint = getString(R.string.backup_file_name); String content = getString(R.string.backup_file_dir, BackupManager.getBackupDir().getAbsolutePath()); final MaterialDialog exportFilenameDialog = new MaterialDialog.Builder(mActivity) .title(R.string.backup_file_name) .content(content) .input(hint, defaultFilename, (dialog, input) -> { File file = new File(BackupManager.getBackupDir(), input.toString()); new ExportAsyncTaskBelowQ(mActivity, RuleListFragment.this, mRuleAdapter, file, getString(R.string.exporting)).execute(); }) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE) .negativeText(R.string.cancel) .build(); final EditText editText = exportFilenameDialog.getInputEditText(); if (editText != null) { exportFilenameDialog.setOnShowListener(dialog -> { int stop = defaultFilename.length() - BackupManager.getBackupFileExtension().length(); editText.setSelection(0, stop); }); final MDButton positiveBtn = exportFilenameDialog.getActionButton(DialogAction.POSITIVE); editText.addTextChangedListener(new TextWatcherAdapter() { @Override public void afterTextChanged(Editable s) { positiveBtn.setEnabled(Utils.isValidFilename(s.toString())); } }); } exportFilenameDialog.show(); }
Example 4
Source File: CommonUtil.java From homeassist with Apache License 2.0 | 5 votes |
public static String getDialogInput(final MaterialDialog dialog) { EditText editText = dialog.getInputEditText(); if (editText != null) { return dialog.getInputEditText().getText().toString().trim(); } else { throw new IllegalStateException("EditText not found"); } }
Example 5
Source File: DialogHelper.java From javaide with GNU General Public License v3.0 | 5 votes |
public static void initFilenameInputDialog(MaterialDialog show) { final EditText editText = show.getInputEditText(); editText.setSingleLine(); editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); // create an initial filename to suggest to the user String filename = createLogFilename(); editText.setText(filename); // highlight everything but the .txt at the end editText.setSelection(0, filename.length() - 4); }
Example 6
Source File: DialogHelper.java From matlog with GNU General Public License v3.0 | 5 votes |
public static void initFilenameInputDialog(MaterialDialog show) { final EditText editText = show.getInputEditText(); editText.setSingleLine(); editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); // create an initial filename to suggest to the user String filename = createLogFilename(); editText.setText(filename); // highlight everything but the .txt at the end editText.setSelection(0, filename.length() - 4); }
Example 7
Source File: RuleListFragment.java From XposedSmsCode with GNU General Public License v3.0 | 4 votes |
private void attemptExportRuleList() { if (mRuleAdapter.getItemCount() == 0) { SnackbarHelper.makeLong(mRecyclerView, R.string.rule_list_empty_snack_prompt).show(); return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // Android Q 及以后,使用 SAF (Storage Access Framework) 来导入导出文档文件 Intent exportIntent = BackupManager.getExportRuleListSAFIntent(); try { startActivityForResult(exportIntent, REQUEST_CODE_EXPORT_RULES); } catch (Exception e) { // 防止某些 Rom 将 DocumentUI 阉割掉 SnackbarHelper.makeLong(mRecyclerView, R.string.documents_ui_not_found).show(); } } else { // 考虑到在低版本的 Android 系统中,不少 Rom 将 DocumentUI 阉割掉了,无法使用 SAF // Android P 及以前,使用原有方式进行文件导入导出 String perm = Manifest.permission.WRITE_EXTERNAL_STORAGE; if (ContextCompat.checkSelfPermission(mActivity, perm) != PackageManager.PERMISSION_GRANTED) { showNoPermissionInfo(); return; } final String defaultFilename = BackupManager.getDefaultBackupFilename(); String hint = getString(R.string.backup_file_name); String content = getString(R.string.backup_file_dir, BackupManager.getBackupDir().getAbsolutePath()); final MaterialDialog exportFilenameDialog = new MaterialDialog.Builder(mActivity) .title(R.string.backup_file_name) .content(content) .input(hint, defaultFilename, (dialog, input) -> { File file = new File(BackupManager.getBackupDir(), input.toString()); mPresenter.exportRulesBelowQ(mRuleAdapter.getRuleList(), file, getString(R.string.exporting)); }) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE) .negativeText(R.string.cancel) .build(); final EditText editText = exportFilenameDialog.getInputEditText(); if (editText != null) { exportFilenameDialog.setOnShowListener(dialog -> { int stop = defaultFilename.length() - BackupManager.getBackupFileExtension().length(); editText.setSelection(0, stop); }); final MDButton positiveBtn = exportFilenameDialog.getActionButton(DialogAction.POSITIVE); editText.addTextChangedListener(new TextWatcherAdapter() { @Override public void afterTextChanged(Editable s) { positiveBtn.setEnabled(Utils.isValidFilename(s.toString())); } }); } exportFilenameDialog.show(); } }
Example 8
Source File: AlgDialog.java From TwistyTimer with GNU General Public License v3.0 | 4 votes |
@Override public void onClick(View view) { final DatabaseHandler dbHandler = TwistyTimer.getDBHandler(); switch (view.getId()) { case R.id.editButton: MaterialDialog dialog = ThemeUtils.roundDialog(mContext, new MaterialDialog.Builder(mContext) .title(R.string.edit_algorithm) .input("", algorithm.getAlgs(), (dialog1, input) -> { algorithm.setAlgs(input.toString()); dbHandler.updateAlgorithmAlg(mId, input.toString()); algText.setText(input.toString()); updateList(); }) .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE) .positiveText(R.string.action_done) .negativeText(R.string.action_cancel) .build()); EditText editText = dialog.getInputEditText(); if (editText != null) { editText.setSingleLine(false); editText.setLines(5); editText.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION); editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); } dialog.show(); break; case R.id.progressButton: final AppCompatSeekBar seekBar = (AppCompatSeekBar) LayoutInflater.from(mContext).inflate(R.layout.dialog_progress, null); seekBar.setProgress(algorithm.getProgress()); ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext) .title(R.string.dialog_set_progress) .customView(seekBar, false) .positiveText(R.string.action_update) .negativeText(R.string.action_cancel) .onPositive((dialog12, which) -> { int seekProgress = seekBar.getProgress(); algorithm.setProgress(seekProgress); dbHandler.updateAlgorithmProgress(mId, seekProgress); progressBar.setProgress(seekProgress); updateList(); }) .build()); break; case R.id.revertButton: ThemeUtils.roundAndShowDialog(mContext, new MaterialDialog.Builder(mContext) .title(R.string.dialog_revert_title_confirmation) .content(R.string.dialog_revert_content_confirmation) .positiveText(R.string.action_reset) .negativeText(R.string.action_cancel) .onPositive((dialog13, which) -> { algorithm.setAlgs(AlgUtils.getDefaultAlgs(algorithm.getSubset(), algorithm.getName())); dbHandler.updateAlgorithmAlg(mId, algorithm.getAlgs()); algText.setText(algorithm.getAlgs()); }) .build()); break; } }