Giter Club home page Giter Club logo

colorful's Introduction

Discontinued

Android has had native theming for awhile now, so Colorful's purpose has been served and the library has been discontinued.

Colorful

Release Build Status

Colorful is a dynamic theme library allowing you to change your apps' color schemes easily.

Colorful v2 is here! v2 has been rewritten from the ground up in Kotlin to be lighter, faster, and more feature-packed

License

Colorful is licensed under the Apache 2.0 License

Copyright 2018 Garret Yoder

Image Image Image

Installation

Add jitpack to your maven sources

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add Colorful as a dependency to your build.gradle

dependencies {
    implementation 'com.github.garretyoder:Colorful:2.3.4'
}

Usage

Initialization

In your Application class, you must initialize Colorful and set the default theme colors.

class SampleApp:Application() {
    override fun onCreate() {
        super.onCreate()
        val defaults:Defaults = Defaults(
                primaryColor = ThemeColor.GREEN,
                accentColor = ThemeColor.BLUE,
                useDarkTheme = false,
                translucent = false)
        initColorful(this, defaults)
    }
}

The following is a list of all theme colors available.

ThemeColor.RED
ThemeColor.PINK
ThemeColor.PURPLE
ThemeColor.DEEP_PURPLE
ThemeColor.INDIGO
ThemeColor.BLUE
ThemeColor.LIGHT_BLUE
ThemeColor.CYAN
ThemeColor.TEAL
ThemeColor.GREEN
ThemeColor.LIGHT_GREEN
ThemeColor.LIME
ThemeColor.YELLOW
ThemeColor.AMBER
ThemeColor.ORANGE
ThemeColor.DEEP_ORANGE
ThemeColor.BROWN
ThemeColor.GREY
ThemeColor.BLUE_GREY
ThemeColor.WHITE
ThemeColor.BLACK

Using Themes

Any Activity you wish to be automatically themed must inherit from either CActivity, CAppCompatActivity if you wish to use AppCompat or CMaterialActivity if you wish to use the new Material Componets theme. Note The material componets theme is still beta and is available only in the testing android-p branch. To use the material-componets theme, please add the android-p colorful branch to your gradle build.

class MainActivity : CActivity()
class MainActivity : CAppCompatActivity()

Only available in the android-p branch

class MainActivity : CMaterialActivity()

If you wish to use your own activity, you can manually apply Colorful's theme to any activity using apply(activity:Activity)

Colorful().apply(this, override = true, baseTheme = BaseTheme.THEME_MATERIAL)

The override value will control whether Colorful overrides your activitie's existing base theme, or merely sets primary and accent colors. Note: dark/light themeing will not work when override is disabled The baseTheme value will control which base theme Colorful will use, Appcompat, Material, or Material Componets.

Alternatively, as of Colorful 2.1, you can now have your activity inherit from the interface CThemeInterface which will provide the handleOnCreate and handleOnResume methods for automatic theme handling. See both CActivity and CAppCompatActivity for examples on how to implement the CThemeInterface

Setting The Theme

You can set the colors at any time using the edit() method

Colorful().edit()
        .setPrimaryColor(ThemeColor.RED)
        .setAccentColor(ThemeColor.BLUE)
        .setDarkTheme(true)
        .setTranslucent(true)
        .apply(context:Context)

You must call apply(context:Context) to save your changes

primaryColor the primary color of your theme. This affects componets such as toolbars, task descriptions, etc accentColor the accent color of your theme. This affects componets such as buttons, sliders, checkboxes, etc darkTheme the base theme of your style. This controls whether the theme is dark or light. translucent This controls whether translucency is enabled. This will turn the status bar translucent or solid

Colorful will handle saving and loading your theme preferences for you.

The apply method optionally takes a high-order function as a argument. This serves as a callback that will be triggered once Colorful has finished it's theme changes. A example usage would be to recreate the current activity after setting a new theme to immediately reflect changes.

Colorful().edit()
    .setPrimaryColor(ThemeColor.PURPLE)
    .setAccentColor(ThemeColor.GREEN)
    .apply(this) { 
        this.recreate() 
    }

Getting the current theme values

Colorful can provide you with hex string, or android rgb int formatted values for the currently set colors. This is acheived through the ColorPack class, which is a pack that contains both dark and normal variants of the color. These are based off the Material Color Pallet 500 (normal) and 700 (dark) values. Examples are shown below.

