Android: Extract default style
Task-number: QTBUG-40621 Change-Id: I4569c87c79769752373a9e6e12cb64c89dfc8f94 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
This commit is contained in:
parent
c6df5fe3ed
commit
4decaa566c
@ -1792,6 +1792,23 @@ public class ExtractStyle {
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject extractDefaultPalette()
|
||||
{
|
||||
TypedArray array = m_theme.obtainStyledAttributes(new int[]{
|
||||
android.R.attr.textAppearance
|
||||
});
|
||||
int pos = 0;
|
||||
JSONObject json = extractTextAppearance(array.getResourceId(pos++, -1));
|
||||
try {
|
||||
json.put("defaultBackgroundColor", defaultBackgroundColor);
|
||||
json.put("defaultTextColorPrimary", defaultTextColor);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
array.recycle();
|
||||
return json;
|
||||
}
|
||||
|
||||
public ExtractStyle(Context context, String extractPath)
|
||||
{
|
||||
// Log.i(MinistroService.TAG, "Extract " + extractPath);
|
||||
@ -1803,9 +1820,13 @@ public class ExtractStyle {
|
||||
TypedArray array = m_theme.obtainStyledAttributes(new int[]{
|
||||
android.R.attr.colorBackground,
|
||||
android.R.attr.textColorPrimary,
|
||||
android.R.attr.textColor
|
||||
});
|
||||
defaultBackgroundColor = array.getColor(0, 0);
|
||||
defaultTextColor = array.getColor(1, 0xFFFFFF);
|
||||
int textColor = array.getColor(1, 0xFFFFFF);
|
||||
if (textColor == 0xFFFFFF)
|
||||
textColor = array.getColor(2, 0xFFFFFF);
|
||||
defaultTextColor = textColor;
|
||||
array.recycle();
|
||||
|
||||
try
|
||||
@ -1813,6 +1834,7 @@ public class ExtractStyle {
|
||||
SimpleJsonWriter jsonWriter = new SimpleJsonWriter(m_extractPath+"style.json");
|
||||
jsonWriter.beginObject();
|
||||
try {
|
||||
jsonWriter.name("defaultStyle").value(extractDefaultPalette());
|
||||
extractWindow(jsonWriter, "windowStyle");
|
||||
jsonWriter.name("buttonStyle").value(extractTextAppearanceInformations("buttonStyle", "QPushButton", null, -1));
|
||||
jsonWriter.name("spinnerStyle").value(extractTextAppearanceInformations("spinnerStyle", "QComboBox", null, -1));
|
||||
|
Loading…
Reference in New Issue
Block a user