From 70092c8de2f4e34cf113c72cc0d4eff435c008d7 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Thu, 23 Feb 2023 19:30:27 +0100 Subject: [PATCH] Make "Up" and "Overflow" menu icons more visible in AccountProfile (#3272) * Make "Up" and "Overflow" menu icons more visible in AccountProfile The toolbar in AccountProfile is transparent, so any profile image the user has chosen is shown under it. This makes the "Up" and "Overflow" menu icons also have transparent backgrouns. Consequently, they can be hard to spot, or possibly invisible, on backgrounds that are very dark or very light. Fix this by compositing the icons in a LayerDrawable, with a circular background identical to the surface colour. This ensures they stand out against the background image, and blend in when the user scrolls. * Get and reuse the background drawable * Apply a smidgen of transparency --- .../components/account/AccountActivity.kt | 19 +++++++++++++++++++ .../main/res/drawable/background_circle.xml | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 app/src/main/res/drawable/background_circle.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt index 7f17bfe5..ba261c1d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt @@ -22,6 +22,7 @@ import android.content.Context import android.content.Intent import android.content.res.ColorStateList import android.graphics.Color +import android.graphics.drawable.LayerDrawable import android.os.Bundle import android.text.Editable import android.view.Menu @@ -32,6 +33,7 @@ import androidx.activity.viewModels import androidx.annotation.ColorInt import androidx.annotation.Px import androidx.appcompat.app.AlertDialog +import androidx.appcompat.content.res.AppCompatResources import androidx.core.app.ActivityOptionsCompat import androidx.core.view.ViewCompat import androidx.core.view.WindowCompat @@ -299,6 +301,23 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI toolbarBackground.fillColor = ColorStateList.valueOf(Color.TRANSPARENT) binding.accountToolbar.background = toolbarBackground + // Provide a non-transparent background to the navigation and overflow icons to ensure + // they remain visible over whatever the profile background image might be. + val backgroundCircle = AppCompatResources.getDrawable(this, R.drawable.background_circle)!! + backgroundCircle.alpha = 210 // Any lower than this and the backgrounds interfere + binding.accountToolbar.navigationIcon = LayerDrawable( + arrayOf( + backgroundCircle, + binding.accountToolbar.navigationIcon + ) + ) + binding.accountToolbar.overflowIcon = LayerDrawable( + arrayOf( + backgroundCircle, + binding.accountToolbar.overflowIcon + ) + ) + binding.accountHeaderInfoContainer.background = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation) val avatarBackground = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation).apply { diff --git a/app/src/main/res/drawable/background_circle.xml b/app/src/main/res/drawable/background_circle.xml new file mode 100644 index 00000000..e10c9756 --- /dev/null +++ b/app/src/main/res/drawable/background_circle.xml @@ -0,0 +1,5 @@ + + + +