Browse Source

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
pull/3361/head
Nik Clayton 3 years ago committed by GitHub
parent
commit
70092c8de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/src/main/java/com/keylesspalace/tusky/components/account/AccountActivity.kt
  2. 5
      app/src/main/res/drawable/background_circle.xml

19
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 {

5
app/src/main/res/drawable/background_circle.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="?attr/colorSurface" />
</shape>
Loading…
Cancel
Save