From 8ce4c697cea6b9f88da2698e2390550957d284a5 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 3 Dec 2018 11:02:28 +0100 Subject: [PATCH] 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 --- .../tusky/adapter/AccountFieldAdapter.kt | 16 +++++++++++----- .../com/keylesspalace/tusky/entity/Account.kt | 4 +++- app/src/main/res/drawable/ic_check_circle.xml | 8 ++++++++ app/src/main/res/layout/item_account_field.xml | 15 ++++++++------- 4 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/ic_check_circle.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountFieldAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountFieldAdapter.kt index 2f1ece54..c83c778d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/AccountFieldAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/AccountFieldAdapter.kt @@ -33,9 +33,7 @@ class AccountFieldAdapter(private val linkListener: LinkListener) : RecyclerView var emojis: List = emptyList() var fields: List = 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) { diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt index 52dd7f91..88df75ce 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Account.kt @@ -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() Spanned + val value: @WriteWith() Spanned, + @SerializedName("verified_at") val verifiedAt: Date? ): Parcelable @Parcelize diff --git a/app/src/main/res/drawable/ic_check_circle.xml b/app/src/main/res/drawable/ic_check_circle.xml new file mode 100644 index 00000000..1503448e --- /dev/null +++ b/app/src/main/res/drawable/ic_check_circle.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_account_field.xml b/app/src/main/res/layout/item_account_field.xml index 0b06b9b0..8a4c062d 100644 --- a/app/src/main/res/layout/item_account_field.xml +++ b/app/src/main/res/layout/item_account_field.xml @@ -7,28 +7,29 @@ android:orientation="horizontal" android:paddingTop="4dp"> + + app:layout_constraintWidth_percent=".3" + tools:text="Field title" />