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 emojis: List<Emoji> = emptyList()
var fields: List<Field> = emptyList() var fields: List<Field> = emptyList()
override fun getItemCount(): Int { override fun getItemCount() = fields.size
return fields.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountFieldAdapter.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountFieldAdapter.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_account_field, parent, false) 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) { override fun onBindViewHolder(viewHolder: AccountFieldAdapter.ViewHolder, position: Int) {
viewHolder.nameTextView.text = fields[position].name val field = fields[position]
val emojifiedValue = CustomEmojiHelper.emojifyText(fields[position].value, emojis, viewHolder.valueTextView) viewHolder.nameTextView.text = field.name
val emojifiedValue = CustomEmojiHelper.emojifyText(field.value, emojis, viewHolder.valueTextView)
LinkHelper.setClickableText(viewHolder.valueTextView, emojifiedValue, null, linkListener) 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) { 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.Parceler
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
import kotlinx.android.parcel.WriteWith import kotlinx.android.parcel.WriteWith
import java.util.*
@Parcelize @Parcelize
data class Account( data class Account(
@ -78,7 +79,8 @@ data class AccountSource(
@Parcelize @Parcelize
data class Field ( data class Field (
val name: String, val name: String,
val value: @WriteWith<SpannedParceler>() Spanned val value: @WriteWith<SpannedParceler>() Spanned,
@SerializedName("verified_at") val verifiedAt: Date?
): Parcelable ): Parcelable
@Parcelize @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:orientation="horizontal"
android:paddingTop="4dp"> android:paddingTop="4dp">
<!-- 30% width for the field name, 70% for the value -->
<android.support.text.emoji.widget.EmojiTextView <android.support.text.emoji.widget.EmojiTextView
android:id="@+id/accountFieldName" android:id="@+id/accountFieldName"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium" android:fontFamily="sans-serif-medium"
android:gravity="center"
android:lineSpacingMultiplier="1.1" android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toStartOf="@+id/accountFieldValue"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constrainedWidth="true" app:layout_constraintWidth_percent=".3"
app:layout_constraintWidth_max="160dp" tools:text="Field title" />
tools:text="Field title " />
<android.support.text.emoji.widget.EmojiTextView <android.support.text.emoji.widget.EmojiTextView
android:id="@+id/accountFieldValue" android:id="@+id/accountFieldValue"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:drawablePadding="6dp"
android:lineSpacingMultiplier="1.1" android:lineSpacingMultiplier="1.1"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/accountFieldName" app:layout_constraintStart_toEndOf="@+id/accountFieldName"
tools:text="Field content. This can contain links and custom emojis" /> tools:text="Field content. This can contain links and custom emojis" />