Colorful().getPrimaryColor().getColorPack().dark().asInt()
Colorful().getAccentColor().getColorPack().normal().asHex()

Colorful().getDarkTheme() will return a boolean value for whether the dark theme is enabled

Colorful().getTranslucent() will return a boolean value for whether the current style has transluceny enabled.

Custom styles

Colorful has beta support for combining your own styles with it's own. This is not yet guaranteed to work reliably.

Colorful().edit()
                .setPrimaryColor(ThemeColor.RED)
                .setAccentColor(ThemeColor.BLUE)
                .setDarkTheme(true)
                .setTranslucent(true)
                .setCustomThemeOverride(R.style.AppTheme)
                .apply(this)

The setCustomThemeOverride method will allow Colorful to mix a provided theme with it's own. If you wish to set specific theme items yourself, such as coloring all text orange, you can do this within a style file and then have Colorful merge it with it's own theme.

Custom theme colors

Colorful allows you to define custom themes (e.g. light red primary color with dark yellow accents). If you want to use custom styles you have to do following 3 things:

  1. create styles for your custom themes:
<style name="my_custom_primary_color">
	<item name="android:colorPrimary">@color/md_red_200</item>
	<item name="colorPrimary">@color/md_red_200</item>
</style>
<style name="my_custom_primary_dark_color">
	<item name="android:colorPrimaryDark">@color/md_red_400</item>
	<item name="colorPrimaryDark">@color/md_red_400</item>
</style>
<style name="my_custom_accent_color">
	<item name="android:colorAccent">@color/md_yellow_700</item>
	<item name="colorAccent">@color/md_yellow_700</item>
</style>
  1. Create a custom theme color object, like following:
var myCustomColor1 = CustomThemeColor(
	context,
	R.style.my_custom_primary_color,
	R.style.my_custom_primary_dark_color,
	R.color.md_red_200, // <= use the color you defined in my_custom_primary_color
	R.color.md_red_400 // <= use the color you defined in my_custom_primary_dark_color
)
// used as accent color, dark color is irrelevant...
var myCustomColor2 = CustomThemeColor(
	context,
	R.style.my_custom_accent_color,
	R.style.my_custom_accent_color,
	R.color.md_yellow_700, // <= use the color you defined in my_custom_accent_color
	R.color.md_yellow_700 // <= use the color you defined in my_custom_accent_color
)
  1. use this custom theme color object like you would use any ThemeColor.<COLOR> enum object, e.g.
var defaults = Defaults(
	primaryColor = myCustomColor1,
	accentColor = myCustomColor2,
	useDarkTheme = true,
	translucent = false,
	customTheme = 0
)

colorful's People

Contributors

garretyoder avatar mflisar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorful's Issues

Realtime accent color change ?

Can we have the accent colors change immediately after apply? That is without leaving the current screen? I tried to trigger a color change from color picker dialog but it doesn't do anything to the current screen

Sample code for use without kotlin

Is is possible to use this without having to use kotlin? just Java
Kindly share some sample code on the README.
I tried some Kotlin decompiling but it didn't work

Does Proguard settings mentioned in document?

I tries build a release build of my app and app crashed while start:

