2019-12-17 16:24:42 +01:00
|
|
|
package org.thoughtcrime.securesms.loki.redesign.views
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.widget.RelativeLayout
|
2019-12-18 11:36:09 +01:00
|
|
|
import kotlinx.android.synthetic.main.view_profile_picture.view.*
|
2019-12-17 16:24:42 +01:00
|
|
|
import network.loki.messenger.R
|
|
|
|
|
|
|
|
class ProfilePictureView : RelativeLayout {
|
|
|
|
var hexEncodedPublicKey: String? = null
|
|
|
|
var additionalHexEncodedPublicKey: String? = null
|
|
|
|
var isRSSFeed = false
|
|
|
|
|
|
|
|
// region Lifecycle
|
|
|
|
constructor(context: Context) : super(context) {
|
|
|
|
setUpViewHierarchy()
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
|
|
|
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.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
2019-12-18 11:36:09 +01:00
|
|
|
val contentView = inflater.inflate(R.layout.view_profile_picture, null)
|
2019-12-17 16:24:42 +01:00
|
|
|
addView(contentView)
|
|
|
|
}
|
2019-12-18 11:36:09 +01:00
|
|
|
// endregion
|
2019-12-17 16:24:42 +01:00
|
|
|
|
2019-12-18 11:36:09 +01:00
|
|
|
// region Updating
|
2019-12-17 16:24:42 +01:00
|
|
|
fun update() {
|
|
|
|
val hexEncodedPublicKey = hexEncodedPublicKey ?: return
|
|
|
|
val additionalHexEncodedPublicKey = additionalHexEncodedPublicKey
|
|
|
|
doubleModeImageViewContainer.visibility = if (additionalHexEncodedPublicKey != null && !isRSSFeed) View.VISIBLE else View.INVISIBLE
|
|
|
|
singleModeImageView.visibility = if (additionalHexEncodedPublicKey == null && !isRSSFeed) View.VISIBLE else View.INVISIBLE
|
|
|
|
rssTextView.visibility = if (isRSSFeed) View.VISIBLE else View.INVISIBLE
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
}
|