From c9241a1a7baaef1fb5f61f28eea32ae75210e07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Wed, 2 Apr 2014 13:50:27 +0200 Subject: [PATCH] Android: Don't accept the volume-key events. On Android the volume keys are by default connected to the global volume control and by accepting them we remove this feature. Meaning each application would need to re-implement this functionality. Ideally we should only accept the volume keys if they where accepted by the user to avoid overriding default behavior, but we currently don't have the infrastructure to do that. To revert back to the old behavior the env. variable QT_ANDROID_VOLUME_KEYS can be set. Task-number: QTBUG-36570 Change-Id: Ib053a40383f2de452f385b19f7795c2fc23fc4fe Reviewed-by: Paul Olav Tvete --- .../qtproject/qt5/android/QtActivityDelegate.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index e62b5dab82..b396dfdfa1 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -75,6 +75,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Method; +import java.lang.System; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -806,6 +807,13 @@ public class QtActivityDelegate c = composed; } + if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP + || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN + || keyCode == KeyEvent.KEYCODE_MUTE) + && System.getenv("QT_ANDROID_VOLUME_KEYS") == null) { + return false; + } + m_lastChar = lc; if (keyCode == KeyEvent.KEYCODE_BACK) { m_backKeyPressedSent = !m_keyboardIsVisible; @@ -831,6 +839,13 @@ public class QtActivityDelegate } } + if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP + || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN + || keyCode == KeyEvent.KEYCODE_MUTE) + && System.getenv("QT_ANDROID_VOLUME_KEYS") == null) { + return false; + } + if (keyCode == KeyEvent.KEYCODE_BACK && !m_backKeyPressedSent) { hideSoftwareKeyboard(); setKeyboardVisibility(false, System.nanoTime());