Giter Site home page Giter Site logo

jaredrummler / cyanea Goto Github PK

View Code? Open in Web Editor NEW
1.4K 27.0 144.0 7.17 MB

A theme engine for Android

License: Apache License 2.0

Kotlin 99.38% Java 0.62%
android theme themeengine dynamic color material material-design material-ui kotlin material-components

cyanea's Introduction

Cyanea

A theme engine for Android.
Themes are immutable, possibilities are beautiful.

License Build Status Maven Central API

About

A powerful, dynamic, and fun theme engine. Named after Octopus Cyanea which is adept at camouflage and not only can change color frequently, but also can change the patterns on and texture of its skin.

Downloads

Download the latest AAR or grab via Gradle:

implementation 'com.jaredrummler:cyanea:1.0.2'

Demo

You can download an APK of the demo project


Getting Started

Step 1

Getting the project setup to use Cyanea is simple. First, initialize Cyanea in your Application class:

class MyApplication : Application() {

  override fun onCreate() {
    super.onCreate()
    Cyanea.init(this, resources)
  }

}

Also ensure that your MyApplication class is registered in your AndroidManifest.xml file:

<manifest
  xmlns:android="http://schemas.android.com/apk/res/android"
    ...>
  <application
    android:name=".MyApplication"
  ...>
  </application>
</manifest>

Alternatively, you can use com.jaredrummler.cyanea.CyaneaApp as the Application class or have MyApplication class inherit from CyaneaApp (recommended).

Step 2

You must declare your activity to extend any of the activity classes that start with 'Cyanea' (e.g., CyaneaAppCompatActivity, CyaneaFragmentActivity).

class MyActivity : CyaneaAppCompatActivity() {

}

If you can't extend your activity class, create a CyaneaDelegate and add the appropriate methods. See CyaneaAppCompatActivity.kt as an example.

Step 3

Each activity must use a Theme.Cyanea theme (or decendant). You should declare the theme in the AndroidManifest:

<activity
  android:name=".MyActivity"
  android:theme="@style/Theme.Cyanea.Light.DarkActionBar"/>

The library provides core themes — one of which must be applied to each activity:

  • Theme.Cyanea.Dark
  • Theme.Cyanea.Dark.LightActionBar
  • Theme.Cyanea.Dark.NoActionBar
  • Theme.Cyanea.Light
  • Theme.Cyanea.Light.DarkActionBar
  • Theme.Cyanea.Light.NoActionBar

Step 4

Set a default primary and accent color for the app in colors.xml:

<resources>
  <color name="cyanea_primary_reference">#0288D1</color>
  <color name="cyanea_accent_reference">#FFA000</color>
</resources>

Note: Do not set colorPrimary, colorPrimaryDark, colorAccent, etc. in the theme in styles.xml.

User Preferences

Cyanea adds preferences for choosing the primary, accent and background colors of the app. A theme-picker with 50+ pre-defined themes is also included in the library.

Activities

The following activites are added to launch the preferences and theme picker: CyaneaSettingsActivity, CyaneaThemePickerActivity.

Pre-defined themes

To override and create your own pre-defined themes add the following file to your project: assets/themes/cyanea_themes.json. The file must be a JSON array with each theme as seen here.

Minimal JSON required for a pre-defined theme:

{
  "theme_name": "Vitamin Sea",
  "base_theme": "LIGHT",
  "primary": "#0359AE",
  "accent": "#14B09B",
  "background": "#EBE5D9"
}

Dynamic Theming

Use the following code to change the primary, accent or background colors of the app:

cyanea.edit {
  primary(Color.BLUE)
  accent(Color.CYAN)
  backgroundResource(R.color.background_material_dark)
  // Many other theme modifications are available
}.recreate(activity)

The methods which end with Resource take a color resource. Remove Resource to pass a literal (hardcoded) color integer. Unlike several other open source libraries, Cyanea can use any color you specify for primary, accent and background; you don't need pre-defined styles.

