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.google.android.marvin.mytalkback.ProcessorVolumeStream.java

private void adjustVolumeFromKeyEvent(int keyCode) {
    final int direction = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE
            : AudioManager.ADJUST_LOWER);

    if (mTouchingScreen) {
        mAudioManager.adjustStreamVolume(STREAM_TOUCHING_SCREEN, direction, DEFAULT_FLAGS);
    } else {/*from  w  ww . j av a2 s  . co  m*/
        // Attempt to adjust the suggested stream, but let the system
        // override in special situations like during voice calls, when an
        // application has locked the volume control stream, or when music
        // is playing.
        mAudioManager.adjustSuggestedStreamVolume(direction, STREAM_DEFAULT, DEFAULT_FLAGS);
    }
}

From source file:com.google.android.marvin.talkback.ProcessorVolumeStream.java

private boolean attemptEditTextNavigation(int keyCode) {
    AccessibilityNodeInfoCompat currentNode = mCursorController.getCursor();
    try {//from   w  ww . j  a  v  a2s .c  o  m
        if ((currentNode == null) || !AccessibilityNodeInfoUtils.nodeMatchesClassByType(mContext, currentNode,
                android.widget.EditText.class)) {
            return false;
        }

        final CursorGranularity currentGranularity = mCursorController.getGranularityAt(currentNode);
        if (currentGranularity == CursorGranularity.DEFAULT) {
            mCursorController.setGranularity(CursorGranularity.CHARACTER, false /* fromUser */);
        }

        boolean result = false;
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            result = mCursorController.next(false /* shouldWrap */, false /* shouldScroll */);
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            result = mCursorController.previous(false /* shouldWarp */, false /* shouldScroll */);
        }

        if (!result) {
            mFeedbackController.playAuditory(R.id.sounds_complete);
        }

        // Consume the key event, even if navigation in the EditText failed
        return true;
    } finally {
        AccessibilityNodeInfoUtils.recycleNodes(currentNode);
    }
}

From source file:net.reichholf.dreamdroid.fragment.helper.DreamDroidHttpFragmentHelper.java

public boolean onKeyUp(int keyCode, KeyEvent event) {
    return keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || false;
}

From source file:com.dena.app.usage.watcher.MainActivity.java

public boolean onKeyDown(int keyCode, KeyEvent evt) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                AudioManager.FLAG_SHOW_UI);
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                AudioManager.FLAG_SHOW_UI);
        return true;
    default:// ww w .  j a v  a  2 s.  c  o m
        break;
    }
    return super.onKeyDown(keyCode, evt);
}

From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        setResult(RESULT_CANCELED);//from w w w.j av a2s. co m
        finish();
        break;
    case KeyEvent.KEYCODE_FOCUS:
    case KeyEvent.KEYCODE_CAMERA:
        // Handle these events so they don't launch the Camera app
        return true;
    // Use volume up/down to turn on light
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        cameraManager.setTorch(false);
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        cameraManager.setTorch(true);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.apache.cordova.App.java

/**
 * Override the default behavior of the Android volume buttons.
 * If overridden, when the volume button is pressed, the "volume[up|down]button" JavaScript event will be fired.
 *
 * @param button        volumeup, volumedown
 * @param override      T=override, F=cancel override
 *///from ww  w  .ja va  2  s  .com
public void overrideButton(String button, boolean override) {
    LOG.i("App",
            "WARNING: Volume Button Default Behavior will be overridden.  The volume event will be fired!");
    if (button.equals("volumeup")) {
        webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, override);
    } else if (button.equals("volumedown")) {
        webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, override);
    }
}

From source file:org.chromium.chrome.browser.media.remote.ExpandedControllerActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if ((keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_UP)
            || mVideoInfo.state == PlayerState.FINISHED) {
        return super.dispatchKeyEvent(event);
    }//from  w  w  w  . j  ava 2s  .  c  o m

    return handleVolumeKeyEvent(mMediaRouteController, event);
}

From source file:com.philips.castdemo.videobrowser.VideoBrowser.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (mCastManager.isConnected()) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            changeVolume(CastApplication.VOLUME_INCREMENT);
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            changeVolume(-CastApplication.VOLUME_INCREMENT);
        } else {/*  w  w w  . j  a v a  2 s  . co  m*/
            // we don't want to consume non-volume key events
            return super.onKeyDown(keyCode, event);
        }
        if (mCastManager.getPlaybackStatus() == MediaStatus.PLAYER_STATE_PLAYING) {
            return super.onKeyDown(keyCode, event);
        } else {
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:net.reichholf.dreamdroid.abstivities.AbstractHttpActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        onButtonClicked(Remote.KEY_VOLP, false);
        return true;

    case KeyEvent.KEYCODE_VOLUME_DOWN:
        onButtonClicked(Remote.KEY_VOLM, false);
        return true;
    }//from  w ww .j ava  2 s  .  c  om

    return super.onKeyDown(keyCode, event);
}

From source file:com.google.android.marvin.talkback.ProcessorVolumeStream.java

private void adjustVolumeFromKeyEvent(int keyCode) {
    final int direction = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE
            : AudioManager.ADJUST_LOWER);

    if (mTouchingScreen) {
        mAudioManager.adjustStreamVolume(STREAM_TOUCHING_SCREEN, direction, DEFAULT_FLAGS_TOUCHING_SCREEN);
    } else {//from ww w . ja v a2 s . c  o  m
        // Attempt to adjust the suggested stream, but let the system
        // override in special situations like during voice calls, when an
        // application has locked the volume control stream, or when music
        // is playing.
        mAudioManager.adjustSuggestedStreamVolume(direction, STREAM_DEFAULT, DEFAULT_FLAGS_NOT_TOUCHING_SCREEN);
    }
}