small accent update

This commit is contained in:
X1nto 2021-02-28 15:05:42 +04:00
parent 3525ef88c1
commit ad299ed96d
4 changed files with 11 additions and 12 deletions

View File

@ -5,7 +5,7 @@ import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.vanced.manager.R
import com.vanced.manager.utils.applyAccent
import com.vanced.manager.utils.showWithAccent
import com.vanced.manager.utils.isMiuiOptimizationsEnabled
import com.vanced.manager.utils.openUrl
@ -24,7 +24,7 @@ object DialogContainer {
}
}
create()
applyAccent()
showWithAccent()
}
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
prefs.edit { putBoolean("firstLaunch", false) }
@ -44,7 +44,7 @@ object DialogContainer {
}
setCancelable(false)
create()
applyAccent()
showWithAccent()
}
}
@ -54,7 +54,7 @@ object DialogContainer {
setMessage("So this statement is false huh? I'll go with True!")
setPositiveButton("wut?") { dialog, _ -> dialog.dismiss() }
create()
applyAccent()
showWithAccent()
}
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
@ -89,7 +89,7 @@ object DialogContainer {
}
}
create()
applyAccent()
showWithAccent()
}
}
@ -99,7 +99,7 @@ object DialogContainer {
setMessage(msg)
setPositiveButton(context.getString(R.string.close)) { dialog, _ -> dialog.dismiss() }
create()
applyAccent()
showWithAccent()
}
}

View File

@ -71,7 +71,7 @@ class MusicPreferencesDialog : BindingBottomSheetDialogFragment<DialogMusicPrefe
dismiss()
}
create()
}.applyAccent()
}.showWithAccent()
return@setOnClickListener
}

View File

@ -90,7 +90,7 @@ class VancedPreferencesDialog : BindingBottomSheetDialogFragment<DialogVancedPre
dismiss()
}
create()
}.applyAccent()
}.showWithAccent()
return@setOnClickListener
}

View File

@ -25,7 +25,6 @@ fun DialogFragment.show(activity: FragmentActivity) {
} catch (e: Exception) {
log("VMUI", e.stackTraceToString())
}
}
fun List<String>.convertToAppVersions(): List<String> = listOf("latest") + reversed()
@ -49,14 +48,14 @@ fun Int.toHex(): String = java.lang.String.format("#%06X", 0xFFFFFF and this)
//Material team decided to keep their LinearProgressIndicator final
//At least extension methods exist
fun LinearProgressIndicator.applyAccent() {
with(accentColor.value ?: context.defPrefs.managerAccent) {
with(accentColor.value!!) {
setIndicatorColor(this)
trackColor = ColorUtils.setAlphaComponent(this, 70)
}
}
fun MaterialAlertDialogBuilder.applyAccent() {
with(accentColor.value ?: context.defPrefs.managerAccent) {
fun MaterialAlertDialogBuilder.showWithAccent() {
with(accentColor.value!!) {
show().apply {
getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(this@with)
getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(this@with)