List of usage examples for android.view.inputmethod EditorInfo IME_NULL
int IME_NULL
To view the source code for android.view.inputmethod EditorInfo IME_NULL.
Click Source Link
From source file:com.miz.mizuu.fragments.IdentifyMovieFragment.java
public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mToolbar = (Toolbar) v.findViewById(R.id.toolbar); ((MizActivity) getActivity()).setSupportActionBar(mToolbar); mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); mProgress = (ProgressBar) v.findViewById(R.id.progressBar1); mListView.setOnItemClickListener(new OnItemClickListener() { @Override// w w w . jav a2 s .co m public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { updateMovie(arg2); } }); mListView.setEmptyView(v.findViewById(R.id.no_results)); v.findViewById(R.id.no_results).setVisibility(View.GONE); // Manually make it gone to begin with mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mLocale = mSpinnerAdapter.getItem(position).getLanguage(); searchForMovies(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mSpinnerAdapter = new LanguageAdapter(); mSpinner.setAdapter(mSpinnerAdapter); String language = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(LANGUAGE_PREFERENCE, "en"); mSpinner.setSelection(mSpinnerAdapter.getIndexForLocale(language)); mQuery.setText(mMovieStructure.getDecryptedFilename()); mQuery.setSelection(mQuery.length()); mQuery.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.toString().length() > 0) searchForMovies(); else { mMovieSearch.cancel(true); mAdapter.clearItems(); mAdapter.notifyDataSetChanged(); } } }); mQuery.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_SEARCH) searchForMovies(); return true; } }); if (mMovieSearch == null) { if (MizLib.isOnline(getActivity())) { mMovieSearch = new MovieSearch(getActivity(), mQuery.getText().toString()); } else { Toast.makeText(getActivity(), getString(R.string.noInternet), Toast.LENGTH_SHORT).show(); } } }
From source file:com.miz.mizuu.fragments.IdentifyTvShowEpisodeFragment.java
public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mToolbar = (Toolbar) v.findViewById(R.id.toolbar); ((MizActivity) getActivity()).setSupportActionBar(mToolbar); mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); mProgress = (ProgressBar) v.findViewById(R.id.progressBar1); mListView.setOnItemClickListener(new OnItemClickListener() { @Override//from ww w .j a v a2 s. c om public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { updateShow(arg2); } }); mListView.setEmptyView(v.findViewById(R.id.no_results)); v.findViewById(R.id.no_results).setVisibility(View.GONE); // Manually make it gone to begin with mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mLocale = mSpinnerAdapter.getItem(position).getLanguage(); searchForShows(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mSpinnerAdapter = new LanguageAdapter(); mSpinner.setAdapter(mSpinnerAdapter); String language = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(LANGUAGE_PREFERENCE, "en"); mSpinner.setSelection(mSpinnerAdapter.getIndexForLocale(language)); mQuery.setText(mShowTitle); mQuery.setSelection(mQuery.length()); mQuery.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.toString().length() > 0) searchForShows(); else { mTvShowSearch.cancel(true); mAdapter.clearItems(); mAdapter.notifyDataSetChanged(); } } }); mQuery.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_SEARCH) searchForShows(); return true; } }); if (mTvShowSearch == null) { if (MizLib.isOnline(getActivity())) { mTvShowSearch = new TvShowSearch(getActivity(), mQuery.getText().toString()); } else { Toast.makeText(getActivity(), getString(R.string.noInternet), Toast.LENGTH_SHORT).show(); } } }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
private void setUpInterface() { timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); final boolean showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false); if (showTimerShortcut) { commentField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override//from w ww . j av a 2s.c om public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { timerView.setVisibility(View.GONE); commentButton.setVisibility(View.VISIBLE); } else { timerView.setVisibility(View.VISIBLE); commentButton.setVisibility(View.GONE); } } }); } commentField.setHorizontallyScrolling(false); commentField.setMaxLines(Integer.MAX_VALUE); commentField.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { AndroidUtilities.hideSoftInputForViews(activity, commentField); return true; } return false; } }); commentField.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { commentField.setCursorVisible(true); } }); commentField.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { commentButton.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE); if (showTimerShortcut) { timerView.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (commentField.getText().length() > 0) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) { // commentField.setCursorVisible(false); addComment(); } } return false; } }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addComment(); } }); final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { pendingCommentPicture = null; pictureButton.setImageResource(cameraButton); } }; pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture); pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pendingCommentPicture != null) { actFmCameraModule.showPictureLauncher(clearImage); } else { actFmCameraModule.showPictureLauncher(null); } respondToPicture = true; } }); if (!TextUtils.isEmpty(task.getNotes())) { TextView notes = new TextView(getContext()); notes.setLinkTextColor(Color.rgb(100, 160, 255)); notes.setTextSize(18); notes.setText(task.getNotes()); notes.setPadding(5, 10, 5, 10); Linkify.addLinks(notes, Linkify.ALL); } if (activity != null) { String uri = activity.getIntent().getStringExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS); if (uri != null) { pendingCommentPicture = Uri.parse(uri); setPictureButtonToPendingPicture(); } } }
From source file:app.sunstreak.yourpisd.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login_new); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);//from w w w . ja va 2s . co m } final SharedPreferences sharedPrefs = getPreferences(Context.MODE_PRIVATE); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); height = size.y; mLoginFormView = findViewById(R.id.login_form); mLoginStatusView = (LinearLayout) findViewById(R.id.login_status); mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message); if (DateHelper.isAprilFools()) { LinearLayout container = (LinearLayout) mLoginFormView.findViewById(R.id.container); ImageView logo = (ImageView) container.findViewById(R.id.logo); InputStream is; try { is = getAssets().open("doge.png"); logo.setImageBitmap(BitmapFactory.decodeStream(is)); is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } mAutoLogin = sharedPrefs.getBoolean("auto_login", false); System.out.println(mAutoLogin); session = ((YPApplication) getApplication()).session; try { boolean refresh = getIntent().getExtras().getBoolean("Refresh"); if (refresh) { mEmail = session.getUsername(); mPassword = session.getPassword(); showProgress(true); mAuthTask = new UserLoginTask(); mAuthTask.execute((Void) null); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0); } else mLoginFormView.setVisibility(View.VISIBLE); } catch (NullPointerException e) { // Keep going. } if (sharedPrefs.getBoolean("patched", false)) { SharedPreferences.Editor editor = sharedPrefs.edit(); editor.remove("password"); editor.putBoolean("patched", true); editor.commit(); } if (!sharedPrefs.getBoolean("AcceptedUserAgreement", false)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.user_agreement_title)); builder.setMessage(getResources().getString(R.string.user_agreement)); // Setting Positive "Yes" Button builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sharedPrefs.edit().putBoolean("AcceptedUserAgreement", true).commit(); dialog.cancel(); } }); // Setting Negative "NO" Button builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event sharedPrefs.edit().putBoolean("AcceptedUserAgreement", false).commit(); Toast.makeText(LoginActivity.this, "Quitting app", Toast.LENGTH_SHORT).show(); finish(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } // Set up the remember_password CheckBox mRememberPasswordCheckBox = (CheckBox) findViewById(R.id.remember_password); mRememberPasswordCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mRememberPassword = isChecked; } }); mRememberPassword = sharedPrefs.getBoolean("remember_password", false); mRememberPasswordCheckBox.setChecked(mRememberPassword); // Set up the auto_login CheckBox mAutoLoginCheckBox = (CheckBox) findViewById(R.id.auto_login); mAutoLoginCheckBox.setChecked(mAutoLogin); mAutoLoginCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton button, boolean isChecked) { mAutoLogin = isChecked; if (isChecked) { mRememberPasswordCheckBox.setChecked(true); } } }); // Set up the login form. mEmailView = (EditText) findViewById(R.id.email); mPasswordView = (EditText) findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { if (id == R.id.login || id == EditorInfo.IME_NULL) { attemptLogin(); return true; } return false; } }); //Load stored username/password mEmailView.setText(sharedPrefs.getString("email", mEmail)); mPasswordView.setText(new String(Base64.decode(sharedPrefs.getString("e_password", ""), Base64.DEFAULT))); // If the password was not saved, give focus to the password. if (mPasswordView.getText().equals("")) mPasswordView.requestFocus(); mLoginFormView = findViewById(R.id.login_form); mLoginStatusView = (LinearLayout) findViewById(R.id.login_status); mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message); findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { attemptLogin(); } }); findViewById(R.id.sign_in_button).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0); return false; } }); mLoginFormView.setVisibility(View.VISIBLE); // Login if auto-login is checked. if (mAutoLogin) attemptLogin(); }
From source file:mroza.forms.ChooseProgramActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; getMenuInflater().inflate(R.menu.choose_program_menu, menu); //Associate programs_searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); android.support.v7.widget.SearchView searchView = (android.support.v7.widget.SearchView) menu .findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); EditText searchPlate = (EditText) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchPlate.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchPlate.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from w w w .j a va 2 s . com*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { //On search or enter clicked if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_NULL) { if (v.getText().toString().equals("")) { refreshChildTableList(); clearSearchField(); clearFilters(true); enableShowAllButton(false); } } return false; } }); restoreSavedFilters(); return true; }
From source file:dev.dworks.apps.asecure.MainActivity.java
private void showLoginDialog() { final SharedPreferences.Editor editor = mSharedPreferences.edit(); final boolean passwordSet = !TextUtils.isEmpty(password); final String setPassword = password; LayoutInflater layoutInflater = LayoutInflater.from(this); final View loginView = layoutInflater.inflate(R.layout.dialog_login, null); TextView header = (TextView) loginView.findViewById(R.id.login_header); final EditText password = (EditText) loginView.findViewById(R.id.password); final EditText password_repeat = (EditText) loginView.findViewById(R.id.password_repeat); final Button login = (Button) loginView.findViewById(R.id.login_button); //Button cancel = (Button) loginView.findViewById(R.id.cancel_button); if (!passwordSet) { password_repeat.setVisibility(View.VISIBLE); header.setVisibility(View.VISIBLE); } else {//from ww w. jav a 2 s . c om password.setVisibility(View.GONE); password_repeat.setVisibility(View.VISIBLE); password_repeat.setHint(R.string.login_pwd); } header.setText(!passwordSet ? getString(R.string.login_message) : getString(R.string.msg_login)); final Dialog dialog = new Dialog(this, R.style.Theme_Asecure_DailogLogin); dialog.setContentView(loginView); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); dialog.show(); password_repeat.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == R.id.login_button || actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) { login.performClick(); return true; } return false; } }); login.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (passwordSet) { final String passwordString = password_repeat.getText().toString(); if (TextUtils.isEmpty(passwordString) || passwordString.compareTo(setPassword) != 0) { password_repeat.startAnimation(shake); password_repeat.setError(getString(R.string.msg_wrong_password)); return; } } else { final String passwordString = password_repeat.getText().toString(); final String passwordRepeatString = password_repeat.getText().toString(); if (TextUtils.isEmpty(passwordString)) { password.startAnimation(shake); password.setError(getString(R.string.msg_pwd_empty)); return; } if (TextUtils.isEmpty(passwordRepeatString)) { password_repeat.startAnimation(shake); password_repeat.setError(getString(R.string.msg_pwd_empty)); return; } else if (passwordString.compareTo(passwordRepeatString) != 0) { password_repeat.startAnimation(shake); password_repeat.setError(getString(R.string.msg_pwd_dont_match)); return; } editor.putString("LoginPasswordPref", password.getText().toString()); editor.commit(); } dialog.dismiss(); } }); /* cancel.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { dialog.dismiss(); finish(); }});*/ }
From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // Inflate the layout for this fragment this.main = (MainActivity) getActivity(); this.listId = this.main.getCurrentList().getId(); this.view = inflater.inflate(R.layout.layout_tasks_fragment, container, false); this.adapter = null; this.created = true; this.listView = (ListView) this.view.findViewById(R.id.tasks_list); this.listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); // Events//from w w w. j a va2 s .c o m this.newTask = (EditText) this.view.findViewById(R.id.tasks_new); if (MirakelCommonPreferences.isTablet()) { this.newTask.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); } this.newTask.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) { newTask(v.getText().toString()); v.setText(null); } return false; } }); this.newTask.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(final Editable s) { final ImageButton send = (ImageButton) TasksFragment.this.view.findViewById(R.id.btnEnter); if (s.length() > 0) { send.setVisibility(View.VISIBLE); } else { send.setVisibility(View.GONE); } } @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { // Nothing } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { // Nothing } }); update(true); final ImageButton btnEnter = (ImageButton) this.view.findViewById(R.id.btnEnter); btnEnter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { newTask(TasksFragment.this.newTask.getText().toString()); TasksFragment.this.newTask.setText(null); } }); updateButtons(); return this.view; }
From source file:com.irccloud.android.activity.BaseActivity.java
public void onIRCEvent(int what, Object obj) { String message = ""; final IRCCloudJSONObject o; switch (what) { case NetworkConnection.EVENT_BADCHANNELKEY: o = (IRCCloudJSONObject) obj;/*w w w. j a v a 2 s . c o m*/ runOnUiThread(new Runnable() { @Override public void run() { Server server = ServersList.getInstance().getServer(o.cid()); AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this); View view = getDialogTextPrompt(); TextView prompt = view.findViewById(R.id.prompt); final EditText keyinput = view.findViewById(R.id.textInput); keyinput.setText(""); keyinput.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) { try { if (keyinput.getText() != null) conn.join(o.cid(), o.getString("chan"), keyinput.getText().toString()); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } ((AlertDialog) keyinput.getTag()).dismiss(); } return true; } }); try { prompt.setText("Password for " + o.getString("chan")); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } builder.setTitle( server.getName() + " (" + server.getHostname() + ":" + (server.getPort()) + ")"); builder.setView(view); builder.setPositiveButton("Join", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { conn.join(o.cid(), o.getString("chan"), keyinput.getText().toString()); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); keyinput.setTag(dialog); dialog.setOwnerActivity(BaseActivity.this); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); } }); break; case NetworkConnection.EVENT_INVALIDNICK: o = (IRCCloudJSONObject) obj; runOnUiThread(new Runnable() { @Override public void run() { Server server = ServersList.getInstance().getServer(o.cid()); AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this); View view = getDialogTextPrompt(); TextView prompt = view.findViewById(R.id.prompt); final EditText nickinput = view.findViewById(R.id.textInput); nickinput.setText(""); nickinput.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) { try { conn.say(o.cid(), null, "/nick " + nickinput.getText().toString()); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } ((AlertDialog) nickinput.getTag()).dismiss(); } return true; } }); try { String message = o.getString("invalid_nick") + " is not a valid nickname, try again"; if (server.isupport != null && server.isupport.has("NICKLEN")) message += "\n(" + server.isupport.get("NICKLEN").asText() + " chars)"; message += "."; prompt.setText(message); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } builder.setTitle( server.getName() + " (" + server.getHostname() + ":" + (server.getPort()) + ")"); builder.setView(view); builder.setPositiveButton("Change Nickname", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { conn.say(o.cid(), null, "/nick " + nickinput.getText().toString()); } catch (Exception e) { // TODO Auto-generated catch block NetworkConnection.printStackTraceToCrashlytics(e); } dialog.dismiss(); } }); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); nickinput.setTag(dialog); dialog.setOwnerActivity(BaseActivity.this); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); } }); break; case NetworkConnection.EVENT_ALERT: try { o = (IRCCloudJSONObject) obj; String type = o.type(); if (type.equalsIgnoreCase("invite_only_chan")) showAlert(o.cid(), "You need an invitation to join " + o.getString("chan")); else if (type.equalsIgnoreCase("channel_full")) showAlert(o.cid(), o.getString("chan") + " isn't allowing any more members to join."); else if (type.equalsIgnoreCase("banned_from_channel")) showAlert(o.cid(), "You've been banned from " + o.getString("chan")); else if (type.equalsIgnoreCase("invalid_nickchange")) showAlert(o.cid(), o.getString("ban_channel") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("no_messages_from_non_registered")) { if (o.has("nick") && o.getString("nick").length() > 0) showAlert(o.cid(), o.getString("nick") + ": " + o.getString("msg")); else showAlert(o.cid(), o.getString("msg")); } else if (type.equalsIgnoreCase("not_registered")) { String first = o.getString("first"); if (o.has("rest")) first += " " + o.getString("rest"); showAlert(o.cid(), first + ": " + o.getString("msg")); } else if (type.equalsIgnoreCase("too_many_channels")) showAlert(o.cid(), "Couldn't join " + o.getString("chan") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("too_many_targets")) showAlert(o.cid(), o.getString("description") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("no_such_server")) showAlert(o.cid(), o.getString("server") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("unknown_command")) showAlert(o.cid(), "Unknown command: " + o.getString("command")); else if (type.equalsIgnoreCase("help_not_found")) showAlert(o.cid(), o.getString("topic") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("accept_exists")) showAlert(o.cid(), o.getString("nick") + " " + o.getString("msg")); else if (type.equalsIgnoreCase("accept_not")) showAlert(o.cid(), o.getString("nick") + " " + o.getString("msg")); else if (type.equalsIgnoreCase("nick_collision")) showAlert(o.cid(), o.getString("collision") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("nick_too_fast")) showAlert(o.cid(), o.getString("nick") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("save_nick")) showAlert(o.cid(), o.getString("nick") + ": " + o.getString("msg") + ": " + o.getString("new_nick")); else if (type.equalsIgnoreCase("unknown_mode")) showAlert(o.cid(), "Missing mode: " + o.getString("params")); else if (type.equalsIgnoreCase("user_not_in_channel")) showAlert(o.cid(), o.getString("nick") + " is not in " + o.getString("channel")); else if (type.equalsIgnoreCase("need_more_params")) showAlert(o.cid(), "Missing parameters for command: " + o.getString("command")); else if (type.equalsIgnoreCase("chan_privs_needed")) showAlert(o.cid(), o.getString("chan") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("not_on_channel")) showAlert(o.cid(), o.getString("channel") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("ban_on_chan")) showAlert(o.cid(), "You cannot change your nick to " + o.getString("proposed_nick") + " while banned on " + o.getString("channel")); else if (type.equalsIgnoreCase("cannot_send_to_chan")) showAlert(o.cid(), o.getString("channel") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("user_on_channel")) showAlert(o.cid(), o.getString("nick") + " is already a member of " + o.getString("channel")); else if (type.equalsIgnoreCase("no_nick_given")) showAlert(o.cid(), "No nickname given"); else if (type.equalsIgnoreCase("nickname_in_use")) showAlert(o.cid(), o.getString("nick") + " is already in use"); else if (type.equalsIgnoreCase("silence")) { String mask = o.getString("usermask"); if (mask.startsWith("-")) message = mask.substring(1) + " removed from silence list"; else if (mask.startsWith("+")) message = mask.substring(1) + " added to silence list"; else message = "Silence list change: " + mask; showAlert(o.cid(), message); } else if (type.equalsIgnoreCase("no_channel_topic")) showAlert(o.cid(), o.getString("channel") + ": " + o.getString("msg")); else if (type.equalsIgnoreCase("time")) { message = o.getString("time_string"); if (o.has("time_stamp") && o.getString("time_stamp").length() > 0) message += " (" + o.getString("time_stamp") + ")"; message += " " + o.getString("time_server"); showAlert(o.cid(), message); } else showAlert(o.cid(), o.getString("msg")); } catch (Exception e1) { NetworkConnection.printStackTraceToCrashlytics(e1); } break; default: break; } }
From source file:com.todoroo.astrid.tags.TagsControlSet.java
/** Adds a tag to the tag field */ private void addTag(String tagName) { LayoutInflater inflater = getActivity().getLayoutInflater(); // check if already exists TextView lastText;//from ww w .jav a 2s . co m for (int i = 0; i < newTagLayout.getChildCount(); i++) { View view = newTagLayout.getChildAt(i); lastText = (TextView) view.findViewById(R.id.text1); if (lastText.getText().equals(tagName)) { return; } } final View tagItem; tagItem = inflater.inflate(R.layout.tag_edit_row, null); newTagLayout.addView(tagItem); if (tagName == null) { tagName = ""; //$NON-NLS-1$ } final AutoCompleteTextView textView = (AutoCompleteTextView) tagItem.findViewById(R.id.text1); textView.setText(tagName); textView.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (count > 0 && newTagLayout.getChildAt(newTagLayout.getChildCount() - 1) == tagItem) { addTag(""); //$NON-NLS-1$ } } }); textView.setOnEditorActionListener((arg0, actionId, arg2) -> { if (actionId != EditorInfo.IME_NULL) { return false; } if (getLastTextView().getText().length() != 0) { addTag(""); //$NON-NLS-1$ } return true; }); tagItem.findViewById(R.id.button1).setOnClickListener(v -> { TextView lastView = getLastTextView(); if (lastView == textView && textView.getText().length() == 0) { return; } if (newTagLayout.getChildCount() > 1) { newTagLayout.removeView(tagItem); } else { textView.setText(""); //$NON-NLS-1$ } }); }
From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); LinearLayout layout = new LinearLayout(mParentActivity); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); mTextViewTitle = new TextView(mParentActivity); LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10); mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); layout.addView(mTextViewTitle, textviewParams); mInputEditText = new EditText(mParentActivity); LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10); layout.addView(mInputEditText, editTextParams); setContentView(layout, layoutParams); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mInputMode = mMsg.inputMode;//from w w w . jav a 2 s. co m mInputFlag = mMsg.inputFlag; mReturnType = mMsg.returnType; mMaxLength = mMsg.maxLength; mTextViewTitle.setText(mMsg.title); mInputEditText.setText(mMsg.content); int oldImeOptions = mInputEditText.getImeOptions(); mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); oldImeOptions = mInputEditText.getImeOptions(); switch (mInputMode) { case kEditBoxInputModeAny: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE; break; case kEditBoxInputModeEmailAddr: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case kEditBoxInputModeNumeric: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModePhoneNumber: mInputModeContraints = InputType.TYPE_CLASS_PHONE; break; case kEditBoxInputModeUrl: mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; case kEditBoxInputModeDecimal: mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModeSingleLine: mInputModeContraints = InputType.TYPE_CLASS_TEXT; break; default: break; } if (mIsMultiline) { mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; } mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints); switch (mInputFlag) { case kEditBoxInputFlagPassword: mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case kEditBoxInputFlagSensitive: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; break; case kEditBoxInputFlagInitialCapsWord: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; case kEditBoxInputFlagInitialCapsSentence: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; break; case kEditBoxInputFlagInitialCapsAllCharacters: mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; break; default: break; } mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints); switch (mReturnType) { case kKeyboardReturnTypeDefault: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; case kKeyboardReturnTypeDone: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); break; case kKeyboardReturnTypeSend: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); break; case kKeyboardReturnTypeSearch: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); break; case kKeyboardReturnTypeGo: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); break; default: mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; } if (mMaxLength > 0) { mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) }); } Handler initHandler = new Handler(); initHandler.postDelayed(new Runnable() { public void run() { mInputEditText.requestFocus(); mInputEditText.setSelection(mInputEditText.length()); openKeyboard(); } }, 200); mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // if user didn't set keyboard type, // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP' if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN)) { //Log.d("EditBox", "actionId: "+actionId +",event: "+event); mParentActivity.setEditBoxResult(mInputEditText.getText().toString()); closeKeyboard(); dismiss(); return true; } return false; } }); }