Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Rotate improvement #15

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)


[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
alt="Get it on Google Play"
Expand Down
4 changes: 0 additions & 4 deletions app/signing.properties

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions imagepreview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ ext {
}

android {
compileSdkVersion 29
compileSdkVersion 30


defaultConfig {
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode libraryVersionCode
versionName libraryVersion
vectorDrawables.useSupportLibrary = true
Expand All @@ -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"
Expand All @@ -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'

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand All @@ -373,6 +375,7 @@ class ImagePreview {
try {
hide()
}catch (e:IllegalStateException){
}catch (e:NullPointerException){
}
false
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
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
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

companion object {
@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
Expand All @@ -31,33 +37,43 @@ 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)
}

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<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
view_pager_iv.setImage(ImageSource.bitmap(resource))
}

override fun onLoadCleared(placeholder: Drawable?) {}
})
view_pager_iv.setOnClickListener {
mOnImageClickListener?.onImageClick()
}
}

private var mOnImageClickListener: OnImageClickListener? = null

fun setListener(listener: OnImageClickListener){
fun setListener(listener: OnImageClickListener) {
mOnImageClickListener = listener
}

interface OnImageClickListener{
interface OnImageClickListener {
fun onImageClick()
}

Expand Down
3 changes: 3 additions & 0 deletions imagepreview/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<resources>

<!--Image Picker Customization-->
<color name="tb_media_picker_primary">#FFFFFF</color>
<color name="tb_media_picker_primaryDark">#707070</color>
<color name="tb_media_picker_accent">#2AE2FF</color>
<!--Image Picker Customization-->
<color name="tb_image_preview_primary">#000000</color>
<color name="tb_image_preview_primaryDark">#707070</color>
Expand Down
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -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.
#Mon May 31 16:59:15 CEST 2021
sdk.dir=/Users/oli/Library/Android/sdk