Example usage for android.view KeyEvent KEYCODE_VOLUME_UP

List of usage examples for android.view KeyEvent KEYCODE_VOLUME_UP

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_VOLUME_UP.

Prototype

int KEYCODE_VOLUME_UP

To view the source code for android.view KeyEvent KEYCODE_VOLUME_UP.

Click Source Link

Document

Key code constant: Volume Up key.

Usage

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    final boolean result;

    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        // For onKeyLongPress to work
        event.startTracking();/*from   w  ww  .j  ava 2s.  c o m*/
        result = !mApp.isLocalAudible();
    } else {
        result = super.onKeyDown(keyCode, event);
    }

    return result;
}

From source file:com.BibleQuote.BibleQuoteAndroid.ui.ReaderActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == 0) {
        keyCode = event.getScanCode();//  ww w .  j a  v a  2 s . com
    }

    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP && PreferenceHelper.volumeButtonsToScroll())
            || DevicesKeyCodes.KeyCodeUp(keyCode)) {
        vWeb.pageUp(false);
        viewChapterNav();
        return true;
    } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && PreferenceHelper.volumeButtonsToScroll())
            || DevicesKeyCodes.KeyCodeDown(keyCode)) {
        vWeb.pageDown(false);
        viewChapterNav();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.app.azza.ocr.OcrCaptureActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();

    Text text = null;// www  .jav a2  s.  c  o  m
    List mtextList = getAllGraphicsText();
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_DOWN) {

            Toast toast = Toast.makeText(this, "volume up pressed", Toast.LENGTH_SHORT);
            toast.show();

            Log.v("upVolume", "up " + lineNumberToSpeak);
            //        for(Object block:textList){
            //             text=(Text)block;
            //
            //            tts.speak(text.getValue(), TextToSpeech.QUEUE_ADD, null, "DEFAULT");
            //        }
            if (mtextList.size() > 0) {
                // for (int i = 0; i < textList.size(); i++) {
                if (lineNumberToSpeak < mtextList.size()) {
                    text = (Text) mtextList.get(lineNumberToSpeak);
                    if (text != null && text.getValue() != null) {
                        tts.speak(text.getValue(), TextToSpeech.QUEUE_ADD, null, "DEFAULT");
                        if (lineNumberToSpeak < mtextList.size())
                            lineNumberToSpeak++;

                    } else {
                        Log.d(TAG, "text data is null");
                    }
                    // }
                } else {
                    // al list al gdeda lines feha 22al
                    lineNumberToSpeak = 0;
                }
            } else {
                Log.d(TAG, "no text detected");
            }

        }
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            Toast toast = Toast.makeText(this, "volume down pressed", Toast.LENGTH_SHORT);
            toast.show();
            if (mtextList.size() > 0) {
                // for (int i = 0; i < textList.size(); i++) {
                if (lineNumberToSpeak > -1) {
                    text = (Text) mtextList.get(lineNumberToSpeak);
                    if (text != null && text.getValue() != null) {
                        tts.speak(text.getValue(), TextToSpeech.QUEUE_ADD, null, "DEFAULT");
                        if (lineNumberToSpeak > 0)
                            lineNumberToSpeak--;

                    } else {
                        Log.d(TAG, "text data is null");
                    }
                } else {
                    lineNumberToSpeak = 0;
                }
            } else {
                Log.d(TAG, "no text detected");
            }
        }
        return true;
    default:
        return super.dispatchKeyEvent(event);
    }
}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (useVolButtonChangePage) {
        //??/*from w  ww .  ja v a2 s.c om*/
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_UP:
            if (mViewPagerAdapter != null) {
                return true;
            }
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            if (mViewPagerAdapter != null) {
                return true;
            }
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:cx.ring.fragments.CallFragment.java

public void onKeyUp(int keyCode, KeyEvent event) {
    try {//from   w  w  w .j a va  2s  .  co  m

        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:
        case KeyEvent.KEYCODE_VOLUME_UP:
            break;
        default:
            String toSend = Character.toString(event.getDisplayLabel());
            toSend = toSend.toUpperCase(Locale.getDefault());
            Log.d(TAG, "toSend " + toSend);
            mCallbacks.getRemoteService().playDtmf(toSend);
            break;
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
public boolean onKeyLongPress(final int keyCode, final KeyEvent event) {
    boolean result = true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        MPDControl.run(MPDControl.ACTION_NEXT);
        break;//from ww  w  .  j a v a 2 s . c  om
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        MPDControl.run(MPDControl.ACTION_PREVIOUS);
        break;
    default:
        result = super.onKeyLongPress(keyCode, event);
        break;
    }
    return result;
}

From source file:de.spiritcroc.modular_remote.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        return pages.get(viewPager.getCurrentItem()).onKeyUp(keyCode) || super.onKeyDown(keyCode, event);
    }//from w  w w  .  j a va  2  s.  co m

    return super.onKeyUp(keyCode, event);
}

From source file:org.liberty.android.fantastischmemo.ui.QACardActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (option.getVolumeKeyShortcut()) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            return true;
        }/*from w  ww  .j av  a2s. c o  m*/

        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.mobilevue.vod.VideoControllerView.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayer == null) {
        return true;
    }//from  w w  w  .  j a  v a 2  s.  c o  m

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(sDefaultTimeout);
            if (mPauseButton != null) {
                mPauseButton.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayer.isPlaying()) {
            mPlayer.start();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
}

From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java

@Override
public final boolean onKeyUp(final int keyCode, @NonNull final KeyEvent event) {
    boolean result = true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (event.isTracking() && !event.isCanceled() && !mApp.isLocalAudible()) {
            if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                MPDControl.run(MPDControl.ACTION_VOLUME_STEP_UP);
            } else {
                MPDControl.run(MPDControl.ACTION_VOLUME_STEP_DOWN);
            }/*from  w  ww.j a  v a2 s  .c  om*/
        }
        break;
    default:
        result = super.onKeyUp(keyCode, event);
        break;
    }

    return result;
}