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>
bb10
Eskil Abrahamsen Blomfeldt 2019-03-18 14:02:26 +01:00
parent 26462f9c4c
commit 12978d4ad0
2 changed files with 16 additions and 3 deletions

View File

@ -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);

View File

@ -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 -->