List of usage examples for android.view KeyEvent KEYCODE_DPAD_LEFT
int KEYCODE_DPAD_LEFT
To view the source code for android.view KeyEvent KEYCODE_DPAD_LEFT.
Click Source Link
From source file:org.brandroid.openmanager.fragments.ContentFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.content_layout, container, false); mGrid = (GridView) v.findViewById(R.id.content_grid); final OpenFragment me = this; mGrid.setOnKeyListener(new OnKeyListener() { @Override/*from w ww . ja v a2 s . c o m*/ public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) return false; int col = 0; int cols = 1; try { if (!OpenExplorer.BEFORE_HONEYCOMB) { Method m = GridView.class.getMethod("getNumColumns", new Class[0]); Object tmp = m.invoke(mGrid, new Object[0]); if (tmp instanceof Integer) { cols = (Integer) tmp; col = mGrid.getSelectedItemPosition() % cols; } } } catch (Exception e) { } Logger.LogDebug("ContentFragment.mGrid.onKey(" + keyCode + "," + event + ")@" + col); if (!OpenExplorer.BEFORE_HONEYCOMB) cols = (Integer) mGrid.getNumColumns(); if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && col == 0) return onFragmentDPAD(me, false); else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && col == cols - 1) return onFragmentDPAD(me, true); else if (MenuUtils.getMenuShortcut(event) != null) { MenuItem item = MenuUtils.getMenuShortcut(event); if (onOptionsItemSelected(item)) { Toast.makeText(v.getContext(), item.getTitle(), Toast.LENGTH_SHORT).show(); return true; } } return false; } }); v.setOnLongClickListener(this); mGrid.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { getMenuInflater().inflate(R.menu.context_file, menu); onPrepareOptionsMenu(menu); } }); //if(mProgressBarLoading == null) // mProgressBarLoading = v.findViewById(R.id.content_progress); setProgressVisibility(false); super.onCreateView(inflater, container, savedInstanceState); //v.setBackgroundResource(R.color.lightgray); /* if (savedInstanceState != null && savedInstanceState.containsKey("location")) { String location = savedInstanceState.getString("location"); if(location != null && !location.equals("") && location.startsWith("/")) { Logger.LogDebug("Content location restoring to " + location); mPath = new OpenFile(location); mData = getManager().getChildren(mPath); updateData(mData); } //setContentPath(path, false); } */ return v; }
From source file:com.malgon.applecrunch.Game3.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (loaded) { if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { canonSprite.moveX(-moveCanonX); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { canonSprite.moveX(moveCanonX); } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { Sprite laserSprite = new Sprite(180, 80, laserTexture); Hotspot laserHotspot = new Hotspot(laserSprite); rokon.addSprite(laserSprite); rokon.addHotspot(laserHotspot); laserSprite.setXY(canonSprite.getX() + 20, canonSprite.getY()); laserSprite.setVisible(true); laserSprite.setVelocityY(-laserVelocity); laserSprite.setCollisionHandler(collisionHandler); for (int i = 0; i < appleSpriteList.size(); i++) laserSprite.addCollisionSprite(appleSpriteList.get(i)); for (int i = 0; i < androidSpriteList.size(); i++) laserSprite.addCollisionSprite(androidSpriteList.get(i)); laserSpriteList.add(laserSprite); laserHotspotList.add(laserHotspot); }// www . j a v a2 s . c o m } return super.onKeyDown(keyCode, event); }
From source file:net.qiujuer.genius.ui.widget.GeniusAbsSeekBar.java
@Override public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { boolean handled = false; boolean isAdd = false; if (isEnabled()) { int progress = getAnimatedProgress(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = true;//from w ww. j av a 2 s . co m isAdd = isRtl(); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = true; isAdd = !isRtl(); break; } if (handled) { if (isAdd) { if (progress < mMax) animateSetProgress(progress + mKeyProgressIncrement); } else { if (progress > mMin) animateSetProgress(progress - mKeyProgressIncrement); } } } return handled || super.onKeyDown(keyCode, event); }
From source file:net.sourceforge.servestream.activity.MediaPlayerActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int repcnt = event.getRepeatCount(); if ((seekmethod == 0) ? seekMethod1(keyCode) : seekMethod2(keyCode)) return true; switch (keyCode) { case KeyEvent.KEYCODE_SLASH: seekmethod = 1 - seekmethod;/* www. j a v a2 s .c om*/ return true; case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; } if (!mPrevButton.hasFocus()) { mPrevButton.requestFocus(); } scanBackward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!useDpadMusicControl()) { break; } if (!mNextButton.hasFocus()) { mNextButton.requestFocus(); } scanForward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_S: toggleShuffle(); return true; case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: doPauseResume(); return true; } return super.onKeyDown(keyCode, event); }
From source file:org.musicmod.android.app.MusicPlaybackActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { try {// w w w . j a v a 2 s .c o m switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; } if (mService != null) { if (!mSeeking && mStartSeekPos >= 0) { mPauseButton.requestFocus(); if (mStartSeekPos < 1000) { mService.prev(); } else { mService.seek(0); } } else { scanBackward(-1, event.getEventTime() - event.getDownTime()); mPauseButton.requestFocus(); mStartSeekPos = -1; } } mSeeking = false; mPosOverride = -1; return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!useDpadMusicControl()) { break; } if (mService != null) { if (!mSeeking && mStartSeekPos >= 0) { mPauseButton.requestFocus(); mService.next(); } else { scanForward(-1, event.getEventTime() - event.getDownTime()); mPauseButton.requestFocus(); mStartSeekPos = -1; } } mSeeking = false; mPosOverride = -1; return true; } } catch (RemoteException ex) { } return super.onKeyUp(keyCode, event); }
From source file:com.acious.android.paginationseekbar.PaginationSeekBar.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { //TODO: Should we reverse the keys for RTL? The framework's SeekBar does NOT.... boolean handled = false; if (isEnabled()) { int progress = getAnimatedProgress(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: handled = true;// w w w . j a v a 2s. c o m if (progress <= mMin) break; animateSetProgress(progress - mKeyProgressIncrement); break; case KeyEvent.KEYCODE_DPAD_RIGHT: handled = true; if (progress >= mMax) break; animateSetProgress(progress + mKeyProgressIncrement); break; } } return handled || super.onKeyDown(keyCode, event); }
From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); if (isAnimating() && action == KeyEvent.ACTION_DOWN) { stopAnimating();/*from www. j a va2 s . c o m*/ return true; } switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: // Yes, this is nasty: if the setting is true, we fall through to // the next case. if (!config.isVolumeKeyNavEnabled()) { return false; } case KeyEvent.KEYCODE_DPAD_RIGHT: if (action == KeyEvent.ACTION_DOWN) { pageDown(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_VOLUME_UP: // Same dirty trick. if (!config.isVolumeKeyNavEnabled()) { return false; } case KeyEvent.KEYCODE_DPAD_LEFT: if (action == KeyEvent.ACTION_DOWN) { pageUp(Orientation.HORIZONTAL); } return true; case KeyEvent.KEYCODE_BACK: if (action == KeyEvent.ACTION_DOWN) { if (titleBarLayout.getVisibility() == View.VISIBLE) { hideTitleBar(); } else if (bookView.hasPrevPosition()) { bookView.goBackInHistory(); return true; } else { this.finish(); } } } return false; }
From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int c = event.getUnicodeChar(); if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) { setVolume(mVolumeLevel + 20); } else {//from ww w.ja va 2 s . c o m mMediaServer.status().command.volumeUp(); } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) { setVolume(mVolumeLevel - 20); } else { mMediaServer.status().command.volumeDown(); } return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { if (event.isAltPressed()) { mMediaServer.status().command.seek(Uri.encode("-".concat(Preferences.get(this).getSeekTime()))); return true; } else if (event.isShiftPressed()) { mMediaServer.status().command.seek(Uri.encode("-3")); return true; } else { mMediaServer.status().command.key("nav-left"); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { if (event.isAltPressed()) { mMediaServer.status().command.seek(Uri.encode("+".concat(Preferences.get(this).getSeekTime()))); return true; } else if (event.isShiftPressed()) { mMediaServer.status().command.seek(Uri.encode("+3")); return true; } else { mMediaServer.status().command.key("nav-right"); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { mMediaServer.status().command.key("nav-up"); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { mMediaServer.status().command.key("nav-down"); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { mMediaServer.status().command.key("nav-activate"); return true; } else if (c == ' ') { mMediaServer.status().command.playback.pause(); return true; } else if (c == 's') { mMediaServer.status().command.playback.stop(); return true; } else if (c == 'p') { mMediaServer.status().command.playback.previous(); return true; } else if (c == 'n') { mMediaServer.status().command.playback.next(); return true; } else if (c == '+') { // TODO: Play faster return super.onKeyDown(keyCode, event); } else if (c == '-') { // TODO: Play slower return super.onKeyDown(keyCode, event); } else if (c == 'f') { mMediaServer.status().command.fullscreen(); return true; } else if (c == 'm') { mute(); return true; } else { return super.onKeyDown(keyCode, event); } }
From source file:org.musicmod.android.app.MusicPlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { int repcnt = event.getRepeatCount(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; }/*from www.j a v a 2s .c o m*/ if (!mPrevButton.hasFocus()) { mPrevButton.requestFocus(); } scanBackward(repcnt, event.getEventTime() - event.getDownTime()); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (!useDpadMusicControl()) { break; } if (!mNextButton.hasFocus()) { mNextButton.requestFocus(); } scanForward(repcnt, event.getEventTime() - event.getDownTime()); return true; // case KeyEvent.KEYCODE_R: // toggleRepeat(); // return true; // // case KeyEvent.KEYCODE_S: // toggleShuffle(); // return true; case KeyEvent.KEYCODE_N: if (mService != null) { try { mService.next(); return true; } catch (RemoteException e) { e.printStackTrace(); } } else { return false; } case KeyEvent.KEYCODE_P: if (mService != null) { try { mService.prev(); return true; } catch (RemoteException e) { e.printStackTrace(); } } else { return false; } case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: doPauseResume(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.iiordanov.bVNC.RemoteCanvasActivity.java
/** * Initializes the on-screen keys for meta keys and arrow keys. *//* ww w. j av a 2s .c o m*/ private void initializeOnScreenKeys() { layoutKeys = (RelativeLayout) findViewById(R.id.layoutKeys); keyStow = (ImageButton) findViewById(R.id.keyStow); setKeyStowDrawableAndVisibility(); keyStow.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (layoutKeys.getVisibility() == View.VISIBLE) { extraKeysHidden = true; setExtraKeysVisibility(View.GONE, false); } else { extraKeysHidden = false; setExtraKeysVisibility(View.VISIBLE, true); } layoutKeys.offsetTopAndBottom(prevBottomOffset); setKeyStowDrawableAndVisibility(); } }); // Define action of tab key and meta keys. keyTab = (ImageButton) findViewById(R.id.keyTab); keyTab.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = KeyEvent.KEYCODE_TAB; if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyTab.setImageResource(R.drawable.tabon); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyTab.setImageResource(R.drawable.taboff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); keyEsc = (ImageButton) findViewById(R.id.keyEsc); keyEsc.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = 111; /* KEYCODE_ESCAPE */ if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyEsc.setImageResource(R.drawable.escon); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyEsc.setImageResource(R.drawable.escoff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); keyCtrl = (ImageButton) findViewById(R.id.keyCtrl); keyCtrl.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { boolean on = canvas.getKeyboard().onScreenCtrlToggle(); keyCtrlToggled = false; if (on) keyCtrl.setImageResource(R.drawable.ctrlon); else keyCtrl.setImageResource(R.drawable.ctrloff); } }); keyCtrl.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); boolean on = canvas.getKeyboard().onScreenCtrlToggle(); keyCtrlToggled = true; if (on) keyCtrl.setImageResource(R.drawable.ctrlon); else keyCtrl.setImageResource(R.drawable.ctrloff); return true; } }); keySuper = (ImageButton) findViewById(R.id.keySuper); keySuper.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { boolean on = canvas.getKeyboard().onScreenSuperToggle(); keySuperToggled = false; if (on) keySuper.setImageResource(R.drawable.superon); else keySuper.setImageResource(R.drawable.superoff); } }); keySuper.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); boolean on = canvas.getKeyboard().onScreenSuperToggle(); keySuperToggled = true; if (on) keySuper.setImageResource(R.drawable.superon); else keySuper.setImageResource(R.drawable.superoff); return true; } }); keyAlt = (ImageButton) findViewById(R.id.keyAlt); keyAlt.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { boolean on = canvas.getKeyboard().onScreenAltToggle(); keyAltToggled = false; if (on) keyAlt.setImageResource(R.drawable.alton); else keyAlt.setImageResource(R.drawable.altoff); } }); keyAlt.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); boolean on = canvas.getKeyboard().onScreenAltToggle(); keyAltToggled = true; if (on) keyAlt.setImageResource(R.drawable.alton); else keyAlt.setImageResource(R.drawable.altoff); return true; } }); keyShift = (ImageButton) findViewById(R.id.keyShift); keyShift.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { boolean on = canvas.getKeyboard().onScreenShiftToggle(); keyShiftToggled = false; if (on) keyShift.setImageResource(R.drawable.shifton); else keyShift.setImageResource(R.drawable.shiftoff); } }); keyShift.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); boolean on = canvas.getKeyboard().onScreenShiftToggle(); keyShiftToggled = true; if (on) keyShift.setImageResource(R.drawable.shifton); else keyShift.setImageResource(R.drawable.shiftoff); return true; } }); // TODO: Evaluate whether I should instead be using: // vncCanvas.sendMetaKey(MetaKeyBean.keyArrowLeft); // Define action of arrow keys. keyUp = (ImageButton) findViewById(R.id.keyUpArrow); keyUp.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = KeyEvent.KEYCODE_DPAD_UP; if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyUp.setImageResource(R.drawable.upon); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyUp.setImageResource(R.drawable.upoff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); keyDown = (ImageButton) findViewById(R.id.keyDownArrow); keyDown.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = KeyEvent.KEYCODE_DPAD_DOWN; if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyDown.setImageResource(R.drawable.downon); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyDown.setImageResource(R.drawable.downoff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); keyLeft = (ImageButton) findViewById(R.id.keyLeftArrow); keyLeft.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = KeyEvent.KEYCODE_DPAD_LEFT; if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyLeft.setImageResource(R.drawable.lefton); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyLeft.setImageResource(R.drawable.leftoff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); keyRight = (ImageButton) findViewById(R.id.keyRightArrow); keyRight.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent e) { RemoteKeyboard k = canvas.getKeyboard(); int key = KeyEvent.KEYCODE_DPAD_RIGHT; if (e.getAction() == MotionEvent.ACTION_DOWN) { BCFactory.getInstance().getBCHaptic().performLongPressHaptic(canvas); keyRight.setImageResource(R.drawable.righton); k.repeatKeyEvent(key, new KeyEvent(e.getAction(), key)); return true; } else if (e.getAction() == MotionEvent.ACTION_UP) { keyRight.setImageResource(R.drawable.rightoff); resetOnScreenKeys(0); k.stopRepeatingKeyEvent(); return true; } return false; } }); }