List of usage examples for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY
int HIDE_IMPLICIT_ONLY
To view the source code for android.view.inputmethod InputMethodManager HIDE_IMPLICIT_ONLY.
Click Source Link
From source file:org.appcelerator.titanium.util.TiUIHelper.java
/** * Shows/hides the soft keyboard./* w w w.ja v a 2 s . co m*/ * @param view the current focused view. * @param show whether to show soft keyboard. */ public static void showSoftKeyboard(final View view, final boolean show) { if (view == null) return; InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Activity.INPUT_METHOD_SERVICE); if (imm != null) { boolean useForce = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || Build.VERSION.SDK_INT >= 8) ? true : false; String model = TiPlatformHelper.getInstance().getModel(); if (model != null && model.toLowerCase().startsWith("droid")) { useForce = true; } if (show) { imm.showSoftInput(view, useForce ? InputMethodManager.SHOW_FORCED : InputMethodManager.SHOW_IMPLICIT); } else { imm.hideSoftInputFromWindow(view.getWindowToken(), useForce ? 0 : InputMethodManager.HIDE_IMPLICIT_ONLY); } } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
/** * hide search view with a circular reveal animation *//*from ww w. j ava 2s .c o m*/ public void hideSearchView() { final int END_RADIUS = 16; int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight()); Animator animator; if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32, searchCoords[1] - 16, startRadius, END_RADIUS); } else { // TODO: ViewAnimationUtils.createCircularReveal animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 1f, 0f); } // removing background fade view utils.revealShow(fabBgView, false); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(600); animator.start(); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { searchViewLayout.setVisibility(View.GONE); isSearchViewEnabled = false; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); }
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); }/*from w w w . j a v a 2 s . co 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:net.nightwhistler.pageturner.fragment.ReadingFragment.java
public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);//from w w w . j a va 2 s . c o m searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final int[] counter = { 0 }; //Yes, this is essentially a pointer to an int :P final SearchTextTask task = new SearchTextTask(bookView.getBook()); task.setOnPreExecute(() -> { searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); }); task.setOnProgressUpdate((values) -> { if (isAdded()) { LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { counter[0] = counter[0] + 1; String update = String.format(getString(R.string.search_hits), counter[0]); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } }); task.setOnCancelled((result) -> { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } }); task.setOnPostExecute((result) -> { searchProgress.dismiss(); if (!task.isCancelled() && isAdded()) { List<SearchResult> resultList = result.getOrElse(new ArrayList<>()); if (resultList.size() > 0) { searchResults = resultList; showSearchResultDialog(resultList); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }); searchProgress.setOnCancelListener(dialog -> task.cancel(true)); executeTask(task, query); }
From source file:net.nightwhistler.pageturner.activity.ReadingFragment.java
@Override public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);/* w ww.j a va 2s .com*/ searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final SearchTextTask task = new SearchTextTask(bookView.getBook()) { int i = 0; @Override protected void onPreExecute() { super.onPreExecute(); searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context .getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } @Override protected void onProgressUpdate(SearchResult... values) { if (!isAdded()) { return; } super.onProgressUpdate(values); LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { i++; String update = String.format(getString(R.string.search_hits), i); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } @Override protected void onCancelled() { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } } protected void onPostExecute(java.util.List<SearchResult> result) { searchProgress.dismiss(); if (!isCancelled() && isAdded()) { if (result.size() > 0) { searchResults = result; showSearchResultDialog(result); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }; }; searchProgress.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { task.cancel(true); } }); task.execute(query); }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
@Override public void performSearch(String query) { LOG.debug("Starting search for: " + query); final ProgressDialog searchProgress = new ProgressDialog(context); searchProgress.setOwnerActivity(getActivity()); searchProgress.setCancelable(true);//from ww w . j a v a 2 s . com searchProgress.setMax(100); searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); final SearchTextTask task = new SearchTextTask(bookView.getBook()) { int i = 0; @Override protected void onPreExecute() { super.onPreExecute(); searchProgress.setMessage(getString(R.string.search_wait)); searchProgress.show(); // Hide on-screen keyboard if it is showing InputMethodManager imm = (InputMethodManager) context .getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); } @Override protected void onProgressUpdate(SearchResult... values) { if (!isAdded()) { return; } super.onProgressUpdate(values); LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart() + " with context " + values[0].getDisplay()); SearchResult res = values[0]; if (res.getDisplay() != null) { i++; String update = String.format(getString(R.string.search_hits), i); searchProgress.setMessage(update); } searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart())); } @Override protected void onCancelled() { if (isAdded()) { Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show(); } } protected void onPostExecute(java.util.List<SearchResult> result) { searchProgress.dismiss(); if (!isCancelled() && isAdded()) { if (result.size() > 0) { searchResults = result; searchResultWraper.setSearchResult(searchResults); // showSearchResultDialog(result); Intent intent = new Intent(getActivity(), ReadingOptionsActivity.class); Bundle bundle = new Bundle(); bundle.putInt("SELECTED_TAB", 4); intent.putExtras(bundle); startActivity(intent); } else { Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show(); } } }; }; searchProgress.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { task.cancel(true); } }); task.execute(query); }