diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a88949..8dc5a340 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ -#### SNAPSHOT -- Update NDK to 26.1.10909125 -- Update Android Gradle plugin to 8.1.2 +#### 1.2.29 +- 2024-07-10 - [commits](https://github.com/koral--/android-gif-drawable/compare/v1.2.28...v1.2.29) +- Update NDK to 26.3.11579264 +- Use Java 21 for building +- Update Android Gradle plugin to 8.5.0 +- Minimum SDK version increased to 21 - Add binary compatibility check +- Add support 16 KB page sizes for Android 15, fixes [(#846)](https://github. com/koral--/android-gif-drawable/pull/846) #### 1.2.28 - 2023-08-29 - [commits](https://github.com/koral--/android-gif-drawable/compare/v1.2.27...v1.2.28) diff --git a/README.md b/README.md index de5ae75f..5c5bf2e0 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Bundled GIFLib via JNI is used to render frames. This way should be more efficie Insert the following dependency to `build.gradle` file of your project. ```groovy dependencies { - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.28' + implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.29' } ``` Note that Maven central repository should be defined eg. in top-level `build.gradle` like this: diff --git a/android-gif-drawable/src/main/c/CMakeLists.txt b/android-gif-drawable/src/main/c/CMakeLists.txt index 3a61417a..8b5551ca 100644 --- a/android-gif-drawable/src/main/c/CMakeLists.txt +++ b/android-gif-drawable/src/main/c/CMakeLists.txt @@ -24,3 +24,4 @@ list(APPEND LIBS ) target_link_libraries(pl_droidsonroids_gif ${LIBS}) +target_link_options(pl_droidsonroids_gif PRIVATE "-Wl,-z,max-page-size=16384") diff --git a/android-gif-drawable/src/main/c/giflib/dgif_lib.c b/android-gif-drawable/src/main/c/giflib/dgif_lib.c index 9abbff17..614bd1ee 100644 --- a/android-gif-drawable/src/main/c/giflib/dgif_lib.c +++ b/android-gif-drawable/src/main/c/giflib/dgif_lib.c @@ -104,7 +104,9 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error) { } GifFile->Error = 0; - *Error = 0; + if (Error != NULL) { + *Error = 0; + } /* What version of GIF? */ //Private->gif89 = (Buf[GIF_VERSION_POS] == '9'); diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifAnimationMetaData.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifAnimationMetaData.java index ff3575a2..fe6b3aa1 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifAnimationMetaData.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifAnimationMetaData.java @@ -5,7 +5,6 @@ import android.content.res.AssetManager; import android.content.res.Resources; import android.net.Uri; -import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -250,13 +249,9 @@ public long getDrawableAllocationByteCount(@Nullable GifDrawable oldDrawable, @I final int sampleSizeFactor = sampleSize * sampleSize; final long bufferSize; if (oldDrawable != null && !oldDrawable.mBuffer.isRecycled()) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - bufferSize = oldDrawable.mBuffer.getAllocationByteCount(); - } else { - bufferSize = oldDrawable.getFrameByteCount(); - } - } else { - bufferSize = (mWidth * mHeight * 4) / sampleSizeFactor; + bufferSize = oldDrawable.mBuffer.getAllocationByteCount(); + } else { + bufferSize = (mWidth * mHeight * 4L) / sampleSizeFactor; } return (mPixelsBytesCount / sampleSizeFactor) + bufferSize; } diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawable.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawable.java index b3182eca..fd8b77c9 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawable.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifDrawable.java @@ -698,13 +698,7 @@ public int getFrameByteCount() { * @return possible size of the memory needed to store pixels of this object */ public long getAllocationByteCount() { - long byteCount = mNativeInfoHandle.getAllocationByteCount(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - byteCount += mBuffer.getAllocationByteCount(); - } else { - byteCount += getFrameByteCount(); - } - return byteCount; + return mNativeInfoHandle.getAllocationByteCount() + mBuffer.getAllocationByteCount(); } /** @@ -762,7 +756,7 @@ public int getPixel(@IntRange(from = 0) int x, @IntRange(from = 0) int y) { } @Override - protected void onBoundsChange(Rect bounds) { + protected void onBoundsChange(@NonNull Rect bounds) { mDstRect.set(bounds); if (mTransform != null) { mTransform.onBoundsChange(bounds); @@ -889,7 +883,7 @@ public void setTintMode(@Nullable PorterDuff.Mode tintMode) { } @Override - protected boolean onStateChange(int[] stateSet) { + protected boolean onStateChange(@NonNull int[] stateSet) { if (mTint != null && mTintMode != null) { mTintFilter = updateTintFilter(mTint, mTintMode); return true; diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageButton.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageButton.java index f2ff9998..7a679b13 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageButton.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageButton.java @@ -3,9 +3,7 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Parcelable; -import androidx.annotation.RequiresApi; import android.util.AttributeSet; import android.widget.ImageButton; @@ -65,7 +63,6 @@ public GifImageButton(Context context, AttributeSet attrs, int defStyle) { * @param defStyleRes * @see ImageButton#ImageButton(Context, AttributeSet, int, int) */ - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public GifImageButton(Context context, AttributeSet attrs, int defStyle, int defStyleRes) { super(context, attrs, defStyle, defStyleRes); postInit(GifViewUtils.initImageView(this, attrs, defStyle, defStyleRes)); diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageView.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageView.java index 8bf75599..7c6aeb13 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageView.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifImageView.java @@ -3,9 +3,7 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Parcelable; -import androidx.annotation.RequiresApi; import android.util.AttributeSet; import android.widget.ImageView; @@ -65,7 +63,6 @@ public GifImageView(Context context, AttributeSet attrs, int defStyle) { * @param defStyleRes * @see ImageView#ImageView(Context, AttributeSet, int, int) */ - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public GifImageView(Context context, AttributeSet attrs, int defStyle, int defStyleRes) { super(context, attrs, defStyle, defStyleRes); postInit(GifViewUtils.initImageView(this, attrs, defStyle, defStyleRes)); diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java index 83008675..65c7040e 100755 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java @@ -5,11 +5,6 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; - -import androidx.annotation.FloatRange; -import androidx.annotation.IntRange; -import androidx.annotation.RequiresApi; - import android.system.ErrnoException; import android.system.Os; import android.view.Surface; @@ -19,6 +14,9 @@ import java.io.InputStream; import java.nio.ByteBuffer; +import androidx.annotation.FloatRange; +import androidx.annotation.IntRange; + /** * Native library wrapper */ @@ -85,7 +83,6 @@ private static long openFileDescriptor(FileDescriptor fileDescriptor, long offse return openNativeFileDescriptor(nativeFileDescriptor, offset); } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) private static int getNativeFileDescriptor(FileDescriptor fileDescriptor, boolean closeOriginalDescriptor) throws GifIOException, ErrnoException { try { final int nativeFileDescriptor = createTempNativeFileDescriptor(); diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextView.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextView.java index dc8a213c..87a66669 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextView.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextView.java @@ -4,9 +4,7 @@ import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.Parcelable; -import androidx.annotation.RequiresApi; import android.util.AttributeSet; import android.widget.TextView; @@ -70,7 +68,6 @@ public GifTextView(Context context, AttributeSet attrs, int defStyle) { * @param defStyleRes * @see TextView#TextView(Context, AttributeSet, int, int) */ - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public GifTextView(Context context, AttributeSet attrs, int defStyle, int defStyleRes) { super(context, attrs, defStyle, defStyleRes); init(attrs, defStyle, defStyleRes); @@ -143,12 +140,8 @@ private Drawable getGifOrDefaultDrawable(int resId) { // ignored } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return resources.getDrawable(resId, getContext().getTheme()); - } else { - return resources.getDrawable(resId); - } - } + return resources.getDrawable(resId, getContext().getTheme()); + } @Override public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) { diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java index 47f54985..ab92e0c1 100644 --- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java +++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java @@ -6,9 +6,6 @@ import android.graphics.Matrix; import android.graphics.RectF; import android.graphics.SurfaceTexture; -import android.opengl.EGL14; -import android.opengl.GLES20; -import android.os.Build; import android.os.Parcelable; import android.util.AttributeSet; import android.util.TypedValue; @@ -22,13 +19,6 @@ import androidx.annotation.FloatRange; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; - -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; -import javax.microedition.khronos.egl.EGLSurface; /** *
{@link TextureView} which can display animated GIFs. GifTextureView can only be used in a
@@ -84,7 +74,6 @@ public GifTextureView(Context context, AttributeSet attrs, int defStyleAttr) {
init(attrs, defStyleAttr, 0);
}
- @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public GifTextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(attrs, defStyleAttr, defStyleRes);
@@ -142,7 +131,7 @@ public SurfaceTextureListener getSurfaceTextureListener() {
* @param surfaceTexture ignored
*/
@Override
- public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
+ public void setSurfaceTexture(@NonNull SurfaceTexture surfaceTexture) {
throw new UnsupportedOperationException("Changing SurfaceTexture is not supported");
}
@@ -241,7 +230,7 @@ public void run() {
}
@Override
- public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
+ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surface, int width, int height) {
final GifTextureView gifTextureView = mGifTextureViewReference.get();
if (gifTextureView != null) {
gifTextureView.updateTextureViewSize(mGifInfoHandle);
@@ -250,12 +239,12 @@ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int hei
}
@Override
- public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
+ public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surface, int width, int height) {
//no-op
}
@Override
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surface) {
isSurfaceValid.close();
mGifInfoHandle.postUnbindSurface();
interrupt();
@@ -263,7 +252,7 @@ public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
}
@Override
- public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
//no-op
}
@@ -479,6 +468,7 @@ public void setTransform(Matrix transform) {
* @see #setTransform(android.graphics.Matrix)
* @see #setScaleType(ScaleType)
*/
+ @NonNull
@Override
public Matrix getTransform(Matrix transform) {
if (transform == null) {
diff --git a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/PlaceholderDrawingSurfaceTextureListener.java b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/PlaceholderDrawingSurfaceTextureListener.java
index bccd731e..0de31198 100644
--- a/android-gif-drawable/src/main/java/pl/droidsonroids/gif/PlaceholderDrawingSurfaceTextureListener.java
+++ b/android-gif-drawable/src/main/java/pl/droidsonroids/gif/PlaceholderDrawingSurfaceTextureListener.java
@@ -5,6 +5,8 @@
import android.view.Surface;
import android.view.TextureView;
+import androidx.annotation.NonNull;
+
class PlaceholderDrawingSurfaceTextureListener implements TextureView.SurfaceTextureListener {
private final GifTextureView.PlaceholderDrawListener mDrawer;
@@ -13,7 +15,7 @@ class PlaceholderDrawingSurfaceTextureListener implements TextureView.SurfaceTex
}
@Override
- public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
+ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
final Surface surface = new Surface(surfaceTexture);
final Canvas canvas = surface.lockCanvas(null);
mDrawer.onDrawPlaceholder(canvas);
@@ -22,17 +24,17 @@ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
}
@Override
- public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
+ public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
//no-op
}
@Override
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
+ public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
return false;
}
@Override
- public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
+ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surfaceTexture) {
//no-op
}
}
diff --git a/android-gif-drawable/src/test/java/pl/droidsonroids/gif/GifViewUtilsDensityTest.java b/android-gif-drawable/src/test/java/pl/droidsonroids/gif/GifViewUtilsDensityTest.java
index 81046d1b..8fa454c0 100644
--- a/android-gif-drawable/src/test/java/pl/droidsonroids/gif/GifViewUtilsDensityTest.java
+++ b/android-gif-drawable/src/test/java/pl/droidsonroids/gif/GifViewUtilsDensityTest.java
@@ -2,19 +2,15 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
-import androidx.annotation.RequiresApi;
-
import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.util.DisplayMetrics.DENSITY_HIGH;
import static android.util.DisplayMetrics.DENSITY_LOW;
@@ -31,7 +27,6 @@
import static org.mockito.Mockito.when;
import static pl.droidsonroids.gif.GifViewUtils.getDensityScale;
-@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@RunWith(MockitoJUnitRunner.class)
public class GifViewUtilsDensityTest {
@@ -39,14 +34,11 @@ public class GifViewUtilsDensityTest {
Resources resources;
private Resources getMockedResources(final int resourceDensity, final int displayDensity) {
- doAnswer(new Answer