You can get the current colors using cyanea.primary or using the default instance Cyanea.instance.primary.

Using Colors

Most views will automatically be themed using the library. To use the primary, accent, background, etc. colors use attributes in your layouts:

Attributes:

  • ?colorPrimary
  • ?colorPrimaryDark
  • ?colorAccent
  • ?backgroundColor
  • ?backgroundColorDark
  • ?backgroundColorLight
  • ?menuIconColor
  • ?subMenuIconColor

Example:

<com.example.MyCustomView
  android:background="?backgroundColor"
  android:textColor="?colorAccent"
  app:someOtherColor="?colorPrimary" />

You can also use the primary, accent, background colors using @color/cyanea_primary_reference.

Advanced Usage

Processing Views

You can modify a view before it is laid out using a CyaneaViewProcessor. Simple let your Activity or Application implement CyaneaViewProcessor.Provider and add your processors to the array.

Example:

class MyActivity : Activity(), CyaneaViewProcessor.Provider {

  override fun getViewProcessors(): Array<CyaneaViewProcessor<out View>> = arrayOf(
      // Add a view processors to manipulate a view when inflated.
      object : CyaneaViewProcessor<TextView>() {
        override fun getType(): Class<TextView> = TextView::class.java
        override fun process(view: TextView, attrs: AttributeSet?, cyanea: Cyanea) {
          view.text = "Hijacked!"
        }
      }
  )

}

Decorators

You can inject custom attributes into layout files using CyaneaDecorator. The library ships with a FontDecorator which allows you to use app:cyaneaFont="path/to/Font.ttf" in any view. The font will automatically be set on the view. To implement your own decorator, let your Activity or Application implement CyaneaDecorator.Provider and return an array of your custom decorators.

Example:

class MyActivity : Activity(), CyaneaDecorator.Provider {

  override fun getDecorators(): Array<CyaneaDecorator> = arrayOf(
      // Add a decorator to apply custom attributes to any view
      FontDecorator()
  )

}

Please reference the FontDecorator as an example.

Inflation Delegate

You can add an inflation delegate to hook into when views are created and create the views yourself.

Example:

Cyanea.setInflationDelegate(object : CyaneaInflationDelegate {
  override fun createView(parent: View?, name: String, context: Context, attrs: AttributeSet): View? {
    var view: View? = null
    if (name == "androidx.appcompat.widget.Toolbar") {
      view = MyCustomToolbar(context, attrs)
    }
    return view
  }
})

License

Copyright (C) 2018 Jared Rummler

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

cyanea's People

Contributors

inorichi avatar jaredrummler avatar jaredsburrows avatar jrcacd 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

cyanea's Issues

Not Compatible with Android Q

IllegalStateException: when (name) {
LAYOUT…etSystemService(name)
} must not be null
at com.jaredrummler.cyanea.inflator.CyaneaContextWrapper.getSystemService

?actionBarTheme for Toolbar seems not correct before change the theme

In the demo-main module, we can see that the DrawerActivity includes a Toolbar.

But when first run it (Don't change theme), the toolbar's text color seems not correct. Here are the screenshots:
screenshot-2019-08-16_00 17 27 984
It's okay, MainActivity don't use Toolbar.

screenshot-2019-08-16_00 16 40 540
The title text color of Toolbar and other menu icons color is black rather than white.

Devices:

  • Genymotion Android 8.0
  • Xiaomi mix2s MIUI 10 Android 9.0

FloatingActionButton can't be applied color reference

Show Wallpaper Theme?

I've currently trying to implement this in a new launcher project. Works great but the Background color is breaking the background I've set to null to show the device Wallpaper. Could we have a theme setup for showing wallpapers or a toggle in the theme settings to override the window background to show wallpapers so it doesn't break bottom sheets or other views dependent of background color.

Thankyou

Add CI

Circle CI for private repo

Need Help

Can we change the
private val processors = hashSetOf<CyaneaViewProcessor>()
to
private val processors = ArryList<CyaneaViewProcessor>()

Bcz if I override fun getViewProcessors() in My activity for textview.
1.It added not last val processors in between some index.
2.So TextViewProcessor call after getViewProcessors() of my activity and color of text not change.

Thanks
Akash

How to instantiate the backgound color?


> Set a default primary and accent color for the app in colors.xml:
> 
> <resources>
>   <color name="cyanea_primary_reference">#0288D1</color>
>   <color name="cyanea_accent_reference">#FFA000</color>
> </resources>

Clean up and fix all warnings

Warnings:

$ gradlew -Dorg.gradle.configureondemand=false assemble
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaResources.kt: (15, 5): 'constructor Resources(AssetManager!, DisplayMetrics!, Configuration!)' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaResources.kt: (65, 13): 'getDrawable(Int): Drawable!' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaResources.kt: (98, 13): 'getColor(Int): Int' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaResources.kt: (104, 18): 'getColorStateList(Int): ColorStateList!' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaTheme.kt: (158, 20): 'getColor(Int): Int' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/CyaneaTheme.kt: (167, 20): 'getColor(Int): Int' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/delegate/CyaneaDelegateImplBase.kt: (91, 13): Unchecked cast: CyaneaViewProcessor<*> to CyaneaViewProcessor<View>
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/delegate/CyaneaDelegateImplBase.kt: (98, 13): Unchecked cast: CyaneaViewProcessor<*> to CyaneaViewProcessor<View>
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/delegate/CyaneaDelegateImplBase.kt: (105, 13): Unchecked cast: CyaneaViewProcessor<*> to CyaneaViewProcessor<View>
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/delegate/CyaneaDelegateImplV21.kt: (36, 34): 'constructor TaskDescription(String!, Bitmap!, Int)' is deprecated. Deprecated in Java
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/inflator/CyaneaContextWrapper.kt: (26, 35): Type mismatch: inferred type is String? but String was expected
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/inflator/CyaneaLayoutInflater.kt: (101, 32): Parameter 'parent' is never used
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/inflator/CyaneaLayoutInflater.kt: (112, 45): Unchecked cast: Any! to Array<Any>
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/tinting/CyaneaTinter.kt: (57, 34): Name shadowed: colorStateList
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/tinting/CyaneaTinter.kt: (117, 35): Unchecked cast: Any! to Array<Any?>
w: /Users/noname/repo/Cyanea/library/src/main/java/com/jaredrummler/cyanea/tinting/MenuTint.kt: (168, 14): 'setAlpha(Int): Unit' is deprecated. Deprecated in Java

Fix then apply:

tasks.withType(KotlinCompile) {
    kotlinOptions {
        jvmTarget = "1.8"
        allWarningsAsErrors = true
    }
}

Status bar color broken in Android kitkat

Hello,
I really like this library, but it is broken on Android kitkat (maybe even some newer versions, I only have a kitkat and oreo device available). The status bar is transparent with the background color behind it, therefore it looks really ugly with light themes. On the oreo device, everything works fine.

Device: Samsung Galaxy S4 mini GT-I9195I
Android version: 4.4.4
Steps to reproduce: install the Cyanea demo app onto the device
Screenshot_2020-03-20-22-18-21
Screenshot_2020-03-20-22-18-42

Do you know any workaround or a way to fix it properly?

Does this library support AndroidX?

Errors occur when I change the theme

I get the following error when I try to change the theme
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.drewan.klix, PID: 9595 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.drewan.klix/com.drewan.klix.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.getDecorView()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.getDecorView()' on a null object reference at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:675) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:618) at androidx.appcompat.app.AppCompatDelegateImpl.initWindowDecorActionBar(AppCompatDelegateImpl.java:390) at androidx.appcompat.app.AppCompatDelegateImpl.getSupportActionBar(AppCompatDelegateImpl.java:377) at androidx.appcompat.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:105) at com.jaredrummler.cyanea.tinting.SystemBarTint.<init>(SystemBarTint.kt:126) at com.jaredrummler.cyanea.delegate.CyaneaDelegateImplBase.tintBars(CyaneaDelegateImplBase.kt:150) at com.jaredrummler.cyanea.delegate.CyaneaDelegateImplBase.onCreate(CyaneaDelegateImplBase.kt:60) at com.jaredrummler.cyanea.delegate.CyaneaDelegateImplV21.onCreate(CyaneaDelegateImplV21.kt:45) at com.jaredrummler.cyanea.delegate.CyaneaDelegateImplV23.onCreate(CyaneaDelegateImplV23.kt:53) at com.jaredrummler.cyanea.delegate.CyaneaDelegateImplV24.onCreate(CyaneaDelegateImplV24.kt:40) at com.jaredrummler.cyanea.app.CyaneaAppCompatActivity.onCreate(CyaneaAppCompatActivity.kt:48) at com.drewan.klix.MainActivity.onCreate(MainActivity.java:14) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6119)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)  Application terminated.

Add ability to import themes

Import themes from JSON file.

Structure:

[
  {
    "theme_name": "Cyanea",
    "base_theme": "LIGHT",
    "primary": "#FF3F51B5",
    "primary_dark": "#FF354499",
    "primary_light": "#FF5B6BC0",
    "accent": "#FFFF5722",
    "accent_dark": "#FFD8491C",
    "accent_light": "#FFFF7043",
    "background": "#FFEEEEEE",
    "background_darker": "#FFCACACA",
    "background_lighter": "#FFF0F0F0",
    "menu_icon_color": "#FFFFFFFF",
    "navigation_bar": "#FF3F51B5",
    "sub_menu_icon_color": "#FF000000"
  }
]

Required keys:

theme_name
base_theme
primary
accent
background

Fragments in a viewpager not being themed properly.

I have three fragments in a FragmentStatePagerAdapter almost done exactly like the demo project, however none of the fragments are theming properly. The parent activity is themed properly and the primary and accent colors are working however the ?backgroundColor attribute is not.

https://github.com/ItsCalebJones/SpaceLaunchNow-Android/tree/dev-new-ui/mobile/src/main/java/me/calebjones/spacelaunchnow/ui/launchdetail

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/summary_card"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/material_card_edge_margin"
            android:animateLayoutChanges="true"
            android:padding="@dimen/material_card_edge_margin"
            android:visibility="visible"
            app:cardBackgroundColor="?backgroundColor"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="@dimen/material_card_elevation_resting"
            card_view:cardPreventCornerOverlap="true"
            card_view:cardUseCompatPadding="true">

It seems to be very similar to #41 where at runtime calling getCyanea() can return the correct colors which means I could manually set the colors for each view, however that defeats the purpose of a clean library.

Notice cardBackground is using correct dark styling:
screenshot_1545329519

Now a fragment inside the viewpager is not using correct dark styling:
screenshot_1545329547

From the fragment if I call the getBackground I can then set that color, but I'd also need to set all textViews as they are not being styled properly either.

Background color for default theme is always white

Whenever I fetch programmatically the backgroundColorDark and Light they're respectively white and gray, my activity has the theme Theme.Cyanea.Dark.NoActionBar.
The ?colorBackgroundDark and ?colorBackgroundLight seem to work fine

Crash with inflating NavHostFragment

Hi,

I am using the new Navigation Architecture for Fragment transactions. My home screen has a NavHostFragment defined in its layout.

For theming I am using the CyaneaThemePickerActivity. After picking a theme, if I press the back button to navigate back to the home screen, I get this crash. I am unable to find out what the root cause is.

Adding the stack trace below for reference,


Unable to start activity ComponentInfo{com.example.features.home.HomeActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #79: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)
        at android.app.ActivityThread.-wrap19(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #79: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #79: Error inflating class fragment
     Caused by: java.lang.IllegalStateException: Fragment androidx.navigation.fragment.NavHostFragment did not create a view.
        at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3778)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:120)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
        at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater$PrivateWrapperFactory2.onCreateView(CyaneaLayoutInflater.kt:210)
        at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater.inflate(CyaneaLayoutInflater.kt:61)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
        at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
        at com.example.features.home.HomeActivity.initBindingAndViewModel(HomeActivity.kt:220)
        at com.example.features.home.HomeActivity.init(HomeActivity.kt:86)
        at com.example.features.home.HomeActivity.onCreate(HomeActivity.kt:81)
        at android.app.Activity.performCreate(Activity.java:6679)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)
        at android.app.ActivityThread.-wrap19(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Color applied incorrectly

While implementing and testing around, I found out that sometimes colors are applied incorrectly and it required clear app data to reset it. Sometimes force stop app will help, sometimes it require clear app data.

Noticed that the color accent applied to TextView/CardView/ActionBar title where it shouldn't.

Tested on: normal device and emulator, android 9.0 and 8.0 with v1.0.1 library

Comparing the "normal" pref xml (com.jaredrummler.cyanea) and "incorrect" xml, found out accent_light and accent_dark values is different.

Not sure is related to pref commit is having race condition or the activity recreated and wrong color applied.

I decided to test on the demo app that downloaded directly from here, which also the same results.

image

image

Video: https://file.io/GEztLq or https://upload.cat/88665821462cd5ed

Theme Picker Fragment Request

Id like to see the Theme Picker and color picker activities added as fragments so we can adjust and style the window like the whole project.

Ex: I use center toolbar titles in my app but when the users access these activities, they are consumed of why these aren't center titled.

Accessing hidden field violation

Hi @jaredrummler , I am facing issue using the library on Android 10.
When I set the colors in onCreate(...) before setContentView(...), the color is applied but the view keeps blinking.

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        cyanea.edit {
            primary(Color.BLACK)
            accent(Color.BLUE)
        }

        setContentView(R.layout.activity_main)
        setSupportActionBar(toolbar)

        fab.setOnClickListener { view ->
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show()
        }
    }

