mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Code cleaning
This commit is contained in:
parent
a618a9214e
commit
e3c2af2c59
13 changed files with 28 additions and 56 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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) {
|
|
@ -14,30 +14,27 @@
|
|||
* 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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//class AttachmentsAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) : FragmentStateAdapter(fragmentManager, lifecycle) {
|
||||
// class AttachmentsAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) : FragmentStateAdapter(fragmentManager, lifecycle) {
|
||||
class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
||||
|
||||
var attachmentSourceProvider: AttachmentSourceProvider? = null
|
||||
|
@ -75,7 +72,6 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
is AttachmentInfo.Audio -> TODO()
|
||||
is AttachmentInfo.File -> TODO()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
@ -85,7 +81,7 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
attachmentSourceProvider?.getAttachmentInfoAt(position)?.let {
|
||||
holder.bind(it)
|
||||
when(it) {
|
||||
when (it) {
|
||||
is AttachmentInfo.Image -> {
|
||||
attachmentSourceProvider?.loadImage(holder as ZoomableImageViewHolder, it)
|
||||
}
|
||||
|
@ -94,7 +90,6 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,15 +114,13 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
// }
|
||||
// return fragment
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
//private const val ARG_OBJECT = "object"
|
||||
// private const val ARG_OBJECT = "object"
|
||||
//
|
||||
//// Instances of this class are fragments representing a single
|
||||
//// object in our collection.
|
||||
//class DemoObjectFragment : Fragment() {
|
||||
// // Instances of this class are fragments representing a single
|
||||
// // object in our collection.
|
||||
// class DemoObjectFragment : Fragment() {
|
||||
//
|
||||
// override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
// return inflater.inflate(R.layout.view_image_attachment, container, false)
|
||||
|
@ -139,4 +132,4 @@ class AttachmentsAdapter() : RecyclerView.Adapter<BaseViewHolder>() {
|
|||
// textView.text = getInt(ARG_OBJECT).toString()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// }
|
|
@ -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()
|
|
@ -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
|
|
@ -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
|
||||
|
@ -100,7 +100,7 @@ class SwipeToDismissHandler(
|
|||
onDismiss()
|
||||
}
|
||||
|
||||
//remove the update listener, otherwise it will be saved on the next animation execution:
|
||||
// remove the update listener, otherwise it will be saved on the next animation execution:
|
||||
swipeView.animate().setUpdateListener(null)
|
||||
})
|
||||
.start()
|
||||
|
@ -112,7 +112,6 @@ internal fun ViewPropertyAnimator.setAnimatorListener(
|
|||
onAnimationStart: ((Animator?) -> Unit)? = null
|
||||
) = this.setListener(
|
||||
object : AnimatorListenerAdapter() {
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
onAnimationEnd?.invoke(animation)
|
||||
}
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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
|
||||
|
@ -108,11 +108,10 @@ class RoomAttachmentProvider(
|
|||
val dateString = item.root.localDateTime().let {
|
||||
"${dateFormatter.formatMessageDay(it)} at ${dateFormatter.formatMessageHour(it)} "
|
||||
}
|
||||
overlayView?.updateWith("${position + 1} of ${attachments.size}","${item.senderInfo.displayName} $dateString" )
|
||||
overlayView?.updateWith("${position + 1} of ${attachments.size}", "${item.senderInfo.displayName} $dateString")
|
||||
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)
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue