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"> <declare-styleable name="SessionsListHeaderView">
<attr name="sessionsListHeaderTitle" format="string" /> <attr name="sessionsListHeaderTitle" format="string" />
<attr name="sessionsListHeaderDescription" format="string" /> <attr name="sessionsListHeaderDescription" format="string" />
<attr name="sessionsListHeaderHasLearnMoreLink" format="boolean" />
</declare-styleable> </declare-styleable>
</resources> </resources>

View File

@ -65,14 +65,23 @@ class SessionsListHeaderView @JvmOverloads constructor(
return 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 learnMore = context.getString(R.string.action_learn_more)
val fullDescription = buildString { val fullDescription = buildString {
append(description) append(description)
append(" ") append(" ")
append(learnMore) append(learnMore)
} }
binding.sessionsListHeaderDescription.isVisible = true
binding.sessionsListHeaderDescription.setTextWithColoredPart( binding.sessionsListHeaderDescription.setTextWithColoredPart(
fullText = fullDescription, fullText = fullDescription,
coloredPart = learnMore, coloredPart = learnMore,

View File

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