Skip to content
Snippets Groups Projects
Commit 60cac62a authored by Oliver Zimmerman's avatar Oliver Zimmerman
Browse files

Rename custom view to Section instead of Card to avoid confusion with existing views

parent 1017cc57
No related branches found
No related tags found
No related merge requests found
package de.rki.coronawarnapp.ui.view
import android.content.Context
import android.text.SpannableString
import android.util.AttributeSet
import androidx.appcompat.content.res.AppCompatResources.getDrawable
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.withStyledAttributes
import de.rki.coronawarnapp.R
import kotlinx.android.synthetic.main.view_test_result_card.view.*
import kotlinx.android.synthetic.main.view_test_result_section.view.*
/**
* The [TestResultCard] Displays the appropriate test result.
* The [TestResultSection] Displays the appropriate test result.
*/
class TestResultCard @JvmOverloads constructor(
class TestResultSection @JvmOverloads
constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
init {
inflate(context, R.layout.view_test_result_card, this)
context.withStyledAttributes(attrs, R.styleable.TestResultCard) {
test_result_card_headline.text = getString(R.styleable.TestResultCard_test_result_card_headline)
test_result_card_content.text = getString(R.styleable.TestResultCard_test_result_card_content)
test_result_card_registered_at_text.text =
getString(R.styleable.TestResultCard_test_result_card_registered_at_text)
val resultIconId = getResourceId(R.styleable.TestResultCard_test_result_card_status_icon, 0)
inflate(context, R.layout.view_test_result_section, this)
context.withStyledAttributes(attrs, R.styleable.TestResultSection) {
test_result_section_headline.text = getString(R.styleable.TestResultSection_test_result_section_headline)
test_result_section_content.text = SpannableString(getString(R.styleable.TestResultSection_test_result_section_content))
test_result_section_registered_at_text.text =
getString(R.styleable.TestResultSection_test_result_section_registered_at_text)
val resultIconId = getResourceId(R.styleable.TestResultSection_test_result_section_status_icon, 0)
if (resultIconId != 0) {
val drawable = getDrawable(context, resultIconId)
test_result_card_status_icon.setImageDrawable(drawable)
test_result_section_status_icon.setImageDrawable(drawable)
}
}
}
}
......@@ -12,32 +12,32 @@
android:padding="@dimen/card_padding">
<TextView
android:id="@+id/test_result_card_headline"
android:id="@+id/test_result_section_headline"
style="@style/body2"
android:accessibilityHeading="true"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_small"
app:layout_constraintEnd_toStartOf="@id/test_result_card_status_icon"
app:layout_constraintEnd_toStartOf="@id/test_result_section_status_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Ihr Befund"/>
<TextView
android:id="@+id/test_result_card_content"
android:id="@+id/test_result_section_content"
style="@style/headline5"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_small"
android:layout_marginBottom="@dimen/spacing_normal"
app:layout_constraintBottom_toTopOf="@id/test_result_card_registered_at_text"
app:layout_constraintEnd_toStartOf="@id/test_result_card_status_icon"
app:layout_constraintBottom_toTopOf="@id/test_result_section_registered_at_text"
app:layout_constraintEnd_toStartOf="@id/test_result_section_status_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/test_result_card_headline"
app:layout_constraintTop_toBottomOf="@id/test_result_section_headline"
tools:text="SARS-CoV-2 Negativ" />
<ImageView
android:id="@+id/test_result_card_status_icon"
android:id="@+id/test_result_section_status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
......@@ -46,14 +46,14 @@
tools:src="@drawable/ic_test_result_illustration_negative" />
<TextView
android:id="@+id/test_result_card_registered_at_text"
android:id="@+id/test_result_section_registered_at_text"
style="@style/body2"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginEnd="@dimen/spacing_small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/test_result_card_status_icon"
app:layout_constraintEnd_toStartOf="@id/test_result_section_status_icon"
app:layout_constraintStart_toStartOf="parent"
tools:text="@string/test_result_card_registered_at_text" />
......
......@@ -19,10 +19,10 @@
<declare-styleable name="BulletPointList">
<attr name="entries" format="reference" />
</declare-styleable>
<declare-styleable name="TestResultCard">
<attr name="test_result_card_headline" format="string" />
<attr name="test_result_card_content" format="string" />
<attr name="test_result_card_status_icon" format="reference" />
<attr name="test_result_card_registered_at_text" format="string" />
<declare-styleable name="TestResultSection">
<attr name="test_result_section_headline" format="string" />
<attr name="test_result_section_content" format="string" />
<attr name="test_result_section_status_icon" format="reference" />
<attr name="test_result_section_registered_at_text" format="string" />
</declare-styleable>
</resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment