style: use colorAccent
Use colorAccent instead of colorPrimary and colorSecondary.
This commit is contained in:
@@ -16,24 +16,14 @@ import org.oxycblt.auxio.R
|
||||
val ACCENTS = arrayOf(
|
||||
Accent(R.color.red, R.style.Theme_Red, R.style.Theme_Red_Black, R.string.clr_red),
|
||||
Accent(R.color.pink, R.style.Theme_Pink, R.style.Theme_Pink_Black, R.string.clr_pink),
|
||||
Accent(
|
||||
R.color.purple,
|
||||
R.style.Theme_Purple,
|
||||
R.style.Theme_Purple_Black,
|
||||
R.string.clr_purple
|
||||
),
|
||||
Accent(R.color.purple, R.style.Theme_Purple, R.style.Theme_Purple_Black, R.string.clr_purple),
|
||||
Accent(
|
||||
R.color.deep_purple,
|
||||
R.style.Theme_DeepPurple,
|
||||
R.style.Theme_DeepPurple_Black,
|
||||
R.string.clr_deep_purple
|
||||
),
|
||||
Accent(
|
||||
R.color.indigo,
|
||||
R.style.Theme_Indigo,
|
||||
R.style.Theme_Indigo_Black,
|
||||
R.string.clr_indigo
|
||||
),
|
||||
Accent(R.color.indigo, R.style.Theme_Indigo, R.style.Theme_Indigo_Black, R.string.clr_indigo),
|
||||
Accent(R.color.blue, R.style.Theme_Blue, R.style.Theme_Blue_Black, R.string.clr_blue),
|
||||
Accent(
|
||||
R.color.light_blue,
|
||||
@@ -48,21 +38,11 @@ val ACCENTS = arrayOf(
|
||||
R.color.light_green,
|
||||
R.style.Theme_LightGreen,
|
||||
R.style.Theme_LightGreen_Black,
|
||||
R.string.color_light_green
|
||||
),
|
||||
Accent(R.color.lime, R.style.Theme_Lime, R.style.Theme_Lime_Black, R.string.color_lime),
|
||||
Accent(
|
||||
R.color.yellow,
|
||||
R.style.Theme_Yellow,
|
||||
R.style.Theme_Yellow_Black,
|
||||
R.string.color_yellow
|
||||
),
|
||||
Accent(
|
||||
R.color.orange,
|
||||
R.style.Theme_Orange,
|
||||
R.style.Theme_Orange_Black,
|
||||
R.string.clr_orange
|
||||
R.string.clr_light_green
|
||||
),
|
||||
Accent(R.color.lime, R.style.Theme_Lime, R.style.Theme_Lime_Black, R.string.clr_lime),
|
||||
Accent(R.color.yellow, R.style.Theme_Yellow, R.style.Theme_Yellow_Black, R.string.clr_yellow),
|
||||
Accent(R.color.orange, R.style.Theme_Orange, R.style.Theme_Orange_Black, R.string.clr_orange),
|
||||
Accent(
|
||||
R.color.deep_orange,
|
||||
R.style.Theme_DeepOrange,
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.oxycblt.auxio.playback.system.PlaybackService
|
||||
import org.oxycblt.auxio.ui.newBroadcastIntent
|
||||
import org.oxycblt.auxio.ui.newMainIntent
|
||||
|
||||
private fun createBaseView(
|
||||
private fun createViews(
|
||||
context: Context,
|
||||
@LayoutRes layout: Int,
|
||||
state: WidgetState
|
||||
@@ -56,33 +56,23 @@ private fun createBaseView(
|
||||
|
||||
if (state.albumArt != null) {
|
||||
views.setImageViewBitmap(R.id.widget_cover, state.albumArt)
|
||||
views.setCharSequence(
|
||||
R.id.widget_cover, "setContentDescription",
|
||||
context.getString(R.string.desc_album_cover, state.song.album.name)
|
||||
views.setContentDescription(
|
||||
R.id.widget_cover, context.getString(R.string.desc_album_cover, state.song.album.name)
|
||||
)
|
||||
} else {
|
||||
views.setImageViewResource(R.id.widget_cover, R.drawable.ic_song)
|
||||
views.setCharSequence(
|
||||
R.id.widget_cover,
|
||||
"setContentDescription",
|
||||
context.getString(R.string.desc_no_cover)
|
||||
)
|
||||
views.setContentDescription(R.id.widget_cover, context.getString(R.string.desc_no_cover))
|
||||
}
|
||||
|
||||
return views
|
||||
}
|
||||
|
||||
fun createSmallWidget(context: Context, state: WidgetState): RemoteViews {
|
||||
return createBaseView(context, R.layout.widget_small, state)
|
||||
return createViews(context, R.layout.widget_small, state)
|
||||
}
|
||||
|
||||
fun createFullWidget(context: Context, state: WidgetState): RemoteViews {
|
||||
val views = createBaseView(context, R.layout.widget_full, state)
|
||||
|
||||
// The main way the large widget differs from the other widgets is the addition of extra
|
||||
// controls. However, since the context we use to load attributes is from the main process,
|
||||
// attempting to dynamically color anything will result in an error. More duplicate
|
||||
// resources it is. This is getting really tiring.
|
||||
val views = createViews(context, R.layout.widget_full, state)
|
||||
|
||||
views.setOnClickPendingIntent(
|
||||
R.id.widget_loop,
|
||||
@@ -98,10 +88,15 @@ fun createFullWidget(context: Context, state: WidgetState): RemoteViews {
|
||||
)
|
||||
)
|
||||
|
||||
val shuffleRes = if (state.isShuffled)
|
||||
R.drawable.ic_shuffle_tinted
|
||||
else
|
||||
R.drawable.ic_shuffle
|
||||
// The main way the large widget differs from the other widgets is the addition of extra
|
||||
// controls. However, since the context we use to load attributes is from the main process,
|
||||
// attempting to dynamically color anything will result in an error. More duplicate
|
||||
// resources it is. This is getting really tiring.
|
||||
|
||||
val shuffleRes = when {
|
||||
state.isShuffled -> R.drawable.ic_shuffle_tinted
|
||||
else -> R.drawable.ic_shuffle
|
||||
}
|
||||
|
||||
val loopRes = when (state.loopMode) {
|
||||
LoopMode.NONE -> R.drawable.ic_loop
|
||||
|
||||
@@ -64,8 +64,6 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME: Fix the race conditions with the bitmap loading.
|
||||
|
||||
loadBitmap(context, song) { bitmap ->
|
||||
val state = WidgetState(
|
||||
song,
|
||||
@@ -85,6 +83,15 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Revert this widget to its default view
|
||||
*/
|
||||
fun reset(context: Context) {
|
||||
logD("Resetting widget")
|
||||
|
||||
applyDefaultViews(context, AppWidgetManager.getInstance(context))
|
||||
}
|
||||
|
||||
private fun AppWidgetManager.applyViewsCompat(
|
||||
context: Context,
|
||||
views: Map<SizeF, RemoteViews>
|
||||
@@ -125,7 +132,8 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
// Widget dimens pre-12 are weird. Basically, they correspond to columns
|
||||
// but with 2 columns worth of DiP added for some insane reason. Take
|
||||
// the dimens, normalize them into cells, and then turn them back into dimens.
|
||||
// This is super lossy and may result in wonky layouts, but it *seems* to work.
|
||||
// This may result in wonky layouts, but it *seems* to work well enough
|
||||
// in practice.
|
||||
width = normalizeDimen(width)
|
||||
height = normalizeDimen(height)
|
||||
|
||||
@@ -153,7 +161,6 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
// No layout fits. Just use the smallest view.
|
||||
|
||||
logD("No widget layout found")
|
||||
|
||||
val minimum = requireNotNull(
|
||||
@@ -175,15 +182,6 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
return 70 * (cells - 2) - 30
|
||||
}
|
||||
|
||||
/*
|
||||
* Revert this widget to its default view
|
||||
*/
|
||||
fun reset(context: Context) {
|
||||
logD("Resetting widget")
|
||||
|
||||
applyDefaultViews(context, AppWidgetManager.getInstance(context))
|
||||
}
|
||||
|
||||
@SuppressLint("RemoteViewLayout")
|
||||
private fun applyDefaultViews(context: Context, manager: AppWidgetManager) {
|
||||
val views = RemoteViews(context.packageName, R.layout.widget_default)
|
||||
|
||||
Reference in New Issue
Block a user