summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Zachmann <t.zachmann@zagge.de>2014-01-01 08:13:02 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-11 22:13:19 +0100
commit055591750aaccab9e764eb7348968d9716dd4f47 (patch)
treed467d839b3b6bbaccdfe9b5d99adf7d58fc41216
parent459ad9e018071cdf613d3deb70ea4d96178ca683 (diff)
downloadqtbase-055591750aaccab9e764eb7348968d9716dd4f47.tar.gz
qtbase-055591750aaccab9e764eb7348968d9716dd4f47.tar.bz2
qtbase-055591750aaccab9e764eb7348968d9716dd4f47.zip
Fix Use android theme when defined
It is possible to define the theme to use for android in the AndroidManifest.xml. If it is defined in the activity qt itself should not overwrite it. The change uses the defined style in case it is given in the AndroidManifest.xml. This seems to fix also QTBUG-35151. Task-number: QTBUG-35050 Change-Id: I8b55c02ca1ecd7baa5f2f9460d154095aacf015f Reviewed-by: BogDan Vatra <bogdan@kde.org>
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
index 6762717d91..b2f92c04e9 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
@@ -34,6 +34,7 @@ import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.DataOutputStream;
import java.io.DataInputStream;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
@@ -816,6 +817,21 @@ public class QtActivity extends Activity
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
+
+ try {
+ m_activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
+ for (Field f : Class.forName("android.R$style").getDeclaredFields()) {
+ if (f.getInt(null) == m_activityInfo.getThemeResource()) {
+ QT_ANDROID_THEMES = new String[] {f.getName()};
+ QT_ANDROID_DEFAULT_THEME = f.getName();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ finish();
+ return;
+ }
+
try {
setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null));
} catch (Exception e) {
@@ -840,14 +856,6 @@ public class QtActivity extends Activity
ENVIRONMENT_VARIABLES += "\tQT_ANDROID_THEME=" + QT_ANDROID_DEFAULT_THEME
+ "/\tQT_ANDROID_THEME_DISPLAY_DPI=" + getResources().getDisplayMetrics().densityDpi + "\t";
- try {
- m_activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- finish();
- return;
- }
-
if (null == getLastNonConfigurationInstance()) {
// if splash screen is defined, then show it
if (m_activityInfo.metaData.containsKey("android.app.splash_screen") )