Below is the logs for the issue.

com.mobily.thememanager W/ly.thememanage: Accessing hidden field Landroid/graphics/drawable/GradientDrawable;->mGradientState:Landroid/graphics/drawable/GradientDrawable$GradientState; (greylist-max-p, reflection, denied)
com.mobily.thememanager W/ly.thememanage: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)

Can I apply any solution or it needs to applied within the library?
I tried applying the command

adb shell settings put global hidden_api_policy  1

The logs are not shown anymore but still the view keeps blinking.

Getting more errors after adding library and sync project

After adding this library on my project i get this below errors:

BTW i dont use androidX in my project

Android resource linking failed
Output:  D:\Projects\Android\materialx-21\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
D:\Projects\Android\materialx-21\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
D:\Projects\Android\materialx-21\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1462: error: resource android:attr/fontVariationSettings not found.
D:\Projects\Android\materialx-21\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1462: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Command: C:\Users\mahdi\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\31830a7344ad9d31563398b090cc4da6\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
        D:\Software\sdk\platforms\android-27\android.jar\
        --manifest\
        D:\Projects\Android\materialx-21\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        D:\Projects\Android\materialx-21\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @D:\Projects\Android\materialx-21\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        D:\Projects\Android\materialx-21\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --custom-package\
        ir.cafeAlachiq.instagramApplication\
        -0\
        apk\
        --output-text-symbols\
        D:\Projects\Android\materialx-21\app\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

