Fix profile picture size issue

This commit is contained in:
Niels Andriesse 2021-07-01 10:02:02 +10:00
parent 0221784d60
commit 6aa4ad1cd0
3 changed files with 19 additions and 19 deletions

View File

@ -18,8 +18,10 @@ import android.util.Log
import android.util.Pair import android.util.Pair
import android.util.TypedValue import android.util.TypedValue
import android.view.* import android.view.*
import android.widget.LinearLayout
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.Toast import android.widget.Toast
import androidx.annotation.DimenRes
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@ -281,6 +283,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
actionBar.setCustomView(R.layout.activity_conversation_v2_action_bar) actionBar.setCustomView(R.layout.activity_conversation_v2_action_bar)
actionBar.setDisplayShowCustomEnabled(true) actionBar.setDisplayShowCustomEnabled(true)
conversationTitleView.text = thread.toShortString() conversationTitleView.text = thread.toShortString()
@DimenRes val sizeID: Int
if (thread.isClosedGroupRecipient) {
sizeID = R.dimen.medium_profile_picture_size
} else {
sizeID = R.dimen.small_profile_picture_size
}
val size = resources.getDimension(sizeID).roundToInt()
profilePictureView.layoutParams = LinearLayout.LayoutParams(size, size)
profilePictureView.glide = glide profilePictureView.glide = glide
profilePictureView.update(thread, threadID) profilePictureView.update(thread, threadID)
} }

View File

@ -31,23 +31,12 @@ class ProfilePictureView : RelativeLayout {
private val profilePicturesCache = mutableMapOf<String, String?>() private val profilePicturesCache = mutableMapOf<String, String?>()
// region Lifecycle // region Lifecycle
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) { initialize() }
setUpViewHierarchy() constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
} constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { initialize() }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { private fun initialize() {
setUpViewHierarchy()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
setUpViewHierarchy()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
setUpViewHierarchy()
}
private fun setUpViewHierarchy() {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contentView = inflater.inflate(R.layout.view_profile_picture, null) val contentView = inflater.inflate(R.layout.view_profile_picture, null)
addView(contentView) addView(contentView)

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
@ -9,8 +10,8 @@
<org.thoughtcrime.securesms.loki.views.ProfilePictureView <org.thoughtcrime.securesms.loki.views.ProfilePictureView
android:id="@+id/profilePictureView" android:id="@+id/profilePictureView"
android:layout_width="@dimen/small_profile_picture_size" android:layout_width="@dimen/medium_profile_picture_size"
android:layout_height="@dimen/small_profile_picture_size" /> android:layout_height="@dimen/medium_profile_picture_size" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"