Fixed volume keys not being handled by Android if screen keyboard is visible.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 04 Aug 2013 23:28:34 +0200
changeset 7574006f7a09ea1c
parent 7573 b76d8bfe9a2f
child 7575 930f21eaacd7
Fixed volume keys not being handled by Android if screen keyboard is visible.
See bug #1569.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Aug 04 09:37:27 2013 -0700
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Aug 04 23:28:34 2013 +0200
     1.3 @@ -134,6 +134,16 @@
     1.4          }
     1.5      }
     1.6  
     1.7 +    @Override
     1.8 +    public boolean dispatchKeyEvent(KeyEvent event) {
     1.9 +        int keyCode = event.getKeyCode();
    1.10 +        // Ignore volume keys so they're handled by Android
    1.11 +        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
    1.12 +            keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
    1.13 +            return false;
    1.14 +        }
    1.15 +        return super.dispatchKeyEvent(event);
    1.16 +    }
    1.17  
    1.18      /** Called by onPause or surfaceDestroyed. Even if surfaceDestroyed
    1.19       *  is the first to be called, mIsSurfaceReady should still be set
    1.20 @@ -726,12 +736,6 @@
    1.21      // Key events
    1.22      @Override
    1.23      public boolean onKey(View  v, int keyCode, KeyEvent event) {
    1.24 -
    1.25 -        // Ignore volume keys so they're handled by Android
    1.26 -        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
    1.27 -            keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
    1.28 -            return false;
    1.29 -        }
    1.30          
    1.31          if (event.getAction() == KeyEvent.ACTION_DOWN) {
    1.32              //Log.v("SDL", "key down: " + keyCode);