diff options
author | BogDan Vatra <bogdan@kdab.com> | 2016-03-17 17:52:34 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2016-03-22 09:14:14 +0000 |
commit | a3269e18012129bab69d9744147f48025f42ddf1 (patch) | |
tree | 6ed2c8b0926c0b2036a0cbaecdb81d808d4d2f18 /src | |
parent | e4d79e1fdeb6b26ba0b12b578daacf7cd672b960 (diff) |
Allow the user to choose how much from Android theme is extracted
This way Quick Controls 2 users will have a much faster start up and the
extraction time is reduced x10.
[ChangeLog][Android] Allow the user to choose how much from Android
theme is extracted.
Change-Id: I063086251880d50d7fdd72ee35536c4094b47f74
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src')
4 files changed, 34 insertions, 7 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java index 3fcc5b8516..46a443c365 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java @@ -270,6 +270,7 @@ public class ExtractStyle { Context m_context; final int defaultBackgroundColor; final int defaultTextColor; + final boolean m_minimal; class SimpleJsonWriter { @@ -984,7 +985,7 @@ public class ExtractStyle { public JSONObject getDrawable(Object drawable, String filename, Rect padding) { - if (drawable == null) + if (drawable == null || m_minimal) return null; DrawableCache dc = m_drawableCache.get(filename); @@ -1986,9 +1987,10 @@ public class ExtractStyle { return json; } - public ExtractStyle(Context context, String extractPath) + public ExtractStyle(Context context, String extractPath, boolean minimal) { // Log.i(MinistroService.TAG, "Extract " + extractPath); + m_minimal = minimal; m_extractPath = extractPath + "/"; new File(m_extractPath).mkdirs(); // MinistroActivity.nativeChmode(m_extractPath, 0755); 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 61a824e749..ac471bf126 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -113,6 +113,7 @@ public class QtActivityDelegate private static final String STATIC_INIT_CLASSES_KEY = "static.init.classes"; private static final String NECESSITAS_API_LEVEL_KEY = "necessitas.api.level"; private static final String EXTRACT_STYLE_KEY = "extract.android.style"; + private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option"; private static String m_environmentVariables = null; private static String m_applicationParameters = null; @@ -509,7 +510,8 @@ public class QtActivityDelegate if (loaderParams.containsKey(EXTRACT_STYLE_KEY)) { String path = loaderParams.getString(EXTRACT_STYLE_KEY); - new ExtractStyle(m_activity, path); + new ExtractStyle(m_activity, path, loaderParams.containsKey(EXTRACT_STYLE_MINIMAL_KEY) && + loaderParams.getBoolean(EXTRACT_STYLE_MINIMAL_KEY)); } try { diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java index 0963220b0d..3efdbf7a7c 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java @@ -90,6 +90,7 @@ public abstract class QtLoader { public static final String STATIC_INIT_CLASSES_KEY = "static.init.classes"; public static final String NECESSITAS_API_LEVEL_KEY = "necessitas.api.level"; public static final String EXTRACT_STYLE_KEY = "extract.android.style"; + private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option"; /// Ministro server parameter keys public static final String REQUIRED_MODULES_KEY = "required.modules"; @@ -111,12 +112,11 @@ public abstract class QtLoader { // and must be separated with "\t" // e.g "-param1\t-param2=value2\t-param3\tvalue3" - public String ENVIRONMENT_VARIABLES = "QT_USE_ANDROID_NATIVE_STYLE=1\tQT_USE_ANDROID_NATIVE_DIALOGS=1\t"; + public String ENVIRONMENT_VARIABLES = "QT_USE_ANDROID_NATIVE_DIALOGS=1"; // use this variable to add any environment variables to your application. // the env vars must be separated with "\t" // e.g. "ENV_VAR1=1\tENV_VAR2=2\t" // Currently the following vars are used by the android plugin: - // * QT_USE_ANDROID_NATIVE_STYLE - 1 to use the android widget style if available. // * QT_USE_ANDROID_NATIVE_DIALOGS -1 to use the android native dialogs. public String[] QT_ANDROID_THEMES = null; // A list with all themes that your application want to use. @@ -593,8 +593,22 @@ public abstract class QtLoader { String themePath = m_context.getApplicationInfo().dataDir + "/qt-reserved-files/android-style/"; String stylePath = themePath + m_displayDensity + "/"; - if (!(new File(stylePath)).exists()) + + String extractOption = "full"; + 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 (!(new File(stylePath)).exists() && !extractOption.equals("none")) { loaderParams.putString(EXTRACT_STYLE_KEY, stylePath); + loaderParams.putBoolean(EXTRACT_STYLE_MINIMAL_KEY, extractOption.equals("minimal")); + if (extractOption.equals("full")) + ENVIRONMENT_VARIABLES += "\tQT_USE_ANDROID_NATIVE_STYLE=1"; + } ENVIRONMENT_VARIABLES += "\tMINISTRO_ANDROID_STYLE_PATH=" + stylePath + "\tQT_ANDROID_THEMES_ROOT_PATH=" + themePath; diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml index 22c3ea7578..808cc82ae9 100644 --- a/src/android/templates/AndroidManifest.xml +++ b/src/android/templates/AndroidManifest.xml @@ -52,7 +52,16 @@ <!-- auto screen scale factor --> <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/> <!-- auto screen scale factor --> - </activity> + + <!-- extract android style --> + <!-- available android:values : + * 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"/> + <!-- extract android style --> + </activity> <!--service android:process=":qt" android:name="org.qtproject.qt5.android.bindings.QtService"--> <!-- android:process=":qt" is needed to force the service to run on a separate process than the Activity --> |