Removing learn more link from security header

This commit is contained in:
Maxime NATUREL 2022-09-12 14:54:26 +02:00
parent 70a5093e3d
commit 1d11eae0cc
3 changed files with 15 additions and 2 deletions

View file

@ -4,6 +4,7 @@
<declare-styleable name="SessionsListHeaderView">
<attr name="sessionsListHeaderTitle" format="string" />
<attr name="sessionsListHeaderDescription" format="string" />
<attr name="sessionsListHeaderHasLearnMoreLink" format="boolean" />
</declare-styleable>
</resources>

View file

@ -65,14 +65,23 @@ class SessionsListHeaderView @JvmOverloads constructor(
return
}
val hasLearnMoreLink = typedArray.getBoolean(R.styleable.SessionsListHeaderView_sessionsListHeaderHasLearnMoreLink, true)
if(hasLearnMoreLink) {
setDescriptionWithLearnMore(description)
} else {
binding.sessionsListHeaderDescription.text = description
}
binding.sessionsListHeaderDescription.isVisible = true
}
private fun setDescriptionWithLearnMore(description: String) {
val learnMore = context.getString(R.string.action_learn_more)
val fullDescription = buildString {
append(description)
append(" ")
append(learnMore)
}
binding.sessionsListHeaderDescription.isVisible = true
binding.sessionsListHeaderDescription.setTextWithColoredPart(
fullText = fullDescription,
coloredPart = learnMore,

View file

@ -14,6 +14,7 @@
android:layout_height="wrap_content"
app:sessionsListHeaderDescription="@string/device_manager_header_section_security_recommendations_description"
app:sessionsListHeaderTitle="@string/device_manager_header_section_security_recommendations_title"
app:sessionsListHeaderHasLearnMoreLink="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -62,6 +63,7 @@
android:layout_height="wrap_content"
app:sessionsListHeaderDescription=""
app:sessionsListHeaderTitle="@string/device_manager_current_session_title"
app:sessionsListHeaderHasLearnMoreLink="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/deviceListSecurityRecommendationsDivider" />
@ -92,6 +94,7 @@
android:layout_height="wrap_content"
app:sessionsListHeaderDescription="@string/device_manager_sessions_other_description"
app:sessionsListHeaderTitle="@string/device_manager_sessions_other_title"
app:sessionsListHeaderHasLearnMoreLink="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/deviceListDividerCurrentSession" />