List of usage examples for android.view KeyEvent getRepeatCount
public final int getRepeatCount()
From source file:com.hwx.wheel.steeringwheel.bluetooth.ScaleActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { onBackPressed();/* ww w .ja va 2 s . c om*/ return true; } return false; }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
/** * Overrides click on the BACK arrow to prevent fingerprint from being worked around. * * @param keyCode Key code of the key that triggered the down event. * @param event Event triggered./*from www . j a v a 2 s .c o m*/ * @return 'True' when the key event was processed by this method. */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { return true; } return super.onKeyDown(keyCode, event); }
From source file:com.mercandalli.android.apps.files.file.audio.FileAudioActivity.java
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { finishActivity();/*w w w .j a v a2s .c om*/ } return super.onKeyDown(keyCode, event); }
From source file:com.launcher.silverfish.launcher.LauncherActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // Override the functionality of back and home key if ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) && event.getRepeatCount() == 0) { event.startTracking();/*from ww w . j a va2s . c o m*/ return true; } return super.onKeyDown(keyCode, event); }
From source file:com.example.android.CreateNewPlayer.java
/** * onKeyDown overrides onKeyDown and allows code to be executed when the * back button is pushed in the simulator / on the mobile phone Since * pushing "back" won't necessarily call the destroy method as far as I * understand it.//www . j a v a2s. c o m * * @param keyCode * : code of the key pressed * @param event * : the event for the key pressed */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == zero) { // continue backwards (kills current activity calling onDestroy) finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.commonsware.android.kbmouse.hotkeys.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && event.getRepeatCount() == 0) { int position = adapter.getCheckedPosition(); if (position >= 0) { Uri videoUri = adapter.getVideoUri(position); if (event.isAltPressed()) { playVideo(videoUri);/*from w w w . jav a 2s . c o m*/ } else if (event.isCtrlPressed()) { showLargeThumbnail(videoUri); } return (true); } } return (super.onKeyDown(keyCode, event)); }
From source file:com.mercandalli.android.apps.files.main.NavDrawerActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { return keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && backPressed() || super.onKeyDown(keyCode, event); }
From source file:de.theknut.xposedgelsettings.ui.MainActivity.java
@SuppressWarnings("deprecation") @Override/*w ww. java 2 s.c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = CommonUI.CONTEXT = mActivity = CommonUI.ACTIVITY = this; if (getSharedPreferences(Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE) .getBoolean("forceenglishlocale", false)) { Resources res = mContext.getResources(); Configuration conf = res.getConfiguration(); conf.locale = new Locale(Locale.US.getDisplayLanguage().toLowerCase()); res.updateConfiguration(conf, res.getDisplayMetrics()); } mTitle = mDrawerTitle = getTitle(); mFragmentTitles = getResources().getStringArray(R.array.fragmenttitles_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.getRootView().setBackgroundColor(CommonUI.UIColor); getActionBar().setBackgroundDrawable(new ColorDrawable(CommonUI.UIColor)); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mFragmentTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerLayout.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getRepeatCount() != 0) return false; if (!mDrawerLayout.isDrawerOpen(Gravity.LEFT)) { if ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) { mDrawerLayout.openDrawer(Gravity.LEFT); return true; } } else { if (keyCode == KeyEvent.KEYCODE_BACK) { MainActivity.this.finish(); return true; } else if (keyCode == KeyEvent.KEYCODE_MENU) { mDrawerLayout.closeDrawer(Gravity.LEFT); return true; } } return false; } }); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); getActionBar().setBackgroundDrawable(new ColorDrawable(CommonUI.UIColor)); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); SharedPreferences prefs = getSharedPreferences(Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE); CommonUI.NO_BACKGROUND_IMAGE = prefs.getBoolean("nobackgroundimage", false); CommonUI.AUTO_BLUR_IMAGE = prefs.getBoolean("autoblurimage", false); if (savedInstanceState == null) { Intent i = getIntent(); if (i != null && i.hasExtra("fragment")) { if (i.getStringExtra("fragment").equals("badges")) { selectItem(6); } } else { selectItem(0); } } }
From source file:com.tweetlanes.android.core.view.DirectMessageActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (mDeleting) { showNoBackToast();/*from ww w . ja v a 2 s . c om*/ return false; } if (event.getRepeatCount() == 0) { Intent returnIntent = new Intent(); returnIntent.putExtra("statusDelete", mHasDoneDelete); setResult(RESULT_OK, returnIntent); finish(); return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.ty.highway.highwaysystem.ui.activity.basic.BaseActivity.java
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { finish();/*from www .j a v a 2 s . c o m*/ } return super.onKeyDown(keyCode, event); }