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 7574 006f7a09ea1c
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
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Aug 04 09:37:27 2013 -0700
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Aug 04 23:28:34 2013 +0200
@@ -134,6 +134,16 @@
         }
     }
 
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        int keyCode = event.getKeyCode();
+        // Ignore volume keys so they're handled by Android
+        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
+            keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+            return false;
+        }
+        return super.dispatchKeyEvent(event);
+    }
 
     /** Called by onPause or surfaceDestroyed. Even if surfaceDestroyed
      *  is the first to be called, mIsSurfaceReady should still be set
@@ -726,12 +736,6 @@
     // Key events
     @Override
     public boolean onKey(View  v, int keyCode, KeyEvent event) {
-
-        // Ignore volume keys so they're handled by Android
-        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
-            keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
-            return false;
-        }
         
         if (event.getAction() == KeyEvent.ACTION_DOWN) {
             //Log.v("SDL", "key down: " + keyCode);