Fix baseline issues with RecipientSelectView

This commit is contained in:
cketti 2020-07-23 21:37:53 +02:00
parent 423575051d
commit 5b62e6c6a2
4 changed files with 36 additions and 6 deletions

View file

@ -0,0 +1,26 @@
package com.fsck.k9.ui.compose
import android.content.Context
import android.util.AttributeSet
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
/**
* Custom [ConstraintLayout] that returns an appropriate baseline value for our recipient token layout.
*/
class RecipientTokenConstraintLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
private lateinit var textView: TextView
override fun onFinishInflate() {
super.onFinishInflate()
textView = findViewById(android.R.id.text1)
}
override fun getBaseline(): Int {
return textView.top + textView.baseline
}
}

View file

@ -221,7 +221,7 @@
android:dropDownWidth="wrap_content"
android:dropDownAnchor="@id/to_wrapper"
tools:text="Recipient"
style="@style/ComposeEditText"
style="@style/RecipientEditText"
/>
<ViewAnimator
@ -291,7 +291,7 @@
android:paddingBottom="10dp"
android:dropDownWidth="wrap_content"
android:dropDownAnchor="@id/cc_wrapper"
style="@style/ComposeEditText"
style="@style/RecipientEditText"
/>
</LinearLayout>
@ -337,7 +337,7 @@
android:paddingBottom="10dp"
android:dropDownWidth="wrap_content"
android:dropDownAnchor="@id/bcc_wrapper"
style="@style/ComposeEditText"
style="@style/RecipientEditText"
/>
</LinearLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.fsck.k9.ui.compose.RecipientTokenConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
@ -20,6 +20,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@null"
android:minHeight="32dp"
app:layout_constraintBottom_toBottomOf="@android:id/text1"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
@ -132,4 +133,4 @@
app:srcCompat="@drawable/status_dots_3"
app:tint="?attr/openpgp_green" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.fsck.k9.ui.compose.RecipientTokenConstraintLayout>

View file

@ -6,9 +6,12 @@
<item name="android:textColor">#aaa</item>
</style>
<style name="ComposeEditText" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">15sp</item>
<item name="android:textSize">16sp</item>
<item name="android:textColorHint">#aaa</item>
</style>
<style name="RecipientEditText" parent="ComposeEditText">
<item name="android:lineSpacingExtra">4dp</item>
</style>
<style name="ComposeEditTextLarge" parent="@android:style/TextAppearance.Medium">
<item name="android:textColorHint">#aaa</item>
</style>