The Android Arsenal – Design

0
8

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

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.

Download the latest AAR or grab via Gradle:

implementation 'com.jaredrummler:cyanea:1.0.0'

Demo

You can download an APK of the demo project

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.

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"
}