Code cleaning

This commit is contained in:
Valere 2020-07-07 09:24:21 +02:00
parent a618a9214e
commit e3c2af2c59
13 changed files with 28 additions and 56 deletions

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="im.vector.riotx.attachment_viewer">
package="im.vector.riotx.attachmentviewer">
<application>
<activity
android:name="im.vector.riotx.attachment_viewer.AttachmentViewerActivity"
android:name="im.vector.riotx.attachmentviewer.AttachmentViewerActivity"
android:theme="@style/Theme.Transparent" />
</application>

View file

@ -14,11 +14,10 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
@ -27,7 +26,6 @@ import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import com.bumptech.glide.request.target.CustomViewTarget
import com.bumptech.glide.request.transition.Transition
import com.github.chrisbanes.photoview.PhotoView
class AnimatedImageViewHolder constructor(itemView: View) :
BaseViewHolder(itemView) {
@ -58,7 +56,7 @@ class AnimatedImageViewHolder constructor(itemView: View) :
}
touchImageView.setImageDrawable(resource)
if (resource is Animatable) {
resource.start();
resource.start()
}
}
}

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.content.Context
import android.view.View

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.graphics.Color
import android.os.Bundle
@ -120,7 +120,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity() {
scaleDetector = createScaleGestureDetector()
ViewCompat.setOnApplyWindowInsetsListener(rootContainer) { _, insets ->
overlayView?.updatePadding(top = insets.systemWindowInsetTop)
topInset = insets.systemWindowInsetTop
@ -129,7 +128,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity() {
}
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
// The zoomable view is configured to disallow interception when image is zoomed
// Check if the overlay is visible, and wants to handle the click
@ -137,20 +135,18 @@ abstract class AttachmentViewerActivity : AppCompatActivity() {
return true
}
Log.v("ATTACHEMENTS", "================\ndispatchTouchEvent $ev")
handleUpDownEvent(ev)
Log.v("ATTACHEMENTS", "scaleDetector is in progress ${scaleDetector.isInProgress}")
Log.v("ATTACHEMENTS", "pointerCount ${ev.pointerCount}")
Log.v("ATTACHEMENTS", "wasScaled ${wasScaled}")
Log.v("ATTACHEMENTS", "wasScaled $wasScaled")
if (swipeDirection == null && (scaleDetector.isInProgress || ev.pointerCount > 1 || wasScaled)) {
wasScaled = true
Log.v("ATTACHEMENTS", "dispatch to pager")
return attachmentPager.dispatchTouchEvent(ev)
}
Log.v("ATTACHEMENTS", "is current item scaled ${isScaled()}")
return (if (isScaled()) super.dispatchTouchEvent(ev) else handleTouchIfNotScaled(ev)).also {
Log.v("ATTACHEMENTS", "\n================")
@ -210,8 +206,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity() {
}
private fun handleTouchIfNotScaled(event: MotionEvent): Boolean {
Log.v("ATTACHEMENTS", "handleTouchIfNotScaled ${event}")
Log.v("ATTACHEMENTS", "handleTouchIfNotScaled $event")
directionDetector.handleTouchEvent(event)
return when (swipeDirection) {

View file

@ -14,26 +14,23 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
abstract class BaseViewHolder constructor(itemView: View) :
RecyclerView.ViewHolder(itemView) {
abstract fun bind(attachmentInfo: AttachmentInfo)
}
class AttachmentViewHolder constructor(itemView: View) :
BaseViewHolder(itemView) {
override fun bind(attachmentInfo: AttachmentInfo) {
}
}
@ -75,7 +72,6 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
is AttachmentInfo.Audio -> TODO()
is AttachmentInfo.File -> TODO()
}
}
override fun getItemCount(): Int {
@ -94,7 +90,6 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
}
else -> {}
}
}
}
@ -119,10 +114,8 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
// }
// return fragment
// }
}
// private const val ARG_OBJECT = "object"
//
// // Instances of this class are fragments representing a single

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
sealed class SwipeDirection {
object NotDetected : SwipeDirection()

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.content.Context
import android.view.MotionEvent

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
@ -112,7 +112,6 @@ internal fun ViewPropertyAnimator.setAnimatorListener(
onAnimationStart: ((Animator?) -> Unit)? = null
) = this.setListener(
object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
onAnimationEnd?.invoke(animation)
}

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
package im.vector.riotx.attachment_viewer
package im.vector.riotx.attachmentviewer
import android.graphics.drawable.Drawable
import android.util.Log

View file

@ -23,15 +23,12 @@ import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.updateLayoutParams
import im.vector.riotx.R
import im.vector.riotx.attachment_viewer.AttachmentInfo
class AttachmentOverlayView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
var onShareCallback: (() -> Unit) ? = null
var onBack: (() -> Unit) ? = null

View file

@ -144,7 +144,6 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
}
fun renderThumbnailDontTransform(data: Data, imageView: ImageView, callback: ((Boolean) -> Unit)? = null) {
// a11y
imageView.contentDescription = data.filename
@ -181,8 +180,6 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
})
.dontTransform()
.into(imageView)
}
private fun createGlideRequest(data: Data, mode: Mode, imageView: ImageView, size: Size): GlideRequest<Drawable> {

View file

@ -26,10 +26,10 @@ import im.vector.matrix.android.api.session.room.model.message.MessageWithAttach
import im.vector.matrix.android.api.session.room.model.message.getFileUrl
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
import im.vector.riotx.attachment_viewer.AnimatedImageViewHolder
import im.vector.riotx.attachment_viewer.AttachmentInfo
import im.vector.riotx.attachment_viewer.AttachmentSourceProvider
import im.vector.riotx.attachment_viewer.ZoomableImageViewHolder
import im.vector.riotx.attachmentviewer.AnimatedImageViewHolder
import im.vector.riotx.attachmentviewer.AttachmentInfo
import im.vector.riotx.attachmentviewer.AttachmentSourceProvider
import im.vector.riotx.attachmentviewer.ZoomableImageViewHolder
import im.vector.riotx.core.date.VectorDateFormatter
import im.vector.riotx.core.extensions.localDateTime
import javax.inject.Inject
@ -112,7 +112,6 @@ class RoomAttachmentProvider(
return overlayView
}
// override fun loadImage(holder: ImageViewHolder, info: AttachmentInfo.Image) {
// (info.data as? ImageContentRenderer.Data)?.let {
// imageContentRenderer.render(it, ImageContentRenderer.Mode.FULL_SIZE, holder.touchImageView)

View file

@ -29,7 +29,7 @@ import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.transition.Transition
import im.vector.riotx.R
import im.vector.riotx.attachment_viewer.AttachmentViewerActivity
import im.vector.riotx.attachmentviewer.AttachmentViewerActivity
import im.vector.riotx.core.di.*
import im.vector.riotx.features.themes.ActivityOtherThemes
import im.vector.riotx.features.themes.ThemeUtils
@ -62,7 +62,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
private var isAnimatingOut = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Timber.i("onCreate Activity ${this.javaClass.simpleName}")
val vectorComponent = getVectorComponent()
@ -81,7 +80,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
val index = events.indexOfFirst { it.eventId == args.eventId }
initialIndex = index
if (savedInstanceState == null && addTransitionListener()) {
args.sharedTransitionName?.let {
ViewCompat.setTransitionName(imageTransitionView, it)
@ -110,12 +108,10 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
window.statusBarColor = ContextCompat.getColor(this, R.color.black_alpha)
window.navigationBarColor = ContextCompat.getColor(this, R.color.black_alpha)
}
private fun getOtherThemes() = ActivityOtherThemes.VectorAttachmentsPreview
override fun shouldAnimateDismiss(): Boolean {
return currentPosition != initialIndex
}
@ -137,7 +133,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
transitionImageContainer.isVisible = true
}
isAnimatingOut = true
ActivityCompat.finishAfterTransition(this);
ActivityCompat.finishAfterTransition(this)
}
/* ==========================================================================================
@ -180,7 +176,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
private fun args() = intent.getParcelableExtra<Args>(EXTRA_ARGS)
private fun getVectorComponent(): VectorComponent {
return (application as HasVectorInjector).injector()
}
@ -205,7 +200,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), RoomAttachmen
it.putExtra(EXTRA_ARGS, Args(roomId, eventId, sharedTransitionName))
it.putExtra(EXTRA_IMAGE_DATA, mediaData)
}
}
override fun onDismissTapped() {