mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
Fix button appearance for older devices
+ Buttons on API < 29 now all have the same color for the customTheme + This can be worked on again, if someone figures out how to dynamically change button colors on older android APIs
This commit is contained in:
parent
6862be3521
commit
d4ea809569
4 changed files with 18 additions and 8 deletions
|
@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity(),
|
||||||
when (currentTheme) {
|
when (currentTheme) {
|
||||||
"dark" -> R.style.darkTheme
|
"dark" -> R.style.darkTheme
|
||||||
"finn" -> R.style.finnmglasTheme
|
"finn" -> R.style.finnmglasTheme
|
||||||
else -> R.style.finnmglasTheme
|
else -> R.style.customTheme
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
|
@ -34,7 +34,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
when (getSavedTheme(this)) {
|
when (getSavedTheme(this)) {
|
||||||
"dark" -> R.style.darkTheme
|
"dark" -> R.style.darkTheme
|
||||||
"finn" -> R.style.finnmglasTheme
|
"finn" -> R.style.finnmglasTheme
|
||||||
else -> R.style.finnmglasTheme
|
else -> R.style.customTheme
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,7 @@ import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.pm.ResolveInfo
|
import android.content.pm.ResolveInfo
|
||||||
import android.graphics.Bitmap
|
import android.graphics.*
|
||||||
import android.graphics.BlendMode
|
|
||||||
import android.graphics.BlendModeColorFilter
|
|
||||||
import android.graphics.PorterDuff
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
@ -325,6 +322,9 @@ fun getDominantColor(bitmap: Bitmap?): Int {
|
||||||
fun setButtonColor(btn: Button, color: Int) {
|
fun setButtonColor(btn: Button, color: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= 29)
|
if (Build.VERSION.SDK_INT >= 29)
|
||||||
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
|
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
|
||||||
else
|
else {
|
||||||
btn.background.setColorFilter(color, PorterDuff.Mode.MULTIPLY)
|
// not setting it here, unable to find a good alternative
|
||||||
|
// I tried:
|
||||||
|
// btn.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,16 @@
|
||||||
<item name="android:windowAnimationStyle">@style/WindowFadeTransition</item>
|
<item name="android:windowAnimationStyle">@style/WindowFadeTransition</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Custom theme -->
|
||||||
|
<style name="customTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<item name="android:textColor">#ffffff</item>
|
||||||
|
<item name="android:buttonStyle">@style/Widget.AppCompat.Button.Colored</item>
|
||||||
|
<item name="colorButtonNormal">#252827</item>
|
||||||
|
|
||||||
|
<item name="android:windowDisablePreview">true</item>
|
||||||
|
<item name="android:windowAnimationStyle">@style/WindowFadeTransition</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
|
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||||
<item name="android:textColor">#000000</item>
|
<item name="android:textColor">#000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Reference in a new issue