Merge pull request #2594 from vector-im/feature/ons/fix_room_topic_scroll

Disable scroll effect when click to a link in the topic.
This commit is contained in:
Benoit Marty 2021-01-07 15:20:47 +01:00 committed by GitHub
commit bd3bdd6996
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 1 deletions

View file

@ -12,6 +12,7 @@ Bugfix 🐛:
- Unspecced msgType field in m.sticker (#2580)
- Wait for all room members to be known before sending a message to a e2e room (#2518)
- Url previews sometimes attached to wrong message (#2561)
- Room Topic not displayed correctly after visiting a link (#2551)
- Hiding membership events works the exact opposite (#2603)
- Tapping drawer having more than 1 room in notifications gives "malformed link" error (#2605)

View file

@ -18,6 +18,7 @@ package im.vector.app.core.epoxy
import android.animation.ObjectAnimator
import android.text.TextUtils
import android.text.method.MovementMethod
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.doOnPreDraw
@ -36,6 +37,9 @@ abstract class ExpandableTextItem : VectorEpoxyModel<ExpandableTextItem.Holder>(
@EpoxyAttribute
var maxLines: Int = 3
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var movementMethod: MovementMethod? = null
private var isExpanded = false
private var expandedLines = 0
@ -43,6 +47,7 @@ abstract class ExpandableTextItem : VectorEpoxyModel<ExpandableTextItem.Holder>(
super.bind(holder)
holder.content.text = content
holder.content.copyOnLongClick()
holder.content.movementMethod = movementMethod
holder.content.doOnPreDraw {
if (holder.content.lineCount > maxLines) {

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2020 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.core.ui.views
import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
class NonScrollingTextView : AppCompatTextView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun scrollTo(x: Int, y: Int) {
// NOOP
}
}

View file

@ -26,6 +26,8 @@ import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.features.home.ShortcutCreator
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.tools.createLinkMovementMethod
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.session.room.model.RoomSummary
@ -53,6 +55,7 @@ class RoomProfileController @Inject constructor(
fun onSettingsClicked()
fun onLeaveRoomClicked()
fun onRoomIdClicked()
fun onUrlInTopicLongClicked(url: String)
}
override fun buildModels(data: RoomProfileViewState?) {
@ -71,6 +74,16 @@ class RoomProfileController @Inject constructor(
id("topic")
content(it)
maxLines(2)
movementMethod(createLinkMovementMethod(object : TimelineEventController.UrlClickCallback {
override fun onUrlClicked(url: String, title: String): Boolean {
return false
}
override fun onUrlLongClicked(url: String): Boolean {
callback?.onUrlInTopicLongClicked(url)
return true
}
}))
}
}

View file

@ -276,6 +276,10 @@ class RoomProfileFragment @Inject constructor(
copyToClipboard(requireContext(), roomProfileArgs.roomId)
}
override fun onUrlInTopicLongClicked(url: String) {
copyToClipboard(requireContext(), url, true)
}
private fun onShareRoomProfile(permalink: String) {
startSharePlainTextIntent(
fragment = this,

View file

@ -6,7 +6,7 @@
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
<im.vector.app.core.ui.views.NonScrollingTextView
android:id="@+id/expandableContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"