List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.iiordanov.runsoft.bVNC.RemoteCanvasActivity.java
private void initChatListView() { listView = (ListView) findViewById(R.id.listViewChat); btnChatShowToggle = (Button) findViewById(R.id.btnChatShowToggle); Button btnChatClose = (Button) findViewById(R.id.btnChatClose); Button btnSend = (Button) findViewById(R.id.btnSend); chat_layout = findViewById(R.id.chat_layout); if (adapter == null) { adapter = new ChatListAdapter(this, dataList); }// w w w . j a va 2 s .c o m listView.setAdapter(adapter); btnChatShowToggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (TextUtils.isEmpty((CharSequence) btnChatShowToggle.getTag())) { chat_layout.setVisibility(View.VISIBLE); canvas.getKeyboard().setIsChating(true); btnChatShowToggle.setTag("toggle on"); btnChatShowToggle.setVisibility(View.GONE); } else { canvas.getKeyboard().setIsChating(false); chat_layout.setVisibility(View.GONE); btnChatShowToggle.setTag(""); } } }); btnChatClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { btnChatShowToggle.setVisibility(View.VISIBLE); canvas.getKeyboard().setIsChating(false); chat_layout.setVisibility(View.GONE); btnChatShowToggle.setTag(""); } }); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO runsoft.com.runsupport.mqtt.MSGRECVD final EditText edit = new EditText(RemoteCanvasActivity.this); edit.setBackgroundColor(Color.WHITE); edit.setTextColor(getResources().getColor(R.color.button_text_color)); new AlertDialog.Builder(RemoteCanvasActivity.this).setTitle(" ").setView(edit) .setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String msg = edit.getText().toString().trim(); if (TextUtils.isEmpty(msg)) { Toast.makeText(mThis, " ", Toast.LENGTH_LONG).show(); return; } try { Intent broadcastIntent = new Intent(); broadcastIntent.setAction("runsoft.com.runsupport.mqtt.MSGRECVD"); broadcastIntent.putExtra("runsoft.com.runsupport.mqtt.MSGRECVD_MSGBODY", String.format(Locale.getDefault(), "{\"mode\":\"%s\",\"msg\":\"%s\"}", "map_find_send_msg", msg)); sendBroadcast(broadcastIntent); } catch (Exception e1) { e1.printStackTrace(); } ChatData chatData = new ChatData(); chatData.msg = " : " + msg; chatData.date = getRegdateRelative(); dataList.add(0, chatData); adapter.notifyDataSetChanged(); InputMethodManager inputMgr = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } }).create().show(); } }); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void saveCfg() { localfinished = false;/*from w w w . j ava2s. c om*/ if (Globals.isMidi(currSongName) && Globals.isPlaying == 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Save Cfg"); alert.setMessage("Save a MIDI configuration file"); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; // Set an EditText view to get user input final EditText input = new EditText(this); input.setFilters(new InputFilter[] { filter }); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (!value.toLowerCase(Locale.US).endsWith(Globals.compressCfg ? ".tzf" : ".tcf")) value += (Globals.compressCfg ? ".tzf" : ".tcf"); String parent = currSongName.substring(0, currSongName.lastIndexOf('/') + 1); boolean aWrite = true; boolean alreadyExists = new File(parent + value).exists(); String needRename = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { new FileOutputStream(parent + value, true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } if (!alreadyExists && aWrite) new File(parent + value).delete(); if (aWrite && new File(parent).canWrite()) { value = parent + value; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { //TODO // Write the file to getExternalFilesDir, then move it with the Uri // We need to tell JNIHandler that movement is needed. String[] tmp = Globals.getDocFilePaths(TimidityActivity.this, parent); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename = parent .substring(parent.indexOf(probablyTheRoot) + probablyTheRoot.length()) + value; value = probablyTheDirectory + '/' + value; } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; return; } } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } final String finalval = value; final boolean canWrite = aWrite; final String needToRename = needRename; final String probRoot = probablyTheRoot; if (new File(finalval).exists() || (new File(probRoot + needRename).exists() && needToRename != null)) { AlertDialog dialog2 = new AlertDialog.Builder(TimidityActivity.this).create(); dialog2.setTitle("Warning"); dialog2.setMessage("Overwrite config file?"); dialog2.setCancelable(false); dialog2.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename != null) { Globals.tryToDeleteFile(TimidityActivity.this, probRoot + needToRename); Globals.tryToDeleteFile(TimidityActivity.this, finalval); } else { Globals.tryToDeleteFile(TimidityActivity.this, finalval); } } else { new File(finalval).delete(); } saveCfgPart2(finalval, needToRename); } }); dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog2.show(); } else { saveCfgPart2(finalval, needToRename); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alerty = alert.show(); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void makeSearchBox() { int boxColor = Color.rgb(241, 238, 229); int innerBoxColor = Color.rgb(246, 244, 239); int inlineColor = Color.rgb(133, 105, 75); RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height searchBox = new SkyBox(this); searchBox.setBoxColor(boxColor);//w ww . j av a 2 s . c om searchBox.setArrowHeight(ps(25)); searchBox.setArrowDirection(false); param.leftMargin = ps(50); param.topMargin = ps(400); param.width = ps(400); param.height = ps(300); searchBox.setLayoutParams(param); searchBox.setArrowDirection(false); searchEditor = new EditText(this); this.setFrame(searchEditor, ps(20), ps(20), ps(400 - 140), ps(50)); searchEditor.setTextSize(15f); searchEditor.setEllipsize(TruncateAt.END); searchEditor.setBackgroundColor(innerBoxColor); Drawable icon = getResources().getDrawable(R.drawable.search2x); Bitmap bitmap = ((BitmapDrawable) icon).getBitmap(); Drawable fd = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, ps(28), ps(28), true)); searchEditor.setCompoundDrawablesWithIntrinsicBounds(fd, null, null, null); RoundRectShape rrs = new RoundRectShape( new float[] { ps(15), ps(15), ps(15), ps(15), ps(15), ps(15), ps(15), ps(15) }, null, null); SkyDrawable sd = new SkyDrawable(rrs, innerBoxColor, inlineColor, 2); searchEditor.setBackgroundDrawable(sd); searchEditor.setHint(getString(R.string.searchhint)); searchEditor.setPadding(ps(20), ps(5), ps(10), ps(5)); searchEditor.setLines(1); searchEditor.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchEditor.setSingleLine(); searchEditor.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_NEXT) { String key = searchEditor.getText().toString(); if (key != null && key.length() > 1) { showIndicator(); clearSearchBox(1); makeFullScreen(); rv.searchKey(key); } } return false; } }); searchBox.contentView.addView(searchEditor); Button cancelButton = new Button(this); this.setFrame(cancelButton, ps(290), ps(20), ps(90), ps(50)); cancelButton.setText(getString(R.string.cancel)); cancelButton.setId(3001); RoundRectShape crs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable cd = new SkyDrawable(crs, innerBoxColor, inlineColor, 2); cancelButton.setBackgroundDrawable(cd); cancelButton.setTextSize(12); cancelButton.setOnClickListener(listener); cancelButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(cancelButton)); searchBox.contentView.addView(cancelButton); searchScrollView = new ScrollView(this); RoundRectShape rvs = new RoundRectShape( new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null); SkyDrawable rd = new SkyDrawable(rvs, innerBoxColor, inlineColor, 2); searchScrollView.setBackgroundDrawable(rd); this.setFrame(searchScrollView, ps(20), ps(100), ps(360), ps(200)); this.searchBox.contentView.addView(searchScrollView); searchResultView = new LinearLayout(this); searchResultView.setOrientation(LinearLayout.VERTICAL); searchScrollView.addView(searchResultView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.ePubView.addView(searchBox); this.hideSearchBox(); }
From source file:dentex.youtube.downloader.DashboardActivity.java
public void spawnSearchBar() { Utils.logger("d", "showing searchbar...", DEBUG_TAG); EditText inputSearch = new EditText(DashboardActivity.this); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); inputSearch.setLayoutParams(layoutParams); if (TextUtils.isEmpty(searchText)) { inputSearch.setHint(R.string.menu_search); } else {/* w ww . jav a 2 s .co m*/ inputSearch.setText(searchText); } inputSearch.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); inputSearch.setSingleLine(); inputSearch.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); inputSearch.setId(999); LinearLayout layout = (LinearLayout) findViewById(R.id.dashboard); layout.addView(inputSearch, 0); isSearchBarVisible = true; inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { Utils.logger("d", "Text [" + s + "] - Start [" + start + "] - Before [" + before + "] - Count [" + count + "]", DEBUG_TAG); if (count < before) da.resetData(); da.getFilter().filter(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:edu.oakland.festinfo.activities.MapPageActivity.java
@Click(R.id.search_for_marker) public void searchForMarker() { AlertDialog.Builder searchInput = new AlertDialog.Builder(MapPageActivity.this); searchInput.setTitle("Enter Search Text: "); final EditText changeInput = new EditText(MapPageActivity.this); changeInput.setInputType(InputType.TYPE_CLASS_TEXT); searchInput.setView(changeInput);//from w w w .j ava 2 s . c om searchInput.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { boolean foundMarker = false; if (changeInput.getText().toString().matches("")) { Toast.makeText(getApplicationContext(), "No Input Entered!", Toast.LENGTH_SHORT).show(); } else { for (int i = 0; i < combinedArray.size(); i++) { if (combinedArray.get(i).getMarker().getTitle().toLowerCase() .equals(changeInput.getText().toString().toLowerCase())) { LatLng point = combinedArray.get(i).getMarker().getPosition(); map.animateCamera(CameraUpdateFactory.newLatLng(point)); combinedArray.get(i).getMarker().showInfoWindow(); foundMarker = true; break; } } if (foundMarker == false) { Toast.makeText(MapPageActivity.this, "Cannot find marker", Toast.LENGTH_SHORT).show(); } } } }); searchInput.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); searchInput.show(); }
From source file:de.ub0r.android.websms.WebSMS.java
@Override protected final Dialog onCreateDialog(final int id) { AlertDialog.Builder builder;//from w w w . j a v a 2 s.c o m switch (id) { case DIALOG_CUSTOMSENDER: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.custom_sender); builder.setCancelable(true); final EditText et = new EditText(this); builder.setView(et); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { WebSMS.lastCustomSender = et.getText().toString(); } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); case DIALOG_SENDLATER_DATE: Calendar c = Calendar.getInstance(); return new DatePickerDialog(this, this, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)); case DIALOG_SENDLATER_TIME: c = Calendar.getInstance(); return new MyTimePickerDialog(this, this, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true); case DIALOG_EMO: return this.createEmoticonsDialog(); default: return null; } }
From source file:com.bookkos.bircle.CaptureActivity.java
private void titleInputDialog(final String isbn, final JSONArray json_array) { // ?????//from w w w . j a v a 2 s .c o m final EditText titleEditText = new EditText(_activity); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("???????????"); alertDialogBuilder.setMessage("??????????!"); alertDialogBuilder.setView(titleEditText); alertDialogBuilder.setPositiveButton("????", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String title = titleEditText.getText().toString(); // ?????manually_catalog_register??? if (!title.isEmpty() || title != " " || title != "") { title = title.replaceAll(" ", "_"); title = title.replaceAll("", "_"); String request_url = initManuallyCatalogRegistUrl + isbn + "&title=" + title; HttpConnectPostReturnFlag manuallyCatalogRegist = new HttpConnectPostReturnFlag( _activity, request_url); manuallyCatalogRegist.execute(); // ???????????, ??json_array?????????, ??? if (json_array != null) { parseShelfData(isbn, json_array); } else { // ??????, ?ISBN?????? if (registFlag == 1) { // ????????????? arrayList.add("&book_code[]=" + lastResult); if (bookListViewAdapter.isEmpty()) { animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight); borrowReturnButton.setEnabled(false); registButton.setEnabled(false); } bookListViewAdapter.add(new BookListViewItem(lastResult.toString())); // for(int i=0; i < arrayList.size(); i++){ // text += arrayList.get(i) + "\n"; // } Toast.makeText(_context, "ISBN = " + lastResult + " ?????.", Toast.LENGTH_SHORT).show(); bircleBeepManager.playBeepSoundAndVibrate(2); restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS); } } } else { Toast.makeText(_context, "???????!", Toast.LENGTH_LONG) .show(); } } }); alertDialogBuilder.setNeutralButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS); } }); alertDialogBuilder.setCancelable(true); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialogBuilder.show(); }
From source file:org.de.jmg.learn.MainActivity.java
private void uploadtoQuizlet() { if (vok.getGesamtzahl() < 3) return;// ww w . j a v a2s . c o m try { 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(true); } else { 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) { String userId = MainActivity.this.QuizletUser; if (!_blnPrivate) { userId = ""; } else { if (lib.ShowMessageOKCancel(MainActivity.this, MainActivity.this.getString(R.string.msgPrivateNotSupported), "", false) == yesnoundefined.no) return; } new UploadToQuzletTask().execute(input.getText().toString(), userId); lib.removeDlg(dlg); } }); A.setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { lib.removeDlg(dlg); } }); String name = ""; if (vok.getURI() != null) { name = vok.getURI().getLastPathSegment(); } if (!libString.IsNullOrEmpty(vok.getFileName())) { try { name = new File(vok.getFileName()).getName(); } catch (Exception ex) { ex.printStackTrace(); } } A.setTitle(String.format(getString(R.string.UploadToQuizlet), name)); //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(""); /* 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:org.anurag.file.quest.TaskerActivity.java
@Override public void onClick(final View v) { CURRENT_ITEM = mViewPager.getCurrentItem(); switch (v.getId()) { case R.id.bottom_Quit: QuickAction ad = new QuickAction(getApplicationContext()); ActionItem adi = new ActionItem(0, "Quit The App"); ad.addActionItem(adi);/*from w w w . ja v a 2s .co m*/ adi = new ActionItem(getResources().getDrawable(R.drawable.org_anurag_questbrowser_underline)); ad.addActionItem(adi); adi = new ActionItem(1, " Yes", getResources().getDrawable(R.drawable.ic_launcher_apply)); ad.addActionItem(adi); adi = new ActionItem(2, " No", getResources().getDrawable(R.drawable.ic_launcher_quit)); ad.addActionItem(adi); ad.setOnActionItemClickListener(new OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int actionId) { // TODO Auto-generated method stub if (actionId == 1) { TaskerActivity.this.finish(); } } }); ad.show(v); break; case R.id.bottom_refresh: setAdapter(CURRENT_ITEM); Toast.makeText(getBaseContext(), "View Refreshed", Toast.LENGTH_SHORT).show(); break; case R.id.bottom_paste: if (CURRENT_ITEM == 0) { QuickAction ac = new QuickAction(getBaseContext()); ActionItem it = new ActionItem(0, "Paste Option Is Not Allowed Here"); ac.addActionItem(it); ac.show(v); } else { pasteCommand(false); } break; case R.id.bottom_copy: OPERATION_ON_MULTI_SELECT_FILES(CURRENT_ITEM, 5, "First select this multi select mode for current panel,then select files "); break; case R.id.bottom_cut: OPERATION_ON_MULTI_SELECT_FILES(CURRENT_ITEM, 2, "First select this multi select mode for current panel,then select files "); break; case R.id.bottom_zip: OPERATION_ON_MULTI_SELECT_FILES(CURRENT_ITEM, 3, "First select this multi select mode for current panel,then select files "); break; case R.id.bottom_delete: OPERATION_ON_MULTI_SELECT_FILES(CURRENT_ITEM, 4, "First select this multi select mode for current panel,then select files"); break; case R.id.appSettings: ShowMenu(); break; case R.id.bottom_multi: { QuickAction action = new QuickAction(getBaseContext()); ActionItem item = new ActionItem(); if (element == null || !elementInFocus) { item = new ActionItem(-1, "Enable for File Gallery", getResources().getDrawable(R.drawable.ic_launcher_images)); action.addActionItem(item); } else { if (MediaElementAdapter.MULTI_SELECT) item = new ActionItem(0, "Enabled for File Gallery", getResources().getDrawable(R.drawable.ic_launcher_apply)); else item = new ActionItem(0, "Enable for File Gallery", getResources().getDrawable(R.drawable.ic_launcher_images)); action.addActionItem(item); } if ((SimpleAdapter.MULTI_SELECT)) item = new ActionItem(1, "Enabled for /", getResources().getDrawable(R.drawable.ic_launcher_apply)); else item = new ActionItem(1, "Enable for /", getResources().getDrawable(R.drawable.ic_launcher_system)); action.addActionItem(item); if ((RootAdapter.MULTI_SELECT)) item = new ActionItem(2, "Enabled for Sdcard", getResources().getDrawable(R.drawable.ic_launcher_apply)); else item = new ActionItem(2, "Enable for Sdcard", getResources().getDrawable(R.drawable.ic_launcher_sdcard)); action.addActionItem(item); if (MULTI_SELECT_APPS) item = new ActionItem(3, "Enabled for App Store", getResources().getDrawable(R.drawable.ic_launcher_apply)); else item = new ActionItem(3, "Enable for App Store", getResources().getDrawable(R.drawable.ic_launcher_apk)); action.addActionItem(item); action.show(v); action.setOnActionItemClickListener(new OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int actionId) { // TODO Auto-generated method stub switch (actionId) { case -1: { QuickAction ac = new QuickAction(getBaseContext()); ActionItem it = new ActionItem(0, "First Go to FILE GALLERY " + "and select a category then enable MULTISELECT MODE for that"); ac.addActionItem(it); ac.show(v); } break; case 0: if (MediaElementAdapter.MULTI_SELECT) { element = new MediaElementAdapter(getBaseContext(), R.layout.row_list_1, mediaFileList); MediaElementAdapter.thumbselection = new boolean[mediaFileList.size()]; MediaElementAdapter.MULTI_SELECT = false; LIST_VIEW_3D.setAdapter(element); } else { element = new MediaElementAdapter(getBaseContext(), R.layout.row_list_1, mediaFileList); MediaElementAdapter.thumbselection = new boolean[mediaFileList.size()]; MediaElementAdapter.MULTI_SELECT = true; LIST_VIEW_3D.setAdapter(element); if (CURRENT_ITEM == 3) { mFlipperBottom.showNext(); mFlipperBottom.setAnimation(prevAnim()); mVFlipper.showPrevious(); mVFlipper.setAnimation(prevAnim()); } mViewPager.setCurrentItem(0); } break; case 1: if (SimpleAdapter.MULTI_SELECT) { nSimple = new SimpleAdapter(getBaseContext(), R.layout.row_list_1, sFiles); SimpleAdapter.thumbselection = new boolean[sFiles.size()]; SimpleAdapter.MULTI_SELECT = false; simple.setAdapter(nSimple); } else { nSimple = new SimpleAdapter(getBaseContext(), R.layout.row_list_1, sFiles); SimpleAdapter.thumbselection = new boolean[sFiles.size()]; SimpleAdapter.MULTI_SELECT = true; mViewPager.setCurrentItem(1); simple.setAdapter(nSimple); } break; case 2: if (RootAdapter.MULTI_SELECT) { RootAdapter = new RootAdapter(getBaseContext(), R.layout.row_list_1, nFiles); RootAdapter.thumbselection = new boolean[nFiles.size()]; RootAdapter.MULTI_SELECT = false; root.setAdapter(RootAdapter); } else { RootAdapter = new RootAdapter(getBaseContext(), R.layout.row_list_1, nFiles); RootAdapter.thumbselection = new boolean[nFiles.size()]; RootAdapter.MULTI_SELECT = true; mViewPager.setCurrentItem(2); root.setAdapter(RootAdapter); } break; case 3: if (MULTI_SELECT_APPS) { MULTI_SELECT_APPS = nAppAdapter.MULTI_SELECT = false; APP_LIST_VIEW.setAdapter(nAppAdapter); APP_LIST_VIEW.setSelection(pos); } else { MULTI_SELECT_APPS = nAppAdapter.MULTI_SELECT = true; mViewPager.setCurrentItem(3); APP_LIST_VIEW.setAdapter(nAppAdapter); APP_LIST_VIEW.setSelection(pos); } break; } } }); } break; case R.id.bottom_multi_send_app: if (MULTI_SELECT_APPS) { if (nAppAdapter.C > 0) { try { new MultiSendApps(mContext, size, nAppAdapter.MULTI_APPS); } catch (Exception e) { Toast.makeText(getBaseContext(), R.string.unabletosend, Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getBaseContext(), R.string.someapps, Toast.LENGTH_SHORT).show(); } } else { QuickAction ac = new QuickAction(getBaseContext()); ActionItem it = new ActionItem(0, getResources().getString((R.string.enablefirstforappstore))); ac.addActionItem(it); ac.show(v); } break; case R.id.bottom_multi_select_backup: if (MULTI_SELECT_APPS) { if (nAppAdapter.C > 0) { new MultileAppBackup(mContext, size.x * 7 / 9, nAppAdapter.MULTI_APPS, nAppAdapter.C, sto, sav, nAppAdapter.C); } else { Toast.makeText(getBaseContext(), R.string.someapps, Toast.LENGTH_SHORT).show(); } } else { QuickAction ac = new QuickAction(getBaseContext()); ActionItem it = new ActionItem(0, getResources().getString(R.string.enablefirstforappstore)); ac.addActionItem(it); ac.show(v); } break; case R.id.bottom_user_apps: // SETS THE SETTING TO SHOW DOWNLOADED APPS ONLY edit.putInt("SHOW_APP", 1); edit.commit(); SHOW_APP = nManager.SHOW_APP = 1; Toast.makeText(getBaseContext(), "Now Displaying User Apps Only", Toast.LENGTH_SHORT).show(); nList = nManager.giveMeAppList(); nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList); APP_LIST_VIEW.setAdapter(nAppAdapter); break; case R.id.bottom_system_apps: // SETS THE SETTING TO SHOW SYSTEM APPS ONLY edit.putInt("SHOW_APP", 2); edit.commit(); SHOW_APP = nManager.SHOW_APP = 2; Toast.makeText(getBaseContext(), "Now Displaying System Apps Only", Toast.LENGTH_SHORT).show(); nList = nManager.giveMeAppList(); nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList); APP_LIST_VIEW.setAdapter(nAppAdapter); break; case R.id.bottom_both_apps: // SETS THE SETTING TO SHOW DOWNLOADED AND SYSTEM APPS edit.putInt("SHOW_APP", 3); edit.commit(); SHOW_APP = nManager.SHOW_APP = 3; Toast.makeText(getBaseContext(), "Now Displaying Both User And System Apps", Toast.LENGTH_SHORT).show(); nList = nManager.giveMeAppList(); nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList); APP_LIST_VIEW.setAdapter(nAppAdapter); break; case R.id.searchBtn: searchList = new ArrayList<File>(); try { if (CURRENT_ITEM == 0 && !elementInFocus) { QuickAction ac = new QuickAction(getBaseContext()); ActionItem i = new ActionItem(1, "Filter Music Files", getResources().getDrawable(R.drawable.ic_launcher_music)); ac.addActionItem(i); i = new ActionItem(2, "Filter Apk Files", getResources().getDrawable(R.drawable.ic_launcher_apk)); ac.addActionItem(i); i = new ActionItem(3, "Filter Document Files", getResources().getDrawable(R.drawable.ic_launcher_ppt)); ac.addActionItem(i); i = new ActionItem(4, "Filter Image Files", getResources().getDrawable(R.drawable.ic_launcher_images)); ac.addActionItem(i); i = new ActionItem(5, "Filter Video Files", getResources().getDrawable(R.drawable.ic_launcher_video)); ac.addActionItem(i); i = new ActionItem(6, "Filter Zipped Files", getResources().getDrawable(R.drawable.ic_launcher_zip_it)); ac.addActionItem(i); i = new ActionItem(7, "Filter Miscellaneous Files", getResources().getDrawable(R.drawable.ic_launcher_rar)); ac.addActionItem(i); ac.setOnActionItemClickListener(this); ac.show(v); } else { search(); } } catch (IllegalStateException e) { } break; case R.id.applyBtn: //rename the file with given name from editBox editBox = new EditText(getBaseContext()); editBox = (EditText) findViewById(R.id.editBox); String name = editBox.getText().toString(); //String ext = extBox.getText().toString(); if (name.length() > 0) { if (CREATE_FILE) { // GETS THE PATH WHERE FOLDER OR FILE HAS TO BE CREATED // CREATE HIDDEN FOLDER if (CREATE_FLAG == 1) { if (name.startsWith(".")) name = CREATE_FLAG_PATH + "/" + name; else if (!name.startsWith(".")) name = CREATE_FLAG_PATH + "/." + name; if (CURRENT_ITEM == 1) { /** * TRY TO CREATE FOLDER WITH ROOT PREVILLEGES... */ LinuxShell.execute("mkdir " + name + "\n"); if (new File(name).exists()) { Toast.makeText(mContext, "Folder created at : " + name, Toast.LENGTH_SHORT).show(); setAdapter(CURRENT_ITEM); } else Toast.makeText(mContext, "Failed to create folder", Toast.LENGTH_SHORT).show(); } else if (CURRENT_ITEM == 2) { if (new File(name).mkdir()) { Toast.makeText(getApplicationContext(), "Folder Created At: " + name, Toast.LENGTH_LONG).show(); setAdapter(CURRENT_ITEM); } else if (!new File(name).mkdir()) Toast.makeText(getApplicationContext(), "Unable To Create Folder", Toast.LENGTH_LONG).show(); } RENAME_COMMAND = CREATE_FILE = SEARCH_FLAG = CUT_COMMAND = COPY_COMMAND = false; } // CREATE A SIMPLE FOLDER else if (CREATE_FLAG == 2) { name = CREATE_FLAG_PATH + "/" + name; if (CURRENT_ITEM == 1) { /** * TRY TO CREATE FOLDER WITH ROOT PREVILLEGES... */ LinuxShell.execute("mkdir " + name + "\n"); if (new File(name).exists()) { Toast.makeText(mContext, "Folder created at : " + name, Toast.LENGTH_SHORT).show(); setAdapter(CURRENT_ITEM); } else Toast.makeText(mContext, "Failed to create folder", Toast.LENGTH_SHORT).show(); } else if (CURRENT_ITEM == 2) { if (new File(name).mkdir()) { Toast.makeText(getApplicationContext(), "Folder Created At: " + name, Toast.LENGTH_LONG).show(); setAdapter(CURRENT_ITEM); } else if (!new File(name).mkdir()) Toast.makeText(getApplicationContext(), "Unable To Create Folder", Toast.LENGTH_LONG).show(); } RENAME_COMMAND = CREATE_FILE = SEARCH_FLAG = CUT_COMMAND = COPY_COMMAND = false; } //CREATE AN EMPTY FILE else if (CREATE_FLAG == 3) { try { if (CURRENT_ITEM == 1) { name = SFileManager.getCurrentDirectory() + "/" + editBox.getText().toString(); File f = new File(name); if (f.exists()) { Toast.makeText(getBaseContext(), "File with same name already exists", Toast.LENGTH_SHORT).show(); } else if (!f.exists()) { LinuxShell.execute("cat > " + name); setAdapter(CURRENT_ITEM); } } else if (CURRENT_ITEM == 2) { if (new File(name).createNewFile()) { Toast.makeText(getApplicationContext(), "File Created At: " + name, Toast.LENGTH_LONG).show(); setAdapter(CURRENT_ITEM); } } } catch (IOException e) { Toast.makeText(getApplicationContext(), "Unable To Create File", Toast.LENGTH_LONG) .show(); } } // AFTER CREATING FILES OR FOLDER AGAIN FLIPPER IS SET TO MAIN MENU mVFlipper.setAnimation(nextAnim()); mVFlipper.showNext(); } //THIS FLIPPER IS SET FOR RENAMING else if (RENAME_COMMAND) { if (CURRENT_ITEM == 0) { name = getPathWithoutFilename(file0).getPath() + "/" + name; if (file0.renameTo(new File(name))) { Toast.makeText(getBaseContext(), "Succesfully Renamed To :" + new File(name).getName(), Toast.LENGTH_SHORT).show(); } else { /** * THIS INTENT IS FIRED WHEN RENAMING OF FILE FAILS * SHOWING POSSIBLE ERROR */ new ErrorDialogs(mContext, size.x * 4 / 5, "renameError"); } } else if (CURRENT_ITEM == 1) { name = SFileManager.getCurrentDirectory() + "/" + name; try { /* * yet to implement rename command for root files */ } catch (Exception e) { /** * THIS INTENT IS FIRED WHEN RENAMING OF FILE FAILS * SHOWING POSSIBLE ERROR */ new ErrorDialogs(mContext, size.x * 4 / 5, "renameError"); } } else if (CURRENT_ITEM == 2) { name = RFileManager.getCurrentDirectory() + "/" + name; if (file2.renameTo(new File(name))) { Toast.makeText(getBaseContext(), "Succesfully Renamed To :" + new File(name).getName(), Toast.LENGTH_SHORT).show(); } else { /** * THIS INTENT IS FIRED WHEN RENAMING OF FILE FAILS * SHOWING POSSIBLE ERROR */ new ErrorDialogs(mContext, size.x * 4 / 5, "renameError"); } } //AFTER RENAMING THE FOLDER OR FILES THE FLIPPER IS SET AGAIN TO MAIN MENU mVFlipper.setAnimation(nextAnim()); mVFlipper.showNext(); } setAdapter(CURRENT_ITEM); RENAME_COMMAND = CREATE_FILE = SEARCH_FLAG = CUT_COMMAND = COPY_COMMAND = false; } else if (name.length() == 0) Toast.makeText(getBaseContext(), "Please Enter A Valid Name", Toast.LENGTH_SHORT).show(); break; case R.id.homeDirBtn: HOME_DIRECTORY = preferences.getString("HOME_DIRECTORY", null); if (HOME_DIRECTORY == null) { new GetHomeDirectory(mContext, size.x * 4 / 5, preferences); } else if (new File(HOME_DIRECTORY).exists()) { if (CURRENT_ITEM == 2) { nRFileManager = new RFileManager(); RFileManager.SHOW_HIDDEN_FOLDER = SHOW_HIDDEN_FOLDERS; RFileManager.SORT_TYPE = SORT_TYPE; RFileManager.nStack.push(HOME_DIRECTORY); nFiles = RFileManager.giveMeFileList(); RootAdapter = new RootAdapter(getBaseContext(), R.layout.row_list_1, nFiles); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setCurrentItem(2); } else if (CURRENT_ITEM == 1) { nSFManager = new SFileManager(); SFileManager.SHOW_HIDDEN_FOLDER = SHOW_HIDDEN_FOLDERS; SFileManager.SORT_TYPE = SORT_TYPE; SFileManager.nStack.push(HOME_DIRECTORY); sFiles = SFileManager.giveMeFileList(); nSimple = new SimpleAdapter(getBaseContext(), R.layout.row_list_1, sFiles); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setCurrentItem(1); } else if (CURRENT_ITEM == 0) { QuickAction d = new QuickAction(getBaseContext()); ActionItem df = new ActionItem(8, "/", getResources().getDrawable(R.drawable.ic_launcher_droid_home)); d.addActionItem(df); df = new ActionItem(9, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_droid_home)); d.addActionItem(df); d.show(v); d.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int actionId) { // TODO Auto-generated method stub switch (actionId) { case 8: SFileManager.nStack.push(HOME_DIRECTORY); setAdapter(1); break; case 9: LAST_PAGE = 0; RFileManager.nStack.push(HOME_DIRECTORY); setAdapter(2); break; } } }); } } else { HOME_DIRECTORY = PATH; edit.putString("HOME_DIRECTORY", PATH); edit.commit(); new ErrorDialogs(mContext, size.x * 4 / 5, "homeError"); } break; case R.id.jumpToBtn: if (CURRENT_ITEM == 0) { // IF CURRENT ITEM == 0 // DISPLAYS LIST THAT IS APPLICABLE TO ONLY ALL FILE PANEL QuickAction ac = new QuickAction(getBaseContext()); ActionItem i = new ActionItem(8, " Jump To Music Files", getResources().getDrawable(R.drawable.ic_launcher_music)); ac.addActionItem(i); i = new ActionItem(9, " Jump To Apk Files", getResources().getDrawable(R.drawable.ic_launcher_apk)); ac.addActionItem(i); i = new ActionItem(10, " Jump To Document Files", getResources().getDrawable(R.drawable.ic_launcher_ppt)); ac.addActionItem(i); i = new ActionItem(11, " Jump To Image Files", getResources().getDrawable(R.drawable.ic_launcher_images)); ac.addActionItem(i); i = new ActionItem(12, " Jump To Video Files", getResources().getDrawable(R.drawable.ic_launcher_video)); ac.addActionItem(i); i = new ActionItem(13, " Jump To Zipped Files", getResources().getDrawable(R.drawable.ic_launcher_zip_it)); ac.addActionItem(i); i = new ActionItem(14, " Jump To Miscellaneous Files", getResources().getDrawable(R.drawable.ic_launcher_rar)); ac.addActionItem(i); ac.setOnActionItemClickListener(this); ac.show(v); } else { // IF CURRENT ITMEM !=0 //This option allows user to directly go to specified directory from any directory final QuickAction actionJump = new QuickAction(getBaseContext(), 1); ActionItem paste = new ActionItem(900, "Paste Here", getResources().getDrawable(R.drawable.ic_launcher_paste)); ActionItem download = new ActionItem(1000, "Jump To Download Folder", getResources().getDrawable(R.drawable.ic_launcher_downloads)); ActionItem camera = new ActionItem(1100, "Jump To Camera Folder", getResources().getDrawable(R.drawable.ic_launcher_camera)); ActionItem songs = new ActionItem(1200, "Jump To Music Folder", getResources().getDrawable(R.drawable.ic_launcher_music)); ActionItem vid = new ActionItem(1201, "Jump To Video Folder", getResources().getDrawable(R.drawable.ic_launcher_video)); ActionItem pro = new ActionItem(1300, "Properties", getResources().getDrawable(R.drawable.ic_launcher_stats)); ActionItem apps = new ActionItem(1400, "Selected Default Apps", getResources().getDrawable(R.drawable.ic_launcher_select_app)); actionJump.addActionItem(paste); actionJump.addActionItem(download); actionJump.addActionItem(camera); actionJump.addActionItem(songs); actionJump.addActionItem(vid); actionJump.addActionItem(pro); actionJump.addActionItem(apps); actionJump.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int actionId) { // TODO Auto-generated method stub File fJump = null; switch (actionId) { case 900: pasteCommand(false); break; case 1000: fJump = new File(PATH + "/Download"); if (!fJump.exists()) fJump.mkdir(); if (CURRENT_ITEM == 2) RFileManager.nStack.push(fJump.getAbsolutePath()); else if (CURRENT_ITEM == 1) SFileManager.nStack.push(fJump.getAbsolutePath()); setAdapter(CURRENT_ITEM); break; case 1100: fJump = new File(PATH + "/DCIM"); if (!fJump.exists()) fJump.mkdir(); if (CURRENT_ITEM == 2) RFileManager.nStack.push(fJump.getAbsolutePath()); else if (CURRENT_ITEM == 1) SFileManager.nStack.push(fJump.getAbsolutePath()); setAdapter(CURRENT_ITEM); break; case 1200: fJump = new File(PATH + "/Music"); if (!fJump.exists()) fJump.mkdir(); if (CURRENT_ITEM == 2) RFileManager.nStack.push(fJump.getAbsolutePath()); else if (CURRENT_ITEM == 1) SFileManager.nStack.push(fJump.getAbsolutePath()); setAdapter(CURRENT_ITEM); break; case 1201: fJump = new File(PATH + "/Video"); if (!fJump.exists()) fJump.mkdir(); if (CURRENT_ITEM == 2) RFileManager.nStack.push(fJump.getAbsolutePath()); else if (CURRENT_ITEM == 1) SFileManager.nStack.push(fJump.getAbsolutePath()); setAdapter(CURRENT_ITEM); break; case 1300: if (CURRENT_ITEM == 1) { new FileProperties(getBaseContext(), size.x * 5 / 6, file); /*LAUNCH_INTENT = new Intent(getBaseContext(), FileProperties.class); LAUNCH_INTENT.setData(Uri.parse(nSFManager.getCurrentDirectory())); startActivity(LAUNCH_INTENT);*/ } else if (CURRENT_ITEM == 2) { new FileProperties(mContext, size.x * 5 / 6, file2); } break; case 1400: showDefaultApps(v); } } }); actionJump.show(v); } break; case R.id.addBtn: if (CURRENT_ITEM == 0) { showDefaultApps(v); } else { NEW_OPTIONS(v); } break; case R.id.appStats: // DISPLAYS THE INFORMATION ABOUT THE INSTALLED APPS ON PHONE new AppStats(mContext, size.x * 5 / 6); break; case R.id.backupAll: QuickAction as = new QuickAction(getBaseContext()); ActionItem o = new ActionItem(100, "Backup User Apps", getResources().getDrawable(R.drawable.ic_launcher_user)); as.addActionItem(o); o = new ActionItem(200, "Backup System Apps", getResources().getDrawable(R.drawable.ic_launcher_system)); as.addActionItem(o); o = new ActionItem(300, "Backup Both Of Them", getResources().getDrawable(R.drawable.ic_launcher_both)); as.addActionItem(o); as.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int Id) { // TODO Auto-generated method stub //ArrayList<ApplicationInfo> li; switch (Id) { case 100: new AppBackupDialog(mContext, size.x * 8 / 9, "1BackupAll"); break; case 200: new AppBackupDialog(mContext, size.x * 8 / 9, "2BackupAll"); break; case 300: new AppBackupDialog(mContext, size.x * 8 / 9, "3BackupAll"); } } }); as.show(v); break; case R.id.cleanBackups: //THIS BUTTON DISPLAYS TWO OPTIONS -1.TO DELETED THE BACKUPS //2. DELETE THE FLASHABLE ZIPS CREATED QuickAction c = new QuickAction(getBaseContext()); ActionItem i = new ActionItem(100, "Delete Earlier Backup", getResources().getDrawable(R.drawable.ic_launcher_backupall)); c.addActionItem(i); i = new ActionItem(200, "Delete Flashable Zips", getResources().getDrawable(R.drawable.ic_launcher_zip_it)); c.addActionItem(i); c.show(v); c.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { @Override public void onItemClick(QuickAction source, int pos, int actionId) { // TODO Auto-generated method stub switch (actionId) { case 100: new DeleteBackups(mContext, size.x * 4 / 5); break; case 200: new DeleteFlashable(mContext, size.x * 4 / 5); } } }); break; case R.id.zipItBtn: if (CURRENT_ITEM == 3) new ErrorDialogs(mContext, size.x * 4 / 5, "FlashableZips"); break; } }
From source file:com.ichi2.anki.DeckPicker.java
public void renameDeckDialog(final long did) { final Resources res = getResources(); mDialogEditText = new EditText(DeckPicker.this); mDialogEditText.setSingleLine();//w ww .j a va2 s . c om final String currentName = getCol().getDecks().name(did); mDialogEditText.setText(currentName); new MaterialDialog.Builder(DeckPicker.this).title(res.getString(R.string.rename_deck)) .customView(mDialogEditText, true).positiveText(res.getString(R.string.rename)) .negativeText(res.getString(R.string.dialog_cancel)).callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { String newName = mDialogEditText.getText().toString().replaceAll("\"", ""); Collection col = getCol(); if (!TextUtils.isEmpty(newName) && !newName.equals(currentName)) { try { col.getDecks().rename(col.getDecks().get(did), newName); } catch (DeckRenameException e) { // We get a localized string from libanki to explain the error Themes.showThemedToast(DeckPicker.this, e.getLocalizedMessage(res), false); } } dismissAllDialogFragments(); mDeckListAdapter.notifyDataSetChanged(); updateDeckList(); if (mFragmented) { loadStudyOptionsFragment(false); } } @Override public void onNegative(MaterialDialog dialog) { dismissAllDialogFragments(); } }).build().show(); }