Revert "configure attributes for SkottieView to be initialized from XML layout"
This reverts commit c7950237e0089cb2c37ebf8950726f4af6f32dd1.
Reason for revert: blocking the G3 roll
Original change's description:
> configure attributes for SkottieView to be initialized from XML layout
>
> Change-Id: I9eb1702ed11f23873ffe7fbc60d9f9d885d3073c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301716
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
TBR=djsollen@google.com,stani@google.com,jmbetancourt@google.com
Change-Id: I3be0fd42230d114c8051b01bf39a8726c40fd4ef
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307225
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/platform_tools/android/apps/skottie/skottielib/src/main/java/org/skia/skottie/SkottieView.java b/platform_tools/android/apps/skottie/skottielib/src/main/java/org/skia/skottie/SkottieView.java
index 9ba3255..902861a 100644
--- a/platform_tools/android/apps/skottie/skottielib/src/main/java/org/skia/skottie/SkottieView.java
+++ b/platform_tools/android/apps/skottie/skottielib/src/main/java/org/skia/skottie/SkottieView.java
@@ -8,8 +8,6 @@
package org.skia.skottie;
import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Color;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.SurfaceView;
@@ -20,86 +18,46 @@
import android.widget.FrameLayout;
import java.io.FileNotFoundException;
import java.io.InputStream;
-import org.skia.skottielib.R;
public class SkottieView extends FrameLayout {
private SkottieAnimation mAnimation;
- private View mbackingView;
+ private View backingView;
- private static final int BACKING_VIEW_TEXTURE = 0;
- private static final int BACKING_VIEW_SURFACE = 1;
-
-
- // SkottieView constructor when initialized in XML layout
+ //TODO add and access custom attributes for SkottieView
public SkottieView(Context context, AttributeSet attrs) {
super(context, attrs);
- TypedArray a = context.getTheme()
- .obtainStyledAttributes(attrs, R.styleable.SkottieView, 0, 0);
- try {
- switch (a.getInteger(R.styleable.SkottieView_backing_view, -1)) {
- case BACKING_VIEW_TEXTURE:
- mbackingView = new TextureView(context);
- ((TextureView) mbackingView).setOpaque(false);
- break;
- case BACKING_VIEW_SURFACE:
- mbackingView = new SurfaceView(context);
- int bg = a.getColor(R.styleable.SkottieView_background_color, -1);
- if (bg == -1) {
- throw new RuntimeException("background_color attribute "
- + "needed for SurfaceView");
- }
- if (Color.alpha(bg) != 255) {
- throw new RuntimeException("background_color cannot be transparent");
- }
- break;
- default:
- throw new RuntimeException("backing_view attribute needed to "
- + "specify between texture_view or surface_view");
- }
- } finally {
- a.recycle();
- }
- initBackingView();
}
-
- // SkottieView builder constructor
+
private SkottieView(Context context, SkottieViewBuilder builder) {
- super(context, builder.attrs, builder.defStyleAttr);
+ super(context);
// create the backing view
if (builder.advancedFeatures) {
// backing view must be SurfaceView
- mbackingView = new SurfaceView(context);
+ backingView = new SurfaceView(context, builder.attrs, builder.defStyleAttr);
} else {
- mbackingView = new TextureView(context);
- ((TextureView) mbackingView).setOpaque(false);
+ backingView = new TextureView(context, builder.attrs, builder.defStyleAttr);
+ ((TextureView)backingView).setOpaque(false);
}
- initBackingView();
- }
-
- private void initBackingView() {
- mbackingView.setLayoutParams(new ViewGroup.LayoutParams(
+ backingView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
- addView(mbackingView);
+ addView(backingView);
}
//TODO handle SurfaceView
public void setSource(InputStream inputStream) {
- mAnimation = SkottieRunner.getInstance()
- .createAnimation(((TextureView) mbackingView), inputStream);
+ mAnimation = SkottieRunner.getInstance().createAnimation(((TextureView)backingView), inputStream);
}
public void setSource(int resId) {
- InputStream inputStream = mbackingView.getResources().openRawResource(resId);
- mAnimation = SkottieRunner.getInstance()
- .createAnimation(((TextureView) mbackingView), inputStream);
+ InputStream inputStream = backingView.getResources().openRawResource(resId);
+ mAnimation = SkottieRunner.getInstance().createAnimation(((TextureView)backingView), inputStream);
}
public void setSource(Context context, Uri uri) throws FileNotFoundException {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
- mAnimation = SkottieRunner.getInstance()
- .createAnimation(((TextureView) mbackingView), inputStream);
+ mAnimation = SkottieRunner.getInstance().createAnimation(((TextureView)backingView), inputStream);
}
public SkottieAnimation getSkottieAnimation() {
diff --git a/platform_tools/android/apps/skottie/skottielib/src/main/res/values/attrs.xml b/platform_tools/android/apps/skottie/skottielib/src/main/res/values/attrs.xml
deleted file mode 100644
index f299357..0000000
--- a/platform_tools/android/apps/skottie/skottielib/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <declare-styleable name="SkottieView">
- <attr name="backing_view" format="enum">
- <enum name="texture_view" value="0"/>
- <enum name="surface_view" value="1"/>
- </attr>
- <attr name="background_color" format="color"/>
- </declare-styleable>
-</resources>
\ No newline at end of file
diff --git a/platform_tools/android/apps/skottie/src/main/res/layout/main_layout.xml b/platform_tools/android/apps/skottie/src/main/res/layout/main_layout.xml
index d872017..c2005b5 100644
--- a/platform_tools/android/apps/skottie/src/main/res/layout/main_layout.xml
+++ b/platform_tools/android/apps/skottie/src/main/res/layout/main_layout.xml
@@ -13,8 +13,8 @@
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="center"
- android:columnCount="1">
+ android:columnCount="1"
+ >
</GridLayout>
-
</LinearLayout>