Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
garretyoder committed May 20, 2018
2 parents 596a0d4 + 8dd6617 commit 942be4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,22 @@ ThemeColor.BLACK

### Using Themes

Any `Activity` you wish to be automatically themed must inherit from either `CActivity` or `CAppCompatActivity` if you wish to use AppCompat
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.
```kotlin
class MainActivity : CActivity()
```
```kotlin
class MainActivity : CAppCompatActivity()
```
```kotlin
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)`
```kotlin
Colorful().apply(this, override = true, appcompat = false)
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 `appcompat` value will control which base theme Colorful will use, Appcompat or Material
*Note*: The override value is optional and may be omitted. Default value is true.
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](https://github.com/garretyoder/Colorful/blob/master/library/src/main/java/io/multimoon/colorful/CActivity.kt) and [CAppCompatActivity](https://github.com/garretyoder/Colorful/blob/master/library/src/main/java/io/multimoon/colorful/CAppCompatActivity.kt) for examples on how to implement the `CThemeInterface`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.multimoon.colorful
import android.os.Bundle
import android.support.v7.app.AppCompatActivity

class CMaterialActivity : AppCompatActivity(), CThemeInterface {
open class CMaterialActivity : AppCompatActivity(), CThemeInterface {

override var themeString: String = ""

Expand All @@ -16,4 +16,4 @@ class CMaterialActivity : AppCompatActivity(), CThemeInterface {
super.onResume()
handleOnResume(this)
}
}
}

0 comments on commit 942be4e

Please sign in to comment.