Fatal Exception: java.lang.AssertionError: impossible
       at java.lang.Enum$1.create(Enum.java:272)
       at java.lang.Enum$1.create(Enum.java:263)
       at libcore.util.BasicLruCache.get(BasicLruCache.java:58)
       at java.lang.Enum.getSharedConstants(Enum.java:289)
       at java.lang.Enum.valueOf(Enum.java:244)
       at io.multimoon.colorful.ThemeColor.valueOf(Unknown Source:2)
       at io.multimoon.colorful.ThemeColorInterface$Companion.parse(ThemeColor.kt:18)
       at io.multimoon.colorful.ColorfulKt.initColorful(Colorful.kt:29)
       at com.noodoe.nexlogistics.LogisticsApp.onCreate(LogisticsApp.kt:53)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
       at android.app.ActivityThread.-wrap1(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Caused by java.lang.NoSuchMethodException: values []
       at java.lang.Class.getMethod(Class.java:2068)
       at java.lang.Class.getDeclaredMethod(Class.java:2047)
       at java.lang.Enum$1.create(Enum.java:268)
       at java.lang.Enum$1.create(Enum.java:263)
       at libcore.util.BasicLruCache.get(BasicLruCache.java:58)
       at java.lang.Enum.getSharedConstants(Enum.java:289)
       at java.lang.Enum.valueOf(Enum.java:244)
       at io.multimoon.colorful.ThemeColor.valueOf(Unknown Source:2)
       at io.multimoon.colorful.ThemeColorInterface$Companion.parse(ThemeColor.kt:18)
       at io.multimoon.colorful.ColorfulKt.initColorful(Colorful.kt:29)
       at com.noodoe.nexlogistics.LogisticsApp.onCreate(LogisticsApp.kt:53)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
       at android.app.ActivityThread.-wrap1(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

So I added these proguard settings to make app open successfully:

-keep class io.multimoon.colorful.** { *; }
-dontwarn io.multimoon.colorful.**

Does anyone have other ideas?

R styles not found on API 19

Hello,
I am encountering an issue when running the library on API 19 (Android 4.1)...
R seems to not be created correctly on compile.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: dev.defvs.chatterz, PID: 2735
    java.lang.NoClassDefFoundError: io.multimoon.colorful.R$style
        at io.multimoon.colorful.ThemeColor.<clinit>(ThemeColor.kt:60)
        at dev.defvs.chatterz.MainApplication.onCreate(MainApplication.kt:13)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)
        at android.app.ActivityThread.access$1500(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

App bar and Statusbar need same color

i want app and status bar same color but its bot work

 ` Defaults defaults = new Defaults(
            ThemeColor.GREEN,
            ThemeColor.GREEN,
            false,
            false,
            0);
     initColorful(this, defaults);`

it show status bar different green ...

translucent makes statusBar too dark

before
after
I use Colorful.config(this) .translucent(true) .apply(); to make my Drawerlayout's content translucent, but to find it makes it too dark, which didn't happen if I use custom Theme instead of this library.
FIY, my original theme contains these properties:

        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

Load style resources by name not by id

Resource IDs are not 100% guaranteed to never change and this could potentially cause problems. We should be loading style resources internally by string name over res id int.

ThemeEditor public apply method needs null check

The Readme states:

The apply method optionally takes a high-order function as a argument. This serves as a callback that will be triggered once Colorful has finished it's theme changes

However, ThemeEditor#apply() infers a @nonnull annotation on both of its arguments.
If this is to match the readme, the callback should be optional, and therefore must have a null check before being called.

I believe this will also make things easier for non-Kotlin users to make use of.

Thanks

Disabled override how to use light/dark theme

@garretyoder Dark/Light themeing will not work when override is disable, I try using "setCustomThemeOverride" to set it in style , when I changed Light to the Dark theme, but it will not change immediately, Only change after restarting the app. What did i do wrong? How should I correct it?

Code

Activity.java

        Colorful().edit()
                .setCustomThemeOverride(darkTheme ? R.style.AppThemeDark: R.style.AppTheme)
                .apply(getContext(), () -> {
                    recreate();
                    return null;
                });

BaseActivity.java

ColorfulKt.Colorful().apply(this, false, true);

Style.xml

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    </style>

    <style name="AppThemeDark" parent="Theme.AppCompat.NoActionBar">
    </style>

Not working after app restart

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):

     fun init(app: Application) {
     	var primaryColor = when (AppPrefs.themeColor) {
     		"0" -> ThemeColor.GREEN
     		"1" -> ThemeColor.RED
     		"2" -> ThemeColor.PINK
     		"3" -> ThemeColor.BLUE
     		else -> ThemeColor.GREEN
     	}
     	var accentColor = when (AppPrefs.themeColor) {
     		"0" -> ThemeColor.ORANGE
     		"1" -> ThemeColor.BLUE
     		"2" -> ThemeColor.BLUE
     		"3" -> ThemeColor.RED
     		else -> ThemeColor.GREEN
     	}
     	val defaults = Defaults(
     			primaryColor = primaryColor,
     			accentColor = accentColor,
     			useDarkTheme = darkTheme(),
     			translucent = false,
     			customTheme = baseActivityTheme()
     	)
     	initColorful(app, defaults)
     }
    
  2. Update colorful whenever my preferences change:

     fun update(context: Context) {
     	var primaryColor = when (themeColor()) {
     		Color.Green -> ThemeColor.GREEN
     		Color.Red -> ThemeColor.RED
     		Color.Rosa -> ThemeColor.PINK
     		Color.Blue -> ThemeColor.BLUE
     	}
     	var accentColor = when (themeColor()) {
     		Color.Green -> ThemeColor.ORANGE
     		Color.Red -> ThemeColor.BLUE
     		Color.Rosa -> ThemeColor.BLUE
     		Color.Blue -> ThemeColor.RED
     	}
     	Colorful().edit()
     			.setPrimaryColor(primaryColor)
     			.setAccentColor(accentColor)
     			.setDarkTheme(darkTheme())
     			.setTranslucent(false)
     			.setCustomThemeOverride(baseActivityTheme())
     			.apply(context)
     }
    

Observations

  • my own prefs are correct, your's as well
  • theme is not applied on app start (task description works though)
  • if I change the theme in my app and call the above update function, all my activities are themed correctly until I kill my app and restart it

Any ideas why?

"setPrimaryColor" and "setCustomThemeOverride" conflict

@garretyoder Using "setPrimaryColor" and "setCustomThemeOverride" at the same time, "setPrimaryColor" will not work when the application is restarted

Code

Activity.java

        Colorful().edit()
                .setAccentColor(ThemeColor.PINK)
                .setCustomThemeOverride(R.style.AppThemeWhite)
                .apply(getContext(), () -> {
                    recreate();
                    return null;
                });

BaseActivity.java

ColorfulKt.Colorful().apply(this, false, true);

Style.xml

    <style name="AppThemeWhite" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/white</item>
        <item name="toolbarStyle">@style/AppThemeWhite.Toolbar</item>
    </style>

    <style name="AppThemeWhite.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
        <item name="titleTextAppearance">@style/AppThemeWhite.Toolbar.Title</item>
        <item name="subtitleTextAppearance">@style/AppThemeWhite.Toolbar.Subtitle</item>
    </style>

    <style name="AppThemeWhite.Toolbar.Title" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">
        <item name="android:textColor">?attr/colorAccent</item>
    </style>

    <style name="AppThemeWhite.Toolbar.Subtitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
        <item name="android:textColor">?attr/colorAccent</item>
    </style>

ColorClickerPreference crash

I am using Colorful and want to allow users choose themes from settings. Added ColorClickerPreference to my preferences file and getting crash when trying to open settings now.

Log

FATAL EXCEPTION: main
Process: com.itemstudio.castro, PID: 22833
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.itemstudio.castro/com.itemstudio.castro.settings.SettingsActivity}: java.lang.ClassCastException: org.polaric.colorful.ColorPickerPreference cannot be cast to android.preference.Preference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2741)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

