summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-05-30 20:27:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-03 09:18:11 +0200
commitdf1ba3594b4b536b16078da935e585b795ed8817 (patch)
treefeb463e794742d68ec1860a2e42ab6a7d1c5b148 /src/android/jar
parente437d5ff4b02b00e18e94930fe9d02547511ccb2 (diff)
Android: add support for extracting AnimationDrawable
Required for implementing indeterminate ProgressBar Task-number: QTBUG-39215 Change-Id: I128eaf2879dd493da86541767a870ea786a5ddf9 Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java26
1 files changed, 26 insertions, 0 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 cd67c95264..3e98d4ec32 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/ExtractStyle.java
@@ -66,6 +66,7 @@ import android.graphics.NinePatch;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ColorDrawable;
@@ -654,6 +655,27 @@ public class ExtractStyle {
return json;
}
+ private JSONObject getAnimationDrawable(AnimationDrawable drawable, String filename) {
+ JSONObject json = new JSONObject();
+ try {
+ json.put("type", "animation");
+ json.put("oneshot", drawable.isOneShot());
+ final int count = drawable.getNumberOfFrames();
+ JSONArray frames = new JSONArray();
+ for (int i = 0; i < count; ++i)
+ {
+ JSONObject frame = new JSONObject();
+ frame.put("duration", drawable.getDuration(i));
+ frame.put("drawable", getDrawable(drawable.getFrame(i), filename+"__"+i));
+ frames.put(frame);
+ }
+ json.put("frames", frames);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return json;
+ }
+
private JSONObject getJsonRect(Rect rect) throws JSONException
{
JSONObject jsonRect = new JSONObject();
@@ -743,6 +765,10 @@ public class ExtractStyle {
{
return getRotateDrawable((RotateDrawable) drawable, filename);
}
+ if (drawable instanceof AnimationDrawable)
+ {
+ return getAnimationDrawable((AnimationDrawable) drawable, filename);
+ }
if (drawable instanceof ClipDrawable)
{
try {