summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-03-11 11:52:00 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-03-12 13:14:24 +0000
commitc9aaa3e2cde5ffe5edaa4f17f84020d82609b7e9 (patch)
treecc1c8f188ca0f27d8db4e5644bac0da8e1453e12
parent4add7d236bbc3088a384f76de3a3df4668f8594b (diff)
Android: Don't show translucent system UI on top of Qt
On devices by some vendors (Android 4.4+), the default UI theme will have translucent system UI which is placed on top of the main activity layout. When this is unexpected, it may lead to the system UI overlapping with the application's UI on these devices. By default we tell Android to account for the system UI in the main activity's layout, so that the window contents are positioned outside of it. This is done with a new outermost layout which is just used to size the QtLayout correctly. Since there is a use case where people explicitly want translucency on the system UI and have adapted its contents to accommodate for this, we supply the android.app.allow_overlapping_system_ui setting which can be set to true in the AndroidManifest.xml to override the default behavior. [ChangeLog][Android] On devices with translucent system UI, Qt's window is now positioned to avoid overlap with this by default. This behavior can be overridden in the application's AndroidManifest.xml. Change-Id: I2b34e948f3bd655f883f30b0419d9c6ba69242be Task-number: QTBUG-38700 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java25
-rw-r--r--src/android/templates/AndroidManifest.xml4
2 files changed, 28 insertions, 1 deletions
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 93d7baabdb..c7355c1530 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -65,6 +65,7 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
+import android.widget.LinearLayout;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@@ -788,7 +789,29 @@ public class QtActivityDelegate
0, 0,
metrics.xdpi, metrics.ydpi, metrics.scaledDensity);
}
+
+ ViewGroup layout = null;
m_layout = new QtLayout(m_activity);
+ if (Build.VERSION.SDK_INT >= 14) {
+ try {
+ ActivityInfo activityInfo = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(),
+ PackageManager.GET_META_DATA);
+ if (activityInfo.metaData == null
+ || !activityInfo.metaData.containsKey("android.app.allow_overlapping_system_ui")
+ || !activityInfo.metaData.getBoolean("android.app.allow_overlapping_system_ui")) {
+ layout = new LinearLayout(m_activity);
+ layout.setFitsSystemWindows(true);
+ layout.addView(m_layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (layout == null)
+ layout = m_layout;
+
m_editText = new QtEditText(m_activity, this);
m_imm = (InputMethodManager)m_activity.getSystemService(Context.INPUT_METHOD_SERVICE);
m_surfaces = new HashMap<Integer, QtSurface>();
@@ -811,7 +834,7 @@ public class QtActivityDelegate
Log.w("Qt A11y", "Unknown exception: " + e.toString());
}
- m_activity.setContentView(m_layout,
+ m_activity.setContentView(layout,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index 60c612976f..779612cdaf 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -44,6 +44,10 @@
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
+
+ <!-- Show translucent UI on top of Qt's surface when system theme mandates it -->
+ <meta-data android:name="android.app.allow_overlapping_system_ui" android:value="false"/>
+ <!-- Show translucent UI on top of Qt's surface when system theme mandates it -->
</activity>
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/>