diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts
index 556b4ba..f94882a 100644
--- a/androidApp/build.gradle.kts
+++ b/androidApp/build.gradle.kts
@@ -115,7 +115,6 @@ dependencies {
implementation(project(":shared"))
implementation("com.google.android.material:material:1.5.0")
implementation("androidx.appcompat:appcompat:1.4.1")
- implementation("androidx.constraintlayout:constraintlayout:2.1.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
implementation("androidx.preference:preference-ktx:1.1.1")
@@ -131,7 +130,7 @@ dependencies {
implementation("androidx.cardview:cardview:1.0.0")
implementation("androidx.annotation:annotation:1.3.0")
implementation("androidx.work:work-runtime-ktx:2.7.1")
- implementation("androidx.constraintlayout:constraintlayout:2.1.3")
+ implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("org.jsoup:jsoup:1.14.3")
//multidex
diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ImageActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ImageActivity.kt
index 5444485..fe4bd64 100644
--- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ImageActivity.kt
+++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ImageActivity.kt
@@ -3,6 +3,7 @@ package bou.amine.apps.readerforselfossv2.android
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
+import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
@@ -19,7 +20,6 @@ class ImageActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = ActivityImageBinding.inflate(layoutInflater)
val view = binding.root
- binding.pager.requestDisallowInterceptTouchEvent(true)
setContentView(view)
@@ -32,12 +32,36 @@ class ImageActivity : AppCompatActivity() {
binding.pager.adapter = ScreenSlidePagerAdapter(this)
binding.pager.setCurrentItem(position, false)
+
+ val transitionListener = object : MotionLayout.TransitionListener {
+ override fun onTransitionStarted(motionLayout: MotionLayout?, startId: Int, endId: Int) {
+ binding.root.setOnClickListener {
+ }
+ // Nothing
+ }
+
+ override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float
+ ) {
+ // Nothing
+ }
+
+ override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
+ if (motionLayout?.currentState == binding.root.endState) {
+ onBackPressedDispatcher.onBackPressed()
+ }
+ }
+
+ override fun onTransitionTrigger(motionLayout: MotionLayout?, triggerId: Int, positive: Boolean, progress: Float) {
+ // Nothing
+ }
+ }
+ binding.root.setTransitionListener(transitionListener)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
- onBackPressed()
+ onBackPressedDispatcher.onBackPressed()
return true
}
}
diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ImageFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ImageFragment.kt
index 5b9d3fb..d8ac8c0 100644
--- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ImageFragment.kt
+++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ImageFragment.kt
@@ -35,28 +35,6 @@ class ImageFragment : Fragment() {
.load(imageUrl)
.into(binding!!.photoView)
- val transitionListener = object : MotionLayout.TransitionListener {
- override fun onTransitionStarted(motionLayout: MotionLayout?, startId: Int, endId: Int) {
- // Nothing
- }
-
- override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float
- ) {
- // Nothing
- }
-
- override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
- if (motionLayout?.currentState == binding?.root?.endState) {
- activity?.finish()
- }
- }
-
- override fun onTransitionTrigger(motionLayout: MotionLayout?, triggerId: Int, positive: Boolean, progress: Float) {
- // Nothing
- }
- }
- binding!!.root.setTransitionListener(transitionListener)
-
return view
}
diff --git a/androidApp/src/main/res/layout/activity_image.xml b/androidApp/src/main/res/layout/activity_image.xml
index 66f62c8..fbf442f 100644
--- a/androidApp/src/main/res/layout/activity_image.xml
+++ b/androidApp/src/main/res/layout/activity_image.xml
@@ -1,8 +1,10 @@
-
+ android:layout_height="match_parent"
+ app:layoutDescription="@xml/image_close_scene">
+ />
-
+ android:layout_height="match_parent"
+ android:fillViewport="true"
+ app:layout_constraintTop_toBottomOf="@+id/appBarLayout">
-
+
+
+
+
+
diff --git a/androidApp/src/main/res/layout/fragment_image.xml b/androidApp/src/main/res/layout/fragment_image.xml
index 907501c..223c47e 100644
--- a/androidApp/src/main/res/layout/fragment_image.xml
+++ b/androidApp/src/main/res/layout/fragment_image.xml
@@ -1,10 +1,8 @@
-
+ android:layout_height="match_parent">
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/androidApp/src/main/res/xml/image_close_scene.xml b/androidApp/src/main/res/xml/image_close_scene.xml
index 77fbc6b..79ee284 100644
--- a/androidApp/src/main/res/xml/image_close_scene.xml
+++ b/androidApp/src/main/res/xml/image_close_scene.xml
@@ -10,26 +10,26 @@
motion:motionInterpolator="linear">
+ motion:touchAnchorId="@+id/scrollView"
+ motion:touchAnchorSide="top"
+ motion:onTouchUp="autoCompleteToStart" />
+ motion:layout_constraintTop_toBottomOf="@+id/appBarLayout"
+ motion:layout_constraintEnd_toEndOf="parent"
+ motion:layout_constraintStart_toStartOf="parent">