summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-03-18 14:02:26 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-03-20 13:57:12 +0000
commit12978d4ad03af753130ba7c40b6203491cd86cd5 (patch)
treeb355d098c9a1926e97aa0c81b1d5bc22f879ec2f
parent26462f9c4c31a691cf98526c4cea23afee79bcc6 (diff)
Android: Support for separate landscape/portrait splash screens
To get appropriate aspect ratios for the splash screen, you usually need separate drawables for the portrait and landscape versions. We support this by adding two new meta data entries that can be used. If they are not available, we will fall back to the generic one, so we are still compatible with existing AndroidManifest.xmls. [ChangeLog][Android] Added entries in the AndroidManifest.xml for specific portrait and landscape splash screens. If one is present for the current orientation, it will be preferred over the generic one. Task-number: QTBUG-74029 Change-Id: I5ffea56320aef85f62f21a59df4d077b4163a65a Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java13
-rw-r--r--src/android/templates/AndroidManifest.xml6
2 files changed, 16 insertions, 3 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 350c6eee96..5fef1eccad 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -744,11 +744,19 @@ public class QtActivityDelegate
}
m_layout = new QtLayout(m_activity, startApplication);
+ int orientation = m_activity.getResources().getConfiguration().orientation;
+
try {
ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), PackageManager.GET_META_DATA);
- if (info.metaData.containsKey("android.app.splash_screen_drawable")) {
+
+ String splashScreenKey = "android.app.splash_screen_drawable_"
+ + (orientation == Configuration.ORIENTATION_LANDSCAPE ? "landscape" : "portrait");
+ if (!info.metaData.containsKey(splashScreenKey))
+ splashScreenKey = "android.app.splash_screen_drawable";
+
+ if (info.metaData.containsKey(splashScreenKey)) {
m_splashScreenSticky = info.metaData.containsKey("android.app.splash_screen_sticky") && info.metaData.getBoolean("android.app.splash_screen_sticky");
- int id = info.metaData.getInt("android.app.splash_screen_drawable");
+ int id = info.metaData.getInt(splashScreenKey);
m_splashScreen = new ImageView(m_activity);
m_splashScreen.setImageDrawable(m_activity.getResources().getDrawable(id));
m_splashScreen.setScaleType(ImageView.ScaleType.FIT_XY);
@@ -768,7 +776,6 @@ public class QtActivityDelegate
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
- int orientation = m_activity.getResources().getConfiguration().orientation;
int rotation = m_activity.getWindowManager().getDefaultDisplay().getRotation();
boolean rot90 = (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270);
boolean currentlyLandscape = (orientation == Configuration.ORIENTATION_LANDSCAPE);
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index cb97002560..b5b26758d9 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -52,6 +52,12 @@
<!-- Messages maps -->
<!-- Splash screen -->
+ <!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
+ then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
+ use hideSplashScreen() with a fade-out animation from Qt Android Extras to hide the splash screen when you
+ are done populating your window with content. -->
+ <!-- meta-data android:name="android.app.splash_screen_drawable_portrait" android:resource="@drawable/logo_portrait" / -->
+ <!-- meta-data android:name="android.app.splash_screen_drawable_landscape" android:resource="@drawable/logo_landscape" / -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->