Caused by: java.lang.ClassCastException: org.polaric.colorful.ColorPickerPreference cannot be cast to android.preference.Preference
at android.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:104)
at android.preference.GenericInflater.rInflate(GenericInflater.java:490)
at android.preference.GenericInflater.inflate(GenericInflater.java:327)
at android.preference.GenericInflater.inflate(GenericInflater.java:264)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:280)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:326)
at com.itemstudio.castro.settings.SettingsFragment.onCreate(SettingsFragment.java:23)
at android.app.Fragment.performCreate(Fragment.java:2336)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:949)
at android.app.BackStackRecord.setLastIn(BackStackRecord.java:861)
at android.app.BackStackRecord.calculateFragments(BackStackRecord.java:901)
at android.app.BackStackRecord.run(BackStackRecord.java:728)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentController.execPendingActions(FragmentController.java:371)
at android.app.Activity.performStart(Activity.java:6695)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2643)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2741) 
at android.app.ActivityThread.-wrap12(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6176) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

Support user-defined color styles

Colorful uses a android's ability to mix style files together to build complex themes. Since these are stored in XML files in a standard naming format, the functionality could be added to allow users to provide additional colors via style files.

Support colorPrimaryDark (and maybe more)

At least to be able to set the colorPrimaryDark as well through Colorful would be very nice.

Additional text colors would be nice as well altough it's not that important...

"Dynamically"

What does "dynamically" mean?

Is an Activity restart required?

Should be added to the readme.

Support dynamic configs

Instead of always loading the saved preferences, could you add support for a dynamic config?

E.g. I would like to pass in a custom Defaults to Colorful().apply(this, override = true, appcompat = false) which should be used instead of the saved one if present

How to customize views in theme?

I have forced to load an style by calling:

            Colorful().edit()
                .setPrimaryColor(ThemeColor.RED)
                .setAccentColor(ThemeColor.BLUE)
                .setDarkTheme(false)
                .setTranslucent(false)
                .setCustomThemeOverride(R.style.AppThemeDark)
                .apply(activity!!) { activity!!.recreate() }

And set a textAppearance in my style:
Screen Shot 1397-12-21 at 15 11 45

