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() { - @Override - public TypedValue answer(InvocationOnMock invocation) throws Throwable { - final TypedValue outValue = invocation.getArgument(1); - outValue.density = resourceDensity; - return outValue; - } - }).when(resources).getValue(anyInt(), any(TypedValue.class), anyBoolean()); + doAnswer((Answer) invocation -> { + final TypedValue outValue = invocation.getArgument(1); + outValue.density = resourceDensity; + return outValue; + }).when(resources).getValue(anyInt(), any(TypedValue.class), anyBoolean()); final DisplayMetrics displayMetrics = new DisplayMetrics(); displayMetrics.densityDpi = displayDensity; @@ -55,7 +47,7 @@ public TypedValue answer(InvocationOnMock invocation) throws Throwable { } @Test - public void testHighResourceDensities() throws Exception { + public void testHighResourceDensities() { assertThat(getDensityScale(getMockedResources(DENSITY_HIGH, DENSITY_HIGH), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(DENSITY_HIGH, DENSITY_LOW), 0)).isEqualTo(0.5f); assertThat(getDensityScale(getMockedResources(DENSITY_HIGH, DENSITY_MEDIUM), 0)).isEqualTo(2f / 3); @@ -66,12 +58,12 @@ public void testHighResourceDensities() throws Exception { } @Test - public void testLowHighDensity() throws Exception { + public void testLowHighDensity() { assertThat(getDensityScale(getMockedResources(DENSITY_LOW, DENSITY_HIGH), 0)).isEqualTo(2); } @Test - public void testNoneResourceDensities() throws Exception { + public void testNoneResourceDensities() { assertThat(getDensityScale(getMockedResources(TypedValue.DENSITY_NONE, DENSITY_LOW), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(TypedValue.DENSITY_NONE, DENSITY_MEDIUM), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(TypedValue.DENSITY_NONE, DENSITY_DEFAULT), 0)).isEqualTo(1); @@ -82,7 +74,7 @@ public void testNoneResourceDensities() throws Exception { } @Test - public void testNoneDisplayDensities() throws Exception { + public void testNoneDisplayDensities() { assertThat(getDensityScale(getMockedResources(DENSITY_LOW, Bitmap.DENSITY_NONE), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(DENSITY_MEDIUM, Bitmap.DENSITY_NONE), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(TypedValue.DENSITY_DEFAULT, Bitmap.DENSITY_NONE), 0)).isEqualTo(1); @@ -91,7 +83,7 @@ public void testNoneDisplayDensities() throws Exception { } @Test - public void testInvalidDensities() throws Exception { + public void testInvalidDensities() { assertThat(getDensityScale(getMockedResources(DENSITY_HIGH, -1), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(-1, DENSITY_HIGH), 0)).isEqualTo(1); assertThat(getDensityScale(getMockedResources(-1, -1), 0)).isEqualTo(1); diff --git a/build.gradle b/build.gradle index 7315bcc3..fbce5fa6 100644 --- a/build.gradle +++ b/build.gradle @@ -2,23 +2,23 @@ buildscript { ext { versions = [ compileSdk : 34, - targetSdk : 33, - minSdk : 17, - ndk : '26.1.10909125', - androidxAppcompat : '1.6.1', - lifecycle : '2.6.2', + targetSdk : 34, + minSdk : 21, + ndk : '26.3.11579264', + androidxAppcompat : '1.7.0', + lifecycle : '2.8.3', androidxAnnotations: '1.6.0', - androidxTest : '1.5.0', - androidxTestRunner : '1.5.2', - coroutines : '1.7.3', - leakCanary : '2.12', - kotlin : '1.9.10', + androidxTest : '1.6.1', + androidxTestRunner : '1.6.1', + coroutines : '1.8.1', + leakCanary : '2.14', + kotlin : '2.0.0', intellijAnnotations: '13.0', - material : '1.10.0', - androidXextJunit : '1.1.5', - androidGradlePlugin: '8.1.2', + material : '1.12.0', + androidXextJunit : '1.2.1', + androidGradlePlugin: '8.5.0', junit : '4.13.2', - mockito : '5.6.0', + mockito : '5.12.0', robolectric : '4.10.3', assertj3 : '3.24.2', assertj1 : '1.7.1', @@ -26,7 +26,7 @@ buildscript { openglApi : 'gl1.1-android-2.1_r1', mockwebserver : '4.9.2', relinker : '1.4.5', - mavenPublishPlugin : '0.21.0', + mavenPublishPlugin : '0.29.0', ] } repositories { @@ -42,7 +42,7 @@ buildscript { } plugins { - id 'org.jetbrains.kotlinx.binary-compatibility-validator' version '0.13.2' + id 'org.jetbrains.kotlinx.binary-compatibility-validator' version '0.15.1' } subprojects { diff --git a/gradle.properties b/gradle.properties index 86d9ab84..e4e69571 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ RELEASE_SIGNING_ENABLED=true GROUP=pl.droidsonroids.gif POM_ARTIFACT_ID=android-gif-drawable -VERSION_NAME=1.2.28 +VERSION_NAME=1.2.29 POM_NAME=android-gif-drawable POM_DESCRIPTION=Views and Drawable for displaying animated GIFs for Android diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..b740cf13 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f..25da30db 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/sample/build.gradle b/sample/build.gradle index 0472ce47..ab4bc2e5 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -33,10 +33,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } packagingOptions { jniLibs { useLegacyPackaging true @@ -48,6 +44,10 @@ android { } } +kotlin { + jvmToolchain(21) +} + dependencies { compileOnly "org.jetbrains:annotations:$versions.intellijAnnotations" debugImplementation "com.squareup.leakcanary:leakcanary-android:$versions.leakCanary" diff --git a/sample/src/main/java/pl/droidsonroids/gif/sample/TexturePlaceholderFragment.kt b/sample/src/main/java/pl/droidsonroids/gif/sample/TexturePlaceholderFragment.kt index d718e880..9a69232e 100644 --- a/sample/src/main/java/pl/droidsonroids/gif/sample/TexturePlaceholderFragment.kt +++ b/sample/src/main/java/pl/droidsonroids/gif/sample/TexturePlaceholderFragment.kt @@ -15,7 +15,7 @@ import java.io.BufferedInputStream class TexturePlaceholderFragment : Fragment(), GifTextureView.PlaceholderDrawListener { - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val view = GifTextureView(inflater.context) val assetFileDescriptor = inflater.context.assets.openFd("Animated-Flag-Delaware.gif") view.setInputSource(InputSource.InputStreamSource(SlowLoadingInputStream(assetFileDescriptor)), this) @@ -29,8 +29,9 @@ class TexturePlaceholderFragment : Fragment(), GifTextureView.PlaceholderDrawLis } } -private class SlowLoadingInputStream -constructor(private val assetFileDescriptor: AssetFileDescriptor) : BufferedInputStream(assetFileDescriptor.createInputStream(), assetFileDescriptor.length.toInt()) { +private class SlowLoadingInputStream( + private val assetFileDescriptor: AssetFileDescriptor, +) : BufferedInputStream(assetFileDescriptor.createInputStream(), assetFileDescriptor.length.toInt()) { private var mSleepTimeMillis = 5 override fun read(buffer: ByteArray): Int { diff --git a/sample/src/main/java/pl/droidsonroids/gif/sample/TextureViewFragment.kt b/sample/src/main/java/pl/droidsonroids/gif/sample/TextureViewFragment.kt index 36771242..ed2a4f19 100644 --- a/sample/src/main/java/pl/droidsonroids/gif/sample/TextureViewFragment.kt +++ b/sample/src/main/java/pl/droidsonroids/gif/sample/TextureViewFragment.kt @@ -14,7 +14,7 @@ import pl.droidsonroids.gif.InputSource class TextureViewFragment : Fragment() { - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val textureView = TextureView(inflater.context) textureView.isOpaque = false val gifSurfaceTextureDrawer = GifSurfaceTextureDrawer(InputSource.ResourcesSource(resources, R.drawable.anim_flag_chile)) diff --git a/sample/src/main/java/pl/droidsonroids/gif/sample/sources/GifSourcesFragment.kt b/sample/src/main/java/pl/droidsonroids/gif/sample/sources/GifSourcesFragment.kt index 9f072ec2..faea16bd 100644 --- a/sample/src/main/java/pl/droidsonroids/gif/sample/sources/GifSourcesFragment.kt +++ b/sample/src/main/java/pl/droidsonroids/gif/sample/sources/GifSourcesFragment.kt @@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView */ class GifSourcesFragment : Fragment() { - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val recyclerView = RecyclerView(inflater.context) recyclerView.layoutManager = LinearLayoutManager(inflater.context) recyclerView.adapter = GifSourcesAdapter(inflater.context)