Issue with ?colorPrimary not applying the correct color.

No matter what 'theme' I select the default primary color is only being used for ?colorPrimary.

The blue Title bar on the card is using the attribute:

android:background="?colorPrimary"

The default theme color:

    <color name="cyanea_primary_reference">#2196F3</color>
    <color name="cyanea_accent_reference">#FF5252</color>

The current applied theme in the screenshot is 'Cyanae'.

screenshot_1545073380

EDIT: If I leave that fragment and come back the correct styling applies. I suppose that means I need to reapply the styling in onResume in the fragment just to be sure?

menu icons will allways get color tint

A symbol in the menu.item is always filled with color.
It would be nice if there was a configuration that would prevent this behavior if you have a company logo or other symbol that you would like to keep his color.

like setting the android:iconTint="@null"

[HELP] Custom Font Support

Hi,
I am using Calligraphy for custom font support of user choice. But after coming to Cyanea, the fonts are not applied to the application.

I read about the FontDecorator but is it only to be used in XML (Also I'm not getting the kotlin part, I'm still using Java). I want to use custom fonts of user choice from a list of given fonts stored in assets. How am I supposed to use them?

Unable to override color attributes

I want to overwrite the textColorPrimary color to red. When I change the color, the textColorPrimary in the Android Studio preview is red (the correct effect), but the effect of running the display is black, and the color of textColorPrimary has not changed. This problem also exists in the Colorful library. How can I fix this problem?

