From c9aaa3e2cde5ffe5edaa4f17f84020d82609b7e9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 Mar 2015 11:52:00 +0100 Subject: 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 --- .../qtproject/qt5/android/QtActivityDelegate.java | 25 +++++++++++++++++++++- src/android/templates/AndroidManifest.xml | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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(); @@ -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! --> + + + + -- cgit v1.2.3