Skip to content

Commit

Permalink
fix: Ensure text in nav menu account header is legible
Browse files Browse the repository at this point in the history
The user might have set a profile header image that is close to the
colour of the text in the account header in the left navigation menu.
This can make the text difficult or impossible to see.

Work around this by drawing a partially transparent scrim behind the
text so it's always displayed over a background that makes the text
legible.

Fixes #298
  • Loading branch information
nikclayton committed Jun 22, 2024
1 parent 0574c21 commit 3fa499a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/app/pachli/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import com.mikepenz.iconics.IconicsSize
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.mikepenz.materialdrawer.holder.BadgeStyle
import com.mikepenz.materialdrawer.holder.ColorHolder
import com.mikepenz.materialdrawer.holder.ImageHolder
import com.mikepenz.materialdrawer.holder.StringHolder
import com.mikepenz.materialdrawer.iconics.iconicsIcon
import com.mikepenz.materialdrawer.model.AbstractDrawerItem
Expand Down Expand Up @@ -1057,9 +1058,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
}

private fun onFetchUserInfoSuccess(me: Account) {
glide.asBitmap()
.load(me.header)
.into(header.accountHeaderBackground)
header.headerBackground = ImageHolder(me.header)

loadDrawerAvatar(me.avatar, false)

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/material_drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<!-- Partially transparent scrim so the text is visible whatever the background is -->
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@null"
android:foreground="@color/account_header_scrim"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/material_drawer_text_guideline" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/material_drawer_statusbar_guideline"
android:layout_width="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions core/designsystem/src/main/res/values-night/theme_colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
<!-- colors used to show inserted/deleted text -->
<color name="view_edits_background_insert">#00731B</color>
<color name="view_edits_background_delete">#DF0000</color>

<color name="account_header_scrim">#8f000000</color>
</resources>
1 change: 1 addition & 0 deletions core/designsystem/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<color name="transparent_tusky_blue">#8c2b90d9</color>
<color name="transparent_black">#8f000000</color>
<color name="transparent_statusbar_background">#44000000</color>
<color name="account_header_scrim">#8fffffff</color>

<!-- colors used in the app icon -->
<color name="icon_background">#09497b</color>
Expand Down

0 comments on commit 3fa499a

Please sign in to comment.