But nothing seems to take a change in text color of my textviews or buttons.

Is there any guide to how to customize widgets?

What is the use of "override" and "appcompat"?

Hi, thankyou your library, I'm useing 2.0 version now, I want know what is the use of override and appcompat?

ColorfulKt.Colorful().apply(activity, override, appcompat);

When should I use true and when should I use false?

Performing pause of activity that is not resumed

When I apply theme in my setting activity, return to MainActivity, then go to setting activity, I got the following error log(which seems not influence my app):

12-28 17:37:49.563 23151-23151/com.dante.girls E/ActivityThread: Performing pause of activity that is not resumed: {com.dante.girls/com.dante.girls.MainActivity}
                                                                 java.lang.RuntimeException: Performing pause of activity that is not resumed: {com.dante.girls/com.dante.girls.MainActivity}
                                                                     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3352)
                                                                     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3340)
                                                                     at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3315)
                                                                     at android.app.ActivityThread.-wrap13(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Each time I do those actions I got that error, so it's not occasional.

Use THEME_MATERIAL appear error log

@garretyoder If use THEME_MATERIAL or THEME_MATERIAL_COMPONETS, the following error will appear. What did i do wrong?

Code
ColorfulKt.Colorful().apply(this, true, BaseTheme.THEME_MATERIAL_COMPONETS);

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Log

AppCompatDelegate: Failed to instantiate custom view inflater android.support.design.theme.MaterialComponentsViewInflater . Falling back to default.
    java.lang.ClassNotFoundException: Invalid name: android.support.design.theme.MaterialComponentsViewInflater 
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at java.lang.Class.forName(Class.java:378)
        at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1014)
        at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)

Migrate to AndroidX

As the AndroidX version of AppCompat is stable now, I'd recommend to update.

Colorful has error when start strict mode

Colorful has error when start strict mode

image

    override fun onCreate() {
        if (BuildConfig.DEBUG) {
            setStrictMode()
        }
        super.onCreate()
    }

    private fun setStrictMode() {
        StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .detectNetwork()   // or .detectAll() for all detectable problems
                .penaltyLog()
                .build())
        StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .penaltyDeath()
                .build())
    }

Feedback colorful problem

  1. How to get primary and accent color res?
  2. ThemeColor have't white and black color ThemeColor.WHITE, how to set primary or accent color to white or black color?

Compile issue error: style attribute 'attr/colorSecondary

I'm getting the error with the latest build 2.3.3 in my compiler
error: style attribute 'attr/colorSecondary (aka com.***.**:attr/colorSecondary)' not found.
Errors are pointing to the values.xml file in Colorful lib specifically accent1 to accent 20

Kindly assist.
I'm on android support lib 27.1.1

startSupportActionMode works not propertly with Colorful

I have added Colorful library into my app and ActionMode is broken now. Action toolbar appears above the toolbar. Looks like Colorful style doesn't have or ignore my windowActionModeOverlay.

Library initialized as:

 CustomThemeColor defaultTheme = new CustomThemeColor(
                this,
                R.style.my_default_primary_color,
                R.style.my_default_rimary_dark_color,
                R.color.colorPrimary,
                R.color.colorPrimary
        );
        Defaults themeDefaults = new Defaults(
                defaultTheme,
                defaultTheme,
                false,
                false,
                R.style.AppTheme
        );
        initColorful(this, themeDefaults);

Activity extends CAppCompatActivity. But startSupportActionMode leads to this:
screen

Do you know how to fix this?

Attribute "dialogTitle" already defined with incompatible format

There should be a conflict between your library and another one. When adding Colorful it shows a Gradle problem that say:

Error:(723) Attribute "dialogTitle" already defined with incompatible format.

As soon as I delete the dependency the error disappears. I hope you can fix this.

Some times primaryColor and accentColor are not used

@garretyoder I want to use "customTheme", because only in this way can I change textColorPrimary color, but now primaryColor and accentColor are not used, this may be misunderstood, but these two values are non-null.

    val defaults:Defaults = Defaults(
            primaryColor = ThemeColor.GREEN,
            accentColor = ThemeColor.BLUE,
            useDarkTheme = false,
            translucent = false,
            customTheme = R.style.AppTheme)
    initColorful(this, defaults)

Use custom color

How to set custom color codes for Accent and Primary colors, such as#FFFFFF?

If not support now, can you add a method to set the color code for Primary and Accent? This is useful, thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.