49334689-a7385380-f616-11e8-8578-feaafdab21b0
image
49334694-c505b880-f616-11e8-9796-b9b8c44beacc
tim 20181202094843

Custom Status Bar Color

I want the status bar colour to match the Toolbar colour.
How can I achieve that ?
Is there any API for that or do I have to edit the plugin ?

CyaneaContextWrapper getSystemService IllegalStateException

Could be 💩 firmware related issues.

image

Model:

FL02
6045I
5015E
SM-G350E
VFD 610

android version: 6.0 (70%), 4 (13%), 5 (12%), 7 (5%)

Fatal Exception: java.lang.IllegalStateException: when (name) {
    LAYOUT…etSystemService(name)
  } must not be null
       at com.jaredrummler.cyanea.inflator.CyaneaContextWrapper.getSystemService(SourceFile:4)
       at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:123)
       at android.app.Activity.getSystemService(Activity.java:5296)
       at android.view.ViewRootImpl.(ViewRootImpl.java:503)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:306)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3347)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1472)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:207)
       at android.app.ActivityThread.main(ActivityThread.java:5743)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)

Holiday Wishes...

I just wanted to wish @jaredrummler Family and Friends the Best Wishes, Happy Holidays and a Happy New Year!!!

I hope this year ends even more Uplifting and Promising as the last (bumpy) year has ended with!!

Take care My Friend.

~Ibuprophen

CyaneaFragment declarations clash

The onCreateOptionsMenu method in CyaneaFragment has a clash with the same method in Fragment. Seems to be fixed/happen with unrelated build.gradle changes.

Error
Inherited platform declarations clash: The following declarations have the same JVM signature (onCreateOptionsMenu(Landroid/view/Menu;Landroid/view/MenuInflater;)V): fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater): Unit defined in com.andb.apps.todo.InboxFragment fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater?): Unit defined in com.andb.apps.todo.InboxFragment

Crash inflating view on Android 4.4.X

The layout doesn't even reference anything from the theme engine as far as I can tell.

Here's the stacktrace:

