Default to no style extraction on Android P when the target SDK is < 28
Applications with target SDK version lower then 28 running on a device with version greater or equal to 28 will cause compatibility warnings, so default to none when the extract_android_style value is set to default. Note that the new value "default" was introduced to allow this kind of changes in the future, i.e., selecting the best solution based on some simple heuristics. Adding a new value also keep compatibility and allows the user to explicitly set a value when needed. Task-number: QTBUG-69810 Change-Id: I68301716767870ce6de40e45742d9c5fc263ee25 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
1170e707b7
commit
52813712c4
@ -46,6 +46,7 @@ import android.content.ServiceConnection;
|
||||
import android.content.pm.ComponentInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@ -651,15 +652,26 @@ public abstract class QtLoader {
|
||||
String themePath = m_context.getApplicationInfo().dataDir + "/qt-reserved-files/android-style/";
|
||||
String stylePath = themePath + m_displayDensity + "/";
|
||||
|
||||
String extractOption = "full";
|
||||
String extractOption = "default";
|
||||
if (m_contextInfo.metaData.containsKey("android.app.extract_android_style")) {
|
||||
extractOption = m_contextInfo.metaData.getString("android.app.extract_android_style");
|
||||
if (!extractOption.equals("full") && !extractOption.equals("minimal") && !extractOption.equals("none")) {
|
||||
Log.e(QtApplication.QtTAG, "Invalid extract_android_style option \"" + extractOption + "\", defaulting to full");
|
||||
extractOption = "full";
|
||||
if (!extractOption.equals("default") && !extractOption.equals("full") && !extractOption.equals("minimal") && !extractOption.equals("none")) {
|
||||
Log.e(QtApplication.QtTAG, "Invalid extract_android_style option \"" + extractOption + "\", defaulting to \"default\"");
|
||||
extractOption = "default";
|
||||
}
|
||||
}
|
||||
|
||||
// QTBUG-69810: The extraction code will trigger compatibility warnings on Android SDK version >= 28
|
||||
// when the target SDK version is set to something lower then 28, so default to "none" and issue a warning
|
||||
// if that is the case.
|
||||
if (extractOption.equals("default")) {
|
||||
final int targetSdkVersion = m_context.getApplicationInfo().targetSdkVersion;
|
||||
if (targetSdkVersion < 28 && Build.VERSION.SDK_INT >= 28) {
|
||||
Log.e(QtApplication.QtTAG, "extract_android_style option set to \"none\" when targetSdkVersion is less then 28");
|
||||
extractOption = "none";
|
||||
}
|
||||
}
|
||||
|
||||
if (!(new File(stylePath)).exists() && !extractOption.equals("none")) {
|
||||
loaderParams.putString(EXTRACT_STYLE_KEY, stylePath);
|
||||
loaderParams.putBoolean(EXTRACT_STYLE_MINIMAL_KEY, extractOption.equals("minimal"));
|
||||
|
@ -57,11 +57,12 @@
|
||||
|
||||
<!-- extract android style -->
|
||||
<!-- available android:values :
|
||||
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
|
||||
* full - useful QWidget & Quick Controls 1 apps
|
||||
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
|
||||
* none - useful for apps that don't use any of the above Qt modules
|
||||
-->
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
|
||||
<!-- extract android style -->
|
||||
</activity>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user