List of usage examples for android.widget EditText setEllipsize
@Override public void setEllipsize(TextUtils.TruncateAt ellipsis)
From source file:dev.ukanth.ufirewall.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { /*case android.R.id.home: disableOrEnable();/*from w ww .j a v a 2 s . c o m*/ return true;*/ case R.id.menu_toggle: disableOrEnable(); return true; case R.id.menu_apply: applyOrSaveRules(); return true; case R.id.menu_exit: finish(); System.exit(0); return false; case R.id.menu_help: showAbout(); return true; /*case R.id.menu_setpwd: setPassword(); return true;*/ case R.id.menu_log: showLog(); return true; case R.id.menu_rules: showRules(); return true; case R.id.menu_setcustom: setCustomScript(); return true; case R.id.menu_preference: showPreferences(); return true; /*case R.id.menu_reload: Api.applications = null; showOrLoadApplications(); return true;*/ case R.id.menu_search: item.setActionView(R.layout.searchbar); final EditText filterText = (EditText) item.getActionView().findViewById(R.id.searchApps); filterText.addTextChangedListener(filterTextWatcher); filterText.setEllipsize(TruncateAt.END); filterText.setSingleLine(); MenuItemCompat.setOnActionExpandListener(item, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { // Do something when collapsed return true; // Return true to collapse action view } @Override public boolean onMenuItemActionExpand(MenuItem item) { filterText.post(new Runnable() { @Override public void run() { filterText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.showSoftInput(filterText, InputMethodManager.SHOW_IMPLICIT); } }); return true; // Return true to expand action view } }); return true; case R.id.menu_export: new MaterialDialog.Builder(this).title(R.string.exports).cancelable(false) .items(new String[] { getString(R.string.export_rules), getString(R.string.export_all) }) .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { switch (which) { case 0: Api.saveSharedPreferencesToFileConfirm(MainActivity.this); break; case 1: Api.saveAllPreferencesToFileConfirm(MainActivity.this); break; } return true; } }).positiveText(R.string.exports).negativeText(R.string.Cancel).show(); return true; case R.id.menu_import: new MaterialDialog.Builder(this).title(R.string.imports).cancelable(false) .items(new String[] { getString(R.string.import_rules), getString(R.string.import_all), getString(R.string.import_rules_droidwall) }) .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { switch (which) { case 0: //Intent intent = new Intent(MainActivity.this, FileChooserActivity.class); //startActivityForResult(intent, FILE_CHOOSER_LOCAL); File mPath = new File(Environment.getExternalStorageDirectory() + "//afwall//"); FileDialog fileDialog = new FileDialog(MainActivity.this, mPath, true); //fileDialog.setFlag(true); //fileDialog.setFileEndsWith(new String[] {"backup", "afwall-backup"}, "all"); fileDialog.addFileListener(new FileDialog.FileSelectedListener() { public void fileSelected(File file) { String fileSelected = file.toString(); StringBuilder builder = new StringBuilder(); if (Api.loadSharedPreferencesFromFile(MainActivity.this, builder, fileSelected)) { Api.applications = null; showOrLoadApplications(); Api.toast(MainActivity.this, getString(R.string.import_rules_success) + fileSelected); } else { if (builder.toString().equals("")) { Api.toast(MainActivity.this, getString(R.string.import_rules_fail)); } else { Api.toast(MainActivity.this, builder.toString()); } } } }); fileDialog.showDialog(); break; case 1: if (Api.getCurrentPackage(MainActivity.this).equals("dev.ukanth.ufirewall.donate") || G.isDo(getApplicationContext())) { File mPath2 = new File( Environment.getExternalStorageDirectory() + "//afwall//"); FileDialog fileDialog2 = new FileDialog(MainActivity.this, mPath2, false); //fileDialog2.setFlag(false); //fileDialog2.setFileEndsWith(new String[] {"backup_all", "afwall-backup-all"}, "" ); fileDialog2.addFileListener(new FileDialog.FileSelectedListener() { public void fileSelected(File file) { String fileSelected = file.toString(); StringBuilder builder = new StringBuilder(); if (Api.loadAllPreferencesFromFile(MainActivity.this, builder, fileSelected)) { Api.applications = null; showOrLoadApplications(); Api.toast(MainActivity.this, getString(R.string.import_rules_success) + fileSelected); Intent intent = getIntent(); finish(); startActivity(intent); } else { if (builder.toString().equals("")) { Api.toast(MainActivity.this, getString(R.string.import_rules_fail)); } else { Api.toast(MainActivity.this, builder.toString()); } } } }); fileDialog2.showDialog(); } else { new MaterialDialog.Builder(MainActivity.this).cancelable(false) .title(R.string.buy_donate).content(R.string.donate_only) .positiveText(R.string.buy_donate).negativeText(R.string.close) .icon(getResources().getDrawable(R.drawable.ic_launcher)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=pub:ukpriya")); startActivity(intent); } @Override public void onNegative(MaterialDialog dialog) { dialog.cancel(); } }).show(); } break; case 2: new MaterialDialog.Builder(MainActivity.this).cancelable(false) .title(R.string.import_rules_droidwall).content(R.string.overrideRules) .positiveText(R.string.Yes).negativeText(R.string.No) .icon(getResources().getDrawable(R.drawable.ic_launcher)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { if (ImportApi .loadSharedPreferencesFromDroidWall(MainActivity.this)) { Api.applications = null; showOrLoadApplications(); Api.toast(MainActivity.this, getString(R.string.import_rules_success) + Environment .getExternalStorageDirectory().getAbsolutePath() + "/afwall/"); } else { Api.toast(MainActivity.this, getString(R.string.import_rules_fail)); } } @Override public void onNegative(MaterialDialog dialog) { dialog.cancel(); } }).show(); break; } return true; } }).positiveText(R.string.imports).negativeText(R.string.Cancel).show(); return true; default: return super.onOptionsItemSelected(item); } }