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.tweetlanes.android.view.BaseLaneActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Early exit on these events so that the volume up/down sound doesn't play
    // TODO: Handle user options for volume scrolling
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        return true;
    }//from w  w  w.  j a v  a  2  s.c  o  m
    return super.onKeyUp(keyCode, event);
}

From source file:com.justwayward.reader.ui.activity.ReadActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        if (mTocListPopupWindow != null && mTocListPopupWindow.isShowing()) {
            mTocListPopupWindow.dismiss();
            gone(mTvBookReadTocTitle);//from w w w. ja  va2  s .  c  o  m
            visible(mTvBookReadReading, mTvBookReadCommunity, mTvBookReadChangeSource);
            return true;
        } else if (isVisible(rlReadAaSet)) {
            gone(rlReadAaSet);
            return true;
        } else if (isVisible(mLlBookReadBottom)) {
            hideReadBar();
            return true;
        } else if (!CollectionsManager.getInstance().isCollected(bookId)) {
            showJoinBookShelfDialog(recommendBooks);
            return true;
        }
        break;
    case KeyEvent.KEYCODE_MENU:
        toggleReadBar();
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            return true;
        }
        break;
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            return true;
        }
        break;
    default:
        break;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.csipsimple.ui.incall.CallActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    Log.d(TAG, "Key up : " + keyCode);
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_CALL:
    case KeyEvent.KEYCODE_SEARCH:
        return true;
    case KeyEvent.KEYCODE_ENDCALL:
        return inCallAnswerControls.onKeyDown(keyCode, event);

    }/*from  w w w.j av  a  2 s. c  o m*/
    return super.onKeyUp(keyCode, event);
}

From source file:com.justwayward.reader.ui.activity.ReadActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            mPageWidget.nextPage();//from   w w  w  .  j  a  v  a2 s  .  c o  m
            return true;// 
        }
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        if (SettingManager.getInstance().isVolumeFlipEnable()) {
            mPageWidget.prePage();
            return true;
        }
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // Early exit on these events so that the volume up/down sound doesn't
    // play// w  ww .j av  a  2 s. co m
    // TODO: Handle user options for volume scrolling
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

From source file:com.google.android.apps.mytracks.TrackDetailActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_M:
        if (trackId == recordingTrackId) {
            // Recording
            insertMarkerAction();/*from   ww  w  .  j a  v a2s  .c  o m*/
        }
        break;
    case KeyEvent.KEYCODE_H:
        if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.scrollLeft();
        }
        break;
    case KeyEvent.KEYCODE_K:
        if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.scrollRight();
        }
        break;
    case KeyEvent.KEYCODE_0:
        if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.showMyLocation();
        }
        break;

    case KeyEvent.KEYCODE_Q:
        tabHost.setCurrentTab(0);
        break;

    case KeyEvent.KEYCODE_SPACE:
        if ((tabHost.getCurrentTab() == 1)
                && PreferencesUtils.getBoolean(this, R.string.settings_mapsprovider, true)) {
            // Use nogago Maps
        } else {
            tabHost.setCurrentTab(tabHost.getCurrentTab() + 1);
        }
        break;

    case KeyEvent.KEYCODE_I:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (tabHost.getCurrentTab() == 0) {
            Toast.makeText(getApplicationContext(), "Cannot zoom in on statistics", Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.zoomIn();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.zoomIn();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case KeyEvent.KEYCODE_O:
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (tabHost.getCurrentTab() == 0) {
            Toast.makeText(getApplicationContext(), "Cannot zoom in on statistics", Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 1) {
            ChartFragment f = (ChartFragment) tabManager.getCurrentFragment();
            f.zoomOut();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        } else if (tabHost.getCurrentTab() == 2) {
            MapFragment f = (MapFragment) tabManager.getCurrentFragment();
            f.zoomOut();
            // Toast.makeText(getApplicationContext(), "Currently at " +
            // f.getClass().toString(), Toast.LENGTH_SHORT).show();
        }
        break;
    case KeyEvent.KEYCODE_P:
        if (recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
            if (recordingTrackPaused) {
                // Paused -> Resume
                Toast.makeText(getApplicationContext(), "Resumed Recording", Toast.LENGTH_LONG).show();
                AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/resume_track");
                updateMenuItems(true, false);
                TrackRecordingServiceConnectionUtils.resumeTrack(trackRecordingServiceConnection);
                trackController.update(true, false);
            } else {
                // Recording -> Paused
                Toast.makeText(getApplicationContext(), "Paused Recording", Toast.LENGTH_LONG).show();
                AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/pause_track");
                updateMenuItems(true, true);
                TrackRecordingServiceConnectionUtils.pauseTrack(trackRecordingServiceConnection);
                trackController.update(true, true);
            }
        } else {
            Toast.makeText(getApplicationContext(), "Cannot pause track that is not recorded.",
                    Toast.LENGTH_LONG).show();
        }
        break;

    case KeyEvent.KEYCODE_S:
        AnalyticsUtils.sendPageViews(TrackDetailActivity.this, "/action/detail/stop_recording");
        updateMenuItems(false, true);
        TrackRecordingServiceConnectionUtils.stopRecording(TrackDetailActivity.this,
                trackRecordingServiceConnection, true);
        break;

    case KeyEvent.KEYCODE_A:
        Intent intent = IntentUtils.newIntent(this, SettingsActivity.class);
        startActivity(intent);
        break;

    }

    return super.onKeyUp(keyCode, event);
}

From source file:net.smartpager.android.activity.MainActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // exclude keyboard appearance on volume change
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_MENU:
        return super.onKeyUp(keyCode, event);
    default://from   www.j  a  va 2s  . c om
        break;
    }

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, 0);

    return super.onKeyUp(keyCode, event);
}

From source file:org.zirco.ui.activities.MainActivity.java

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

    String volumeKeysBehaviour = PreferenceManager.getDefaultSharedPreferences(this)
            .getString(Constants.PREFERENCES_UI_VOLUME_KEYS_BEHAVIOUR, "DEFAULT");

    if (!volumeKeysBehaviour.equals("DEFAULT")) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_VOLUME_DOWN:

            if (volumeKeysBehaviour.equals("SWITCH_TABS")) {
                showPreviousTab(false);/*from w ww .  ja va  2s .  c  o m*/
            } else if (volumeKeysBehaviour.equals("HISTORY")) {
                mCurrentWebView.goForward();
            } else {
                mCurrentWebView.zoomIn();
            }

            return true;
        case KeyEvent.KEYCODE_VOLUME_UP:

            if (volumeKeysBehaviour.equals("SWITCH_TABS")) {
                showNextTab(false);
            } else if (volumeKeysBehaviour.equals("HISTORY")) {
                mCurrentWebView.goBack();
            } else {
                mCurrentWebView.zoomOut();
            }

            return true;
        default:
            return super.onKeyDown(keyCode, event);
        }
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.lybeat.lilyplayer.widget.media.IjkVideoView.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP
            && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE
            && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL
            && keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();//from  w w w  .  j a v a2s .co m
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisibility();
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.xnxs.mediaplayer.widget.media.VRVideoView.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP
            && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE
            && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL
            && keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();//w w w  .  j a va  2s  . co  m
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisiblity();
        }
    }
    return super.onKeyDown(keyCode, event);
}