ui: use grade instead of indicator

Finally unify all icon activation states under the new grade modifier
in Material Symbols.

This provides similar clarify to the dot/greyed state, but without
inconsistent meanings. The shuffle icon did have to be bolded a little
more though, as the grade did not seem to do much.
This commit is contained in:
OxygenCobalt
2022-07-03 15:29:42 -06:00
parent 4f8fc8008c
commit b3cac19ee4
29 changed files with 90 additions and 181 deletions
@@ -122,7 +122,7 @@ class Indexer {
this.callback = null
}
suspend fun index(context: Context) {
fun index(context: Context) {
val generation = synchronized(this) { ++currentGeneration }
val notGranted =
@@ -25,7 +25,6 @@ import coil.imageLoader
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R
@@ -113,11 +112,17 @@ class IndexerService : Service(), Indexer.Controller, Settings.Callback {
// Load was completed successfully. However, we still need to do some
// extra work to update the app's state.
updateScope.launch {
// Invalidate the image cache, as there may be some covers that are
// no longer valid.
imageLoader.memoryCache?.clear()
if (musicStore.library != null) {
// This is a new library, so we need to make sure the playback state
// is coherent.
// is coherent. This seems a bit muddly, but PlaybackService (or any
// other playback component capable of handling this) may not be
// capable of long-running background work as the library is being
// updated. The initialization steps on the other hand are firmly in
// the place of the playback module.
playbackManager.sanitize(
PlaybackStateDatabase.getInstance(this@IndexerService), newLibrary)
}
@@ -205,8 +205,6 @@ class Task(context: Context, private val audio: MediaStoreBackend.Audio) {
}
}
// TODO: Release types
private fun populateId3v2(tags: Map<String, String>) {
// Title
tags["TIT2"]?.let { audio.title = it }
@@ -1,61 +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.playback
import android.content.Context
import android.graphics.Canvas
import android.util.AttributeSet
import androidx.annotation.AttrRes
import com.google.android.material.button.MaterialButton
import org.oxycblt.auxio.R
import org.oxycblt.auxio.util.getDrawableSafe
/**
* Extends [MaterialButton] to add a dot indicator to the bottom of the view.
*
* TODO: Experiment with the "grade" attribute on Material Icons so that I can replace this
*
* @author OxygenCobalt
*/
class IndicatorMaterialButton
@JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) :
MaterialButton(context, attrs, defStyleAttr) {
private val indicatorDrawable = context.getDrawableSafe(R.drawable.ui_indicator)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
// Put the indicator right below the icon.
val x = (measuredWidth - indicatorDrawable.intrinsicWidth) / 2
val y = ((measuredHeight - iconSize) / 2) + iconSize
indicatorDrawable.bounds.set(
x, y, x + indicatorDrawable.intrinsicWidth, y + indicatorDrawable.intrinsicHeight)
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
// I would use onDrawForeground but apparently that isn't called by Lollipop devices.
// This is not referenced in the documentation at all.
if (isActivated) {
indicatorDrawable.draw(canvas)
}
}
}
@@ -31,6 +31,8 @@ import android.widget.FrameLayout
* particular overrides the layout direction in a way that will not disrupt how other views are laid
* out.
*
* This layout can only contain one child.
*
* @author OxygenCobalt
*/
open class NoRtlFrameLayout
@@ -185,8 +185,8 @@ class PlaybackPanelFragment :
isActivated = repeatMode != RepeatMode.NONE
val iconRes =
when (repeatMode) {
RepeatMode.NONE,
RepeatMode.ALL -> R.drawable.ic_repeat_24
RepeatMode.NONE -> R.drawable.ic_repeat_off_24
RepeatMode.ALL -> R.drawable.ic_repeat_on_24
RepeatMode.TRACK -> R.drawable.ic_repeat_one_24
}
@@ -265,7 +265,7 @@ class MediaSessionComponent(
PlaybackStateCompat.CustomAction.Builder(
PlaybackService.ACTION_INC_REPEAT_MODE,
context.getString(R.string.desc_change_repeat),
R.drawable.ic_remote_repeat_off_24)
R.drawable.ic_repeat_off_24)
.build())
.setBufferedPosition(player.bufferedPosition)
@@ -27,7 +27,6 @@ import android.support.v4.media.session.MediaSessionCompat
import androidx.annotation.DrawableRes
import androidx.core.app.NotificationCompat
import androidx.media.app.NotificationCompat.MediaStyle
import okhttp3.internal.notify
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R
@@ -135,9 +134,9 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
): NotificationCompat.Action {
val drawableRes =
when (repeatMode) {
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
RepeatMode.NONE -> R.drawable.ic_repeat_off_24
RepeatMode.ALL -> R.drawable.ic_repeat_on_24
RepeatMode.TRACK -> R.drawable.ic_repeat_one_24
}
return buildAction(context, PlaybackService.ACTION_INC_REPEAT_MODE, drawableRes)
@@ -148,7 +147,7 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
isShuffled: Boolean
): NotificationCompat.Action {
val drawableRes =
if (isShuffled) R.drawable.ic_shuffle_24 else R.drawable.ic_remote_shuffle_off_24
if (isShuffled) R.drawable.ic_shuffle_on_24 else R.drawable.ic_shuffle_off_24
return buildAction(context, PlaybackService.ACTION_INVERT_SHUFFLE, drawableRes)
}
@@ -165,10 +164,6 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
return action.build()
}
interface Callback {
fun onNotificationChanged(song: Song?, component: NotificationComponent)
}
companion object {
const val CHANNEL_ID = BuildConfig.APPLICATION_ID + ".channel.PLAYBACK"
}
@@ -516,7 +516,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
}
/**
* Do the nice view animations that occur whenever we slide up the bottom sheet. The way I
* Do the nice view animations that occur whenever we slide up the bottom sheet. The way we
* transition is largely inspired by Android 12's notification panel, with the compact view
* fading out completely before the panel view fades in.
*/
@@ -569,6 +569,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
if (dragHelper.smoothSlideViewTo(
sheetView, sheetView.left, calculateSheetTopPosition(offset))) {
// Slide has started, begin animating
postInvalidateOnAnimation()
}
}
@@ -189,15 +189,15 @@ private fun RemoteViews.applyFullControls(
// indicators.
val shuffleRes =
when {
state.isShuffled -> R.drawable.ic_remote_shuffle_on_24
else -> R.drawable.ic_remote_shuffle_off_24
state.isShuffled -> R.drawable.ic_shuffle_on_24
else -> R.drawable.ic_shuffle_off_24
}
val repeatRes =
when (state.repeatMode) {
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
RepeatMode.NONE -> R.drawable.ic_repeat_off_24
RepeatMode.ALL -> R.drawable.ic_repeat_on_24
RepeatMode.TRACK -> R.drawable.ic_repeat_one_24
}
setImageViewResource(R.id.widget_shuffle, shuffleRes)