Merge pull request #3515 from vector-im/feature/bma/fix_crash_theme

Feature/bma/fix crash theme
This commit is contained in:
Benoit Marty 2021-06-16 21:36:30 +02:00 committed by GitHub
commit cb57b1496f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 97 additions and 94 deletions

View File

@ -18,8 +18,6 @@ package im.vector.app.features.crypto.verification.epoxy
import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute
@ -27,6 +25,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.databinding.ItemEmojiVerifBinding
import me.gujun.android.span.Span
import me.gujun.android.span.image
import me.gujun.android.span.span
@ -68,16 +67,18 @@ abstract class BottomSheetVerificationEmojisItem : VectorEpoxyModel<BottomSheetV
}
private fun bindEmojiView(view: ViewGroup, rep: EmojiRepresentation) {
rep.drawableRes?.let {
view.findViewById<TextView>(R.id.item_emoji_tv).isVisible = false
view.findViewById<ImageView>(R.id.item_emoji_image).isVisible = true
view.findViewById<ImageView>(R.id.item_emoji_image).setImageDrawable(ContextCompat.getDrawable(view.context, it))
} ?: run {
view.findViewById<TextView>(R.id.item_emoji_tv).isVisible = true
view.findViewById<ImageView>(R.id.item_emoji_image).isVisible = false
view.findViewById<TextView>(R.id.item_emoji_tv).text = rep.emoji
val views = ItemEmojiVerifBinding.bind(view)
val drawableRes = rep.drawableRes
if (drawableRes != null) {
views.itemEmojiTv.isVisible = false
views.itemEmojiImage.isVisible = true
views.itemEmojiImage.setImageDrawable(ContextCompat.getDrawable(view.context, drawableRes))
} else {
views.itemEmojiTv.isVisible = true
views.itemEmojiImage.isVisible = false
views.itemEmojiTv.text = rep.emoji
}
view.findViewById<TextView>(R.id.item_emoji_name_tv).setText(rep.nameResId)
views.itemEmojiNameTv.setText(rep.nameResId)
}
class Holder : VectorEpoxyHolder() {

View File

@ -69,7 +69,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
holder.acceptView.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.AcceptCall(callId = attributes.callId))
}
holder.rejectView.setLeftDrawable(R.drawable.ic_call_hangup, R.attr.colorError)
holder.rejectView.setLeftDrawable(R.drawable.ic_call_hangup, R.attr.colorOnPrimary)
holder.rejectView.onClick {
attributes.callback?.onTimelineItemAction(RoomDetailAction.EndCall)
}
@ -78,17 +78,17 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem<CallTileTimelineItem.Ho
CallKind.CONFERENCE -> {
holder.rejectView.setText(R.string.ignore)
holder.acceptView.setText(R.string.join)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorPrimary)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorOnPrimary)
}
CallKind.AUDIO -> {
holder.rejectView.setText(R.string.call_notification_reject)
holder.acceptView.setText(R.string.call_notification_answer)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorPrimary)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorOnPrimary)
}
CallKind.VIDEO -> {
holder.rejectView.setText(R.string.call_notification_reject)
holder.acceptView.setText(R.string.call_notification_answer)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.attr.colorPrimary)
holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.attr.colorOnPrimary)
}
else -> {
Timber.w("Shouldn't be in that state")

View File

@ -18,11 +18,10 @@ package im.vector.app.features.popup
import android.app.Activity
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import im.vector.app.R
import im.vector.app.core.extensions.setLeftDrawable
import im.vector.app.core.glide.GlideApp
import im.vector.app.databinding.AlerterIncomingCallLayoutBinding
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -40,30 +39,24 @@ class IncomingCallAlert(uid: String,
private val avatarRenderer: AvatarRenderer,
private val isVideoCall: Boolean,
private val onAccept: () -> Unit,
private val onReject: () -> Unit)
: VectorAlert.ViewBinder {
private val onReject: () -> Unit) : VectorAlert.ViewBinder {
override fun bind(view: View) {
val (callKindText, callKindIcon) = if (isVideoCall) {
Pair(R.string.action_video_call, R.drawable.ic_call_video_small)
val views = AlerterIncomingCallLayoutBinding.bind(view)
val (callKindText, callKindIcon, callKindActionIcon) = if (isVideoCall) {
Triple(R.string.action_video_call, R.drawable.ic_call_video_small, R.drawable.ic_call_answer_video)
} else {
Pair(R.string.action_voice_call, R.drawable.ic_call_audio_small)
Triple(R.string.action_voice_call, R.drawable.ic_call_audio_small, R.drawable.ic_call_answer)
}
view.findViewById<TextView>(R.id.incomingCallKindView).apply {
setText(callKindText)
setLeftDrawable(callKindIcon)
views.incomingCallKindView.setText(callKindText)
views.incomingCallKindView.setLeftDrawable(callKindIcon)
views.incomingCallNameView.text = matrixItem?.getBestName()
matrixItem?.let { avatarRenderer.render(it, views.incomingCallAvatar, GlideApp.with(view.context.applicationContext)) }
views.incomingCallAcceptView.setOnClickListener {
onAccept()
}
view.findViewById<TextView>(R.id.incomingCallNameView).text = matrixItem?.getBestName()
view.findViewById<ImageView>(R.id.incomingCallAvatar)?.let { imageView ->
matrixItem?.let { avatarRenderer.render(it, imageView, GlideApp.with(view.context.applicationContext)) }
}
view.findViewById<ImageView>(R.id.incomingCallAcceptView).apply {
setOnClickListener {
onAccept()
}
setImageResource(callKindIcon)
}
view.findViewById<ImageView>(R.id.incomingCallRejectView).setOnClickListener {
views.incomingCallAcceptView.setImageResource(callKindActionIcon)
views.incomingCallRejectView.setOnClickListener {
onReject()
}
}

View File

@ -18,10 +18,10 @@ package im.vector.app.features.popup
import android.app.Activity
import android.view.View
import android.widget.ImageView
import androidx.annotation.DrawableRes
import im.vector.app.R
import im.vector.app.core.glide.GlideApp
import im.vector.app.databinding.AlerterVerificationLayoutBinding
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -33,19 +33,15 @@ class VerificationVectorAlert(uid: String,
* Alert are displayed by default, but let this lambda return false to prevent displaying
*/
override val shouldBeDisplayedIn: ((Activity) -> Boolean) = { true }
) : DefaultVectorAlert(
uid, title, description, iconId, shouldBeDisplayedIn
) {
) : DefaultVectorAlert(uid, title, description, iconId, shouldBeDisplayedIn) {
override val layoutRes = R.layout.alerter_verification_layout
class ViewBinder(private val matrixItem: MatrixItem?,
private val avatarRenderer: AvatarRenderer)
: VectorAlert.ViewBinder {
private val avatarRenderer: AvatarRenderer) : VectorAlert.ViewBinder {
override fun bind(view: View) {
view.findViewById<ImageView>(R.id.ivUserAvatar)?.let { imageView ->
matrixItem?.let { avatarRenderer.render(it, imageView, GlideApp.with(view.context.applicationContext)) }
}
val views = AlerterVerificationLayoutBinding.bind(view)
matrixItem?.let { avatarRenderer.render(it, views.ivUserAvatar, GlideApp.with(view.context.applicationContext)) }
}
}
}

View File

@ -18,13 +18,10 @@ package im.vector.app.features.settings.troubleshoot
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import im.vector.app.R
import im.vector.app.databinding.ItemNotificationTroubleshootBinding
import im.vector.app.features.themes.ThemeUtils
class NotificationTroubleshootRecyclerViewAdapter(val tests: ArrayList<TroubleshootTest>)
@ -46,71 +43,67 @@ class NotificationTroubleshootRecyclerViewAdapter(val tests: ArrayList<Troublesh
override fun getItemCount(): Int = tests.size
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val troubleshootProgressBar = itemView.findViewById<ProgressBar>(R.id.troubleshootProgressBar)
private val troubleshootTestTitle = itemView.findViewById<TextView>(R.id.troubleshootTestTitle)
private val troubleshootTestDescription = itemView.findViewById<TextView>(R.id.troubleshootTestDescription)
private val troubleshootStatusIcon = itemView.findViewById<ImageView>(R.id.troubleshootStatusIcon)
private val troubleshootTestButton = itemView.findViewById<Button>(R.id.troubleshootTestButton)
private val views = ItemNotificationTroubleshootBinding.bind(itemView)
fun bind(test: TroubleshootTest) {
val context = itemView.context
troubleshootTestTitle.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_primary))
troubleshootTestDescription.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
views.troubleshootTestTitle.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_primary))
views.troubleshootTestDescription.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
when (test.status) {
TroubleshootTest.TestStatus.NOT_STARTED -> {
troubleshootTestTitle.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
views.troubleshootTestTitle.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
troubleshootProgressBar.visibility = View.INVISIBLE
troubleshootStatusIcon.visibility = View.VISIBLE
troubleshootStatusIcon.setImageResource(R.drawable.unit_test)
views.troubleshootProgressBar.visibility = View.INVISIBLE
views.troubleshootStatusIcon.visibility = View.VISIBLE
views.troubleshootStatusIcon.setImageResource(R.drawable.unit_test)
}
TroubleshootTest.TestStatus.WAITING_FOR_USER -> {
troubleshootProgressBar.visibility = View.INVISIBLE
troubleshootStatusIcon.visibility = View.VISIBLE
views.troubleshootProgressBar.visibility = View.INVISIBLE
views.troubleshootStatusIcon.visibility = View.VISIBLE
val infoColor = ContextCompat.getColor(context, R.color.vector_info_color)
val drawable = ContextCompat.getDrawable(itemView.context, R.drawable.ic_notification_privacy_warning)?.apply {
ThemeUtils.tintDrawableWithColor(this, infoColor)
}
troubleshootStatusIcon.setImageDrawable(drawable)
troubleshootTestDescription.setTextColor(infoColor)
views.troubleshootStatusIcon.setImageDrawable(drawable)
views.troubleshootTestDescription.setTextColor(infoColor)
}
TroubleshootTest.TestStatus.RUNNING -> {
troubleshootProgressBar.visibility = View.VISIBLE
troubleshootStatusIcon.visibility = View.INVISIBLE
views.troubleshootProgressBar.visibility = View.VISIBLE
views.troubleshootStatusIcon.visibility = View.INVISIBLE
}
TroubleshootTest.TestStatus.FAILED -> {
troubleshootProgressBar.visibility = View.INVISIBLE
troubleshootStatusIcon.visibility = View.VISIBLE
troubleshootStatusIcon.setImageResource(R.drawable.unit_test_ko)
troubleshootStatusIcon.imageTintList = null
troubleshootTestDescription.setTextColor(ThemeUtils.getColor(context, R.attr.colorError))
views.troubleshootProgressBar.visibility = View.INVISIBLE
views.troubleshootStatusIcon.visibility = View.VISIBLE
views.troubleshootStatusIcon.setImageResource(R.drawable.unit_test_ko)
views.troubleshootStatusIcon.imageTintList = null
views.troubleshootTestDescription.setTextColor(ThemeUtils.getColor(context, R.attr.colorError))
}
TroubleshootTest.TestStatus.SUCCESS -> {
troubleshootProgressBar.visibility = View.INVISIBLE
troubleshootStatusIcon.visibility = View.VISIBLE
troubleshootStatusIcon.setImageResource(R.drawable.unit_test_ok)
views.troubleshootProgressBar.visibility = View.INVISIBLE
views.troubleshootStatusIcon.visibility = View.VISIBLE
views.troubleshootStatusIcon.setImageResource(R.drawable.unit_test_ok)
}
}
val quickFix = test.quickFix
if (quickFix != null) {
troubleshootTestButton.setText(test.quickFix!!.title)
troubleshootTestButton.setOnClickListener {
views.troubleshootTestButton.setText(test.quickFix!!.title)
views.troubleshootTestButton.setOnClickListener {
test.quickFix!!.doFix()
}
troubleshootTestButton.visibility = View.VISIBLE
views.troubleshootTestButton.visibility = View.VISIBLE
} else {
troubleshootTestButton.visibility = View.GONE
views.troubleshootTestButton.visibility = View.GONE
}
troubleshootTestTitle.setText(test.titleResId)
views.troubleshootTestTitle.setText(test.titleResId)
val description = test.description
if (description == null) {
troubleshootTestDescription.visibility = View.GONE
views.troubleshootTestDescription.visibility = View.GONE
} else {
troubleshootTestDescription.visibility = View.VISIBLE
troubleshootTestDescription.text = description
views.troubleshootTestDescription.visibility = View.VISIBLE
views.troubleshootTestDescription.text = description
}
}
}

View File

@ -21,11 +21,9 @@ import android.content.Intent
import android.webkit.WebChromeClient
import android.webkit.WebView
import androidx.annotation.CallSuper
import im.vector.app.R
import im.vector.app.core.di.ScreenComponent
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityVectorWebViewBinding
import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject
@ -48,7 +46,7 @@ class VectorWebViewActivity : VectorBaseActivity<ActivityVectorWebViewBinding>()
override fun initUiAndData() {
configureToolbar(views.webviewToolbar)
waitingView = findViewById(R.id.simple_webview_loader)
waitingView = views.simpleWebviewLoader
views.simpleWebview.settings.apply {
// Enable Javascript

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="25dp"
android:viewportWidth="25"
android:viewportHeight="25">
<path
android:pathData="M0.5,7.5C0.5,5.8432 1.8432,4.5 3.5,4.5H14.5C16.1569,4.5 17.5,5.8432 17.5,7.5V17.5C17.5,19.1569 16.1569,20.5 14.5,20.5H3.5C1.8432,20.5 0.5,19.1569 0.5,17.5V7.5Z"
android:fillColor="#FFFFFF"/>
<path
android:pathData="M19.5,9.5L22.8753,6.7998C23.5301,6.2759 24.5,6.7421 24.5,7.5806V17.4194C24.5,18.2579 23.5301,18.7241 22.8753,18.2002L19.5,15.5V9.5Z"
android:fillColor="#FFFFFF"/>
</vector>

View File

@ -51,6 +51,7 @@
app:layout_constraintEnd_toStartOf="@+id/incomingCallRejectView"
app:layout_constraintStart_toStartOf="@id/incomingCallNameView"
app:layout_constraintTop_toBottomOf="@id/incomingCallNameView"
tools:drawableStart="@drawable/ic_call_audio_small"
tools:text="@string/action_voice_call" />
<ImageView
@ -64,10 +65,12 @@
android:contentDescription="@string/call_notification_answer"
android:focusable="true"
android:padding="8dp"
android:src="@drawable/ic_call_answer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorOnPrimary"
tools:ignore="MissingPrefix"
tools:src="@drawable/ic_call_answer" />
<ImageView
android:id="@+id/incomingCallRejectView"
@ -83,6 +86,8 @@
android:src="@drawable/ic_call_hangup"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/incomingCallAcceptView"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorOnPrimary"
tools:ignore="MissingPrefix" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -5,8 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
tools:background="@android:color/darker_gray"
tools:foreground="?android:attr/selectableItemBackground"
tools:background="?colorPrimary"
tools:style="@style/AlertStyle">
<ImageView
@ -20,7 +19,8 @@
app:layout_constraintTop_toTopOf="parent"
tools:src="@sample/user_round_avatars" />
<ImageView
<!-- Note: this is handled by the Alerter library, it has to be a AppCompatImageView -->
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivIcon"
android:layout_width="24dp"
android:layout_height="24dp"
@ -42,7 +42,8 @@
app:layout_constraintStart_toEndOf="@id/ivUserAvatar"
app:layout_constraintTop_toTopOf="parent">
<TextView
<!-- Note: this is handled by the Alerter library, it has to be a AppCompatTextView -->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvTitle"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="wrap_content"
@ -56,7 +57,8 @@
tools:text="Title"
tools:visibility="visible" />
<TextView
<!-- Note: this is handled by the Alerter library, it has to be a AppCompatTextView -->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvText"
style="@style/Widget.Vector.TextView.Body"
android:layout_width="wrap_content"

View File

@ -25,6 +25,7 @@
android:focusable="true"
android:padding="12dp"
android:src="@drawable/ic_call_answer"
app:tint="?colorOnPrimary"
tools:ignore="MissingConstraints,MissingPrefix" />
<ImageView
@ -38,6 +39,7 @@
android:focusable="true"
android:padding="12dp"
android:src="@drawable/ic_call_hangup"
app:tint="?colorOnPrimary"
tools:ignore="MissingConstraints,MissingPrefix" />
<androidx.constraintlayout.helper.widget.Flow
@ -100,6 +102,7 @@
android:focusable="true"
android:padding="12dp"
android:src="@drawable/ic_call_hangup"
app:tint="?colorOnPrimary"
tools:ignore="MissingConstraints,MissingPrefix" />
<ImageView

View File

@ -5,6 +5,6 @@
android:id="@+id/roomProfileShareAction"
android:icon="@drawable/ic_material_share"
android:title="@string/share"
app:iconTint="?vctr_content_secondary"
app:iconTint="?colorSecondary"
app:showAsAction="ifRoom" />
</menu>