Skip to content

Commit

Permalink
Fixed material you accent not persisting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Oct 2, 2024
1 parent c7005e6 commit 8694ad2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import app.simple.positional.preferences.MainPreferences.getCornerRadius
import app.simple.positional.util.ColorUtils.toHex
import app.simple.positional.util.ConditionUtils.isZero
import app.simple.positional.util.HtmlHelper
import java.util.*
import java.util.Arrays

class AccentColorAdapter(private val list: ArrayList<Pair<Int, String>>) : RecyclerView.Adapter<VerticalListViewHolder>() {

Expand Down Expand Up @@ -55,6 +55,12 @@ class AccentColorAdapter(private val list: ArrayList<Pair<Int, String>>) : Recyc

holder.container.setOnClickListener {
palettesAdapterCallbacks.onColorPressed(list[position].first)

if (list[position].second == "Material You (Dynamic)") {
MainPreferences.setMaterialYouAccentColor(true)
} else {
MainPreferences.setMaterialYouAccentColor(false)
}
}

holder.name.text = list[position].second
Expand All @@ -63,10 +69,18 @@ class AccentColorAdapter(private val list: ArrayList<Pair<Int, String>>) : Recyc
holder.container.background = null
holder.container.background = getRippleDrawable(holder.container.background, list[position].first)

holder.tick.visibility = if (list[position].first == MainPreferences.getAccentColor()) {
View.VISIBLE
holder.tick.visibility = if (MainPreferences.isMaterialYouAccentColor()) {
if (list[position].second == "Material You (Dynamic)") {
View.VISIBLE
} else {
View.INVISIBLE
}
} else {
View.INVISIBLE
if (list[position].first == MainPreferences.getAccentColor()) {
View.VISIBLE
} else {
View.INVISIBLE
}
}
} else if (holder is Header) {
holder.total.text = HtmlHelper.fromHtml("<b>${holder.itemView.context.getString(R.string.total)}</b> ${list.size}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences.*
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.content.pm.ServiceInfo
import android.graphics.Bitmap
import android.graphics.Color
Expand Down Expand Up @@ -254,6 +254,10 @@ abstract class ClockWidgetService : Service(), OnSharedPreferenceChangeListener
}

private fun getAccentTheme(): Int {
if (MainPreferences.isMaterialYouAccentColor()) {
return R.style.MaterialYou
}

return when (MainPreferences.getAccentColor()) {
ContextCompat.getColor(baseContext, R.color.positional) -> {
R.style.Positional
Expand Down

0 comments on commit 8694ad2

Please sign in to comment.