List of usage examples for android.view KeyEvent getKeyCode
public final int getKeyCode()
From source file:com.farmerbb.taskbar.activity.DashboardActivity.java
@Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { event.getKeyCode(); return true; }/* w w w .j a v a 2 s .c om*/ return super.dispatchKeyShortcutEvent(event); }
From source file:de.teambluebaer.patientix.activities.EndActivity.java
/** * This method disables the volumes keys * * @param event Listens on Keyinput event * @return Calls super class if key is allowed *//* ww w .jav a 2s.c om*/ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (blockedKeys.contains(event.getKeyCode())) { return true; } else { return super.dispatchKeyEvent(event); } }
From source file:com.app.blockydemo.ui.fragment.FormulaEditorScriptListFragment.java
@Override public void onListItemClick(int position) { Log.d("catroid", "onListItemClick"); if (!inContextMode) { FormulaEditorFragment formulaEditor = (FormulaEditorFragment) getActivity().getSupportFragmentManager() .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG); if (formulaEditor != null) { formulaEditor.addUserVariableToActiveFormula(adapter.getItem(position).getName()); formulaEditor.updateButtonViewOnKeyboard(); }/*w w w . ja v a 2 s . co m*/ KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK); onKey(null, keyEvent.getKeyCode(), keyEvent); } }
From source file:com.unipiazza.material2stepslogin.fragments.FirstStepFragment.java
@Nullable @Override//from w w w.j a v a 2 s .com public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.first_login_view, null); email = (AutoCompleteTextView) view.findViewById(R.id.email); next = (Button) view.findViewById(R.id.buttonNext); progressBarFirst = (ProgressBar) view.findViewById(R.id.progressBarFirst); layoutFirst = (LinearLayout) view.findViewById(R.id.layoutFirst); logo = (ImageView) view.findViewById(R.id.logo); descriptionText = (TextView) view.findViewById(R.id.descriptionText); registerText = (TextView) view.findViewById(R.id.registerText); buttonRegistra = (Button) view.findViewById(R.id.buttonRegistra); progressBarFirst.setVisibility(View.GONE); if (mtsl != null) { view.setBackgroundColor(mtsl.getFirst_step_background_color()); logo.setImageResource(mtsl.getLogo()); descriptionText.setText(mtsl.getDescription()); if (mtsl.getRegister_description() != 0) registerText.setText(mtsl.getRegister_description()); if (mtsl.getRegister_description_text_color() != 0) registerText.setTextColor(mtsl.getRegister_description_text_color()); if (mtsl.getRegister_text() != 0) buttonRegistra.setText(mtsl.getRegister_text()); if (mtsl.getRegister_background() != 0) buttonRegistra.setBackgroundResource(mtsl.getRegister_background()); if (mtsl.getButton_register_text_color() != 0) buttonRegistra.setTextColor(mtsl.getButton_register_text_color()); if (mtsl.getEditText_email_text_color() != 0) email.setTextColor(mtsl.getEditText_email_text_color()); if (mtsl.getEdittext_email_background() != 0) email.setBackgroundResource(mtsl.getEdittext_email_background()); if (mtsl.getButton_next_background() != 0) next.setBackgroundResource(mtsl.getButton_next_background()); if (mtsl.getButton_next_text_color() != 0) next.setTextColor(mtsl.getButton_next_text_color()); if (mtsl.getDescription_text_color() != 0) descriptionText.setTextColor(mtsl.getDescription_text_color()); } email.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { next.performClick(); } return false; } }); checkAccountPermissions(); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progressBarFirst.setVisibility(View.VISIBLE); layoutFirst.setVisibility(View.GONE); mListener.onNextClicked(email.getText().toString()); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }); buttonRegistra.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onRegisterClicked(); } }); return view; }
From source file:com.github.obsessive.simplifyreader.ui.activity.HomeActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) { if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mDrawerLayout.closeDrawer(Gravity.LEFT); } else {//from www. java 2s .c o m mDrawerLayout.openDrawer(Gravity.LEFT); } return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { mDrawerLayout.closeDrawer(Gravity.LEFT); } else { if ((System.currentTimeMillis() - DOUBLE_CLICK_TIME) > 2000) { showToast(getString(R.string.double_click_exit)); DOUBLE_CLICK_TIME = System.currentTimeMillis(); } else { getBaseApplication().exitApp(); } } return true; } return super.onKeyDown(keyCode, event); }
From source file:org.catrobat.catroid.ui.fragment.FormulaEditorListFragment.java
@Override public void onListItemClick(ListView listView, View view, int position, long id) { FormulaEditorFragment formulaEditor = (FormulaEditorFragment) getSherlockActivity() .getSupportFragmentManager().findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG); if (formulaEditor != null) { formulaEditor.addResourceToActiveFormula(itemsIds[position]); formulaEditor.updateButtonsOnKeyboardAndInvalidateOptionsMenu(); }/* w w w. ja va 2 s .co m*/ KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK); onKey(null, keyEvent.getKeyCode(), keyEvent); }
From source file:com.waz.zclient.pages.main.popup.QuickReplyFragment.java
@Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { final String sendText = textView.getText().toString(); if (TextUtils.isEmpty(sendText)) { return false; }//www. j av a 2 s .co m conversation.sendMessage(new MessageContent.Text(sendText)); TrackingUtils.onSentTextMessage(getControllerFactory().getTrackingController(), getStoreFactory().getConversationStore().getCurrentConversation()); getActivity().finish(); return true; } return false; }
From source file:hku.fyp14017.blencode.ui.ProjectActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { // Dismiss ActionMode without effecting sounds if (spritesListFragment.getActionModeActive() && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { SpriteAdapter adapter = (SpriteAdapter) spritesListFragment.getListAdapter(); adapter.clearCheckedSprites();/* w w w . jav a2 s . c o m*/ } return super.dispatchKeyEvent(event); }
From source file:au.com.wallaceit.reddinator.ViewAllSubredditsActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); global = ((GlobalObjects) getApplicationContext()); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }//from ww w.j a v a 2 s. co m setContentView(R.layout.viewallsubreddit); // setup list view listview = getListView(); listview.setTextFilterEnabled(true); listview.setEmptyView(findViewById(R.id.subredditload)); listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(); // update subreddit without adding to list intent.putExtra("subreddit", sreddits.get(position)); setResult(RESULT_SET_SUBREDDIT, intent); finish(); } }); // get empty view text for easy access later emptyview = (TextView) findViewById(R.id.poploadtxt); // setup search buttons searchbox = (EditText) this.findViewById(R.id.searchbox); searchbox.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) { search(v.getText().toString()); } return true; } }); ImageView searchbtn = (ImageView) this.findViewById(R.id.searchbutton); searchbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String query = searchbox.getText().toString(); if (!query.equals("")) { search(query); } else { new AlertDialog.Builder(ViewAllSubredditsActivity.this).setTitle("No Query") .setMessage("Please enter something to search for").show(); } } }); }
From source file:com.tct.email.activity.setup.EmailPreferenceActivity.java
/** * Listen for secret sequence and, if heard, enable debug menu *//*w w w .j a va 2 s . c o m*/ @Override public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { if (event.getKeyCode() == SECRET_KEY_CODES[mSecretKeyCodeIndex]) { mSecretKeyCodeIndex++; if (mSecretKeyCodeIndex == SECRET_KEY_CODES.length) { mSecretKeyCodeIndex = 0; enableDebugMenu(); } } else { mSecretKeyCodeIndex = 0; } return super.onKeyDown(keyCode, event); }