List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:org.de.jmg.learn.MainActivity.java
private void searchQuizlet() { try {/*from w w w . j ava2 s. co m*/ if (this.QuizletAccessToken == null) { this.QuizletAccessToken = prefs.getString("QuizletAccessToken", null); this.QuizletUser = prefs.getString("QuizletUser", null); if (QuizletAccessToken != null) { final CountDownLatch l = new CountDownLatch(1); new Thread(new Runnable() { @Override public void run() { try { _blnVerifyToken = org.liberty.android.fantastischmemo.downloader.quizlet.lib .verifyAccessToken(new String[] { QuizletAccessToken, QuizletUser }); } catch (Exception e) { e.printStackTrace(); _blnVerifyToken = false; } l.countDown(); } }).start(); l.await(); if (!_blnVerifyToken) { QuizletAccessToken = null; QuizletUser = null; } } } if (this.QuizletAccessToken == null) { this.LoginQuizlet(false); } else if (fPA != null && fPA.fragQuizlet != null) { final AlertDialog.Builder A = new AlertDialog.Builder(context); final CharSequence[] items = { MainActivity.this.getString(R.string.Private), MainActivity.this.getString(R.string.Public) }; A.setSingleChoiceItems(items, _blnPrivate ? 0 : 1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { _blnPrivate = which == 0; } }); final EditText input = new EditText(context); //final LinearLayout ll = new LinearLayout(context); //ll.addView(input); A.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (_blnPrivate || !libString.IsNullOrEmpty(input.getText().toString())) { fPA.fragQuizlet.setSearchPhrase(input.getText().toString()); fPA.fragQuizlet.blnPrivate = _blnPrivate; fPA.fragQuizlet.Load(); lib.removeDlg(dlg); //fPA.fragQuizlet.Login(); } } }); A.setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { lib.removeDlg(dlg); } }); A.setTitle(getString(R.string.SearchQuizlet)); //A.setTitle(getString(R.string.Search)); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT); input.setText(fPA.fragQuizlet.getOriginalSearchPhrase()); /* android.widget.LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) input.getLayoutParams(); params.topMargin = lib.dpToPx(20); input.setLayoutParams(params); */ A.setView(input); /* int PT = input.getPaddingTop(); int PL = input.getPaddingLeft(); int PR = input.getPaddingRight(); int PB = input.getPaddingBottom(); //int PE = input.getPaddingEnd(); //int PS = input.getPaddingStart(); input.setPadding(PL,PT*3,PR,PB); */ dlg = A.create(); dlg.show(); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { lib.removeDlg(dlg); } }); lib.OpenDialogs.add(dlg); } } catch (Exception ex) { lib.ShowException(this, ex); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptVNCAllowExternal(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Enable VNC server"); TextView textView = new TextView(activity); textView.setVisibility(View.VISIBLE); textView.setId(201012010);/*ww w .ja v a 2 s . c om*/ textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n" + "Warning: VNC is not secure make sure you're on a private network!\n"); EditText passwdView = new EditText(activity); passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwdView.setHint("Password"); passwdView.setEnabled(true); passwdView.setVisibility(View.VISIBLE); passwdView.setId(11111); passwdView.setSingleLine(); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222); RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId()); mLayout.addView(textView, textViewParams); RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId()); // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, // mLayout.getId()); mLayout.addView(passwdView, passwordViewParams); alertDialog.setView(mLayout); final Handler handler = this.handler; alertDialog.setButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(11111); if (a.getText().toString().trim().equals("")) { Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show(); vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } else { sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd"); vnc_passwd = a.getText().toString(); vnc_allow_external = 1; // LimboSettingsManager.setVNCAllowExternal(activity, true); } } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); vnc_passwd = null; vnc_allow_external = 0; } }); alertDialog.show(); }
From source file:com.android.launcher3.Utilities.java
public static void showEditMode(final Activity activity, final ShortcutInfo shortcutInfo) { ContextThemeWrapper theme;//from w w w.j av a 2s .co m final Set<String> setString = new HashSet<String>(); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { theme = new ContextThemeWrapper(activity, R.style.AlertDialogCustomAPI23); } else { theme = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); } AlertDialog.Builder alert = new AlertDialog.Builder(theme); LinearLayout layout = new LinearLayout(activity.getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(100, 0, 100, 100); final ImageView img = new ImageView(activity.getApplicationContext()); Drawable icon = null; if (Utilities.getAppIconPackageNamePrefEnabled(activity.getApplicationContext()) != null) { if (Utilities.getAppIconPackageNamePrefEnabled(activity.getApplicationContext()).equals("NULL")) { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), shortcutInfo.getIcon(new IconCache(activity.getApplicationContext(), Launcher.getLauncher(activity).getDeviceProfile().inv))); } } else { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), Launcher.getIcons().get(shortcutInfo.getTargetComponent().getPackageName())); } } } else { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), shortcutInfo.getIcon(new IconCache(activity.getApplicationContext(), Launcher.getLauncher(Launcher.getLauncherActivity()).getDeviceProfile().inv))); } } img.setImageDrawable(icon); img.setPadding(0, 100, 0, 0); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showIconPack(activity, shortcutInfo); } }); final EditText titleBox = new EditText(activity.getApplicationContext()); try { Set<String> title = new HashSet<>( Utilities.getTitle(activity, shortcutInfo.getTargetComponent().getPackageName())); for (Iterator<String> it = title.iterator(); it.hasNext();) { String titleApp = it.next(); titleBox.setText(titleApp); } } catch (Exception e) { titleBox.setText(shortcutInfo.title); } titleBox.getBackground().mutate().setColorFilter( ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP); layout.addView(img); layout.addView(titleBox); alert.setTitle(activity.getApplicationContext().getResources().getString(R.string.edit_label)); alert.setView(layout); alert.setPositiveButton(activity.getApplicationContext().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for (ItemInfo itemInfo : AllAppsList.data) { if (shortcutInfo.getTargetComponent().getPackageName() .equals(itemInfo.getTargetComponent().getPackageName())) { setString.add(titleBox.getText().toString()); getPrefs(activity.getApplicationContext()).edit() .putStringSet(itemInfo.getTargetComponent().getPackageName(), setString) .apply(); Launcher.getShortcutsCreation().clearAllLayout(); applyChange(activity); } } } }); alert.setNegativeButton(activity.getApplicationContext().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Launcher.getShortcutsCreation().clearAllLayout(); } }); alert.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMachineName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Machine Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from w ww . ja v a 2s. c o m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString()); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptImageName(final Activity activity, String hd) { final String hd_string = hd; final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Image Name"); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222);// w w w . j a v a 2s .com EditText imageNameView = new EditText(activity); imageNameView.setEnabled(true); imageNameView.setVisibility(View.VISIBLE); imageNameView.setId(201012010); imageNameView.setSingleLine(); RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); mLayout.addView(imageNameView, searchViewParams); final Spinner size = new Spinner(this); RelativeLayout.LayoutParams setPlusParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); size.setId(201012044); String[] arraySpinner = new String[7]; for (int i = 0; i < arraySpinner.length; i++) { if (i < 5) { arraySpinner[i] = (i + 1) + " GB"; } } arraySpinner[5] = "10 GB"; arraySpinner[6] = "20 GB"; ArrayAdapter sizeAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner); sizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); size.setAdapter(sizeAdapter); setPlusParams.addRule(RelativeLayout.BELOW, imageNameView.getId()); mLayout.addView(size, setPlusParams); // TODO: Not working for now // final TextView preallocText = new TextView(this); // preallocText.setText("Preallocate? "); // preallocText.setTextSize(15); // RelativeLayout.LayoutParams preallocTParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocTParams.addRule(RelativeLayout.BELOW, size.getId()); // mLayout.addView(preallocText, preallocTParams); // preallocText.setId(64512044); // // final CheckBox prealloc = new CheckBox(this); // RelativeLayout.LayoutParams preallocParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocParams.addRule(RelativeLayout.BELOW, size.getId()); // preallocParams.addRule(RelativeLayout.RIGHT_OF, // preallocText.getId()); // preallocParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, // preallocText.getId()); // mLayout.addView(prealloc, preallocParams); // prealloc.setId(64512344); alertDialog.setView(mLayout); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int sizeSel = size.getSelectedItemPosition(); String templateImage = "hd1g.qcow2"; if (sizeSel < 5) { templateImage = "hd" + (sizeSel + 1) + "g.qcow2"; } else if (sizeSel == 5) { templateImage = "hd10g.qcow2"; } else if (sizeSel == 6) { templateImage = "hd20g.qcow2"; } // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); progDialog = ProgressDialog.show(activity, "Please Wait", "Creating HD Image...", true); // CreateImage createImg = new // CreateImage(a.getText().toString(), // hd_string, sizeInt, prealloc.isChecked()); // CreateImage createImg = new CreateImage(a.getText().toString(), // hd_string, sizeInt, false); // createImg.execute(); String image = a.getText().toString(); if (!image.endsWith(".qcow2")) { image += ".qcow2"; } createImg(templateImage, image, hd_string); } }); alertDialog.show(); }
From source file:net.robotmedia.acv.ui.widget.OcrLayout.java
/** Send the provided text to the OCR Error Correction dialog. */ private void sendToErrorCorrectionDialog(String text) { final EditText input = new EditText(this.context); input.setText(text);/*w ww. ja v a 2s . c o m*/ new AlertDialog.Builder(this.context) .setTitle(this.context.getResources().getString(R.string.ocr_error_correction_dialog_title)) .setMessage(this.context.getResources().getString(R.string.ocr_error_correction_dialog_msg)) .setView(input).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { lastOcrText = input.getText().toString(); // Reset the prev/next history lookupWordIdxStack = new Stack<Integer>(); lookupWordIdxStack.push(0); updateDicViewText(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptStateName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Snapshot/State Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from www. j a va 2s. c o m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" }, new String[] { a.getText().toString() }); return; } }); alertDialog.show(); }
From source file:com.homeworkreminder.Main.java
private void showDialogForNewSubject() { // TODO Auto-generated method stub AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); alertDialog.setTitle("Create a new subject"); alertDialog.setMessage("Name the your subject"); final EditText input = new EditText(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(10, 0, 10, 0);/* w w w.ja va2 s .c o m*/ input.setLayoutParams(lp); alertDialog.setView(input); alertDialog.setPositiveButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String subject = input.getText().toString(); if (subject.contentEquals("")) { Toast.makeText(context, "Subject name cannot be empty", Toast.LENGTH_LONG).show(); return; } if (!(subjectArray.contains(subject))) { addSubject(subject); dialog.dismiss(); } else if (subject.contentEquals(ADD_SUBJECT)) { Toast.makeText(context, "Cannot use this name", Toast.LENGTH_LONG).show(); dialog.dismiss(); } else { Toast.makeText(context, "Subject already exists", Toast.LENGTH_LONG).show(); dialog.dismiss(); } } }); // Setting Negative Button alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after // dialog dialog.cancel(); } }); alertDialog.show(); }
From source file:com.ichi2.anki2.DeckPicker.java
/** Handles item selections */ @Override//from w w w .ja v a 2 s .com public boolean onOptionsItemSelected(MenuItem item) { Resources res = getResources(); switch (item.getItemId()) { case MENU_HELP: showDialog(DIALOG_SELECT_HELP); return true; case MENU_SYNC: sync(); return true; case MENU_ADD_NOTE: addNote(); return true; case MENU_STATISTICS: showDialog(DIALOG_SELECT_STATISTICS_TYPE); return true; case MENU_CARDBROWSER: openCardBrowser(); return true; case MENU_CREATE_DECK: StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this); builder2.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder2.setView(mDialogEditText, false, false); builder2.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String deckName = mDialogEditText.getText().toString().replaceAll("[\'\"\\n\\r\\[\\]\\(\\)]", ""); Log.i(AnkiDroidApp.TAG, "Creating deck: " + deckName); AnkiDroidApp.getCol().getDecks().id(deckName, true); loadCounts(); } }); builder2.setNegativeButton(res.getString(R.string.cancel), null); builder2.create().show(); return true; case MENU_CREATE_DYNAMIC_DECK: StyledDialog.Builder builder3 = new StyledDialog.Builder(DeckPicker.this); builder3.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames(); int n = 1; String cramDeckName = "Cram 1"; while (names.contains(cramDeckName)) { n++; cramDeckName = "Cram " + n; } mDialogEditText.setText(cramDeckName); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder3.setView(mDialogEditText, false, false); builder3.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { long id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString()); openStudyOptions(id, new Bundle()); } }); builder3.setNegativeButton(res.getString(R.string.cancel), null); builder3.create().show(); return true; case MENU_ABOUT: startActivity(new Intent(DeckPicker.this, Info.class)); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(DeckPicker.this, ActivityTransitionAnimation.RIGHT); } return true; case MENU_ADD_SHARED_DECK: if (AnkiDroidApp.getCol() != null) { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String hkey = preferences.getString("hkey", ""); if (hkey.length() == 0) { showDialog(DIALOG_USER_NOT_LOGGED_IN_ADD_SHARED_DECK); } else { addSharedDeck(); } } return true; case MENU_IMPORT: showDialog(DIALOG_IMPORT_HINT); return true; case MENU_PREFERENCES: startActivityForResult(new Intent(DeckPicker.this, Preferences.class), PREFERENCES_UPDATE); return true; case MENU_FEEDBACK: Intent i = new Intent(DeckPicker.this, Feedback.class); i.putExtra("request", REPORT_FEEDBACK); startActivityForResult(i, REPORT_FEEDBACK); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT); } return true; case CHECK_DATABASE: integrityCheck(); return true; case StudyOptionsActivity.MENU_ROTATE: if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } return true; case StudyOptionsActivity.MENU_NIGHT: SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this); if (preferences.getBoolean("invertedColors", false)) { preferences.edit().putBoolean("invertedColors", false).commit(); item.setIcon(R.drawable.ic_menu_night); } else { preferences.edit().putBoolean("invertedColors", true).commit(); item.setIcon(R.drawable.ic_menu_night_checked); } return true; case MENU_REUPGRADE: restartUpgradeProcess(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
/** Handles item selections */ @Override// ww w .jav a 2s . c o m public boolean onOptionsItemSelected(MenuItem item) { Resources res = getResources(); switch (item.getItemId()) { case MENU_HELP: showDialog(DIALOG_SELECT_HELP); return true; case MENU_SYNC: sync(); return true; case MENU_ADD_NOTE: addNote(); return true; case MENU_STATISTICS: showDialog(DIALOG_SELECT_STATISTICS_TYPE); return true; case MENU_CARDBROWSER: openCardBrowser(); return true; case MENU_CREATE_DECK: StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this); builder2.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder2.setView(mDialogEditText, false, false); builder2.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String deckName = mDialogEditText.getText().toString().replaceAll("[\'\"\\n\\r\\[\\]\\(\\)]", ""); // Log.i(AnkiDroidApp.TAG, "Creating deck: " + deckName); AnkiDroidApp.getCol().getDecks().id(deckName, true); loadCounts(); } }); builder2.setNegativeButton(res.getString(R.string.cancel), null); builder2.create().show(); return true; case MENU_CREATE_DYNAMIC_DECK: StyledDialog.Builder builder3 = new StyledDialog.Builder(DeckPicker.this); builder3.setTitle(res.getString(R.string.new_deck)); mDialogEditText = (EditText) new EditText(DeckPicker.this); ArrayList<String> names = AnkiDroidApp.getCol().getDecks().allNames(); int n = 1; String cramDeckName = "Cram 1"; while (names.contains(cramDeckName)) { n++; cramDeckName = "Cram " + n; } mDialogEditText.setText(cramDeckName); // mDialogEditText.setFilters(new InputFilter[] { mDeckNameFilter }); builder3.setView(mDialogEditText, false, false); builder3.setPositiveButton(res.getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { long id = AnkiDroidApp.getCol().getDecks().newDyn(mDialogEditText.getText().toString()); openStudyOptions(id, new Bundle()); } }); builder3.setNegativeButton(res.getString(R.string.cancel), null); builder3.create().show(); return true; case MENU_ABOUT: startActivity(new Intent(DeckPicker.this, Info.class)); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(DeckPicker.this, ActivityTransitionAnimation.RIGHT); } return true; case MENU_ADD_SHARED_DECK: if (AnkiDroidApp.getCol() != null) { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String hkey = preferences.getString("hkey", ""); if (hkey.length() == 0) { showDialog(DIALOG_USER_NOT_LOGGED_IN_ADD_SHARED_DECK); } else { addSharedDeck(); } } return true; case MENU_IMPORT: showDialog(DIALOG_IMPORT_HINT); return true; case MENU_PREFERENCES: startActivityForResult(new Intent(DeckPicker.this, Preferences.class), PREFERENCES_UPDATE); return true; case MENU_FEEDBACK: Intent i = new Intent(DeckPicker.this, Feedback.class); i.putExtra("request", REPORT_FEEDBACK); startActivityForResult(i, REPORT_FEEDBACK); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(this, ActivityTransitionAnimation.RIGHT); } return true; case CHECK_DATABASE: integrityCheck(); return true; case StudyOptionsActivity.MENU_ROTATE: if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } return true; case StudyOptionsActivity.MENU_NIGHT: SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(this); if (preferences.getBoolean("invertedColors", false)) { preferences.edit().putBoolean("invertedColors", false).commit(); item.setIcon(R.drawable.ic_menu_night); } else { preferences.edit().putBoolean("invertedColors", true).commit(); item.setIcon(R.drawable.ic_menu_night_checked); } return true; case MENU_REUPGRADE: restartUpgradeProcess(); return true; default: return super.onOptionsItemSelected(item); } }