Closed MFlisar closed 6 years ago
I could solve it. I think your current beta feature of using a custom theme breaks things...
My workaround is following (this works with custom themes as well):
open class BaseActivity : AppCompatActivity(), CBaseActivity {
override var themeString: String = ""
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(ThemeManager.baseActivityTheme()) // <= this works perfectly fine!!! here I apply a custom theme
super.onCreate(savedInstanceState)
handleOnCreate(this, savedInstanceState, true, false)
}
override fun onResume() {
super.onResume()
handleOnResume(this)
}
}
This way, I set the custom theme and then apply your theming on this theme. This works fine for me. To understand my code above, please check out my pull request that I'll make now, I made small improvements...
I would suggest applying custom themes like above instead of what you do currently, I can add this change to my pull request if this is ok for you
The idea behind the user defined theme is that it doesn't inherit from anything. If it inherits from something, it will override colorful defined style values. If you want to use a different base theme (Say, activity background is orange instead of the default white or grey), then you would use your own activity with your own base theme, and override set to false, at which point Colorful wouldn't replace your theme.
What does the custom style you're trying to merge look like, and is this issue reproducible when not using a custom style?
Understood that now. Maybe customStyle
would be a better name for this option?
Would make sense to support passing in a custom base theme as well that will replace the default one...
That's not a half bad idea, that's why this feature is marked beta even though it works fine, I'm not sure of the direction of it yet. Adding a custom base theme is something I could do.
For now, if you want to use a custom base theme my suggestion would be to have your theme inherit from one of colorful's base themes, make your modifications, and then use a if for colorful().darkTheme to decide which one to manually apply.
If you use Colorful().apply, and set override to false, it won't replace the theme the activity already has but will still do coloring.
After trying this quite a while now, I can't get it working after restarting my app.
What I do:
1) Init colorful with the values from my own preferences (had some theming already before I tried your library):
2) Update colorful whenever my preferences change:
Observations
update
function, all my activities are themed correctly until I kill my app and restart itAny ideas why?