mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Add long click gesture to copy userId, user display name, room name, room topic and room alias (#1774)
This commit is contained in:
parent
a5f537f251
commit
d014872e3b
@ -5,7 +5,7 @@ Features ✨:
|
||||
-
|
||||
|
||||
Improvements 🙌:
|
||||
-
|
||||
- Add long click gesture to copy userId, user display name, room name, room topic and room alias (#1774)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Display name not shown under Settings/General (#1926)
|
||||
|
@ -24,7 +24,9 @@ import android.widget.TextView
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.utils.copyToClipboard
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
/**
|
||||
@ -68,3 +70,18 @@ fun TextView.setTextWithColoredPart(@StringRes fullTextRes: Int,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set long click listener to copy the current text of the TextView to the clipboard and show a Snackbar
|
||||
*/
|
||||
fun TextView.copyOnLongClick() {
|
||||
setOnLongClickListener { view ->
|
||||
(view as? TextView)
|
||||
?.text
|
||||
?.let { text ->
|
||||
copyToClipboard(view.context, text, false)
|
||||
Snackbar.make(view, view.resources.getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import im.vector.app.core.animations.MatrixItemAppBarStateChangeListener
|
||||
import im.vector.app.core.dialogs.ConfirmationDialogBuilder
|
||||
import im.vector.app.core.extensions.cleanup
|
||||
import im.vector.app.core.extensions.configureWith
|
||||
import im.vector.app.core.extensions.copyOnLongClick
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.StateView
|
||||
@ -44,11 +45,11 @@ import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.roommemberprofile.devices.DeviceListBottomSheet
|
||||
import im.vector.app.features.roommemberprofile.powerlevel.EditPowerLevelDialogs
|
||||
import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.synthetic.main.fragment_matrix_profile.*
|
||||
import kotlinx.android.synthetic.main.view_stub_room_member_profile_header.*
|
||||
import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import javax.inject.Inject
|
||||
|
||||
@Parcelize
|
||||
@ -110,6 +111,12 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||
is RoomMemberProfileViewEvents.OnInviteActionSuccess -> Unit
|
||||
}.exhaustive
|
||||
}
|
||||
setupLongClicks()
|
||||
}
|
||||
|
||||
private fun setupLongClicks() {
|
||||
memberProfileNameView.copyOnLongClick()
|
||||
memberProfileIdView.copyOnLongClick()
|
||||
}
|
||||
|
||||
private fun handleShowPowerLevelDemoteWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning) {
|
||||
|
@ -34,16 +34,12 @@ import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import com.yalantis.ucrop.UCrop
|
||||
import im.vector.lib.multipicker.MultiPicker
|
||||
import im.vector.lib.multipicker.entity.MultiPickerImageType
|
||||
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.animations.AppBarStateChangeListener
|
||||
import im.vector.app.core.animations.MatrixItemAppBarStateChangeListener
|
||||
import im.vector.app.core.extensions.cleanup
|
||||
import im.vector.app.core.extensions.configureWith
|
||||
import im.vector.app.core.extensions.copyOnLongClick
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.intent.getFilenameFromUri
|
||||
@ -62,9 +58,14 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
|
||||
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
|
||||
import im.vector.app.features.media.BigImageViewerActivity
|
||||
import im.vector.app.features.media.createUCropWithDefaultSettings
|
||||
import im.vector.lib.multipicker.MultiPicker
|
||||
import im.vector.lib.multipicker.entity.MultiPickerImageType
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.synthetic.main.fragment_matrix_profile.*
|
||||
import kotlinx.android.synthetic.main.view_stub_room_profile_header.*
|
||||
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
@ -120,6 +121,13 @@ class RoomProfileFragment @Inject constructor(
|
||||
.observe()
|
||||
.subscribe { handleQuickActions(it) }
|
||||
.disposeOnDestroyView()
|
||||
setupLongClicks()
|
||||
}
|
||||
|
||||
private fun setupLongClicks() {
|
||||
roomProfileNameView.copyOnLongClick()
|
||||
roomProfileAliasView.copyOnLongClick()
|
||||
roomProfileTopicView.copyOnLongClick()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
Loading…
Reference in New Issue
Block a user