Added Amoled theme

Upgrade Gradle 7.1-rc-1 > 7.2
Bumped Kotlin Version 1.5.20 > 1.5.31
Gradle FIles cleanup
All dependencies upgraded
This commit is contained in:
LooKeR
2021-10-07 00:27:07 +05:30
parent f79d666219
commit 5d4fb29f9e
10 changed files with 136 additions and 113 deletions

View File

@ -171,7 +171,8 @@ object Preferences {
sealed class Theme(override val valueString: String) : Enumeration<Theme> {
override val values: List<Theme>
get() = if (Android.sdk(29)) listOf(System, Light, Dark) else listOf(Light, Dark)
get() = if (Android.sdk(29)) listOf(System, Light, Dark, Amoled)
else listOf(Light, Dark, Amoled)
abstract fun getResId(configuration: Configuration): Int
@ -189,6 +190,10 @@ object Preferences {
object Dark : Theme("dark") {
override fun getResId(configuration: Configuration): Int = R.style.Theme_Main_Dark
}
object Amoled : Theme("amoled") {
override fun getResId(configuration: Configuration): Int = R.style.Theme_Main_Amoled
}
}
operator fun <T> get(key: Key<T>): T {

View File

@ -474,9 +474,8 @@ class EditRepositoryFragment() : ScreenFragment() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe { result, throwable ->
checkDisposable = null
throwable?.printStackTrace()
val resultAddress =
result?.let { if (it.isEmpty()) null else it } ?: address
throwable.printStackTrace()
val resultAddress = if (result.isEmpty()) address else result
val allow = resultAddress == address || run {
layout.address.setText(resultAddress)
invalidateAddress(resultAddress)

View File

@ -100,6 +100,7 @@ class SettingsFragment : ScreenFragment() {
is Preferences.Theme.System -> getString(R.string.system)
is Preferences.Theme.Light -> getString(R.string.light)
is Preferences.Theme.Dark -> getString(R.string.dark)
is Preferences.Theme.Amoled -> getString(R.string.amoled)
}
}
addSwitch(

View File

@ -7,6 +7,7 @@ import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.graphics.drawable.VectorDrawable
import android.net.Uri
import android.util.TypedValue
import android.util.Xml
@ -16,7 +17,6 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.looker.droidify.utility.extension.android.Android
import com.squareup.picasso.Picasso
import com.squareup.picasso.RequestCreator
@ -37,7 +37,7 @@ fun Context.getDrawableCompat(resId: Int): Drawable {
.find { it == XmlPullParser.START_TAG || it == XmlPullParser.END_DOCUMENT }
if (eventType == XmlPullParser.START_TAG) {
when (it.name) {
"vector" -> VectorDrawableCompat.createFromXmlInner(
"vector" -> VectorDrawable.createFromXmlInner(
resources,
it,
Xml.asAttributeSet(it),