Caused by java.lang.NumberFormatException: Invalid int: "res/color/cyanea_primary.xml"
       at java.lang.Integer.invalidInt(Integer.java:137)
       at java.lang.Integer.parse(Integer.java:374)
       at java.lang.Integer.parseInt(Integer.java:365)
       at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:122)
       at android.content.res.TypedArray.getInt(TypedArray.java:267)
       at android.widget.ImageView.(ImageView.java:166)
       at androidx.appcompat.widget.AppCompatImageView.(SourceFile:72)
       at androidx.appcompat.widget.AppCompatImageView.(SourceFile:68)
       at androidx.appcompat.app.AppCompatViewInflater.createImageView(SourceFile:187)
       at androidx.appcompat.app.AppCompatViewInflater.createView(SourceFile:107)
       at androidx.appcompat.app.AppCompatDelegateImpl.createView(SourceFile:1267)
       at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(SourceFile:1317)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater$WrapperFactory2.onCreateView(SourceFile:195)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:762)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:771)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater.inflate(SourceFile:61)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
       at cz.kinst.jakub.view.SimpleStatefulLayout.init(SourceFile:216)
       at cz.kinst.jakub.view.SimpleStatefulLayout.(SourceFile:36)
       at java.lang.reflect.Constructor.constructNative(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
       at android.view.LayoutInflater.createView(LayoutInflater.java:601)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater.processView(SourceFile:138)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater.access$createCustomView(SourceFile:34)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:213)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:762)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
       at com.jaredrummler.cyanea.inflator.CyaneaLayoutInflater.inflate(SourceFile:61)
       at me.calebjones.spacelaunchnow.news.ui.news.NewsListFragment.onCreateView(SourceFile:73)
       at androidx.fragment.app.Fragment.performCreateView(SourceFile:2530)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(SourceFile:887)
       at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(SourceFile:1233)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(SourceFile:1299)
       at androidx.fragment.app.BackStackRecord.executeOps(SourceFile:688)
       at androidx.fragment.app.FragmentManagerImpl.executeOps(SourceFile:2069)
       at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(SourceFile:1859)
       at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(SourceFile:1814)
       at androidx.fragment.app.FragmentManagerImpl.execSingleAction(SourceFile:1691)
       at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(SourceFile:537)
       at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(SourceFile:148)
       at androidx.viewpager.widget.ViewPager.populate(SourceFile:1244)
       at androidx.viewpager.widget.ViewPager.populate(SourceFile:1092)
       at androidx.viewpager.widget.ViewPager.onMeasure(SourceFile:1622)
       at android.view.View.measure(View.java:16749)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android.view.View.measure(View.java:16749)
       at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(SourceFile:1227)
       at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(SourceFile:1572)
       at android.view.View.measure(View.java:16749)
       at androidx.drawerlayout.widget.DrawerLayout.onMeasure(SourceFile:1119)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasureChild(SourceFile:733)
       at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(SourceFile:805)
       at android.view.View.measure(View.java:16749)
       at androidx.drawerlayout.widget.DrawerLayout.onMeasure(SourceFile:1119)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at androidx.appcompat.widget.ContentFrameLayout.onMeasure(SourceFile:143)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1413)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:696)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:589)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2439)
       at android.view.View.measure(View.java:16749)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2072)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1175)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1062)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5996)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android.view.Choreographer.doFrame(Choreographer.java:544)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5590)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)

Here's the layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/news_coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <cz.kinst.jakub.view.SimpleStatefulLayout
        android:id="@+id/news_stateful_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:emptyLayout="@layout/empty_news"
        app:progressLayout="@layout/custom_progress">

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:id="@+id/news_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/news_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
    </cz.kinst.jakub.view.SimpleStatefulLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Duplicate Classes found

After I include on gradle your library, I get all errors from your depedencies.
Duplicate classes found org.jetbrains*, androidx ... etc...

CardView background colour automatically changing

I am having an issue where the cardviews in a 'Details' Fragment is changing to wrong colours.
I am setting the colour to '?backgroundColor' and It works initially when I set the theme, but then it automatically changes to a colour value of #303030 when I close and Re-open the app

The ?backgroundColor tag is used in another fragment as the layout background, that doesn't change to this colour, only the card background colour changes to #303030 automatically

This is what it becomes:
screenshot_launchtrack_20181203-164312

This is what I actually set the colour values to, just #000000
screenshot_launchtrack_20181203-164259

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.