From 510d9f070d08fd211edf4ff1bb4bb2a0d0804f2e Mon Sep 17 00:00:00 2001 From: 73k05 Date: Fri, 17 Jul 2020 15:55:08 +0200 Subject: [PATCH 1/9] add tb_media_picker_accent to be able to build the app as an imported module in another project --- imagepreview/src/main/res/values/colors.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imagepreview/src/main/res/values/colors.xml b/imagepreview/src/main/res/values/colors.xml index fc71ba2..97e4b3f 100644 --- a/imagepreview/src/main/res/values/colors.xml +++ b/imagepreview/src/main/res/values/colors.xml @@ -2,6 +2,9 @@ + #FFFFFF + #707070 + #2AE2FF #000000 #707070 From 858048e5ca4bc627274afc048462fc3b6d82f5a6 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Fri, 17 Jul 2020 18:37:56 +0200 Subject: [PATCH 2/9] Fix IllegalArgumentException: pointerIndex out of range #8 --- .../turtlebody/imagepreview/ImageViewPager.kt | 25 +++++++++++++++++++ .../tb_image_preview_fragment_preview.xml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImageViewPager.kt diff --git a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImageViewPager.kt b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImageViewPager.kt new file mode 100644 index 0000000..93b28fd --- /dev/null +++ b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImageViewPager.kt @@ -0,0 +1,25 @@ +package com.greentoad.turtlebody.imagepreview + +import android.content.Context +import android.util.AttributeSet +import android.util.Log +import android.view.MotionEvent +import androidx.viewpager.widget.ViewPager + + +/********************* + * ViewPager + **********************/ +class ImageViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) { + private val TAG = "ImageViewPager" + + override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { + try { + return super.onInterceptTouchEvent(ev) + } catch (ex: IllegalArgumentException) { + Log.e(TAG, "Error: " + ex.localizedMessage) + } + return false + } + +} \ No newline at end of file diff --git a/imagepreview/src/main/res/layout/tb_image_preview_fragment_preview.xml b/imagepreview/src/main/res/layout/tb_image_preview_fragment_preview.xml index e1b8f23..037e89b 100644 --- a/imagepreview/src/main/res/layout/tb_image_preview_fragment_preview.xml +++ b/imagepreview/src/main/res/layout/tb_image_preview_fragment_preview.xml @@ -10,7 +10,7 @@ android:clickable="true" android:focusable="true"> - From 02d23b61c40a2c0f10a47b8a393cb9d8e1284c53 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Mon, 31 May 2021 16:22:16 +0200 Subject: [PATCH 3/9] Remove release unused config file that has been a problem for jitci building --- app/signing.properties | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 app/signing.properties diff --git a/app/signing.properties b/app/signing.properties deleted file mode 100644 index 2d90512..0000000 --- a/app/signing.properties +++ /dev/null @@ -1,4 +0,0 @@ -STORE_FILE=D:/Android_Projects/TheDroid/AppKeys/MediaPicker/greentoad-turtlebody-android.jks -STORE_PASSWORD=gtnirakaranandroid -KEY_ALIAS=greentoad -KEY_PASSWORD=gtnirakaran12 \ No newline at end of file From 8d1e410b0e44cdde86777630e486618e9b78d765 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Mon, 31 May 2021 16:50:44 +0200 Subject: [PATCH 4/9] Add local.properties config file which is missing for jitci building --- local.properties | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 local.properties diff --git a/local.properties b/local.properties new file mode 100644 index 0000000..9350803 --- /dev/null +++ b/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Mar 18 18:35:29 CET 2020 +sdk.dir= From 0c69c2b1534fd190e1afbffbf03dc2e2c4f85602 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Mon, 31 May 2021 17:08:38 +0200 Subject: [PATCH 5/9] Increase versions for jitci building --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- imagepreview/build.gradle | 20 ++++++++++---------- local.properties | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 10f71fe..b7f7731 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:4.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 01e3711..63aad68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip diff --git a/imagepreview/build.gradle b/imagepreview/build.gradle index 9e47047..ce2bc4a 100644 --- a/imagepreview/build.gradle +++ b/imagepreview/build.gradle @@ -43,12 +43,12 @@ ext { } android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 30 versionCode libraryVersionCode versionName libraryVersion vectorDrawables.useSupportLibrary = true @@ -67,14 +67,14 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation "androidx.core:core-ktx:1.1.0" + implementation "androidx.core:core-ktx:1.5.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.google.android.material:material:1.1.0-alpha10' - implementation 'androidx.recyclerview:recyclerview:1.0.0' + implementation 'com.google.android.material:material:1.4.0-beta01' + implementation 'androidx.recyclerview:recyclerview:1.2.0' //Anko implementation "org.jetbrains.anko:anko:0.10.8" @@ -89,9 +89,9 @@ dependencies { //image viewer implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test:runner:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } diff --git a/local.properties b/local.properties index 9350803..a5e7ec5 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Wed Mar 18 18:35:29 CET 2020 -sdk.dir= +#Mon May 31 16:59:15 CEST 2021 +sdk.dir=/Users/oli/Library/Android/sdk From fc61d9f5f94c69881963508b79e3ca6af4087ec1 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Mon, 31 May 2021 19:46:35 +0200 Subject: [PATCH 6/9] Fix orientation with @eemi2010 recomendations --- .../ui/components/ImageFragmentViewer.kt | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ui/components/ImageFragmentViewer.kt b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ui/components/ImageFragmentViewer.kt index af5313b..aee4793 100644 --- a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ui/components/ImageFragmentViewer.kt +++ b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ui/components/ImageFragmentViewer.kt @@ -1,12 +1,18 @@ package com.greentoad.turtlebody.imagepreview.ui.components +import android.graphics.Bitmap +import android.graphics.drawable.Drawable import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.bumptech.glide.Glide +import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.request.target.CustomTarget +import com.bumptech.glide.request.transition.Transition import com.davemorrissey.labs.subscaleview.ImageSource import com.greentoad.turtlebody.imagepreview.R import com.greentoad.turtlebody.imagepreview.ui.components.ViewPagerAdapter.Companion.B_ARG_URI @@ -14,7 +20,7 @@ import kotlinx.android.synthetic.main.tb_image_preview_view_pager.* import org.jetbrains.anko.AnkoLogger -class ImageFragmentViewer: Fragment(),AnkoLogger { +class ImageFragmentViewer : Fragment(), AnkoLogger { private lateinit var mUri: Uri @@ -22,7 +28,7 @@ class ImageFragmentViewer: Fragment(),AnkoLogger { @JvmStatic fun newInstance(key: Int, b: Bundle?): ImageFragmentViewer { val bf: Bundle = b ?: Bundle() - bf.putInt("fragment.key", key); + bf.putInt("fragment.key", key) val fragment = ImageFragmentViewer() fragment.arguments = bf return fragment @@ -31,13 +37,15 @@ class ImageFragmentViewer: Fragment(),AnkoLogger { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val b = arguments!! - mUri = Uri.parse(b.getString(B_ARG_URI,"")) + val b = requireArguments() + mUri = Uri.parse(b.getString(B_ARG_URI, "")) } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { // Inflate the layout for this fragment return inflater.inflate(R.layout.tb_image_preview_view_pager, container, false) } @@ -45,7 +53,15 @@ class ImageFragmentViewer: Fragment(),AnkoLogger { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - view_pager_iv.setImage(ImageSource.uri(mUri)) + Glide.with(this).asBitmap().load(mUri).diskCacheStrategy(DiskCacheStrategy.ALL) + .into(object : + CustomTarget() { + override fun onResourceReady(resource: Bitmap, transition: Transition?) { + view_pager_iv.setImage(ImageSource.bitmap(resource)) + } + + override fun onLoadCleared(placeholder: Drawable?) {} + }) view_pager_iv.setOnClickListener { mOnImageClickListener?.onImageClick() } @@ -53,11 +69,11 @@ class ImageFragmentViewer: Fragment(),AnkoLogger { private var mOnImageClickListener: OnImageClickListener? = null - fun setListener(listener: OnImageClickListener){ + fun setListener(listener: OnImageClickListener) { mOnImageClickListener = listener } - interface OnImageClickListener{ + interface OnImageClickListener { fun onImageClick() } From e1dc3b5628f89e4f976512f86491dabd043a8910 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Wed, 25 Aug 2021 10:34:26 +0200 Subject: [PATCH 7/9] Try catch crash NullPointerException on hide ImagePreview:336 when fragment is null --- .../java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt index 5fc2ada..9915bd3 100644 --- a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt +++ b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt @@ -373,6 +373,7 @@ class ImagePreview { try { hide() }catch (e:IllegalStateException){ + }catch (e:NullPointerException){ } false } else { From 92a5e675036c28f448b5ed116e607aadd8a10567 Mon Sep 17 00:00:00 2001 From: 73k05 Date: Thu, 26 Aug 2021 09:01:59 +0200 Subject: [PATCH 8/9] Update README.md Update preview image and remove deprecated download link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b0faf4..ede63cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ![](https://thedroid.io/assets/img/tb-image-preview.png) ![API](https://img.shields.io/badge/API-16%2B-34bf49.svg) -[ ![Download](https://api.bintray.com/packages/greentoad/android-image-preview/com.greentoad.turtlebody.imagepreview/images/download.svg?version=latest) ](https://bintray.com/greentoad/android-image-preview/com.greentoad.turtlebody.imagepreview/latest/link) ### Demo: -![](https://media.giphy.com/media/SXxdWquu9zlLiHIuc2/giphy.gif) +![Screenshot_1629961047](https://user-images.githubusercontent.com/9129812/130916268-004b5d8e-17ec-42aa-824c-b718d333b5e4.png) + [Get it on Google Play Date: Mon, 6 Sep 2021 14:54:39 +0200 Subject: [PATCH 9/9] Null Check to avoid crash NullPointerException on hide ImagePreview:336 when fragment is null --- .../turtlebody/imagepreview/ImagePreview.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt index 9915bd3..ce4dcc7 100644 --- a/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt +++ b/imagepreview/src/main/java/com/greentoad/turtlebody/imagepreview/ImagePreview.kt @@ -333,21 +333,23 @@ class ImagePreview { } private fun hide() { - mUiVisibilityFlag = preview_fragment_parent_fl.systemUiVisibility - preview_fragment_parent_fl.systemUiVisibility = - View.SYSTEM_UI_FLAG_FULLSCREEN or - //View.SYSTEM_UI_FLAG_LAYOUT_STABLE or //to get stable view this mUiVisibilityFlag sometime add views which disrupt our original views - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - - preview_fragment_app_bar.setPadding(0,0,0,0) - preview_fragment_bottom_ll.setPadding(0,0,0,0) - - preview_fragment_activity_toolbar.visibility = View.GONE - - if(mPreviewConfig.mUriList.size>1) { - preview_fragment_bottom_ll.visibility = View.GONE + preview_fragment_parent_fl?.let { + mUiVisibilityFlag = preview_fragment_parent_fl.systemUiVisibility + preview_fragment_parent_fl.systemUiVisibility = + View.SYSTEM_UI_FLAG_FULLSCREEN or + //View.SYSTEM_UI_FLAG_LAYOUT_STABLE or //to get stable view this mUiVisibilityFlag sometime add views which disrupt our original views + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + + preview_fragment_app_bar.setPadding(0, 0, 0, 0) + preview_fragment_bottom_ll.setPadding(0, 0, 0, 0) + + preview_fragment_activity_toolbar.visibility = View.GONE + + if (mPreviewConfig.mUriList.size > 1) { + preview_fragment_bottom_ll.visibility = View.GONE + } } }