add checkmark to verified links and better constraints to account fields (#922)

* add checkmark to verified links and better constraints to account fields

* address pr feedback
This commit is contained in:
Konrad Pozniak 2018-12-03 11:02:28 +01:00 committed by GitHub
parent 19783c5aed
commit 8d7f879a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 13 deletions

View File

@ -33,9 +33,7 @@ class AccountFieldAdapter(private val linkListener: LinkListener) : RecyclerView
var emojis: List<Emoji> = emptyList()
var fields: List<Field> = emptyList()
override fun getItemCount(): Int {
return fields.size
}
override fun getItemCount() = fields.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountFieldAdapter.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_account_field, parent, false)
@ -43,9 +41,17 @@ class AccountFieldAdapter(private val linkListener: LinkListener) : RecyclerView
}
override fun onBindViewHolder(viewHolder: AccountFieldAdapter.ViewHolder, position: Int) {
viewHolder.nameTextView.text = fields[position].name
val emojifiedValue = CustomEmojiHelper.emojifyText(fields[position].value, emojis, viewHolder.valueTextView)
val field = fields[position]
viewHolder.nameTextView.text = field.name
val emojifiedValue = CustomEmojiHelper.emojifyText(field.value, emojis, viewHolder.valueTextView)
LinkHelper.setClickableText(viewHolder.valueTextView, emojifiedValue, null, linkListener)
if(field.verifiedAt != null) {
viewHolder.valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_check_circle, 0)
} else {
viewHolder.valueTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0 )
}
}
class ViewHolder(rootView: View) : RecyclerView.ViewHolder(rootView) {

View File

@ -24,6 +24,7 @@ import com.keylesspalace.tusky.util.HtmlUtils
import kotlinx.android.parcel.Parceler
import kotlinx.android.parcel.Parcelize
import kotlinx.android.parcel.WriteWith
import java.util.*
@Parcelize
data class Account(
@ -78,7 +79,8 @@ data class AccountSource(
@Parcelize
data class Field (
val name: String,
val value: @WriteWith<SpannedParceler>() Spanned
val value: @WriteWith<SpannedParceler>() Spanned,
@SerializedName("verified_at") val verifiedAt: Date?
): Parcelable
@Parcelize

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="18dp"
android:width="18dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="@color/color_accent_dark" android:pathData="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z" />
</vector>

View File

@ -7,28 +7,29 @@
android:orientation="horizontal"
android:paddingTop="4dp">
<!-- 30% width for the field name, 70% for the value -->
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/accountFieldName"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toStartOf="@+id/accountFieldValue"
app:layout_constraintStart_toStartOf="parent"
app:layout_constrainedWidth="true"
app:layout_constraintWidth_max="160dp"
tools:text="Field title " />
app:layout_constraintWidth_percent=".3"
tools:text="Field title" />
<android.support.text.emoji.widget.EmojiTextView
android:id="@+id/accountFieldValue"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:drawablePadding="6dp"
android:lineSpacingMultiplier="1.1"
android:textSize="?attr/status_text_medium"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/accountFieldName"
tools:text="Field content. This can contain links and custom emojis" />