List of usage examples for android.content Context INPUT_METHOD_SERVICE
String INPUT_METHOD_SERVICE
To view the source code for android.content Context INPUT_METHOD_SERVICE.
Click Source Link
From source file:com.chrynan.guitarchords.view.GuitarChordView.java
private void init(Context context, AttributeSet attrs) { detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override//from w w w . ja va2 s .c o m public boolean onDown(MotionEvent event) { boolean isMarkerInChord = false; int fret = NO_FRET, string = -1; fret = getSelectedFret(event); string = getSelectedString(event); touchEventMarker = new ChordMarker(string, fret, NO_FINGER); return true; } @Override public void onLongPress(MotionEvent event) { if (editable && touchEventMarker != null && chord != null && chord.contains(touchEventMarker)) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(GuitarChordView.this, InputMethodManager.SHOW_IMPLICIT); } } }); chord = new Chord(); showFretNumbers = true; showFingerNumbers = true; editable = false; stringCount = 6; listeners = new ArrayList<>(); fretNumberListeners = new ArrayList<>(); stringListeners = new ArrayList<>(); touchEventMarker = null; mutedText = MUTED_TEXT; openStringText = OPEN_STRING_TEXT; initPaint(); if (attrs != null) { //TODO handle custom attribute values TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.GuitarChordView, 0, 0); try { bridgeNutColor = a.getColor(R.styleable.GuitarChordView_bridgeNutColor, DEFAULT_COLOR); bridgeNutPaint.setColor(bridgeNutColor); fretMarkerColor = a.getColor(R.styleable.GuitarChordView_fretMarkerColor, DEFAULT_COLOR); fretMarkerPaint.setColor(fretMarkerColor); stringColor = a.getColor(R.styleable.GuitarChordView_stringColor, DEFAULT_COLOR); stringPaint.setColor(stringColor); fretNumberColor = a.getColor(R.styleable.GuitarChordView_fretNumberColor, DEFAULT_COLOR); fretNumberPaint.setColor(fretNumberColor); stringMarkerColor = a.getColor(R.styleable.GuitarChordView_stringMarkerColor, DEFAULT_COLOR); stringMarkerPaint.setColor(stringMarkerColor); noteColor = a.getColor(R.styleable.GuitarChordView_noteColor, DEFAULT_COLOR); notePaint.setColor(noteColor); noteNumberColor = a.getColor(R.styleable.GuitarChordView_noteNumberColor, WHITE); noteNumberPaint.setColor(noteNumberColor); barLineColor = a.getColor(R.styleable.GuitarChordView_barLineColor, DEFAULT_COLOR); barLinePaint.setColor(barLineColor); mutedText = a.getString(R.styleable.GuitarChordView_mutedText); mutedText = (mutedText == null) ? MUTED_TEXT : mutedText; openStringText = a.getString(R.styleable.GuitarChordView_openStringText); openStringText = (openStringText == null) ? OPEN_STRING_TEXT : openStringText; stringCount = a.getInt(R.styleable.GuitarChordView_stringAmount, 6); editable = a.getBoolean(R.styleable.GuitarChordView_editable, false); showFingerNumbers = a.getBoolean(R.styleable.GuitarChordView_showFingerNumbers, true); showFretNumbers = a.getBoolean(R.styleable.GuitarChordView_showFretNumbers, true); } catch (Exception e) { e.printStackTrace(); } finally { a.recycle(); } } }
From source file:com.hybris.mobile.activity.LoginActivity.java
@Override public void onReceiveResult(RESTLoaderResponse restLoaderResponse, WebserviceMethodEnums webserviceEnumMethod) { if (restLoaderResponse.getCode() == RESTLoaderResponse.SUCCESS) { switch (webserviceEnumMethod) { case METHOD_LOGIN: Hybris.setUserOnline(true);/*from www . ja v a 2 s . c o m*/ Hybris.setUsername(mEmailView.getText().toString()); if (getCurrentFocus() != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } showMessage(getString(R.string.login_successful)); // Redirection to the right intent if (getIntent().hasExtra(DataConstants.INTENT_DESTINATION)) { new CheckDataBeforeLaunchingIntentTask().execute(); } else { finish(); } break; case METHOD_REQUEST_PASSWORD: showMessage(getString(R.string.new_password_sent)); break; default: break; } } else if (restLoaderResponse.getCode() == RESTLoaderResponse.ERROR) { switch (webserviceEnumMethod) { case METHOD_LOGIN: showMessage(getString(R.string.error_login)); break; default: break; } } }
From source file:com.pixplicity.castdemo.MainActivity.java
private void setConnected(boolean connected) { mBtSend.setEnabled(connected);//from w w w .j a va 2 s .co m mBtSpeak.setEnabled(connected); mEtMessage.setEnabled(connected); if (connected) { mEtMessage.requestFocus(); // Implicity request a soft input mode InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEtMessage, InputMethodManager.SHOW_IMPLICIT); } }
From source file:com.adarshahd.indianrailinfo.donate.PNRStat.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.id_btn_get_pnr_sts: mPNRNumber = ((EditText) findViewById(R.id.id_act_pnr_sts)).getText().toString(); if (mPNRList.contains(mPNRNumber) && !mUtil.isConnected()) { //Check the preference and show the stored PNR status if (mPref.getBoolean("pnr_offline", false)) { readAndShowOfflinePNRStatus(); return; }/*from w w w.j av a2 s . c om*/ } if (!mUtil.isConnected()) { mUtil.showAlert("Alert", "Network unavailable, Please check your network connection."); return; } mBtnPNR = (Button) v; if (PNROkay(mPNRNumber)) { mBtnPNR.setText("Getting PNR status, please wait . . ."); mBtnPNR.setEnabled(false); mGetPNRSts = new GetPNRStatus().execute(mPNRNumber); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( ((EditText) findViewById(R.id.id_act_pnr_sts)).getWindowToken(), 0); } else { ((EditText) findViewById(R.id.id_act_pnr_sts)).setError("Invalid PNR Number"); mTextViewPNRSts.setText("Invalid PNR number"); mFrameLayout.removeAllViews(); mFrameLayout.addView(mTextViewPNRSts); } break; default: return; } }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void InitiateSearch() { card_search.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w ww.j a v a2 s . c o m public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); InitiateSearch.handleToolBar(getActivity(), card_search, view_search, listView, edit_text_search, line_divider); } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogQuickSearch logQuickSearch = logQuickSearchAdapter.getItem(position); edit_text_search.setText(logQuickSearch.getName()); listView.setVisibility(View.GONE); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(edit_text_search.getWindowToken(), 0); searchFood(logQuickSearch.getName(), 0); } }); edit_text_search.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) { if (edit_text_search.getText().toString().length() == 0) { logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.all()); listView.setAdapter(logQuickSearchAdapter); clearSearch.setImageResource(R.mipmap.ic_keyboard_voice); IsAdapterEmpty(); } else { logQuickSearchAdapter = new LogQuickSearchAdapter(getActivity(), 0, LogQuickSearch.FilterByName(edit_text_search.getText().toString())); listView.setAdapter(logQuickSearchAdapter); clearSearch.setImageResource(R.mipmap.ic_close); IsAdapterEmpty(); } } @Override public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (edit_text_search.getText().toString().length() != 0) { edit_text_search.setText(""); searchBack.setVisibility(View.GONE); listView.setVisibility(View.VISIBLE); clearItems(); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); IsAdapterEmpty(); } else { promptSpeechInput(edit_text_search); } } }); }
From source file:com.ichi2.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;//from ww w .j a va 2s . com initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }
From source file:com.chalmers.schmaps.GoogleMapSearchLocation.java
/** * If the enter button is clicked a room search is done * If the get directions button is pressed you get the path drawn on map * but you have to search for a room first *///from w w w .j a v a 2 s . c o m public void onClick(View v) { switch (v.getId()) { case R.id.edittextbutton: //Removes the key when finish typing InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(lectureEdit.getWindowToken(), 0); //removes the path drawn if there is one mapOverlays.remove(pathOverlay); //removes the dot that point to a previous room found mapOverlays.remove(mapItemizedRoom); roomToFind = lectureEdit.getText().toString(); //removes white signs and converts to lower case roomToFind.toLowerCase().trim(); //Removes illegal characters to prevent sql injection roomToFind = roomToFind.replaceAll("[^[a-z][A-Z][0-9]]", ""); //Set the field variable so it can be tested. setRoomToFind(roomToFind); //open database in read mode search.openRead(); //if we find room show room on map, if not show dialog if (search.exists(roomToFind)) { //create a geopoint roomLocation = new GeoPoint(search.getLat(roomToFind), search.getLong(roomToFind)); mapcon = mapView.getController(); mapcon.animateTo(roomLocation); //zoom level mapcon.setZoom(OVERVIEWZOOMVALUE); //address and level is shown in the dialog overlayItemRoom = new OverlayItem(roomLocation, search.getAddress(roomToFind), search.getLevel(roomToFind)); mapItemizedRoom.removeOverlay(); mapItemizedRoom.addOverlay(overlayItemRoom); mapOverlays.add(mapItemizedRoom); mapView.postInvalidate(); //now someone has searched for a room, set the boolean to true roomSearched = true; } else { //dilaog pops up if room not found dialog = new Dialog(GoogleMapSearchLocation.this); dialog.setTitle("Sorry, can not find the room :("); dialog.setCanceledOnTouchOutside(true); dialog.show(); } //close database search.close(); break; case R.id.directionbutton: Log.e("roomsearched", "in"); //if there there is roomLocation then search for a path //if not a roomLocation then the user has not searched for a room, do not give directions if (gotInternetConnection()) { Log.e("roomsearched", "inin"); if (roomSearched) { walkningDirections(); roomSearched = false; } else { Context context = getApplicationContext(); Toast.makeText(context, "Search for a room first to get directions", Toast.LENGTH_LONG).show(); } } else { Context context = getApplicationContext(); Toast.makeText(context, "Internet connection needed for this option", Toast.LENGTH_LONG).show(); } break; } }
From source file:org.cryptsecure.Utility.java
/** * Show keyboard explicitly for a text input field known to be able to get * the focus.//from w w w. j a va2s . c o m * * @param textInput * the text input */ public static void showKeyboardExplicit(EditText textInput) { InputMethodManager keyboard = (InputMethodManager) textInput.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(textInput, 0); }
From source file:net.dewep.intranetepitech.ui.landing.LandingActivity.java
@Override public void onPageSelected(int position) { if (position == 0) { mLandingLogo.setVisibility(View.GONE); } else {/*w w w. ja v a 2 s.co m*/ mLandingLogo.setVisibility(View.VISIBLE); } if (this.getCurrentFocus() != null) { InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0); } this.getWindow().getDecorView().clearFocus(); }
From source file:com.hichinaschool.flashcards.anki.Feedback.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); Context context = getBaseContext(); SharedPreferences sharedPreferences = AnkiDroidApp.getSharedPrefs(context); mReportErrorMode = sharedPreferences.getString("reportErrorMode", REPORT_ASK); mNonce = UUID.randomUUID().getMostSignificantBits(); mFeedbackUrl = res.getString(R.string.feedback_post_url); mErrorUrl = res.getString(R.string.error_post_url); mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mPostingFeedback = false;// w w w .j ava2 s. c om initAllAlertDialogs(); getErrorFiles(); Intent i = getIntent(); mAllowFeedback = (i.hasExtra("request") && (i.getIntExtra("request", 0) == DeckPicker.REPORT_FEEDBACK || i.getIntExtra("request", 0) == DeckPicker.RESULT_DB_ERROR)) || mReportErrorMode.equals(REPORT_ASK); if (!mAllowFeedback) { if (mReportErrorMode.equals(REPORT_ALWAYS)) { // Always report try { String feedback = "Automatically sent"; Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), true })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } else if (mReportErrorMode.equals(REPORT_NEVER)) { // Never report deleteFiles(false, false); finish(); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(Feedback.this, ActivityTransitionAnimation.NONE); } return; } } View mainView = getLayoutInflater().inflate(R.layout.feedback, null); setContentView(mainView); Themes.setWallpaper(mainView); Themes.setTextViewStyle(findViewById(R.id.tvFeedbackDisclaimer)); Themes.setTextViewStyle(findViewById(R.id.lvFeedbackErrorList)); Button btnSend = (Button) findViewById(R.id.btnFeedbackSend); Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest); Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll); mEtFeedbackText = (EditText) findViewById(R.id.etFeedbackText); mLvErrorList = (ListView) findViewById(R.id.lvFeedbackErrorList); mErrorAdapter = new SimpleAdapter(this, mErrorReports, R.layout.error_item, new String[] { "name", "state", "result" }, new int[] { R.id.error_item_text, R.id.error_item_progress, R.id.error_item_status }); mErrorAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { switch (view.getId()) { case R.id.error_item_progress: if (text.equals(STATE_UPLOADING)) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } return true; case R.id.error_item_status: if (text.length() == 0) { view.setVisibility(View.GONE); return true; } else { view.setVisibility(View.VISIBLE); return false; } } return false; } }); btnClearAll.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, false); refreshErrorListView(); refreshInterface(); } }); mLvErrorList.setAdapter(mErrorAdapter); btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mPostingFeedback) { String feedback = mEtFeedbackText.getText().toString(); Connection.sendFeedback(mSendListener, new Payload(new Object[] { mFeedbackUrl, mErrorUrl, feedback, mErrorReports, mNonce, getApplication(), false })); if (mErrorReports.size() > 0) { mPostingFeedback = true; } if (feedback.length() > 0) { mPostingFeedback = true; } refreshInterface(); } } }); btnKeepLatest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteFiles(false, true); refreshErrorListView(); refreshInterface(); } }); refreshInterface(); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); }