Migrate to ViewBindings (#1072) - WIP
This commit is contained in:
parent
dba65dcd22
commit
a8c6b1cdf7
|
@ -19,17 +19,17 @@ package im.vector.lib.attachmentviewer
|
|||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import im.vector.lib.attachmentviewer.databinding.ItemAnimatedImageAttachmentBinding
|
||||
|
||||
class AnimatedImageViewHolder constructor(itemView: View) :
|
||||
BaseViewHolder(itemView) {
|
||||
|
||||
val touchImageView: ImageView = itemView.findViewById(R.id.imageView)
|
||||
val imageLoaderProgress: ProgressBar = itemView.findViewById(R.id.imageLoaderProgress)
|
||||
val views = ItemAnimatedImageAttachmentBinding.bind(itemView)
|
||||
|
||||
internal val target = DefaultImageLoaderTarget(this, this.touchImageView)
|
||||
internal val target = DefaultImageLoaderTarget(this, views.imageView)
|
||||
|
||||
override fun onRecycled() {
|
||||
super.onRecycled()
|
||||
touchImageView.setImageDrawable(null)
|
||||
views.imageView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
|
|||
attachmentsAdapter = AttachmentsAdapter()
|
||||
views.attachmentPager.adapter = attachmentsAdapter
|
||||
imageTransitionView = views.transitionImageView
|
||||
transitionImageContainer = findViewById(R.id.transitionImageContainer)
|
||||
pager2 = views.attachmentPager
|
||||
directionDetector = createSwipeDirectionDetector()
|
||||
gestureDetector = createGestureDetector()
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.ProgressBar
|
|||
import android.widget.TextView
|
||||
import android.widget.VideoView
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.lib.attachmentviewer.databinding.ItemVideoAttachmentBinding
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
@ -44,13 +45,9 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
|
||||
var eventListener: WeakReference<AttachmentEventListener>? = null
|
||||
|
||||
val thumbnailImage: ImageView = itemView.findViewById(R.id.videoThumbnailImage)
|
||||
val videoView: VideoView = itemView.findViewById(R.id.videoView)
|
||||
val loaderProgressBar: ProgressBar = itemView.findViewById(R.id.videoLoaderProgress)
|
||||
val videoControlIcon: ImageView = itemView.findViewById(R.id.videoControlIcon)
|
||||
val errorTextView: TextView = itemView.findViewById(R.id.videoMediaViewerErrorView)
|
||||
val views = ItemVideoAttachmentBinding.bind(itemView)
|
||||
|
||||
internal val target = DefaultVideoLoaderTarget(this, thumbnailImage)
|
||||
internal val target = DefaultVideoLoaderTarget(this, views.videoThumbnailImage)
|
||||
|
||||
override fun onRecycled() {
|
||||
super.onRecycled()
|
||||
|
@ -77,12 +74,12 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
}
|
||||
|
||||
override fun entersBackground() {
|
||||
if (videoView.isPlaying) {
|
||||
progress = videoView.currentPosition
|
||||
if (views.videoView.isPlaying) {
|
||||
progress = views.videoView.currentPosition
|
||||
progressDisposable?.dispose()
|
||||
progressDisposable = null
|
||||
videoView.stopPlayback()
|
||||
videoView.pause()
|
||||
views.videoView.stopPlayback()
|
||||
views.videoView.pause()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,9 +89,9 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
|
||||
override fun onSelected(selected: Boolean) {
|
||||
if (!selected) {
|
||||
if (videoView.isPlaying) {
|
||||
progress = videoView.currentPosition
|
||||
videoView.stopPlayback()
|
||||
if (views.videoView.isPlaying) {
|
||||
progress = views.videoView.currentPosition
|
||||
views.videoView.stopPlayback()
|
||||
} else {
|
||||
progress = 0
|
||||
}
|
||||
|
@ -109,34 +106,34 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
}
|
||||
|
||||
private fun startPlaying() {
|
||||
thumbnailImage.isVisible = false
|
||||
loaderProgressBar.isVisible = false
|
||||
videoView.isVisible = true
|
||||
views.videoThumbnailImage.isVisible = false
|
||||
views.videoLoaderProgress.isVisible = false
|
||||
views.videoView.isVisible = true
|
||||
|
||||
videoView.setOnPreparedListener {
|
||||
views.videoView.setOnPreparedListener {
|
||||
progressDisposable?.dispose()
|
||||
progressDisposable = Observable.interval(100, TimeUnit.MILLISECONDS)
|
||||
.timeInterval()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
val duration = videoView.duration
|
||||
val progress = videoView.currentPosition
|
||||
val isPlaying = videoView.isPlaying
|
||||
val duration = views.videoView.duration
|
||||
val progress = views.videoView.currentPosition
|
||||
val isPlaying = views.videoView.isPlaying
|
||||
// Log.v("FOO", "isPlaying $isPlaying $progress/$duration")
|
||||
eventListener?.get()?.onEvent(AttachmentEvents.VideoEvent(isPlaying, progress, duration))
|
||||
}
|
||||
}
|
||||
try {
|
||||
videoView.setVideoPath(mVideoPath)
|
||||
views.videoView.setVideoPath(mVideoPath)
|
||||
} catch (failure: Throwable) {
|
||||
// Couldn't open
|
||||
Log.v(VideoViewHolder::class.java.name, "Failed to start video")
|
||||
}
|
||||
|
||||
if (!wasPaused) {
|
||||
videoView.start()
|
||||
views.videoView.start()
|
||||
if (progress > 0) {
|
||||
videoView.seekTo(progress)
|
||||
views.videoView.seekTo(progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,17 +143,17 @@ class VideoViewHolder constructor(itemView: View) :
|
|||
when (commands) {
|
||||
AttachmentCommands.StartVideo -> {
|
||||
wasPaused = false
|
||||
videoView.start()
|
||||
views.videoView.start()
|
||||
}
|
||||
AttachmentCommands.PauseVideo -> {
|
||||
wasPaused = true
|
||||
videoView.pause()
|
||||
views.videoView.pause()
|
||||
}
|
||||
is AttachmentCommands.SeekTo -> {
|
||||
val duration = videoView.duration
|
||||
val duration = views.videoView.duration
|
||||
if (duration > 0) {
|
||||
val seekDuration = duration * (commands.percentProgress / 100f)
|
||||
videoView.seekTo(seekDuration.toInt())
|
||||
views.videoView.seekTo(seekDuration.toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,29 +19,29 @@ package im.vector.lib.attachmentviewer
|
|||
import android.view.View
|
||||
import android.widget.ProgressBar
|
||||
import com.github.chrisbanes.photoview.PhotoView
|
||||
import im.vector.lib.attachmentviewer.databinding.ItemImageAttachmentBinding
|
||||
|
||||
class ZoomableImageViewHolder constructor(itemView: View) :
|
||||
BaseViewHolder(itemView) {
|
||||
|
||||
val touchImageView: PhotoView = itemView.findViewById(R.id.touchImageView)
|
||||
val imageLoaderProgress: ProgressBar = itemView.findViewById(R.id.imageLoaderProgress)
|
||||
val views = ItemImageAttachmentBinding.bind(itemView)
|
||||
|
||||
init {
|
||||
touchImageView.setAllowParentInterceptOnEdge(false)
|
||||
touchImageView.setOnScaleChangeListener { scaleFactor, _, _ ->
|
||||
views.touchImageView.setAllowParentInterceptOnEdge(false)
|
||||
views.touchImageView.setOnScaleChangeListener { scaleFactor, _, _ ->
|
||||
// Log.v("ATTACHEMENTS", "scaleFactor $scaleFactor")
|
||||
// It's a bit annoying but when you pitch down the scaling
|
||||
// is not exactly one :/
|
||||
touchImageView.setAllowParentInterceptOnEdge(scaleFactor <= 1.0008f)
|
||||
views.touchImageView.setAllowParentInterceptOnEdge(scaleFactor <= 1.0008f)
|
||||
}
|
||||
touchImageView.setScale(1.0f, true)
|
||||
touchImageView.setAllowParentInterceptOnEdge(true)
|
||||
views.touchImageView.setScale(1.0f, true)
|
||||
views.touchImageView.setAllowParentInterceptOnEdge(true)
|
||||
}
|
||||
|
||||
internal val target = DefaultImageLoaderTarget.ZoomableImageTarget(this, touchImageView)
|
||||
internal val target = DefaultImageLoaderTarget.ZoomableImageTarget(this, views.touchImageView)
|
||||
|
||||
override fun onRecycled() {
|
||||
super.onRecycled()
|
||||
touchImageView.setImageDrawable(null)
|
||||
views.touchImageView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,12 +61,11 @@ class ExportKeysDialog {
|
|||
views.exportDialogEt.addTextChangedListener(textWatcher)
|
||||
views.exportDialogEtConfirm.addTextChangedListener(textWatcher)
|
||||
|
||||
val showPassword = dialogLayout.findViewById<ImageView>(R.id.exportDialogShowPassword)
|
||||
showPassword.setOnClickListener {
|
||||
views.exportDialogShowPassword.setOnClickListener {
|
||||
passwordVisible = !passwordVisible
|
||||
views.exportDialogEt.showPassword(passwordVisible)
|
||||
views.exportDialogEtConfirm.showPassword(passwordVisible)
|
||||
showPassword.setImageResource(if (passwordVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
|
||||
views.exportDialogShowPassword.setImageResource(if (passwordVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
|
||||
}
|
||||
|
||||
val exportDialog = builder.show()
|
||||
|
|
|
@ -44,11 +44,10 @@ class PromptPasswordDialog {
|
|||
}
|
||||
views.promptPassword.addTextChangedListener(textWatcher)
|
||||
|
||||
val showPassword = dialogLayout.findViewById<ImageView>(R.id.promptPasswordPasswordReveal)
|
||||
showPassword.setOnClickListener {
|
||||
views.promptPasswordPasswordReveal.setOnClickListener {
|
||||
passwordVisible = !passwordVisible
|
||||
views.promptPassword.showPassword(passwordVisible)
|
||||
showPassword.setImageResource(if (passwordVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
|
||||
views.promptPasswordPasswordReveal.setImageResource(if (passwordVisible) R.drawable.ic_eye_closed else R.drawable.ic_eye)
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
|
|
|
@ -22,6 +22,7 @@ import androidx.appcompat.app.AlertDialog
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.databinding.DialogSslFingerprintBinding
|
||||
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
|
||||
import timber.log.Timber
|
||||
import java.util.HashMap
|
||||
|
@ -95,30 +96,27 @@ class UnrecognizedCertificateDialog @Inject constructor(
|
|||
|
||||
val builder = AlertDialog.Builder(activity)
|
||||
val inflater = activity.layoutInflater
|
||||
val layout: View = inflater.inflate(R.layout.dialog_ssl_fingerprint, null)
|
||||
val sslFingerprintTitle = layout.findViewById<TextView>(R.id.ssl_fingerprint_title)
|
||||
sslFingerprintTitle.text = stringProvider.getString(R.string.ssl_fingerprint_hash, unrecognizedFingerprint.hashType.toString())
|
||||
val sslFingerprint = layout.findViewById<TextView>(R.id.ssl_fingerprint)
|
||||
sslFingerprint.text = unrecognizedFingerprint.displayableHexRepr
|
||||
val sslUserId = layout.findViewById<TextView>(R.id.ssl_user_id)
|
||||
val layout = inflater.inflate(R.layout.dialog_ssl_fingerprint, null)
|
||||
val views = DialogSslFingerprintBinding.bind(layout)
|
||||
views.sslFingerprintTitle.text = stringProvider.getString(R.string.ssl_fingerprint_hash, unrecognizedFingerprint.hashType.toString())
|
||||
views.sslFingerprint.text = unrecognizedFingerprint.displayableHexRepr
|
||||
if (userId != null) {
|
||||
sslUserId.text = stringProvider.getString(R.string.generic_label_and_value,
|
||||
views.sslUserId.text = stringProvider.getString(R.string.generic_label_and_value,
|
||||
stringProvider.getString(R.string.username),
|
||||
userId)
|
||||
} else {
|
||||
sslUserId.text = stringProvider.getString(R.string.generic_label_and_value,
|
||||
views.sslUserId.text = stringProvider.getString(R.string.generic_label_and_value,
|
||||
stringProvider.getString(R.string.hs_url),
|
||||
homeServerUrl)
|
||||
}
|
||||
val sslExpl = layout.findViewById<TextView>(R.id.ssl_explanation)
|
||||
if (existing) {
|
||||
if (homeServerConnectionConfigHasFingerprints) {
|
||||
sslExpl.text = stringProvider.getString(R.string.ssl_expected_existing_expl)
|
||||
views.sslExplanation.text = stringProvider.getString(R.string.ssl_expected_existing_expl)
|
||||
} else {
|
||||
sslExpl.text = stringProvider.getString(R.string.ssl_unexpected_existing_expl)
|
||||
views.sslExplanation.text = stringProvider.getString(R.string.ssl_unexpected_existing_expl)
|
||||
}
|
||||
} else {
|
||||
sslExpl.text = stringProvider.getString(R.string.ssl_cert_new_account_expl)
|
||||
views.sslExplanation.text = stringProvider.getString(R.string.ssl_cert_new_account_expl)
|
||||
}
|
||||
builder.setView(layout)
|
||||
builder.setTitle(R.string.ssl_could_not_verify)
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright 2018 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.preference
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import im.vector.app.R
|
||||
|
||||
/**
|
||||
* Preference used in Room setting for Room aliases
|
||||
*/
|
||||
class AddressPreference : VectorPreference {
|
||||
|
||||
// members
|
||||
private var mMainAddressIconView: ImageView? = null
|
||||
private var mIsMainIconVisible = false
|
||||
|
||||
/**
|
||||
* @return the main icon view.
|
||||
*/
|
||||
val mainIconView: View?
|
||||
get() = mMainAddressIconView
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
|
||||
|
||||
init {
|
||||
widgetLayoutResource = R.layout.vector_settings_address_preference
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
|
||||
val view = holder.itemView
|
||||
mMainAddressIconView = view.findViewById(R.id.main_address_icon_view)
|
||||
mMainAddressIconView!!.visibility = if (mIsMainIconVisible) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the main address icon visibility.
|
||||
*
|
||||
* @param isVisible true to display the main icon
|
||||
*/
|
||||
fun setMainIconVisible(isVisible: Boolean) {
|
||||
mIsMainIconVisible = isVisible
|
||||
|
||||
mMainAddressIconView?.visibility = if (mIsMainIconVisible) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Copyright 2018 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.preference
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import androidx.preference.SwitchPreference
|
||||
import im.vector.app.R
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.group.Group
|
||||
|
||||
class VectorGroupPreference : SwitchPreference {
|
||||
|
||||
private var mAvatarView: ImageView? = null
|
||||
|
||||
private var mGroup: Group? = null
|
||||
private var mSession: Session? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
|
||||
val createdView = holder.itemView
|
||||
|
||||
if (mAvatarView == null) {
|
||||
try {
|
||||
// insert the group avatar to the left
|
||||
val iconView = createdView.findViewById<ImageView>(android.R.id.icon)
|
||||
|
||||
var iconViewParent = iconView.parent
|
||||
|
||||
while (null != iconViewParent.parent) {
|
||||
iconViewParent = iconViewParent.parent
|
||||
}
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.vector_settings_round_group_avatar, (iconViewParent as LinearLayout), false) as FrameLayout
|
||||
mAvatarView = layout.findViewById(R.id.settings_round_group_avatar)
|
||||
|
||||
val params = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
params.gravity = Gravity.CENTER
|
||||
layout.layoutParams = params
|
||||
iconViewParent.addView(layout, 0)
|
||||
} catch (e: Exception) {
|
||||
mAvatarView = null
|
||||
}
|
||||
}
|
||||
|
||||
refreshAvatar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the group information
|
||||
*
|
||||
* @param group the group
|
||||
* @param session the session
|
||||
*/
|
||||
fun setGroup(group: Group, session: Session) {
|
||||
mGroup = group
|
||||
mSession = session
|
||||
|
||||
refreshAvatar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the avatar
|
||||
*/
|
||||
private fun refreshAvatar() {
|
||||
if (null != mAvatarView && null != mSession && null != mGroup) {
|
||||
// TODO
|
||||
// VectorUtils.loadGroupAvatar(context, session, mAvatarView, mGroup)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import android.widget.TextView
|
|||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.utils.tappableMatchingText
|
||||
import im.vector.app.databinding.ViewActiveConferenceViewBinding
|
||||
import im.vector.app.features.home.room.detail.RoomDetailViewState
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
|
@ -48,12 +49,15 @@ class ActiveConferenceView @JvmOverloads constructor(
|
|||
var callback: Callback? = null
|
||||
var jitsiWidget: Widget? = null
|
||||
|
||||
private lateinit var views: ViewActiveConferenceViewBinding
|
||||
|
||||
init {
|
||||
setupView()
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
inflate(context, R.layout.view_active_conference_view, this)
|
||||
views = ViewActiveConferenceViewBinding.bind(this)
|
||||
setBackgroundColor(ThemeUtils.getColor(context, R.attr.colorPrimary))
|
||||
|
||||
// "voice" and "video" texts are underlined and clickable
|
||||
|
@ -78,12 +82,12 @@ class ActiveConferenceView @JvmOverloads constructor(
|
|||
}
|
||||
})
|
||||
|
||||
findViewById<TextView>(R.id.activeConferenceInfo).apply {
|
||||
views.activeConferenceInfo.apply {
|
||||
text = styledText
|
||||
movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
findViewById<TextView>(R.id.deleteWidgetButton).setOnClickListener {
|
||||
views.deleteWidgetButton.setOnClickListener {
|
||||
jitsiWidget?.let { callback?.onDelete(it) }
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +109,7 @@ class ActiveConferenceView @JvmOverloads constructor(
|
|||
jitsiWidget = activeConf
|
||||
}
|
||||
// if sent by me or if i can moderate?
|
||||
findViewById<TextView>(R.id.deleteWidgetButton).isVisible = state.isAllowedToManageWidgets
|
||||
views.deleteWidgetButton.isVisible = state.isAllowedToManageWidgets
|
||||
} else {
|
||||
isVisible = false
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import androidx.core.view.isInvisible
|
|||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.databinding.ItemVerificationActionBinding
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
class BottomSheetActionButton @JvmOverloads constructor(
|
||||
|
@ -38,23 +39,18 @@ class BottomSheetActionButton @JvmOverloads constructor(
|
|||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val actionTextView: TextView
|
||||
private val descriptionTextView: TextView
|
||||
private val leftIconImageView: ImageView
|
||||
private val rightIconImageView: ImageView
|
||||
private val clickableView: View
|
||||
private val views : ItemVerificationActionBinding
|
||||
|
||||
var title: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
actionTextView.setTextOrHide(value)
|
||||
views.itemVerificationActionTitle.setTextOrHide(value)
|
||||
}
|
||||
|
||||
var subTitle: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
descriptionTextView.setTextOrHide(value)
|
||||
views.itemVerificationActionSubTitle.setTextOrHide(value)
|
||||
}
|
||||
|
||||
var forceStartPadding: Boolean? = null
|
||||
|
@ -62,9 +58,9 @@ class BottomSheetActionButton @JvmOverloads constructor(
|
|||
field = value
|
||||
if (leftIcon == null) {
|
||||
if (forceStartPadding == true) {
|
||||
leftIconImageView.isInvisible = true
|
||||
views.itemVerificationLeftIcon.isInvisible = true
|
||||
} else {
|
||||
leftIconImageView.isGone = true
|
||||
views.itemVerificationLeftIcon.isGone = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,43 +70,38 @@ class BottomSheetActionButton @JvmOverloads constructor(
|
|||
field = value
|
||||
if (value == null) {
|
||||
if (forceStartPadding == true) {
|
||||
leftIconImageView.isInvisible = true
|
||||
views.itemVerificationLeftIcon.isInvisible = true
|
||||
} else {
|
||||
leftIconImageView.isGone = true
|
||||
views.itemVerificationLeftIcon.isGone = true
|
||||
}
|
||||
leftIconImageView.setImageDrawable(null)
|
||||
views.itemVerificationLeftIcon.setImageDrawable(null)
|
||||
} else {
|
||||
leftIconImageView.isVisible = true
|
||||
leftIconImageView.setImageDrawable(value)
|
||||
views.itemVerificationLeftIcon.isVisible = true
|
||||
views.itemVerificationLeftIcon.setImageDrawable(value)
|
||||
}
|
||||
}
|
||||
|
||||
var rightIcon: Drawable? = null
|
||||
set(value) {
|
||||
field = value
|
||||
rightIconImageView.setImageDrawable(value)
|
||||
views.itemVerificationActionIcon.setImageDrawable(value)
|
||||
}
|
||||
|
||||
var tint: Int? = null
|
||||
set(value) {
|
||||
field = value
|
||||
leftIconImageView.imageTintList = value?.let { ColorStateList.valueOf(value) }
|
||||
views.itemVerificationLeftIcon.imageTintList = value?.let { ColorStateList.valueOf(value) }
|
||||
}
|
||||
|
||||
var titleTextColor: Int? = null
|
||||
set(value) {
|
||||
field = value
|
||||
value?.let { actionTextView.setTextColor(it) }
|
||||
value?.let { views.itemVerificationActionTitle.setTextColor(it) }
|
||||
}
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.item_verification_action, this)
|
||||
|
||||
actionTextView = findViewById(R.id.itemVerificationActionTitle)
|
||||
descriptionTextView = findViewById(R.id.itemVerificationActionSubTitle)
|
||||
leftIconImageView = findViewById(R.id.itemVerificationLeftIcon)
|
||||
rightIconImageView = findViewById(R.id.itemVerificationActionIcon)
|
||||
clickableView = findViewById(R.id.itemVerificationClickableZone)
|
||||
views = ItemVerificationActionBinding.bind(this)
|
||||
|
||||
context.withStyledAttributes(attrs, R.styleable.BottomSheetActionButton) {
|
||||
title = getString(R.styleable.BottomSheetActionButton_actionTitle) ?: ""
|
||||
|
|
|
@ -42,6 +42,7 @@ import im.vector.app.core.extensions.getMeasurements
|
|||
import im.vector.app.core.utils.PERMISSIONS_EMPTY
|
||||
import im.vector.app.core.utils.PERMISSIONS_FOR_PICKING_CONTACT
|
||||
import im.vector.app.core.utils.PERMISSIONS_FOR_TAKING_PHOTO
|
||||
import im.vector.app.databinding.ViewAttachmentTypeSelectorBinding
|
||||
import im.vector.app.features.attachments.AttachmentTypeSelectorView.Callback
|
||||
import kotlin.math.max
|
||||
|
||||
|
@ -62,24 +63,20 @@ class AttachmentTypeSelectorView(context: Context,
|
|||
|
||||
private val iconColorGenerator = ColorGenerator.MATERIAL
|
||||
|
||||
private var galleryButton: ImageButton
|
||||
private var cameraButton: ImageButton
|
||||
private var fileButton: ImageButton
|
||||
private var stickersButton: ImageButton
|
||||
private var audioButton: ImageButton
|
||||
private var contactButton: ImageButton
|
||||
private val views: ViewAttachmentTypeSelectorBinding
|
||||
|
||||
private var anchor: View? = null
|
||||
|
||||
init {
|
||||
val root = FrameLayout(context)
|
||||
val layout = inflater.inflate(R.layout.view_attachment_type_selector, root, true)
|
||||
galleryButton = layout.findViewById<ImageButton>(R.id.attachmentGalleryButton).configure(Type.GALLERY)
|
||||
cameraButton = layout.findViewById<ImageButton>(R.id.attachmentCameraButton).configure(Type.CAMERA)
|
||||
fileButton = layout.findViewById<ImageButton>(R.id.attachmentFileButton).configure(Type.FILE)
|
||||
stickersButton = layout.findViewById<ImageButton>(R.id.attachmentStickersButton).configure(Type.STICKER)
|
||||
audioButton = layout.findViewById<ImageButton>(R.id.attachmentAudioButton).configure(Type.AUDIO)
|
||||
contactButton = layout.findViewById<ImageButton>(R.id.attachmentContactButton).configure(Type.CONTACT)
|
||||
views = ViewAttachmentTypeSelectorBinding.bind(layout)
|
||||
views.attachmentGalleryButton.configure(Type.GALLERY)
|
||||
views.attachmentCameraButton.configure(Type.CAMERA)
|
||||
views.attachmentFileButton.configure(Type.FILE)
|
||||
views.attachmentStickersButton.configure(Type.STICKER)
|
||||
views.attachmentAudioButton.configure(Type.AUDIO)
|
||||
views.attachmentContactButton.configure(Type.CONTACT)
|
||||
contentView = root
|
||||
width = LinearLayout.LayoutParams.MATCH_PARENT
|
||||
height = LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
|
@ -108,12 +105,12 @@ class AttachmentTypeSelectorView(context: Context,
|
|||
contentView.doOnNextLayout {
|
||||
animateWindowInCircular(anchor, contentView)
|
||||
}
|
||||
animateButtonIn(galleryButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(cameraButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(fileButton, ANIMATION_DURATION / 4)
|
||||
animateButtonIn(audioButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(contactButton, ANIMATION_DURATION / 4)
|
||||
animateButtonIn(stickersButton, 0)
|
||||
animateButtonIn(views.attachmentGalleryButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(views.attachmentCameraButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(views.attachmentFileButton, ANIMATION_DURATION / 4)
|
||||
animateButtonIn(views.attachmentAudioButton, ANIMATION_DURATION / 2)
|
||||
animateButtonIn(views.attachmentContactButton, ANIMATION_DURATION / 4)
|
||||
animateButtonIn(views.attachmentStickersButton, 0)
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.widget.LinearLayout
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import im.vector.app.R
|
||||
import im.vector.app.databinding.ViewCallControlsBinding
|
||||
|
||||
import org.matrix.android.sdk.api.session.call.CallState
|
||||
import org.webrtc.PeerConnection
|
||||
|
@ -32,40 +33,22 @@ class CallControlsView @JvmOverloads constructor(
|
|||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var ringingControls: View
|
||||
private var connectedControls: View
|
||||
|
||||
private val ringingControlAccept: View
|
||||
private var ringingControlDecline: View
|
||||
private var iv_end_call: View
|
||||
private var muteIcon: ImageView
|
||||
private var videoToggleIcon: ImageView
|
||||
private var iv_leftMiniControl: View
|
||||
private var iv_more: View
|
||||
private val views: ViewCallControlsBinding
|
||||
|
||||
var interactionListener: InteractionListener? = null
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.view_call_controls, this)
|
||||
// layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
views = ViewCallControlsBinding.bind(this)
|
||||
|
||||
ringingControlAccept = findViewById<View>(R.id.ringingControlAccept)
|
||||
.also { it.setOnClickListener { acceptIncomingCall() } }
|
||||
ringingControlDecline = findViewById<View>(R.id.ringingControlDecline)
|
||||
.also { it.setOnClickListener { declineIncomingCall() } }
|
||||
iv_end_call = findViewById<View>(R.id.iv_end_call)
|
||||
.also { it.setOnClickListener { endOngoingCall() } }
|
||||
muteIcon = findViewById<ImageView>(R.id.muteIcon)
|
||||
.also { it.setOnClickListener { toggleMute() } }
|
||||
videoToggleIcon = findViewById<ImageView>(R.id.videoToggleIcon)
|
||||
.also { it.setOnClickListener { toggleVideo() } }
|
||||
iv_leftMiniControl = findViewById<View>(R.id.iv_leftMiniControl)
|
||||
.also { it.setOnClickListener { returnToChat() } }
|
||||
iv_more = findViewById<View>(R.id.iv_more)
|
||||
.also { it.setOnClickListener { moreControlOption() } }
|
||||
|
||||
ringingControls = findViewById(R.id.ringingControls)
|
||||
connectedControls = findViewById(R.id.connectedControls)
|
||||
views.ringingControlAccept.setOnClickListener { acceptIncomingCall() }
|
||||
views.ringingControlDecline.setOnClickListener { declineIncomingCall() }
|
||||
views.ivEndCall.setOnClickListener { endOngoingCall() }
|
||||
views.muteIcon.setOnClickListener { toggleMute() }
|
||||
views.videoToggleIcon.setOnClickListener { toggleVideo() }
|
||||
views.ivLeftMiniControl.setOnClickListener { returnToChat() }
|
||||
views.ivMore.setOnClickListener { moreControlOption() }
|
||||
}
|
||||
|
||||
private fun acceptIncomingCall() {
|
||||
|
@ -99,51 +82,51 @@ class CallControlsView @JvmOverloads constructor(
|
|||
fun updateForState(state: VectorCallViewState) {
|
||||
val callState = state.callState.invoke()
|
||||
if (state.isAudioMuted) {
|
||||
muteIcon.setImageResource(R.drawable.ic_microphone_off)
|
||||
muteIcon.contentDescription = resources.getString(R.string.a11y_unmute_microphone)
|
||||
views.muteIcon.setImageResource(R.drawable.ic_microphone_off)
|
||||
views.muteIcon.contentDescription = resources.getString(R.string.a11y_unmute_microphone)
|
||||
} else {
|
||||
muteIcon.setImageResource(R.drawable.ic_microphone_on)
|
||||
muteIcon.contentDescription = resources.getString(R.string.a11y_mute_microphone)
|
||||
views.muteIcon.setImageResource(R.drawable.ic_microphone_on)
|
||||
views.muteIcon.contentDescription = resources.getString(R.string.a11y_mute_microphone)
|
||||
}
|
||||
if (state.isVideoEnabled) {
|
||||
videoToggleIcon.setImageResource(R.drawable.ic_video)
|
||||
videoToggleIcon.contentDescription = resources.getString(R.string.a11y_stop_camera)
|
||||
views.videoToggleIcon.setImageResource(R.drawable.ic_video)
|
||||
views.videoToggleIcon.contentDescription = resources.getString(R.string.a11y_stop_camera)
|
||||
} else {
|
||||
videoToggleIcon.setImageResource(R.drawable.ic_video_off)
|
||||
videoToggleIcon.contentDescription = resources.getString(R.string.a11y_start_camera)
|
||||
views. videoToggleIcon.setImageResource(R.drawable.ic_video_off)
|
||||
views.videoToggleIcon.contentDescription = resources.getString(R.string.a11y_start_camera)
|
||||
}
|
||||
|
||||
when (callState) {
|
||||
is CallState.Idle,
|
||||
is CallState.Dialing,
|
||||
is CallState.Answering -> {
|
||||
ringingControls.isVisible = true
|
||||
ringingControlAccept.isVisible = false
|
||||
ringingControlDecline.isVisible = true
|
||||
connectedControls.isVisible = false
|
||||
views.ringingControls.isVisible = true
|
||||
views.ringingControlAccept.isVisible = false
|
||||
views.ringingControlDecline.isVisible = true
|
||||
views.connectedControls.isVisible = false
|
||||
}
|
||||
is CallState.LocalRinging -> {
|
||||
ringingControls.isVisible = true
|
||||
ringingControlAccept.isVisible = true
|
||||
ringingControlDecline.isVisible = true
|
||||
connectedControls.isVisible = false
|
||||
views.ringingControls.isVisible = true
|
||||
views.ringingControlAccept.isVisible = true
|
||||
views.ringingControlDecline.isVisible = true
|
||||
views.connectedControls.isVisible = false
|
||||
}
|
||||
is CallState.Connected -> {
|
||||
if (callState.iceConnectionState == PeerConnection.PeerConnectionState.CONNECTED) {
|
||||
ringingControls.isVisible = false
|
||||
connectedControls.isVisible = true
|
||||
videoToggleIcon.isVisible = state.isVideoCall
|
||||
views.ringingControls.isVisible = false
|
||||
views.connectedControls.isVisible = true
|
||||
views.videoToggleIcon.isVisible = state.isVideoCall
|
||||
} else {
|
||||
ringingControls.isVisible = true
|
||||
ringingControlAccept.isVisible = false
|
||||
ringingControlDecline.isVisible = true
|
||||
connectedControls.isVisible = false
|
||||
views.ringingControls.isVisible = true
|
||||
views.ringingControlAccept.isVisible = false
|
||||
views.ringingControlDecline.isVisible = true
|
||||
views.connectedControls.isVisible = false
|
||||
}
|
||||
}
|
||||
is CallState.Terminated,
|
||||
null -> {
|
||||
ringingControls.isVisible = false
|
||||
connectedControls.isVisible = false
|
||||
views.ringingControls.isVisible = false
|
||||
views.connectedControls.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,13 +86,13 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
when (viewState.widget) {
|
||||
is Fail -> finish()
|
||||
is Success -> {
|
||||
findViewById<View>(R.id.jitsi_progress_layout).isVisible = false
|
||||
views.jitsiProgressLayout.isVisible = false
|
||||
jitsiMeetView?.isVisible = true
|
||||
configureJitsiView(viewState)
|
||||
}
|
||||
else -> {
|
||||
jitsiMeetView?.isVisible = false
|
||||
findViewById<View>(R.id.jitsi_progress_layout).isVisible = true
|
||||
views.jitsiProgressLayout.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import im.vector.app.core.utils.LiveEvent
|
|||
import im.vector.app.core.utils.copyToClipboard
|
||||
import im.vector.app.core.utils.selectTxtFileToWrite
|
||||
import im.vector.app.core.utils.startSharePlainTextIntent
|
||||
import im.vector.app.databinding.BottomSheetSaveRecoveryKeyBinding
|
||||
import im.vector.app.databinding.FragmentKeysBackupRestoreFromKeyBinding
|
||||
import im.vector.app.databinding.FragmentKeysBackupSetupStep3Binding
|
||||
|
||||
|
@ -65,10 +66,10 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
|
|||
viewModel.passphrase.observe(viewLifecycleOwner, Observer {
|
||||
if (it.isNullOrBlank()) {
|
||||
// Recovery was generated, so show key and options to save
|
||||
mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2_no_passphrase)
|
||||
mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title_no_passphrase)
|
||||
views.mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2_no_passphrase)
|
||||
views.mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title_no_passphrase)
|
||||
|
||||
keys_backup_recovery_key_text.text = viewModel.recoveryKey.value!!
|
||||
views.keysBackupRecoveryKeyText.text = viewModel.recoveryKey.value!!
|
||||
.replace(" ", "")
|
||||
.chunked(16)
|
||||
.joinToString("\n") {
|
||||
|
@ -76,11 +77,11 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
|
|||
.chunked(4)
|
||||
.joinToString(" ")
|
||||
}
|
||||
keys_backup_recovery_key_text.isVisible = true
|
||||
views.keysBackupRecoveryKeyText.isVisible = true
|
||||
} else {
|
||||
mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2)
|
||||
mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title)
|
||||
keys_backup_recovery_key_text.isVisible = false
|
||||
views.mRecoveryKeyLabel2TextView.text = getString(R.string.keys_backup_setup_step3_text_line2)
|
||||
views.mFinishButton.text = getString(R.string.keys_backup_setup_step3_button_title)
|
||||
views.keysBackupRecoveryKeyText.isVisible = false
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -88,9 +89,9 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment<Fr
|
|||
}
|
||||
|
||||
private fun setupViews() {
|
||||
mFinishButton.setOnClickListener { onFinishButtonClicked() }
|
||||
keys_backup_setup_step3_copy_button.setOnClickListener { onCopyButtonClicked() }
|
||||
keys_backup_recovery_key_text.setOnClickListener { onRecoveryKeyClicked() }
|
||||
views.mFinishButton.setOnClickListener { onFinishButtonClicked() }
|
||||
views.keysBackupSetupStep3CopyButton.setOnClickListener { onCopyButtonClicked() }
|
||||
views.keysBackupRecoveryKeyText.setOnClickListener { onRecoveryKeyClicked() }
|
||||
}
|
||||
|
||||
private fun onFinishButtonClicked() {
|
||||
|
|
Loading…
Reference in New Issue