List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:com.code.android.vibevault.SearchScreen.java
private void closeKeyboard() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(artistSearchInput.getWindowToken(), 0); }
From source file:com.android.mms.quickmessage.QuickMessagePopup.java
/** * This method dismisses the on screen keyboard if it is visible for the supplied qm * * @param qm - qm to check against/*from ww w .j a v a 2 s .c o m*/ */ private void dismissKeyboard(QuickMessage qm) { if (qm != null) { EditText editView = qm.getEditText(); if (editView != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editView.getApplicationWindowToken(), 0); } } }
From source file:com.housekeeper.ar.healthhousekeeper.personalinfo.ModifyInfoActivity.java
private void closeSoftKeyboard() { /**??**/// w ww. j av a 2 s .c om View view = getWindow().peekDecorView(); if (view != null) { InputMethodManager inputmanger = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
From source file:com.undatech.opaque.RemoteCanvasActivity.java
@Override protected void onPause() { super.onPause(); try {/*from ww w .j av a 2 s. com*/ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(canvas.getWindowToken(), 0); } catch (NullPointerException e) { } }
From source file:com.sim2dial.dialer.ChatFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { sipUri = getArguments().getString("SipUri"); String displayName = getArguments().getString("DisplayName"); String pictureUri = getArguments().getString("PictureUri"); view = inflater.inflate(R.layout.chat, container, false); contactName = (TextView) view.findViewById(R.id.contactName); contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); sendMessage = (TextView) view.findViewById(R.id.sendMessage); sendMessage.setOnClickListener(this); message = (EditText) view.findViewById(R.id.message); if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) { message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); message.setMaxLines(1);/*from w w w .j av a 2 s .c o m*/ } uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout); textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout); messagesLayout = (RelativeLayout) view.findViewById(R.id.messages); messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); sendImage = (TextView) view.findViewById(R.id.sendPicture); registerForContextMenu(sendImage); sendImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload); cancelUpload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { uploadThread.interrupt(); uploadLayout.setVisibility(View.GONE); textLayout.setVisibility(View.VISIBLE); progressBar.setProgress(0); } }); displayChat(displayName, pictureUri); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { chatRoom = lc.createChatRoom(sipUri); } uploadServerUri = Engine.getPref().getString(getString(R.string.pref_image_sharing_server_key), getString(R.string.pref_image_sharing_server_default)); textWatcher = new TextWatcher() { public void afterTextChanged(Editable arg0) { } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { if (message.getText().toString().equals("")) { sendMessage.setEnabled(false); } else { sendMessage.setEnabled(true); } } }; // Force hide keyboard if (LinphoneActivity.isInstanciated()) { InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } // Workaround for SGS3 issue if (savedInstanceState != null) { fileToUploadPath = savedInstanceState.getString("fileToUploadPath"); imageToUpload = savedInstanceState.getParcelable("imageToUpload"); } if (fileToUploadPath != null || imageToUpload != null) { sendImage.post(new Runnable() { @Override public void run() { sendImage.showContextMenu(); } }); } return view; }
From source file:cw.kop.autobackground.sources.SourceInfoFragment.java
private void saveSource() { final Intent sourceIntent = new Intent(); String title = sourceTitle.getText().toString(); String data = sourceData.getText().toString(); if (type.equals(AppSettings.FOLDER)) { data = folderData;//from ww w. j a v a 2 s.c om } if (title.equals("")) { Toast.makeText(appContext, "Title cannot be empty", Toast.LENGTH_SHORT).show(); return; } if (data.equals("")) { Toast.makeText(appContext, "Data cannot be empty", Toast.LENGTH_SHORT).show(); return; } int num = 0; try { num = Integer.parseInt(sourceNum.getText().toString()); } catch (NumberFormatException e) { num = 1; } switch (type) { case AppSettings.WEBSITE: if (!data.contains("http")) { data = "http://" + data; } break; } if (sourcePosition == -1) { if (FileHandler.isDownloading) { Toast.makeText(appContext, "Cannot add source while downloading", Toast.LENGTH_SHORT).show(); return; } sourceIntent.setAction(SourceListFragment.ADD_ENTRY); } else { if (!getArguments().getString("title").equals(title)) { FileHandler.renameFolder(getArguments().getString("title"), title); } if (FileHandler.isDownloading) { Toast.makeText(appContext, "Cannot edit while downloading", Toast.LENGTH_SHORT).show(); return; } sourceIntent.setAction(SourceListFragment.SET_ENTRY); } sourceIntent.putExtra("type", type); sourceIntent.putExtra("title", sourceTitle.getText().toString()); sourceIntent.putExtra("data", data); sourceIntent.putExtra("num", num); sourceIntent.putExtra("position", sourcePosition); sourceIntent.putExtra("use", sourceUse.isChecked()); sourceIntent.putExtra("preview", ((CustomSwitchPreference) findPreference("source_show_preview")).isChecked()); sourceIntent.putExtra("use_time", timePref.isChecked()); sourceIntent.putExtra("time", String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)); try { InputMethodManager im = (InputMethodManager) appContext.getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { e.printStackTrace(); } final int screenHeight = getResources().getDisplayMetrics().heightPixels; final View fragmentView = getView(); if (fragmentView != null) { final float viewStartY = getView().getY(); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { fragmentView.setY((screenHeight - viewStartY) * interpolatedTime + viewStartY); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent); getFragmentManager().popBackStack(); } @Override public void onAnimationRepeat(Animation animation) { } }); animation.setDuration(SLIDE_EXIT_TIME); getView().startAnimation(animation); } else { LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Initializes the SSL related UI widget properties and event handlers to deal with user * interactions./* ww w. j a v a 2 s .c o m*/ */ private void initSSLState() { // Get UI Widget references... final ToggleButton sslToggleButton = (ToggleButton) findViewById(R.id.ssl_toggle); final EditText sslPortEditField = (EditText) findViewById(R.id.ssl_port); final TextView pin = (TextView) findViewById(R.id.ssl_clientcert_pin); // Configure UI to current settings state... boolean sslEnabled = AppSettingsModel.isSSLEnabled(this); sslToggleButton.setChecked(sslEnabled); sslPortEditField.setText("" + AppSettingsModel.getSSLPort(this)); // If SSL is off, disable the port edit field by default... if (!sslEnabled) { sslPortEditField.setEnabled(false); sslPortEditField.setFocusable(false); sslPortEditField.setFocusableInTouchMode(false); } // Manage state changes to SSL toggle... sslToggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isEnabled) { // If SSL is being disabled, and the user had soft keyboard open, close it... if (!isEnabled) { InputMethodManager input = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); input.hideSoftInputFromWindow(sslPortEditField.getWindowToken(), 0); } // Set SSL state in config model accordingly... AppSettingsModel.enableSSL(AppSettingsActivity.this, isEnabled); // Enable/Disable SSL Port text field according to SSL toggle on/off state... sslPortEditField.setEnabled(isEnabled); sslPortEditField.setFocusable(isEnabled); sslPortEditField.setFocusableInTouchMode(isEnabled); } }); pin.setText("..."); final Handler pinHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); pin.setText(msg.getData().getString("pin")); } }; new Thread() { public void run() { String pin = ORKeyPair.getInstance().getPIN(getApplicationContext()); Bundle bundle = new Bundle(); bundle.putString("pin", pin); Message msg = pinHandler.obtainMessage(); msg.setData(bundle); msg.sendToTarget(); } }.start(); sslPortEditField.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { //TODO not very user friendly if (keyCode == KeyEvent.KEYCODE_ENTER) { String sslPortStr = ((EditText) v).getText().toString(); try { int sslPort = Integer.parseInt(sslPortStr.trim()); AppSettingsModel.setSSLPort(AppSettingsActivity.this, sslPort); } catch (NumberFormatException ex) { Toast toast = Toast.makeText(getApplicationContext(), "SSL port format is not correct.", 1); toast.show(); return false; } catch (IllegalArgumentException e) { Toast toast = Toast.makeText(getApplicationContext(), e.getMessage(), 2); toast.show(); sslPortEditField.setText("" + AppSettingsModel.getSSLPort(AppSettingsActivity.this)); return false; } } return false; } }); }
From source file:org.cocos2dx.lib.TextInputWraper.java
protected void initView() { setEGLConfigChooser(8, 8, 8, 8, 16, 0); setZOrderOnTop(true);/*from w ww. j a v a2s.c om*/ getHolder().setFormat(PixelFormat.TRANSLUCENT); setFocusableInTouchMode(true); textInputWraper = new TextInputWraper(this); handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case HANDLER_OPEN_IME_KEYBOARD: if (null != mTextField && mTextField.requestFocus()) { mTextField.removeTextChangedListener(textInputWraper); mTextField.setText(""); String text = (String) msg.obj; mTextField.append(text); textInputWraper.setOriginText(text); mTextField.addTextChangedListener(textInputWraper); InputMethodManager imm = (InputMethodManager) mainView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mTextField, 0); Log.d("GLSurfaceView", "showSoftInput"); } break; case HANDLER_CLOSE_IME_KEYBOARD: if (null != mTextField) { mTextField.removeTextChangedListener(textInputWraper); InputMethodManager imm = (InputMethodManager) mainView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); Log.d("GLSurfaceView", "HideSoftInput"); } break; } } }; mainView = this; }
From source file:org.xingjitong.ChatFragment.java
@SuppressLint("Recycle") @SuppressWarnings("static-access") @Override//from ww w . ja v a 2s . c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SharedPreferences share = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (share.getInt(getString(R.string.setting_reg_uid), 0) == 0) { Toast.makeText(getActivity(), "!?,?!", Toast.LENGTH_LONG).show(); getActivity().getSupportFragmentManager().popBackStack(); } String displayName = getArguments().getString("DisplayName"); String pictureUri = getArguments().getString("PictureUri"); sipUri = getArguments().getString("SipUri"); sipUri = sipUri.substring(sipUri.indexOf(":") + 1, sipUri.indexOf("@")); try { LinphoneAddress address = LinphoneManager.getInstance().getLc().interpretUrl(sipUri); sipUri = address.asString(); sipUri = sipUri.replace("<", "").replace(">", ""); } catch (LinphoneCoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } view = inflater.inflate(R.layout.chat, container, false); contactName = (TextView) view.findViewById(R.id.contactName); contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); sendMessage = (TextView) view.findViewById(R.id.sendMessage); sendMessage.setOnClickListener(this); message = (EditText) view.findViewById(R.id.message); if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) { message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); message.setMaxLines(1); } uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout); textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout); messagesLayout = (RelativeLayout) view.findViewById(R.id.messages); messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); sendImage = (TextView) view.findViewById(R.id.sendPicture); registerForContextMenu(sendImage); sendImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload); cancelUpload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { uploadThread.interrupt(); uploadLayout.setVisibility(View.GONE); textLayout.setVisibility(View.VISIBLE); progressBar.setProgress(0); } }); displayChat(displayName, pictureUri); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { chatRoom = lc.createChatRoom(sipUri); } // SharedPreferences prefs = // PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance()); // uploadServerUri = // prefs.getString(getString(R.string.pref_image_sharing_server_key), // getString(R.string.pref_image_sharing_server_default)); uploadServerUri = getString(R.string.pref_image_sharing_server_default); textWatcher = new TextWatcher() { public void afterTextChanged(Editable arg0) { } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { if (message.getText().toString().equals("")) { sendMessage.setEnabled(false); } else { sendMessage.setEnabled(true); } } }; // Force hide keyboard if (LinphoneActivity.isInstanciated()) { InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } // Workaround for SGS3 issue if (savedInstanceState != null) { fileToUploadPath = savedInstanceState.getString("fileToUploadPath"); imageToUpload = savedInstanceState.getParcelable("imageToUpload"); } if (fileToUploadPath != null || imageToUpload != null) { sendImage.post(new Runnable() { @Override public void run() { sendImage.showContextMenu(); } }); } return view; }
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
/** * initialize the emojiconKeyboard//ww w . ja va 2s .com */ private void initEmoji(View view) { // save the views I will use final EmojiconEditText emojiconEditText = (EmojiconEditText) getActivity() .findViewById(R.id.send_image_description); final ImageButton emojiBtn = (ImageButton) view.findViewById(R.id.send_image_emoti_switch); mListener.setCurrentEmojiconEditText(emojiconEditText); // open/close the emojicon keyboard when pressing the button emojiBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (emojiconEditText == null) return; getActivity().getSupportFragmentManager().beginTransaction() .replace(R.id.emojicon_keyboard, EmojiconsFragment.newInstance(!emojiKeyBoardOpen)) .commit(); emojiconEditText.setFocusableInTouchMode(true); emojiconEditText.requestFocus(); InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); if (emojiKeyBoardOpen) inputMethodManager.showSoftInput(emojiconEditText, InputMethodManager.SHOW_IMPLICIT); else inputMethodManager.hideSoftInputFromWindow(emojiconEditText.getWindowToken(), 0); emojiKeyBoardOpen = !emojiKeyBoardOpen; } }); }