|
| 1 | +diff --git a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java |
| 2 | +index 9dba7f2..85a7027 100644 |
| 3 | +--- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java |
| 4 | ++++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java |
| 5 | +@@ -88,6 +88,7 @@ import java.io.FileOutputStream; |
| 6 | + import java.io.IOException; |
| 7 | + import java.io.OutputStreamWriter; |
| 8 | + import java.lang.reflect.Field; |
| 9 | ++import java.lang.reflect.Method; |
| 10 | + import java.util.ArrayList; |
| 11 | + import java.util.Arrays; |
| 12 | + import java.util.HashMap; |
| 13 | +@@ -903,11 +904,28 @@ public class ExtractStyle { |
| 14 | + } |
| 15 | + return json; |
| 16 | + } |
| 17 | ++ |
| 18 | ++ private ContextThemeWrapper getContextThemeWrapper() |
| 19 | ++ { |
| 20 | ++ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) |
| 21 | ++ return new ContextThemeWrapper(m_context, m_theme); |
| 22 | ++ |
| 23 | ++ int themeResId = 0; |
| 24 | ++ try { |
| 25 | ++ Class<?> clazz = ContextThemeWrapper.class; |
| 26 | ++ Method method = clazz.getMethod("getThemeResId"); |
| 27 | ++ method.setAccessible(true); |
| 28 | ++ themeResId = (Integer)method.invoke(m_context); |
| 29 | ++ } catch (Exception e) { |
| 30 | ++ Log.e(QtNative.QtTAG, "Failed to get theme resource ID", e); |
| 31 | ++ } |
| 32 | ++ return new ContextThemeWrapper(m_context, themeResId); |
| 33 | ++ } |
| 34 | + |
| 35 | + private TypedArray obtainStyledAttributes(int styleName, int[] attributes) |
| 36 | + { |
| 37 | + TypedValue typedValue = new TypedValue(); |
| 38 | +- Context ctx = new ContextThemeWrapper(m_context, m_theme); |
| 39 | ++ Context ctx = getContextThemeWrapper(); |
| 40 | + ctx.getTheme().resolveAttribute(styleName, typedValue, true); |
| 41 | + return ctx.obtainStyledAttributes(typedValue.data, attributes); |
| 42 | + } |
| 43 | +@@ -926,7 +944,7 @@ public class ExtractStyle { |
| 44 | + public void extractViewInformation(int styleName, JSONObject json, String qtClassName, AttributeSet attributeSet) { |
| 45 | + try { |
| 46 | + TypedValue typedValue = new TypedValue(); |
| 47 | +- Context ctx = new ContextThemeWrapper(m_context, m_theme); |
| 48 | ++ Context ctx = getContextThemeWrapper(); |
| 49 | + ctx.getTheme().resolveAttribute(styleName, typedValue, true); |
| 50 | + |
| 51 | + int[] attributes = new int[]{ |
| 52 | +@@ -1120,7 +1138,7 @@ public class ExtractStyle { |
| 53 | + |
| 54 | + try { |
| 55 | + TypedValue typedValue = new TypedValue(); |
| 56 | +- Context ctx = new ContextThemeWrapper(m_context, m_theme); |
| 57 | ++ Context ctx = getContextThemeWrapper(); |
| 58 | + ctx.getTheme().resolveAttribute(styleName, typedValue, true); |
| 59 | + |
| 60 | + // Get textAppearance values |
| 61 | +@@ -1391,7 +1409,7 @@ public class ExtractStyle { |
| 62 | + JSONObject json = extractTextAppearanceInformation(styleName, qtClass); |
| 63 | + |
| 64 | + TypedValue typedValue = new TypedValue(); |
| 65 | +- Context ctx = new ContextThemeWrapper(m_context, m_theme); |
| 66 | ++ Context ctx = getContextThemeWrapper(); |
| 67 | + ctx.getTheme().resolveAttribute(styleName, typedValue, true); |
| 68 | + final int[] attributes = new int[]{android.R.attr.button}; |
| 69 | + TypedArray array = ctx.obtainStyledAttributes(typedValue.data, attributes); |
0 commit comments