<commit_before># App Theme Engine

App Theme Engine is a library that makes it easy for developers to implement a theme system in 
their apps, similar to what's seen in [Cabinet](https://play.google.com/store/apps/details?id=com.afollestad.cabinet) 
and [Impression](https://github.com/afollestad/impression).

# Table of Contents

1. [Gradle Dependency](https://github.com/afollestad/app-theme-engine#gradle-dependency)
    1. [Repository](https://github.com/afollestad/app-theme-engine#repository)
    2. [Dependency](https://github.com/afollestad/app-theme-engine#dependency)
2. [Applying](https://github.com/afollestad/app-theme-engine#applying)
    1. [ATEActivity](https://github.com/afollestad/app-theme-engine#ateactivity)
    2. [Custom Activities and Fragments](https://github.com/afollestad/app-theme-engine#custom-activities-and-fragments)
    3. [Lists](https://github.com/afollestad/app-theme-engine#lists)
2. [Config](https://github.com/afollestad/app-theme-engine#config)
3. [Tags](https://github.com/afollestad/app-theme-engine#tags)
    1. [Background Colors](https://github.com/afollestad/app-theme-engine#background-colors) 
    2. [Text Colors](https://github.com/afollestad/app-theme-engine#text-colors)
    3. [Tint Colors](https://github.com/afollestad/app-theme-engine#tint-colors)
4. [Pre-made Views](https://github.com/afollestad/app-theme-engine#pre-made-views)

---

# Gradle Dependency

[ ![JitPack](https://img.shields.io/github/release/afollestad/app-theme-engine.svg?label=jitpack) ](https://jitpack.io/#afollestad/app-theme-engine)
[![Build Status](https://travis-ci.org/afollestad/app-theme-engine.svg)](https://travis-ci.org/afollestad/app-theme-engine)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)

### Repository

Add this in your root `build.gradle` file (**not** your module `build.gradle` file):

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

### Dependency

Add this to your module's `build.gradle` file:

```gradle
dependencies {
	...
	compile 'com.github.afollestad:app-theme-engine:0.1.0'
}
```

---

# Applying

Before we go into details of how you can configure theme colors, you need to know how the theme engine is applied.

### ATEActivity

As seen in the sample project, you can have all Activities in your app extends `ATEActivity`. This will do
all the heavy lifting for you, all that you have to worry about is theme configuration.

```java
public class MyActivity extends ATEActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}
```

If you were to change theme colors from a visible `ATEActivity`, the changes are reflected automatically
if you use the `apply()` methods discussed in the next two sections.

### Custom Activities and Fragments

If you don't use `ATEActivity`, there's a few things you have to do:

```java
public class MyActivity extends AppCompatActivity {

    private long updateTime = -1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        ATE.preApply(this); // apply primary color to status bar and nav bar
        super.onCreate(savedInstanceState);
        ATE.apply(this);    // apply colors to other views in the Activity
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        if (ATE.didValuesChange(this, updateTime))
            recreate();
    }
}
```

You can also apply theming to views in a Fragment:

```java
public class MyFragment extends Fragment {

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);<commit_msg>README update<commit_after># App Theme Engine

App Theme Engine is a library that makes it easy for developers to implement a theme system in 
their apps, similar to what's seen in [Cabinet](https://play.google.com/store/apps/details?id=com.afollestad.cabinet) 
and [Impression](https://github.com/afollestad/impression).

# Table of Contents

1. [Gradle Dependency](https://github.com/afollestad/app-theme-engine#gradle-dependency)
    1. [Repository](https://github.com/afollestad/app-theme-engine#repository)
    2. [Dependency](https://github.com/afollestad/app-theme-engine#dependency)
2. [Applying](https://github.com/afollestad/app-theme-engine#applying)
    1. [ATEActivity](https://github.com/afollestad/app-theme-engine#ateactivity)
    2. [Custom Activities and Fragments](https://github.com/afollestad/app-theme-engine#custom-activities-and-fragments)
    3. [Lists](https://github.com/afollestad/app-theme-engine#lists)
2. [Config](https://github.com/afollestad/app-theme-engine#config)
3. [Tags](https://github.com/afollestad/app-theme-engine#tags)
    1. [Background Colors](https://github.com/afollestad/app-theme-engine#background-colors) 
    2. [Text Colors](https://github.com/afollestad/app-theme-engine#text-colors)
    3. [Tint Colors](https://github.com/afollestad/app-theme-engine#tint-colors)
4. [Pre-made Views](https://github.com/afollestad/app-theme-engine#pre-made-views)

---

# Gradle Dependency

[ ![JitPack](https://img.shields.io/github/release/afollestad/app-theme-engine.svg?label=jitpack) ](https://jitpack.io/#afollestad/app-theme-engine)
[![Build Status](https://travis-ci.org/afollestad/app-theme-engine.svg)](https://travis-ci.org/afollestad/app-theme-engine)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)

### Repository

Add this in your root `build.gradle` file (**not** your module `build.gradle` file):

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

### Dependency

Add this to your module's `build.gradle` file:

```gradle
dependencies {
	...
	compile 'com.github.afollestad:app-theme-engine:0.1.0'
}
```

---

# Applying

Before we go into details of how you can configure theme colors, you need to know how the theme engine is applied.

### ATEActivity

As seen in the sample project, you can have all Activities in your app extends `ATEActivity`. This will do
all the heavy lifting for you, all that you have to worry about is theme configuration.

```java
public class MyActivity extends ATEActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}
```

If you were to change theme colors from a visible `ATEActivity`, the changes are reflected automatically
if you use the `apply()` methods discussed in the next two sections.

### Custom Activities and Fragments

If you don't use `ATEActivity`, there's a few things you have to do:

```java
public class MyActivity extends AppCompatActivity {

    private long updateTime = -1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        ATE.preApply(this); // apply primary color to status bar and nav bar
        super.onCreate(savedInstanceState);
        ATE.apply(this);    // apply colors to other views in the Activity
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        // If values were applied/committed (from Config) since the Activity was created, recreate it now
        if (ATE.didValuesChange(this, updateTime))
            recreate();
    }
}
```

You can also apply theming to views in a Fragment:

```java
public class MyFragment extends Fragment {

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
{'fraction_non_alphanumeric': 0.13211488250652742, 'fraction_numerical': 0.006266318537859008, 'mean_word_length': 4.026902887139108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 44, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3645650', 'n_tokens_mistral': 2501, 'n_tokens_neox': 2375, 'n_words': 598}