ui: rework iconography

Completely rework Auxio's iconography based on the new material symbols
icon set.

This does the following:
1. Switches the sharp + filled icon style to an outlined + round icon
style.
2. Removes 32dp icons from everywhere except the playback panel.

This does not:
1. Actually handle optical sizes right. This is going to take some more
work to make it harmonious with the current UI.
2. Update margins in some places to be harmonious with the new icons.
This is also going to take some more work to do properly.
This commit is contained in:
OxygenCobalt
2022-06-30 21:09:21 -06:00
parent 9a17806da1
commit 090a1713dd
135 changed files with 653 additions and 674 deletions
@@ -44,7 +44,7 @@ class AuxioApp : Application(), ImageLoaderFactory {
ShortcutInfoCompat.Builder(this, SHORTCUT_SHUFFLE_ID)
.setShortLabel(getString(R.string.lbl_shuffle_shortcut_short))
.setLongLabel(getString(R.string.lbl_shuffle_shortcut_long))
.setIcon(IconCompat.createWithResource(this, R.drawable.ic_shuffle_shortcut))
.setIcon(IconCompat.createWithResource(this, R.drawable.ic_shortcut_shuffle_24))
.setIntent(
Intent(this, MainActivity::class.java).apply {
action = INTENT_KEY_SHORTCUT_SHUFFLE
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.image.ui
package org.oxycblt.auxio.image
import android.annotation.SuppressLint
import android.content.Context
@@ -50,7 +50,6 @@ class ImageGroup
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
FrameLayout(context, attrs, defStyleAttr) {
private val cornerRadius: Float
private val inner: StyledImageView
private var customView: View? = null
private val indicator: StyledImageView
@@ -67,7 +66,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
indicator =
StyledImageView(context).apply {
cornerRadius = this@ImageGroup.cornerRadius
staticIcon = context.getDrawableSafe(R.drawable.ic_equalizer)
staticIcon = context.getDrawableSafe(R.drawable.ic_currently_playing_24)
}
addView(inner)
@@ -15,9 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.image.ui
package org.oxycblt.auxio.image
import android.content.Context
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import androidx.annotation.AttrRes
@@ -25,11 +28,11 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.DrawableCompat
import coil.dispose
import coil.load
import com.google.android.material.shape.MaterialShapeDrawable
import org.oxycblt.auxio.R
import org.oxycblt.auxio.image.SquareFrameTransform
import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.Genre
@@ -68,11 +71,12 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
var staticIcon: Drawable? = null
set(value) {
val wrapped = value?.let { StyledDrawable(context, it) }
field = wrapped
field = value?.let { StyledDrawable(context, it) }
setImageDrawable(field)
}
private var useLargeIcon: Boolean = false
init {
// Use clipToOutline and a background drawable to crop images. While Coil's transformation
// could theoretically be used to round corners, the corner radius is dependent on the
@@ -88,28 +92,30 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.StyledImageView)
val staticIconRes =
val staticIcon =
styledAttrs.getResourceId(
R.styleable.StyledImageView_staticIcon, ResourcesCompat.ID_NULL)
if (staticIconRes != ResourcesCompat.ID_NULL) {
staticIcon = context.getDrawableSafe(staticIconRes)
if (staticIcon != ResourcesCompat.ID_NULL) {
this.staticIcon = context.getDrawableSafe(staticIcon)
}
useLargeIcon = styledAttrs.getBoolean(R.styleable.StyledImageView_useLargeIcon, false)
cornerRadius = styledAttrs.getDimension(R.styleable.StyledImageView_cornerRadius, 0f)
styledAttrs.recycle()
}
/** Bind the album cover for a [song]. */
fun bind(song: Song) = loadImpl(song, R.drawable.ic_song, R.string.desc_album_cover)
fun bind(song: Song) = loadImpl(song, R.drawable.ic_song_24, R.string.desc_album_cover)
/** Bind the album cover for an [album]. */
fun bind(album: Album) = loadImpl(album, R.drawable.ic_album, R.string.desc_album_cover)
fun bind(album: Album) = loadImpl(album, R.drawable.ic_album_24, R.string.desc_album_cover)
/** Bind the image for an [artist] */
fun bind(artist: Artist) = loadImpl(artist, R.drawable.ic_artist, R.string.desc_artist_image)
fun bind(artist: Artist) = loadImpl(artist, R.drawable.ic_artist_24, R.string.desc_artist_image)
/** Bind the image for a [genre] */
fun bind(genre: Genre) = loadImpl(genre, R.drawable.ic_genre, R.string.desc_genre_image)
fun bind(genre: Genre) = loadImpl(genre, R.drawable.ic_genre_24, R.string.desc_genre_image)
private fun <T : Music> loadImpl(music: T, @DrawableRes error: Int, @StringRes desc: Int) {
if (staticIcon != null) {
@@ -124,4 +130,31 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
transformations(SquareFrameTransform.INSTANCE)
}
}
private class StyledDrawable(context: Context, private val src: Drawable) : Drawable() {
init {
DrawableCompat.setTintList(src, context.getColorStateListSafe(R.color.sel_on_cover_bg))
}
override fun draw(canvas: Canvas) {
val adjustWidth = bounds.width() / 4
val adjustHeight = bounds.height() / 4
src.bounds.set(
adjustWidth,
adjustHeight,
bounds.width() - adjustWidth,
bounds.height() - adjustHeight)
src.draw(canvas)
}
override fun setAlpha(alpha: Int) {
src.alpha = alpha
}
override fun setColorFilter(colorFilter: ColorFilter?) {
src.colorFilter = colorFilter
}
override fun getOpacity(): Int = PixelFormat.TRANSLUCENT
}
}
@@ -1,66 +0,0 @@
/*
* Copyright (c) 2022 Auxio Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.auxio.image.ui
import android.content.Context
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
import androidx.core.graphics.drawable.DrawableCompat
import org.oxycblt.auxio.R
import org.oxycblt.auxio.util.getColorStateListSafe
/**
* The internal drawable used by Auxio's images. Do not use this outside of this module.
*
* This enables a few features:
* - Automatic tinting to the correct image tint
* - Automatic sizing to HALF of the canvas.
*
* @author OxygenCobalt
*/
class StyledDrawable(context: Context, private val src: Drawable) : Drawable() {
init {
// Re-tint the drawable to something that will play along with the background.
// Done here because this call (and nothing else) miraculously works on Lollipop devices
DrawableCompat.setTintList(src, context.getColorStateListSafe(R.color.sel_on_cover_bg))
}
override fun draw(canvas: Canvas) {
src.bounds.set(canvas.clipBounds)
val adjustWidth = src.bounds.width() / 4
val adjustHeight = src.bounds.height() / 4
src.bounds.set(
adjustWidth,
adjustHeight,
src.bounds.width() - adjustWidth,
src.bounds.height() - adjustHeight)
src.draw(canvas)
}
override fun setAlpha(alpha: Int) {
src.alpha = alpha
}
override fun setColorFilter(colorFilter: ColorFilter?) {
src.colorFilter = colorFilter
}
override fun getOpacity(): Int = PixelFormat.TRANSLUCENT
}
@@ -158,7 +158,7 @@ private class IndexerNotification(private val context: Context) :
notificationManager.createNotificationChannel(channel)
}
setSmallIcon(R.drawable.ic_indexer)
setSmallIcon(R.drawable.ic_indexer_32)
setCategory(NotificationCompat.CATEGORY_SERVICE)
setShowWhen(false)
setSilent(true)
@@ -183,7 +183,14 @@ class PlaybackPanelFragment :
private fun updateRepeat(repeatMode: RepeatMode) {
requireBinding().playbackRepeat.apply {
isActivated = repeatMode != RepeatMode.NONE
icon = requireContext().getDrawableSafe(repeatMode.icon)
val iconRes =
when (repeatMode) {
RepeatMode.NONE,
RepeatMode.ALL -> R.drawable.ic_repeat_24
RepeatMode.TRACK -> R.drawable.ic_repeat_one_24
}
icon = requireContext().getDrawableSafe(iconRes)
}
}
@@ -18,7 +18,6 @@
package org.oxycblt.auxio.playback.state
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R
/**
* Enum that determines the playback repeat mode.
@@ -38,14 +37,6 @@ enum class RepeatMode {
}
}
val icon: Int
get() =
when (this) {
NONE -> R.drawable.ic_repeat
ALL -> R.drawable.ic_repeat_on
TRACK -> R.drawable.ic_repeat_one
}
/** The integer code representing this particular mode. */
val intCode: Int
get() =
@@ -246,7 +246,7 @@ class MediaSessionComponent(private val context: Context, private val player: Pl
PlaybackStateCompat.CustomAction.Builder(
PlaybackService.ACTION_INC_REPEAT_MODE,
context.getString(R.string.desc_change_repeat),
R.drawable.ic_remote_repeat_off)
R.drawable.ic_remote_repeat_off_24)
.build())
.setBufferedPosition(player.bufferedPosition)
@@ -64,7 +64,7 @@ class NotificationComponent(
notificationManager.createNotificationChannel(channel)
}
setSmallIcon(R.drawable.ic_auxio)
setSmallIcon(R.drawable.ic_auxio_24)
setCategory(NotificationCompat.CATEGORY_SERVICE)
setShowWhen(false)
setSilent(true)
@@ -72,10 +72,12 @@ class NotificationComponent(
setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
addAction(buildRepeatAction(context, RepeatMode.NONE))
addAction(buildAction(context, PlaybackService.ACTION_SKIP_PREV, R.drawable.ic_skip_prev))
addAction(
buildAction(context, PlaybackService.ACTION_SKIP_PREV, R.drawable.ic_skip_prev_24))
addAction(buildPlayPauseAction(context, true))
addAction(buildAction(context, PlaybackService.ACTION_SKIP_NEXT, R.drawable.ic_skip_next))
addAction(buildAction(context, PlaybackService.ACTION_EXIT, R.drawable.ic_close))
addAction(
buildAction(context, PlaybackService.ACTION_SKIP_NEXT, R.drawable.ic_skip_next_24))
addAction(buildAction(context, PlaybackService.ACTION_EXIT, R.drawable.ic_close_24))
setStyle(MediaStyle().setMediaSession(sessionToken).setShowActionsInCompactView(1, 2, 3))
}
@@ -146,7 +148,7 @@ class NotificationComponent(
context: Context,
isPlaying: Boolean
): NotificationCompat.Action {
val drawableRes = if (isPlaying) R.drawable.ic_pause else R.drawable.ic_play
val drawableRes = if (isPlaying) R.drawable.ic_pause_24 else R.drawable.ic_play_24
return buildAction(context, PlaybackService.ACTION_PLAY_PAUSE, drawableRes)
}
@@ -157,9 +159,9 @@ class NotificationComponent(
): NotificationCompat.Action {
val drawableRes =
when (repeatMode) {
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off
RepeatMode.ALL -> R.drawable.ic_repeat
RepeatMode.TRACK -> R.drawable.ic_repeat_one
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off_24
RepeatMode.ALL -> R.drawable.ic_remote_repeat_on_24
RepeatMode.TRACK -> R.drawable.ic_remote_repeat_one_24
}
return buildAction(context, PlaybackService.ACTION_INC_REPEAT_MODE, drawableRes)
@@ -170,7 +172,7 @@ class NotificationComponent(
isShuffled: Boolean
): NotificationCompat.Action {
val drawableRes =
if (isShuffled) R.drawable.ic_shuffle else R.drawable.ic_remote_shuffle_off
if (isShuffled) R.drawable.ic_shuffle_24 else R.drawable.ic_remote_shuffle_off_24
return buildAction(context, PlaybackService.ACTION_INVERT_SHUFFLE, drawableRes)
}
@@ -181,10 +181,10 @@ class SettingsListFragment : PreferenceFragmentCompat() {
@DrawableRes
private fun Int.toThemeIcon(): Int {
return when (this) {
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> R.drawable.ic_auto
AppCompatDelegate.MODE_NIGHT_NO -> R.drawable.ic_light
AppCompatDelegate.MODE_NIGHT_YES -> R.drawable.ic_dark
else -> R.drawable.ic_auto
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> R.drawable.ic_auto_24
AppCompatDelegate.MODE_NIGHT_NO -> R.drawable.ic_light_24
AppCompatDelegate.MODE_NIGHT_YES -> R.drawable.ic_dark_24
else -> R.drawable.ic_auto_24
}
}
}
@@ -506,7 +506,10 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
logD("New state: $newState")
this.state = newState
// TODO: Make accessibility better
// TODO: Improve accessibility by:
// 1. Adding a (non-visible) handle. Material components now technically does have
// this, but it relies on the busted BottomSheetBehavior.
// 2. Adding the controls that BottomSheetBehavior defines in-app.
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
}
@@ -519,8 +522,8 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
val ratio = max(sheetOffset, 0f)
val outRatio = 1 - ratio
val halfOutRatio = min(ratio / 0.5f, 1f)
val halfInRatio = max(ratio - 0.5f, 0f) / 0.5f
val halfOutRatio = min(ratio * 2, 1f)
val halfInRatio = max(ratio - 0.5f, 0f) * 2
contentView.apply {
alpha = outRatio
@@ -542,7 +545,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
// translation with a fraction of the said inset.
lastInsets?.let { insets ->
val bars = insets.getSystemBarInsetsCompat(this)
translationY = (bars.top * halfOutRatio)
translationY = bars.top * halfOutRatio
}
}
@@ -44,19 +44,19 @@ enum class DisplayMode {
val icon: Int
get() =
when (this) {
SHOW_SONGS -> R.drawable.ic_song
SHOW_ALBUMS -> R.drawable.ic_album
SHOW_ARTISTS -> R.drawable.ic_artist
SHOW_GENRES -> R.drawable.ic_genre
SHOW_SONGS -> R.drawable.ic_song_24
SHOW_ALBUMS -> R.drawable.ic_album_24
SHOW_ARTISTS -> R.drawable.ic_artist_24
SHOW_GENRES -> R.drawable.ic_genre_24
}
val itemId: Int
get() =
when (this) {
SHOW_SONGS -> R.drawable.ic_song
SHOW_ALBUMS -> R.drawable.ic_album
SHOW_ARTISTS -> R.drawable.ic_artist
SHOW_GENRES -> R.drawable.ic_genre
SHOW_SONGS -> R.drawable.ic_song_24
SHOW_ALBUMS -> R.drawable.ic_album_24
SHOW_ARTISTS -> R.drawable.ic_artist_24
SHOW_GENRES -> R.drawable.ic_genre_24
}
val intCode: Int
@@ -25,10 +25,10 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.children
/**
* Class that fixes an issue where [CoordinatorLayout] will override [onApplyWindowInsets] and
* delegate the job to ***LAYOUT BEHAVIOR INSTANCES*** instead of the actual views.
* Class that manually overrides the busted window inset functionality of CoordinatorLayout in favor
* of a simple "delegate to child views" implementation.
*
* I can't believe I have to do this.
* @author OxygenCobalt
*/
class EdgeCoordinatorLayout
@JvmOverloads
@@ -236,6 +236,9 @@ val AndroidViewModel.application: Application
fun <R> SQLiteDatabase.queryAll(tableName: String, block: (Cursor) -> R) =
query(tableName, null, null, null, null, null, null)?.use(block)
// Note: ViewCompat.setOnApplyWindowInsets is a horrible buggy mess, so we use the native method
// and convert the insets as needed to their compat forms.
/**
* Resolve system bar insets in a version-aware manner. This can be used to apply padding to a view
* that properly follows all the frustrating changes that were made between Android 8-11.
@@ -121,9 +121,9 @@ private fun RemoteViews.applyPlayPauseControls(
setImageViewResource(
R.id.widget_play_pause,
if (state.isPlaying) {
R.drawable.ic_pause
R.drawable.ic_pause_24
} else {
R.drawable.ic_play
R.drawable.ic_play_24
})
return this
@@ -162,15 +162,15 @@ private fun RemoteViews.applyFullControls(
// indicators.
val shuffleRes =
when {
state.isShuffled -> R.drawable.ic_remote_shuffle_on
else -> R.drawable.ic_remote_shuffle_off
state.isShuffled -> R.drawable.ic_remote_shuffle_on_24
else -> R.drawable.ic_remote_shuffle_off_24
}
val repeatRes =
when (state.repeatMode) {
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off
RepeatMode.ALL -> R.drawable.ic_repeat_on
RepeatMode.TRACK -> R.drawable.ic_repeat_one
RepeatMode.NONE -> R.drawable.ic_remote_repeat_off_24
RepeatMode.ALL -> R.drawable.ic_remote_repeat_on_24
RepeatMode.TRACK -> R.drawable.ic_remote_repeat_one_24
}
setImageViewResource(R.id.widget_shuffle, shuffleRes)
@@ -60,6 +60,10 @@ class WidgetComponent(private val context: Context) :
* Force-update the widget.
*/
fun update() {
// TODO: Rework margins/button layout to do the magic that other button bars do
// TODO: Try to change the error icon again
// TODO:
// Updating Auxio's widget is unlike the rest of Auxio for a few reasons:
// 1. We can't use the typical primitives like ViewModels
// 2. The component range is far smaller, so we have to do some odd hacks to get