{"id":13428302,"url":"https://github.com/jaredrummler/Cyanea","last_synced_at":"2025-03-16T01:32:27.810Z","repository":{"id":48325505,"uuid":"117906712","full_name":"jaredrummler/Cyanea","owner":"jaredrummler","description":"A theme engine for Android","archived":false,"fork":false,"pushed_at":"2022-05-05T02:56:22.000Z","size":7338,"stargazers_count":1451,"open_issues_count":36,"forks_count":144,"subscribers_count":28,"default_branch":"master","last_synced_at":"2024-10-22T16:15:15.219Z","etag":null,"topics":["android","appcompat","color","dynamic","kotlin","material","material-components","material-design","material-ui","theme","themeengine"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredrummler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-17T23:49:00.000Z","updated_at":"2024-10-02T20:17:48.000Z","dependencies_parsed_at":"2022-09-13T23:23:56.360Z","dependency_job_id":null,"html_url":"https://github.com/jaredrummler/Cyanea","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredrummler%2FCyanea","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredrummler%2FCyanea/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredrummler%2FCyanea/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredrummler%2FCyanea/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredrummler","download_url":"https://codeload.github.com/jaredrummler/Cyanea/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221631913,"owners_count":16855020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","appcompat","color","dynamic","kotlin","material","material-components","material-design","material-ui","theme","themeengine"],"created_at":"2024-07-31T01:00:51.724Z","updated_at":"2024-10-27T05:30:58.941Z","avatar_url":"https://github.com/jaredrummler.png","language":"Kotlin","funding_links":[],"categories":["Libraries","Kotlin"],"sub_categories":[],"readme":"# Cyanea\n\n![](https://raw.githubusercontent.com/jaredrummler/github/main/assets/banners/no-longer-maintained.png)\n\n\u003cimg src=\"https://i.imgur.com/eC6d5WO.gif\" align=\"left\" hspace=\"10\" vspace=\"10\"\u003e\u003c/a\u003e\n\n**A theme engine for Android.**\n\u003cbr\u003e\n\u003csub\u003eThemes are immutable, possibilities are beautiful.\u003c/sub\u003e\n\n\u003ca target=\"_blank\" href=\"LICENSE\"\u003e\u003cimg src=\"http://img.shields.io/:license-apache-blue.svg\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003ca target=\"_blank\" href=\"https://travis-ci.org/jaredrummler/Cyanea\"\u003e\u003cimg src=\"https://travis-ci.org/jaredrummler/Cyanea.svg?branch=master\" alt=\"Build Status\" /\u003e\u003c/a\u003e\n\u003ca target=\"_blank\" href=\"https://maven-badges.herokuapp.com/maven-central/com.jaredrummler/cyanea\"\u003e\u003cimg src=\"https://maven-badges.herokuapp.com/maven-central/com.jaredrummler/cyanea/badge.svg\" alt=\"Maven Central\" /\u003e\u003c/a\u003e\n\u003ca target=\"_blank\" href=\"https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#ICE_CREAM_SANDWICH\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-14%2B-blue.svg?style=flat\" alt=\"API\" /\u003e\u003c/a\u003e\n\n# About\n\nA 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.\n\n# Downloads\n\nDownload [the latest AAR](https://repo1.maven.org/maven2/com/jaredrummler/cyanea/1.0.2/cyanea-1.0.2.aar) or grab via Gradle:\n\n```groovy\nimplementation 'com.jaredrummler:cyanea:1.0.2'\n```\n\n## Demo\n\nYou can download an [APK of the demo project](https://github.com/jaredrummler/Cyanea/blob/master/demo.apk?raw=true)\n\n\u003cbr\u003e\n\n# Getting Started\n\n#### Step 1\n\nGetting the project setup to use Cyanea is simple. First, initialize Cyanea in your `Application` class:\n\n```kotlin\nclass MyApplication : Application() {\n\n  override fun onCreate() {\n    super.onCreate()\n    Cyanea.init(this, resources)\n  }\n\n}\n```\n\nAlso ensure that your `MyApplication` class is registered in your `AndroidManifest.xml` file:\n\n```xml\n\u003cmanifest\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    ...\u003e\n  \u003capplication\n    android:name=\".MyApplication\"\n  ...\u003e\n  \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nAlternatively, you can use `com.jaredrummler.cyanea.CyaneaApp` as the `Application` class or have `MyApplication` class inherit from `CyaneaApp` (recommended).\n\n#### Step 2\n\nYou must declare your activity to extend any of the activity classes that start with 'Cyanea' (e.g., CyaneaAppCompatActivity, CyaneaFragmentActivity).\n\n```kotlin\nclass MyActivity : CyaneaAppCompatActivity() {\n\n}\n```\n\nIf you can't extend your activity class, create a `CyaneaDelegate` and add the appropriate methods. See [CyaneaAppCompatActivity.kt](https://github.com/jaredrummler/Cyanea/blob/master/library/src/main/java/com/jaredrummler/cyanea/app/CyaneaAppCompatActivity.kt) as an example.\n\n#### Step 3\n\nEach activity must use a `Theme.Cyanea` theme (or decendant). You should declare the theme in the `AndroidManifest`:\n\n```xml\n\u003cactivity\n  android:name=\".MyActivity\"\n  android:theme=\"@style/Theme.Cyanea.Light.DarkActionBar\"/\u003e\n```\n\nThe library provides core themes — one of which must be applied to each activity:\n\n- `Theme.Cyanea.Dark`\n- `Theme.Cyanea.Dark.LightActionBar`\n- `Theme.Cyanea.Dark.NoActionBar`\n- `Theme.Cyanea.Light`\n- `Theme.Cyanea.Light.DarkActionBar`\n- `Theme.Cyanea.Light.NoActionBar`\n\n#### Step 4\n\nSet a default primary and accent color for the app in `colors.xml`:\n\n```xml\n\u003cresources\u003e\n  \u003ccolor name=\"cyanea_primary_reference\"\u003e#0288D1\u003c/color\u003e\n  \u003ccolor name=\"cyanea_accent_reference\"\u003e#FFA000\u003c/color\u003e\n\u003c/resources\u003e\n```\n\nNote: Do *not* set `colorPrimary`, `colorPrimaryDark`, `colorAccent`, etc. in the theme in `styles.xml`.\n\n# User Preferences\n\n\u003cimg src=\"https://i.imgur.com/pjDEjWl.gif\" align=\"left\" hspace=\"10\" vspace=\"10\"\u003e\u003c/a\u003e\n\nCyanea 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.\n\n#### Activities\n\nThe following activites are added to launch the preferences and theme picker: `CyaneaSettingsActivity`, `CyaneaThemePickerActivity`.\n\n#### Pre-defined themes\n\nTo 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](https://github.com/jaredrummler/Cyanea/blob/master/library/src/main/assets/themes/cyanea_themes.json).\n\nMinimal JSON required for a pre-defined theme:\n\n```json\n{\n  \"theme_name\": \"Vitamin Sea\",\n  \"base_theme\": \"LIGHT\",\n  \"primary\": \"#0359AE\",\n  \"accent\": \"#14B09B\",\n  \"background\": \"#EBE5D9\"\n}\n```\n\n\u003cbr\u003e\n\n# Dynamic Theming\n\nUse the following code to change the primary, accent or background colors of the app:\n\n```kotlin\ncyanea.edit {\n  primary(Color.BLUE)\n  accent(Color.CYAN)\n  backgroundResource(R.color.background_material_dark)\n  // Many other theme modifications are available\n}.recreate(activity)\n```\n\nThe 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.\n\nYou can get the current colors using `cyanea.primary` or using the default instance `Cyanea.instance.primary`.\n\n# Using Colors\n\nMost views will automatically be themed using the library. To use the primary, accent, background, etc. colors use attributes in your layouts:\n\nAttributes:\n\n- `?colorPrimary`\n- `?colorPrimaryDark`\n- `?colorAccent`\n- `?backgroundColor`\n- `?backgroundColorDark`\n- `?backgroundColorLight`\n- `?menuIconColor`\n- `?subMenuIconColor`\n\nExample: \n\n```xml\n\u003ccom.example.MyCustomView\n  android:background=\"?backgroundColor\"\n  android:textColor=\"?colorAccent\"\n  app:someOtherColor=\"?colorPrimary\" /\u003e\n```\n\nYou can also use the primary, accent, background colors using `@color/cyanea_primary_reference`.\n\n# Advanced Usage\n\n### Processing Views\n\nYou 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.\n\nExample:\n\n```kotlin\nclass MyActivity : Activity(), CyaneaViewProcessor.Provider {\n\n  override fun getViewProcessors(): Array\u003cCyaneaViewProcessor\u003cout View\u003e\u003e = arrayOf(\n      // Add a view processors to manipulate a view when inflated.\n      object : CyaneaViewProcessor\u003cTextView\u003e() {\n        override fun getType(): Class\u003cTextView\u003e = TextView::class.java\n        override fun process(view: TextView, attrs: AttributeSet?, cyanea: Cyanea) {\n          view.text = \"Hijacked!\"\n        }\n      }\n  )\n\n}\n```\n\n### Decorators\n\nYou 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.\n\nExample:\n\n```kotlin\nclass MyActivity : Activity(), CyaneaDecorator.Provider {\n\n  override fun getDecorators(): Array\u003cCyaneaDecorator\u003e = arrayOf(\n      // Add a decorator to apply custom attributes to any view\n      FontDecorator()\n  )\n\n}\n```\n\nPlease reference the [FontDecorator](https://github.com/jaredrummler/Cyanea/blob/master/library/src/main/java/com/jaredrummler/cyanea/inflator/decor) as an example.\n\n### Inflation Delegate\n\nYou can add an inflation delegate to hook into when views are created and create the views yourself. \n\nExample:\n\n```kotlin\nCyanea.setInflationDelegate(object : CyaneaInflationDelegate {\n  override fun createView(parent: View?, name: String, context: Context, attrs: AttributeSet): View? {\n    var view: View? = null\n    if (name == \"androidx.appcompat.widget.Toolbar\") {\n      view = MyCustomToolbar(context, attrs)\n    }\n    return view\n  }\n})\n```\n\n# License\n\n    Copyright (C) 2018 Jared Rummler\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredrummler%2FCyanea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredrummler%2FCyanea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredrummler%2FCyanea/lists"}