├── colors
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── marverenic
│ │ │ └── colors
│ │ │ ├── NightMode.java
│ │ │ ├── activity
│ │ │ ├── ColorsActivity.java
│ │ │ ├── ColorsAppCompatActivity.java
│ │ │ └── ColorsActivityDelegate.java
│ │ │ ├── ColorTheme.java
│ │ │ ├── Colors.java
│ │ │ ├── AccentColor.java
│ │ │ └── PrimaryColor.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── marverenic
│ │ └── colors
│ │ ├── activity
│ │ └── ColorsActivityDelegateTest.java
│ │ └── ColorsTest.java
├── proguard-rules.pro
└── build.gradle
├── sample
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ └── layout
│ │ │ └── activity_main.xml
│ │ ├── java
│ │ └── com
│ │ │ └── marverenic
│ │ │ └── colors
│ │ │ └── demo
│ │ │ ├── ColorsDemoApplication.java
│ │ │ ├── EnumAdapter.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── preview.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/colors/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':colors'
2 |
--------------------------------------------------------------------------------
/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/preview.gif
--------------------------------------------------------------------------------
/colors/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Colors
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/marverenic/Colors/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/colors/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 26 16:36:07 EDT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Colors Demo
3 | Primary Color
4 | Accent Color
5 | Night Mode
6 | I\'m feeling lucky
7 |
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Android Studio user configurations
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | *.iml
8 |
9 | # Built application files
10 | *.apk
11 | *.ap_
12 |
13 | # Files for the Dalvik VM
14 | *.dex
15 |
16 | # Java class files
17 | *.class
18 |
19 | # Generated files
20 | bin/
21 | gen/
22 |
23 | # Gradle files
24 | .gradle/
25 | build/
26 |
27 | # Local configuration file (sdk path, etc)
28 | local.properties
29 |
30 | # Proguard folder generated by Eclipse
31 | proguard/
32 |
33 | # Log Files
34 | *.log
35 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/marverenic/colors/demo/ColorsDemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.demo;
2 |
3 | import android.app.Application;
4 |
5 | import com.marverenic.colors.AccentColor;
6 | import com.marverenic.colors.ColorTheme;
7 | import com.marverenic.colors.Colors;
8 | import com.marverenic.colors.PrimaryColor;
9 |
10 | public class ColorsDemoApplication extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | Colors.setTheme(new ColorTheme(PrimaryColor.RED_500, AccentColor.RED_A400));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.marverenic.demo.colors"
9 | minSdkVersion 11
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.1"
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile project(':colors')
26 |
27 | testCompile 'junit:junit:4.12'
28 |
29 | compile 'com.android.support:appcompat-v7:25.3.1'
30 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
31 | }
32 |
--------------------------------------------------------------------------------
/colors/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\.android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\.android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/marverenic/colors/demo/EnumAdapter.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.demo;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 | import android.widget.TextView;
8 |
9 | public class EnumAdapter> extends BaseAdapter {
10 |
11 | private E[] mData;
12 |
13 | public EnumAdapter(E[] values) {
14 | mData = values;
15 | }
16 |
17 | @Override
18 | public int getCount() {
19 | return mData.length;
20 | }
21 |
22 | @Override
23 | public E getItem(int position) {
24 | return mData[position];
25 | }
26 |
27 | @Override
28 | public long getItemId(int position) {
29 | return getItem(position).hashCode();
30 | }
31 |
32 | @Override
33 | public View getView(int position, View convertView, ViewGroup parent) {
34 | if (convertView == null) {
35 | convertView = LayoutInflater.from(parent.getContext())
36 | .inflate(android.R.layout.simple_spinner_item, parent, false);
37 | }
38 |
39 | TextView text = (TextView) convertView.findViewById(android.R.id.text1);
40 | text.setText(getItem(position).toString());
41 |
42 | return convertView;
43 | }
44 |
45 | @Override
46 | public View getDropDownView(int position, View convertView, ViewGroup parent) {
47 | if (convertView == null) {
48 | convertView = LayoutInflater.from(parent.getContext())
49 | .inflate(android.R.layout.simple_spinner_dropdown_item, parent, false);
50 | }
51 |
52 | TextView text = (TextView) convertView.findViewById(android.R.id.text1);
53 | text.setText(getItem(position).toString());
54 |
55 | return convertView;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/colors/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 | group = 'com.marverenic.colors'
6 | version = '1.1'
7 |
8 | android {
9 | compileSdkVersion 25
10 | buildToolsVersion "25.0.3"
11 |
12 | defaultConfig {
13 | minSdkVersion 11
14 | targetSdkVersion 25
15 | versionCode 2
16 | versionName "1.1"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | compile 'com.android.support:appcompat-v7:25.3.1'
30 |
31 | testCompile 'junit:junit:4.12'
32 | testCompile "com.google.truth:truth:0.33"
33 | testCompile 'org.mockito:mockito-core:2.8.9'
34 | }
35 |
36 | bintray {
37 | user = System.getenv('BINTRAY_USER')
38 | key = System.getenv('BINTRAY_KEY')
39 |
40 | pkg {
41 | repo = 'Colors'
42 | name = 'com.marverenic.colors'
43 |
44 | version {
45 | name = '1.1'
46 | released = new Date()
47 | vcsTag = 'v1.1'
48 | }
49 |
50 | licenses = ['Apache-2.0']
51 | vcsUrl = 'https://github.com/marverenic/Colors'
52 | websiteUrl = 'https://github.com/marverenic/Colors'
53 | }
54 | configurations = ['archives']
55 | }
56 | task generateSourcesJar(type: Jar) {
57 | from android.sourceSets.main.java.srcDirs
58 | classifier 'sources'
59 | }
60 |
61 | task javadoc(type: Javadoc) {
62 | source = android.sourceSets.main.java.srcDirs
63 | destinationDir = file("../javadoc/")
64 | failOnError false
65 | }
66 |
67 | task generateJavadocsJar(type: Jar) {
68 | from javadoc.destinationDir
69 | classifier 'javadoc'
70 | dependsOn javadoc
71 | }
72 |
73 | artifacts {
74 | archives generateJavadocsJar
75 | archives generateSourcesJar
76 | }
77 |
--------------------------------------------------------------------------------
/colors/src/test/java/com/marverenic/colors/activity/ColorsActivityDelegateTest.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.res.Resources;
5 |
6 | import com.marverenic.colors.AccentColor;
7 | import com.marverenic.colors.Colors;
8 | import com.marverenic.colors.PrimaryColor;
9 |
10 | import org.junit.Before;
11 | import org.junit.Test;
12 |
13 | import static org.mockito.Mockito.mock;
14 | import static org.mockito.Mockito.never;
15 | import static org.mockito.Mockito.verify;
16 | import static org.mockito.Mockito.when;
17 |
18 | public class ColorsActivityDelegateTest {
19 |
20 | private Activity mActivity;
21 | private ColorsActivityDelegate mDelegate;
22 |
23 | @Before
24 | public void setUp() {
25 | mActivity = mock(Activity.class);
26 | when(mActivity.getTheme()).thenReturn(mock(Resources.Theme.class));
27 |
28 | mDelegate = new ColorsActivityDelegate(mActivity);
29 | }
30 |
31 | @Test
32 | public void testThemeChangesRecreateActivity() {
33 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A100);
34 | mDelegate.onCreate();
35 |
36 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A200);
37 | mDelegate.onResume();
38 |
39 | verify(mActivity).recreate();
40 | }
41 |
42 | @Test
43 | public void testActivityNotRecreatedWithNoThemeChange() {
44 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A100);
45 | mDelegate.onCreate();
46 | mDelegate.onResume();
47 |
48 | verify(mActivity, never()).recreate();
49 | }
50 |
51 | @Test
52 | public void testActivityNotRecreatedWithIntermediateThemeChange() {
53 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A100);
54 | mDelegate.onCreate();
55 |
56 | Colors.setTheme(PrimaryColor.AMBER_500, AccentColor.BLUE_A100);
57 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A100);
58 | mDelegate.onResume();
59 |
60 | verify(mActivity, never()).recreate();
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/NightMode.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.support.annotation.IntDef;
6 | import android.support.v7.app.AppCompatDelegate;
7 |
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.RetentionPolicy;
10 |
11 | public enum NightMode implements Parcelable {
12 |
13 | DAY(AppCompatDelegate.MODE_NIGHT_NO),
14 | NIGHT(AppCompatDelegate.MODE_NIGHT_YES),
15 | AUTO(AppCompatDelegate.MODE_NIGHT_AUTO),
16 | FOLLOW_SYSTEM(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
17 |
18 | @NightModeValue
19 | private int mAppcompatMode;
20 |
21 | NightMode(@NightModeValue int value) {
22 | mAppcompatMode = value;
23 | }
24 |
25 | @NightModeValue
26 | int getAppcompatMode() {
27 | return mAppcompatMode;
28 | }
29 |
30 | static NightMode getFromAppcompatMode(@NightModeValue int value) {
31 | for (NightMode nightMode : values()) {
32 | if (nightMode.getAppcompatMode() == value) {
33 | return nightMode;
34 | }
35 | }
36 |
37 | throw new IllegalArgumentException("Invalid appcompat mode: " + value);
38 | }
39 |
40 | @Override
41 | public void writeToParcel(Parcel dest, int flags) {
42 | dest.writeInt(mAppcompatMode);
43 | }
44 |
45 | @Override
46 | public int describeContents() {
47 | return 0;
48 | }
49 |
50 | @IntDef({AppCompatDelegate.MODE_NIGHT_NO, AppCompatDelegate.MODE_NIGHT_YES,
51 | AppCompatDelegate.MODE_NIGHT_AUTO, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM})
52 | @Retention(RetentionPolicy.SOURCE)
53 | private @interface NightModeValue {}
54 |
55 | public static final Creator CREATOR = new Creator() {
56 | @Override
57 | public NightMode createFromParcel(Parcel in) {
58 | //noinspection WrongConstant
59 | return getFromAppcompatMode(in.readInt());
60 | }
61 |
62 | @Override
63 | public NightMode[] newArray(int size) {
64 | return new NightMode[size];
65 | }
66 | };
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/activity/ColorsActivity.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.activity;
2 |
3 | import android.app.Activity;
4 | import android.app.ActivityManager.TaskDescription;
5 | import android.graphics.Bitmap;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 |
10 | import com.marverenic.colors.AccentColor;
11 | import com.marverenic.colors.Colors;
12 | import com.marverenic.colors.NightMode;
13 | import com.marverenic.colors.PrimaryColor;
14 |
15 | /**
16 | * An extension of {@link Activity} that automatically themes itself. You must call
17 | * {@link Colors#setTheme(PrimaryColor, AccentColor, NightMode)} or one of its overloads before
18 | * creating this Activity.
19 | *
20 | * @see ColorsAppCompatActivity to extend from {@link AppCompatActivity} instead. This is required
21 | * to enable night mode.
22 | * @see ColorsActivityDelegate
23 | */
24 | public class ColorsActivity extends Activity {
25 |
26 | private ColorsActivityDelegate mDelegate;
27 |
28 | @Override
29 | public void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | mDelegate = new ColorsActivityDelegate(this, getTaskName(), getTaskIcon());
32 | mDelegate.onCreate();
33 | }
34 |
35 | @Override
36 | protected void onResume() {
37 | super.onResume();
38 | mDelegate.onResume();
39 | }
40 |
41 | /**
42 | * Override this method to customize this Activity's {@link TaskDescription}.
43 | * Only used on API 21+.
44 | * @return The name to show for this app on the recent apps page, or {@code null} to use the
45 | * default task name
46 | */
47 | @Nullable
48 | protected String getTaskName() {
49 | return null;
50 | }
51 |
52 | /**
53 | * Override this method to customize this Activity's {@link TaskDescription}.
54 | * Only used on API 21+.
55 | * @return The icon to show for this app on the recent apps page, or {@code null} to use the
56 | * default task icon
57 | */
58 | @Nullable
59 | protected Bitmap getTaskIcon() {
60 | return null;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/activity/ColorsAppCompatActivity.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.activity;
2 |
3 | import android.app.ActivityManager.TaskDescription;
4 | import android.graphics.Bitmap;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 |
9 | import com.marverenic.colors.AccentColor;
10 | import com.marverenic.colors.Colors;
11 | import com.marverenic.colors.NightMode;
12 | import com.marverenic.colors.PrimaryColor;
13 |
14 | /**
15 | * An extension of {@link AppCompatActivity} that automatically themes itself. You must call
16 | * {@link Colors#setTheme(PrimaryColor, AccentColor, NightMode)} or one of its overloads before
17 | * creating this Activity.
18 | *
19 | * @see ColorsActivity to extend from {@link android.app.Activity} instead. Not that night mode
20 | * is only supported in AppCompatActivities with a theme that extends from
21 | * {@code Theme.AppCompat.DayNight} or one of its children.
22 | * @see ColorsActivityDelegate
23 | */
24 | public class ColorsAppCompatActivity extends AppCompatActivity {
25 |
26 | private ColorsActivityDelegate mDelegate;
27 |
28 | @Override
29 | public void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | mDelegate = new ColorsActivityDelegate(this, getTaskName(), getTaskIcon());
32 | mDelegate.onCreate();
33 | }
34 |
35 | @Override
36 | protected void onResume() {
37 | super.onResume();
38 | mDelegate.onResume();
39 | }
40 |
41 | /**
42 | * Override this method to customize this Activity's {@link TaskDescription}.
43 | * Only used on API 21+.
44 | * @return The name to show for this app on the recent apps page, or {@code null} to use the
45 | * default task name
46 | */
47 | @Nullable
48 | protected String getTaskName() {
49 | return null;
50 | }
51 |
52 | /**
53 | * Override this method to customize this Activity's {@link TaskDescription}.
54 | * Only used on API 21+.
55 | * @return The icon to show for this app on the recent apps page, or {@code null} to use the
56 | * default task icon
57 | */
58 | @Nullable
59 | protected Bitmap getTaskIcon() {
60 | return null;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/colors/src/test/java/com/marverenic/colors/ColorsTest.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.app.Activity;
4 | import android.content.res.Resources;
5 |
6 | import org.junit.Before;
7 | import org.junit.Test;
8 | import org.mockito.InOrder;
9 |
10 | import static com.google.common.truth.Truth.assertThat;
11 | import static org.mockito.Mockito.inOrder;
12 | import static org.mockito.Mockito.mock;
13 | import static org.mockito.Mockito.when;
14 |
15 | public class ColorsTest {
16 |
17 | private Activity mActivity;
18 | private Resources.Theme mTheme;
19 |
20 | @Before
21 | public void setUp() {
22 | mActivity = mock(Activity.class);
23 | mTheme = mock(Resources.Theme.class);
24 |
25 | when(mActivity.getTheme()).thenReturn(mTheme);
26 | }
27 |
28 | @Test
29 | public void testThemeAppliesStyles() {
30 | Colors.setTheme(PrimaryColor.INDIGO_500, AccentColor.PINK_A400);
31 |
32 | assertThat(Colors.getTheme().getPrimaryColor()).isEqualTo(PrimaryColor.INDIGO_500);
33 | assertThat(Colors.getTheme().getAccentColor()).isEqualTo(AccentColor.PINK_A400);
34 |
35 | Colors.theme(mActivity);
36 |
37 | InOrder inOrder = inOrder(mTheme);
38 | inOrder.verify(mTheme).applyStyle(R.style._ColorsTheme_Primary_Indigo_500, true);
39 | inOrder.verify(mTheme).applyStyle(R.style._ColorsTheme_Accent_Pink_A400, true);
40 | inOrder.verifyNoMoreInteractions();
41 | }
42 |
43 | @Test
44 | public void testSetThemeCreatesCorrectThemeWithDefaultNightMode() {
45 | Colors.setTheme(PrimaryColor.BLUE_700, AccentColor.TEAL_A400);
46 | ColorTheme expected = new ColorTheme(PrimaryColor.BLUE_700, AccentColor.TEAL_A400, NightMode.DAY);
47 |
48 | assertThat(Colors.getTheme()).isEqualTo(expected);
49 | }
50 |
51 | @Test
52 | public void testSetThemeCreatesCorrectTheme() {
53 | Colors.setTheme(PrimaryColor.CYAN_500, AccentColor.GREEN_A100, NightMode.AUTO);
54 | ColorTheme expected = new ColorTheme(PrimaryColor.CYAN_500, AccentColor.GREEN_A100, NightMode.AUTO);
55 |
56 | assertThat(Colors.getTheme()).isEqualTo(expected);
57 | }
58 |
59 | @Test(expected = IllegalArgumentException.class)
60 | public void testSetThemeThrowsForNullPrimaryColor() {
61 | //noinspection ConstantConditions
62 | Colors.setTheme(null, AccentColor.AMBER_A200);
63 | }
64 |
65 | @Test(expected = IllegalArgumentException.class)
66 | public void testSetThemeThrowsForNullAccentColor() {
67 | //noinspection ConstantConditions
68 | Colors.setTheme(PrimaryColor.RED_500, null);
69 | }
70 |
71 | @Test(expected = IllegalArgumentException.class)
72 | public void testSetThemeThrowsForNullNightMode() {
73 | //noinspection ConstantConditions
74 | Colors.setTheme(PrimaryColor.RED_500, AccentColor.AMBER_A100, null);
75 | }
76 |
77 | @Test(expected = IllegalArgumentException.class)
78 | public void testSetThemeThrowsForNullTheme() {
79 | //noinspection ConstantConditions
80 | Colors.setTheme(null);
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/activity/ColorsActivityDelegate.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.activity;
2 |
3 | import android.app.Activity;
4 | import android.app.ActivityManager.TaskDescription;
5 | import android.graphics.Bitmap;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 |
9 | import com.marverenic.colors.ColorTheme;
10 | import com.marverenic.colors.Colors;
11 |
12 | /**
13 | * Serves as a delegate for the theming logic for an activity. This class takes care of theming
14 | * activities and triggering activity recreations when the theme changes when an activity is paused.
15 | *
16 | * To use this class, simply create an instance of it in one of your activities, and call the
17 | * corresponding methods in this class in the appropriate lifecycle callback (e.g. In your
18 | * {@link Activity#onResume()}, call {@link #onResume()}). Delegates should be kept until the
19 | * activity is destroyed, but do not need to be persisted across activity recreations or
20 | * configuration changes.
21 | *
22 | * @see ColorsActivity for an extension of Activity that implements this behavior
23 | * @see ColorsAppCompatActivity for an extension of AppCompatActvity that implements this behavior
24 | */
25 | public final class ColorsActivityDelegate {
26 |
27 | private Activity mActivity;
28 | private ColorTheme mTheme;
29 | private String mTaskName;
30 | private Bitmap mTaskIcon;
31 |
32 | /**
33 | * Creates a new ColorsActivityDelegate for an Activity
34 | * @param parent The activity that will be delegating to this object
35 | * @see #ColorsActivityDelegate(Activity, String, Bitmap) to customize the Activity's
36 | * {@link TaskDescription}
37 | */
38 | public ColorsActivityDelegate(Activity parent) {
39 | this(parent, null, null);
40 | }
41 |
42 | /**
43 | * Creates a new ColorsActivityDelegate for an Activity
44 | * @param parent The activity that will be delegating to this object
45 | * @param taskName The name that should show up in this app's overview entry, or {@code null}
46 | * for the default value
47 | * @param taskIcon The icon that should appear in this app's overview entry, or {@code null}
48 | * for the default value
49 | * @see #ColorsActivityDelegate(Activity, String, Bitmap) to customize the Activity's
50 | * {@link TaskDescription}
51 | */
52 | public ColorsActivityDelegate(Activity parent, @Nullable String taskName,
53 | @Nullable Bitmap taskIcon) {
54 | mActivity = parent;
55 | mTaskName = taskName;
56 | mTaskIcon = taskIcon;
57 | }
58 |
59 | /**
60 | * Call this in your Activity's {@link Activity#onCreate(Bundle)} method. Note that this MUST
61 | * be called before inflating any views or calling {@link Activity#setContentView(int)}.
62 | */
63 | public void onCreate() {
64 | mTheme = Colors.getTheme();
65 | Colors.theme(mActivity, mTaskName, mTaskIcon);
66 | }
67 |
68 | /**
69 | * Call this in your Activity's {@link Activity#onResume()} method.
70 | */
71 | public void onResume() {
72 | if (!Colors.getTheme().equals(mTheme)) {
73 | mActivity.recreate();
74 | }
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/ColorTheme.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.support.annotation.NonNull;
6 |
7 | public final class ColorTheme implements Parcelable {
8 |
9 | @NonNull
10 | private final PrimaryColor mPrimaryColor;
11 |
12 | @NonNull
13 | private final AccentColor mAccentColor;
14 |
15 | @NonNull
16 | private final NightMode mNightMode;
17 |
18 | public ColorTheme(@NonNull PrimaryColor primaryColor, @NonNull AccentColor accentColor) {
19 | this(primaryColor, accentColor, NightMode.DAY);
20 | }
21 |
22 | public ColorTheme(@NonNull PrimaryColor primaryColor, @NonNull AccentColor accentColor,
23 | @NonNull NightMode nightMode) {
24 | if (primaryColor == null) {
25 | throw new IllegalArgumentException("primary color cannot be null");
26 | } else if (accentColor == null) {
27 | throw new IllegalArgumentException("accent color cannot be null");
28 | } else if (nightMode == null) {
29 | throw new IllegalArgumentException("night mode cannot be null");
30 | }
31 |
32 | mPrimaryColor = primaryColor;
33 | mAccentColor = accentColor;
34 | mNightMode = nightMode;
35 | }
36 |
37 | private ColorTheme(Parcel in) {
38 | this(
39 | (PrimaryColor) in.readParcelable(PrimaryColor.class.getClassLoader()),
40 | (AccentColor) in.readParcelable(AccentColor.class.getClassLoader()),
41 | (NightMode) in.readParcelable(NightMode.class.getClassLoader())
42 | );
43 | }
44 |
45 | @NonNull
46 | public PrimaryColor getPrimaryColor() {
47 | return mPrimaryColor;
48 | }
49 |
50 | @NonNull
51 | public AccentColor getAccentColor() {
52 | return mAccentColor;
53 | }
54 |
55 | @NonNull
56 | public NightMode getNightMode() {
57 | return mNightMode;
58 | }
59 |
60 | @Override
61 | public int describeContents() {
62 | return 0;
63 | }
64 |
65 | @Override
66 | public void writeToParcel(Parcel dest, int flags) {
67 | dest.writeParcelable(mPrimaryColor, 0);
68 | dest.writeParcelable(mAccentColor, 0);
69 | dest.writeParcelable(mNightMode, 0);
70 | }
71 |
72 | public static final Creator CREATOR = new Creator() {
73 | @Override
74 | public ColorTheme createFromParcel(Parcel in) {
75 | return new ColorTheme(in);
76 | }
77 |
78 | @Override
79 | public ColorTheme[] newArray(int size) {
80 | return new ColorTheme[size];
81 | }
82 | };
83 |
84 | @Override
85 | public boolean equals(Object o) {
86 | if (this == o) return true;
87 | if (o == null || getClass() != o.getClass()) return false;
88 |
89 | ColorTheme that = (ColorTheme) o;
90 |
91 | return this.mPrimaryColor == that.mPrimaryColor
92 | && this.mAccentColor == that.mAccentColor
93 | && this.mNightMode == that.mNightMode;
94 |
95 | }
96 |
97 | @Override
98 | public int hashCode() {
99 | int result = mPrimaryColor.hashCode();
100 | result = 31 * result + mAccentColor.hashCode();
101 | result = 31 * result + mNightMode.hashCode();
102 | return result;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Colors (Deprecated)
2 |
3 | ⚠ **Colors is deprecated** as of January 26, 2020.
4 | This library will continue to work, but will not receive support or updates.
5 | Consider using [garretyoder/Colorful](https://github.com/garretyoder/Colorful) instead.
6 | [Read more](https://andrewbailey.dev/post/2020/01/26/rebranding-marverenic).
7 |
8 | ---
9 |
10 | [ ](https://bintray.com/marverenic/Colors/com.marverenic.colors/_latestVersion)
11 | [](https://circleci.com/gh/marverenic/Colors)
12 |
13 | Colors is a theming library for Android. It allows your app to use over 5,000 color combinations from the [Material Design Palette](https://material.io/guidelines/style/color.html#color-color-tool) by separately picking a primary and accent color.
14 |
15 |
16 |
17 |
18 |
19 | ## Gradle Installation
20 | ```
21 | dependencies {
22 | compile 'com.marverenic.colors:colors:1.x'
23 | }
24 | ```
25 |
26 | The latest version and release notes can be found on the [Releases](https://github.com/marverenic/Colors/releases) page.
27 |
28 | ## Usage
29 | ### Set a Theme
30 | To use Colors, first set a global application theme. You need to do this before you show any themed Activities. A good place to set a default theme is in your `Application` class. You can set your theme with a single line of code:
31 |
32 | ```java
33 | Colors.setTheme(PrimaryColor.INDIGO_500, AccentColor.PINK_A200);
34 | ```
35 |
36 | ### Theming an Activity
37 | Colors only sets the primary and accent color of the theme, so build your activity as you normally would and give it a basic theme. To make Colors theme your activity, simply make your activity extend from either `ColorsActivity` or `ColorsAppCompatActivity`.
38 |
39 | Colors will recreate your activity if the theme was changed when your activity is returned to. To immediately apply a theme, make sure you call `recreate()` in your Activity after calling `Colors.setTheme(...)`.
40 |
41 | #### ColorsActivityDelegate
42 | Already extending from another library's Activity? No problem. Just create an instance of `ColorsActivityDelegate` in your Activity and call its `onCreate` and `onResume` methods as shown:
43 |
44 | ```java
45 | public class YourActivity extends Activity {
46 | private ColorsActivityDelegate delegate = new ColorsActivityDelegate(this);
47 |
48 | @Override
49 | public void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | delegate.onCreate(); // Must be called before setContentView
52 |
53 | setContentView(/* Your layout resource */);
54 | // More initialization code for your Activity
55 | }
56 |
57 | @Override
58 | public void onResume() {
59 | super.onResume();
60 | delegate.onResume();
61 | }
62 | }
63 | ```
64 |
65 | ### User Theme Preferences
66 | Colors doesn't provide a built-in way to offer the user a theme choice. Developers can build any interface to present to the user and add any number of constraints to which themes can be built.
67 |
68 | Colors also does not save the last chosen theme automatically. If you're using `SharedPreferences`, however, you can easily save the theme:
69 |
70 | ```java
71 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
72 | PrimaryColor primaryColor = PrimaryColor.INDIGO_500;
73 | AccentColor accentColor = AccentColor.PINK_A200;
74 |
75 | prefs.edit()
76 | .putString(PRIMARY_COLOR_PREF_KEY, primaryColor.getId())
77 | .putString(ACCENT_COLOR_PREF_KEY, accentColor.getId())
78 | .apply();
79 | ```
80 |
81 | And restore it just as easily:
82 |
83 | ```java
84 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
85 | PrimaryColor defaultPrimary = PrimaryColor.INDIGO_500;
86 | AccentColor defaultAccent = AccentColor.PINK_A200;
87 |
88 | PrimaryColor primaryColor = PrimaryColor.findById(
89 | prefs.getString(PRIMARY_COLOR_PREF_KEY, defaultPrimary.getId()));
90 |
91 | AccentColor accentColor = AccentColor.findById(
92 | prefs.getString(ACCENT_COLOR_PREF_KEY, defaultAccent.getId()));
93 |
94 | Colors.setTheme(primaryColor, accentColor);
95 | ```
96 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
22 |
23 |
35 |
36 |
49 |
50 |
62 |
63 |
76 |
77 |
89 |
90 |
104 |
105 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/marverenic/colors/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.View;
6 | import android.widget.AdapterView;
7 | import android.widget.Button;
8 | import android.widget.Spinner;
9 |
10 | import com.marverenic.colors.AccentColor;
11 | import com.marverenic.colors.ColorTheme;
12 | import com.marverenic.colors.Colors;
13 | import com.marverenic.colors.NightMode;
14 | import com.marverenic.colors.PrimaryColor;
15 | import com.marverenic.colors.activity.ColorsAppCompatActivity;
16 |
17 | public class MainActivity extends ColorsAppCompatActivity {
18 |
19 | private Spinner mPrimarySpinner;
20 | private Spinner mAccentSpinner;
21 | private Spinner mNightModeSpinner;
22 | private Button mRandomButton;
23 |
24 | @Override
25 | public void onCreate(@Nullable Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_main);
28 |
29 | mPrimarySpinner = (Spinner) findViewById(R.id.spinnerPrimary);
30 | mAccentSpinner = (Spinner) findViewById(R.id.spinnerAccent);
31 | mNightModeSpinner = (Spinner) findViewById(R.id.spinnerNightMode);
32 | mRandomButton = (Button) findViewById(R.id.buttonRandom);
33 |
34 | mPrimarySpinner.setAdapter(new EnumAdapter<>(PrimaryColor.values()));
35 | mAccentSpinner.setAdapter(new EnumAdapter<>(AccentColor.values()));
36 | mNightModeSpinner.setAdapter(new EnumAdapter<>(NightMode.values()));
37 |
38 | setupCallbacks();
39 | }
40 |
41 | @Override
42 | protected void onResume() {
43 | super.onResume();
44 |
45 | int primary = indexOf(PrimaryColor.values(), Colors.getTheme().getPrimaryColor());
46 | int accent = indexOf(AccentColor.values(), Colors.getTheme().getAccentColor());
47 | int nightMode = indexOf(NightMode.values(), Colors.getTheme().getNightMode());
48 |
49 | mPrimarySpinner.setSelection(primary);
50 | mAccentSpinner.setSelection(accent);
51 | mNightModeSpinner.setSelection(nightMode);
52 | }
53 |
54 | private static int indexOf(T[] arr, T val) {
55 | for (int i = 0; i < arr.length; i++) {
56 | if (arr[i].equals(val)) {
57 | return i;
58 | }
59 | }
60 | return -1;
61 | }
62 |
63 | private void setupCallbacks() {
64 | mPrimarySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
65 | @Override
66 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
67 | PrimaryColor primaryColor = PrimaryColor.values()[position];
68 | ColorTheme currentTheme = Colors.getTheme();
69 |
70 | if (primaryColor != currentTheme.getPrimaryColor()) {
71 | ColorTheme theme = new ColorTheme(primaryColor, currentTheme.getAccentColor(),
72 | currentTheme.getNightMode());
73 | Colors.setTheme(theme);
74 | recreate();
75 | }
76 | }
77 |
78 | @Override
79 | public void onNothingSelected(AdapterView> parent) {}
80 | });
81 |
82 | mAccentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
83 | @Override
84 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
85 | AccentColor accentColor = AccentColor.values()[position];
86 | ColorTheme currentTheme = Colors.getTheme();
87 |
88 | if (accentColor != currentTheme.getAccentColor()) {
89 | ColorTheme theme = new ColorTheme(currentTheme.getPrimaryColor(), accentColor,
90 | currentTheme.getNightMode());
91 | Colors.setTheme(theme);
92 | recreate();
93 | }
94 | }
95 |
96 | @Override
97 | public void onNothingSelected(AdapterView> parent) {}
98 | });
99 |
100 | mNightModeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
101 | @Override
102 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
103 | NightMode nightMode = NightMode.values()[position];
104 | ColorTheme currentTheme = Colors.getTheme();
105 |
106 | if (nightMode != currentTheme.getNightMode()) {
107 | ColorTheme theme = new ColorTheme(currentTheme.getPrimaryColor(),
108 | currentTheme.getAccentColor(), nightMode);
109 | Colors.setTheme(theme);
110 | recreate();
111 | }
112 | }
113 |
114 | @Override
115 | public void onNothingSelected(AdapterView> parent) {}
116 | });
117 |
118 | mRandomButton.setOnClickListener(new View.OnClickListener() {
119 | @Override
120 | public void onClick(View v) {
121 | randomizeTheme();
122 | }
123 | });
124 | }
125 |
126 | private void randomizeTheme() {
127 | PrimaryColor[] primaryColors = PrimaryColor.values();
128 | AccentColor[] accentColors = AccentColor.values();
129 | NightMode[] nightModes = NightMode.values();
130 |
131 | int whichPrimary = (int) (Math.random() * primaryColors.length);
132 | int whichAccent = (int) (Math.random() * accentColors.length);
133 | int whichNightMode = (int) (Math.random() * nightModes.length);
134 |
135 | ColorTheme random = new ColorTheme(primaryColors[whichPrimary], accentColors[whichAccent],
136 | nightModes[whichNightMode]);
137 | Colors.setTheme(random);
138 | recreate();
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/Colors.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.app.Activity;
4 | import android.app.ActivityManager.TaskDescription;
5 | import android.content.res.Resources;
6 | import android.graphics.Bitmap;
7 | import android.os.Build;
8 | import android.support.annotation.ColorInt;
9 | import android.support.annotation.ColorRes;
10 | import android.support.annotation.NonNull;
11 | import android.support.annotation.Nullable;
12 | import android.support.annotation.RequiresApi;
13 | import android.support.v4.content.ContextCompat;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.support.v7.app.AppCompatDelegate;
16 |
17 | import com.marverenic.colors.activity.ColorsActivity;
18 | import com.marverenic.colors.activity.ColorsActivityDelegate;
19 | import com.marverenic.colors.activity.ColorsAppCompatActivity;
20 |
21 | public final class Colors {
22 |
23 | private static ColorTheme sTheme;
24 |
25 | private Colors() {
26 | throw new RuntimeException("This class cannot be instantiated");
27 | }
28 |
29 | /**
30 | * Applies the current color scheme set by {@link #setTheme(ColorTheme)} to the provided
31 | * Activity. This must be called before inflating the Activity's content view.
32 | * @param activity The Activity to be themed
33 | * @throws IllegalStateException if a theme has not been specified
34 | * @see #theme(Activity, String, Bitmap) to customize the app's {@link TaskDescription}
35 | * @since 1.0
36 | */
37 | public static void theme(Activity activity) {
38 | theme(activity, null, null);
39 | }
40 |
41 | /**
42 | * Applies the current color scheme set by {@link #setTheme(ColorTheme)} to the provided
43 | * Activity and sets its {@link TaskDescription} with the provided values. This must be called
44 | * before inflating the Activity's content view.
45 | *
46 | * Most users should not call this method directly. Instead, you should use
47 | * {@link ColorsActivity}, {@link ColorsAppCompatActivity}, or {@link ColorsActivityDelegate}
48 | * to theme your activities.
49 | *
50 | * @param activity The Activity to be themed
51 | * @param taskName The name to show on the recent apps page for your application. If
52 | * {@code null}, then the default name will be used. Only applicable on API 21+.
53 | * @param taskIcon The icon to show on the recent apps page for your application. If
54 | * {@code null}, then the default icon will be used. Only applicable on API 21+.
55 | * @throws IllegalArgumentException if a theme has not been specified
56 | * @see #theme(Activity) if you don't need to customize your app's {@link TaskDescription}.
57 | * @since 1.1
58 | */
59 | public static void theme(Activity activity, @Nullable String taskName,
60 | @Nullable Bitmap taskIcon) {
61 |
62 | if (sTheme == null) {
63 | throw new IllegalStateException("Theme has not been set");
64 | }
65 |
66 | if (activity instanceof AppCompatActivity) {
67 | AppCompatDelegate.setDefaultNightMode(sTheme.getNightMode().getAppcompatMode());
68 | }
69 |
70 | Resources.Theme theme = activity.getTheme();
71 | theme.applyStyle(sTheme.getPrimaryColor().getThemeRes(), true);
72 | theme.applyStyle(sTheme.getAccentColor().getThemeRes(), true);
73 |
74 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
75 | applyTaskDescription(activity, taskName, taskIcon);
76 | }
77 | }
78 |
79 | @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
80 | private static void applyTaskDescription(Activity activity, @Nullable String taskName,
81 | @Nullable Bitmap taskIcon) {
82 | @ColorRes int primaryColorRes = sTheme.getPrimaryColor().getPrimaryColorRes();
83 | @ColorInt int primaryColor = ContextCompat.getColor(activity, primaryColorRes);
84 |
85 | TaskDescription taskDescription = new TaskDescription(taskName, taskIcon, primaryColor);
86 | activity.setTaskDescription(taskDescription);
87 | }
88 |
89 | /**
90 | * Sets your app's global theme. To apply this theme to your Activities, you must call
91 | * {@link #theme(Activity)} before your view hierarchy is inflated. If you are calling this in
92 | * an Activity that is already onscreen, then call {@link Activity#recreate()} to immediately
93 | * apply the new theme to your Activity.
94 | *
95 | * Most users should not call this method directly. Instead, you should use
96 | * {@link ColorsActivity}, {@link ColorsAppCompatActivity}, or {@link ColorsActivityDelegate}
97 | * to theme your activities.
98 | *
99 | * @param primaryColor The primary color for your theme from the Material Design palette
100 | * @param accentColor The accent color for your theme from the Material Design palette
101 | * @see #setTheme(PrimaryColor, AccentColor, NightMode) to specify a night mode setting.
102 | * Otherwise, night mode will be disabled.
103 | * @since 1.0
104 | */
105 | public static void setTheme(@NonNull PrimaryColor primaryColor,
106 | @NonNull AccentColor accentColor) {
107 | setTheme(new ColorTheme(primaryColor, accentColor));
108 | }
109 |
110 | /**
111 | * Sets your app's global theme. To apply this theme to your Activities, you must call
112 | * {@link #theme(Activity)} before your view hierarchy is inflated. If you are calling this in
113 | * an Activity that is already onscreen, then call {@link Activity#recreate()} to immediately
114 | * apply the new theme to your Activity.
115 | * @param primaryColor The primary color for your theme from the Material Design palette
116 | * @param accentColor The accent color for your theme from the Material Design palette
117 | * @param nightMode The night mode option for your theme, which affects whether the background
118 | * is light or dark. Note that for this to be effective, your app's base theme
119 | * should extend from {@code Theme.AppCompat.DayNight} or one of its children.
120 | * @since 1.1
121 | */
122 | public static void setTheme(@NonNull PrimaryColor primaryColor,
123 | @NonNull AccentColor accentColor,
124 | @NonNull NightMode nightMode) {
125 | setTheme(new ColorTheme(primaryColor, accentColor, nightMode));
126 | }
127 |
128 | /**
129 | * Manually restores a pre-built theme.
130 | * @param theme The theme to set as your app's global theme
131 | * @see #setTheme(PrimaryColor, AccentColor, NightMode) To concisely set a new theme
132 | * @see #setTheme(PrimaryColor, AccentColor) To concisely set a new theme with night mode off
133 | * @since 1.0
134 | */
135 | public static void setTheme(@NonNull ColorTheme theme) {
136 | if (theme == null) {
137 | throw new IllegalArgumentException("theme cannot be null");
138 | }
139 | sTheme = theme;
140 | }
141 |
142 | /**
143 | * @return Your app's current global theme
144 | * @throws IllegalStateException If this is called before setting a theme
145 | * @since 1.0
146 | */
147 | @NonNull
148 | public static ColorTheme getTheme() {
149 | if (sTheme == null) {
150 | throw new IllegalStateException("Theme has not been set");
151 | }
152 | return sTheme;
153 | }
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/AccentColor.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.support.annotation.ColorRes;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.StyleRes;
8 |
9 | public enum AccentColor implements Parcelable {
10 |
11 | RED_A100("Red A100", R.style._ColorsTheme_Accent_Red_A100, R.color._color_lib_red_A100),
12 | RED_A200("Red A200", R.style._ColorsTheme_Accent_Red_A200, R.color._color_lib_red_A200),
13 | RED_A400("Red A400", R.style._ColorsTheme_Accent_Red_A400, R.color._color_lib_red_A400),
14 | RED_A700("Red A700", R.style._ColorsTheme_Accent_Red_A700, R.color._color_lib_red_A700),
15 |
16 | PINK_A100("Pink A100", R.style._ColorsTheme_Accent_Pink_A100, R.color._color_lib_pink_A100),
17 | PINK_A200("Pink A200", R.style._ColorsTheme_Accent_Pink_A200, R.color._color_lib_pink_A200),
18 | PINK_A400("Pink A400", R.style._ColorsTheme_Accent_Pink_A400, R.color._color_lib_pink_A400),
19 | PINK_A700("Pink A700", R.style._ColorsTheme_Accent_Pink_A700, R.color._color_lib_pink_A700),
20 |
21 | PURPLE_A100("Purple A100", R.style._ColorsTheme_Accent_Purple_A100, R.color._color_lib_purple_A100),
22 | PURPLE_A200("Purple A200", R.style._ColorsTheme_Accent_Purple_A200, R.color._color_lib_purple_A200),
23 | PURPLE_A400("Purple A400", R.style._ColorsTheme_Accent_Purple_A400, R.color._color_lib_purple_A400),
24 | PURPLE_A700("Purple A700", R.style._ColorsTheme_Accent_Purple_A700, R.color._color_lib_purple_A700),
25 |
26 | DEEP_PURPLE_A100("Deep Purple A100", R.style._ColorsTheme_Accent_DeepPurple_A100, R.color._color_lib_deep_purple_A100),
27 | DEEP_PURPLE_A200("Deep Purple A200", R.style._ColorsTheme_Accent_DeepPurple_A200, R.color._color_lib_deep_purple_A200),
28 | DEEP_PURPLE_A400("Deep Purple A400", R.style._ColorsTheme_Accent_DeepPurple_A400, R.color._color_lib_deep_purple_A400),
29 | DEEP_PURPLE_A700("Deep Purple A700", R.style._ColorsTheme_Accent_DeepPurple_A700, R.color._color_lib_deep_purple_A700),
30 |
31 | INDIGO_A100("Indigo A100", R.style._ColorsTheme_Accent_Indigo_A100, R.color._color_lib_indigo_A100),
32 | INDIGO_A200("Indigo A200", R.style._ColorsTheme_Accent_Indigo_A200, R.color._color_lib_indigo_A200),
33 | INDIGO_A400("Indigo A400", R.style._ColorsTheme_Accent_Indigo_A400, R.color._color_lib_indigo_A400),
34 | INDIGO_A700("Indigo A700", R.style._ColorsTheme_Accent_Indigo_A700, R.color._color_lib_indigo_A700),
35 |
36 | BLUE_A100("Blue A100", R.style._ColorsTheme_Accent_Blue_A100, R.color._color_lib_blue_A100),
37 | BLUE_A200("Blue A200", R.style._ColorsTheme_Accent_Blue_A200, R.color._color_lib_blue_A200),
38 | BLUE_A400("Blue A400", R.style._ColorsTheme_Accent_Blue_A400, R.color._color_lib_blue_A400),
39 | BLUE_A700("Blue A700", R.style._ColorsTheme_Accent_Blue_A700, R.color._color_lib_blue_A700),
40 |
41 | LIGHT_BLUE_A100("Light Blue A100", R.style._ColorsTheme_Accent_LightBlue_A100, R.color._color_lib_light_blue_A100),
42 | LIGHT_BLUE_A200("Light Blue A200", R.style._ColorsTheme_Accent_LightBlue_A200, R.color._color_lib_light_blue_A200),
43 | LIGHT_BLUE_A400("Light Blue A400", R.style._ColorsTheme_Accent_LightBlue_A400, R.color._color_lib_light_blue_A400),
44 | LIGHT_BLUE_A700("Light Blue A700", R.style._ColorsTheme_Accent_LightBlue_A700, R.color._color_lib_light_blue_A700),
45 |
46 | CYAN_A100("Cyan A100", R.style._ColorsTheme_Accent_Cyan_A100, R.color._color_lib_cyan_A100),
47 | CYAN_A200("Cyan A200", R.style._ColorsTheme_Accent_Cyan_A200, R.color._color_lib_cyan_A200),
48 | CYAN_A400("Cyan A400", R.style._ColorsTheme_Accent_Cyan_A400, R.color._color_lib_cyan_A400),
49 | CYAN_A700("Cyan A700", R.style._ColorsTheme_Accent_Cyan_A700, R.color._color_lib_cyan_A700),
50 |
51 | TEAL_A100("Teal A100", R.style._ColorsTheme_Accent_Teal_A100, R.color._color_lib_teal_A100),
52 | TEAL_A200("Teal A200", R.style._ColorsTheme_Accent_Teal_A200, R.color._color_lib_teal_A200),
53 | TEAL_A400("Teal A400", R.style._ColorsTheme_Accent_Teal_A400, R.color._color_lib_teal_A400),
54 | TEAL_A700("Teal A700", R.style._ColorsTheme_Accent_Teal_A700, R.color._color_lib_teal_A700),
55 |
56 | GREEN_A100("Green A100", R.style._ColorsTheme_Accent_Green_A100, R.color._color_lib_green_A100),
57 | GREEN_A200("Green A200", R.style._ColorsTheme_Accent_Green_A200, R.color._color_lib_green_A200),
58 | GREEN_A400("Green A400", R.style._ColorsTheme_Accent_Green_A400, R.color._color_lib_green_A400),
59 | GREEN_A700("Green A700", R.style._ColorsTheme_Accent_Green_A700, R.color._color_lib_green_A700),
60 |
61 | LIGHT_GREEN_A100("Light Green A100", R.style._ColorsTheme_Accent_LightGreen_A100, R.color._color_lib_light_green_A100),
62 | LIGHT_GREEN_A200("Light Green A200", R.style._ColorsTheme_Accent_LightGreen_A200, R.color._color_lib_light_green_A200),
63 | LIGHT_GREEN_A400("Light Green A400", R.style._ColorsTheme_Accent_LightGreen_A400, R.color._color_lib_light_green_A400),
64 | LIGHT_GREEN_A700("Light Green A700", R.style._ColorsTheme_Accent_LightGreen_A700, R.color._color_lib_light_green_A700),
65 |
66 | LIME_A100("Lime A100", R.style._ColorsTheme_Accent_Lime_A100, R.color._color_lib_lime_A100),
67 | LIME_A200("Lime A200", R.style._ColorsTheme_Accent_Lime_A200, R.color._color_lib_lime_A200),
68 | LIME_A400("Lime A400", R.style._ColorsTheme_Accent_Lime_A400, R.color._color_lib_lime_A400),
69 | LIME_A700("Lime A700", R.style._ColorsTheme_Accent_Lime_A700, R.color._color_lib_lime_A700),
70 |
71 | YELLOW_A100("Yellow A100", R.style._ColorsTheme_Accent_Yellow_A100, R.color._color_lib_yellow_A100),
72 | YELLOW_A200("Yellow A200", R.style._ColorsTheme_Accent_Yellow_A200, R.color._color_lib_yellow_A200),
73 | YELLOW_A400("Yellow A400", R.style._ColorsTheme_Accent_Yellow_A400, R.color._color_lib_yellow_A400),
74 | YELLOW_A700("Yellow A700", R.style._ColorsTheme_Accent_Yellow_A700, R.color._color_lib_yellow_A700),
75 |
76 | AMBER_A100("Amber A100", R.style._ColorsTheme_Accent_Amber_A100, R.color._color_lib_amber_A100),
77 | AMBER_A200("Amber A200", R.style._ColorsTheme_Accent_Amber_A200, R.color._color_lib_amber_A200),
78 | AMBER_A400("Amber A400", R.style._ColorsTheme_Accent_Amber_A400, R.color._color_lib_amber_A400),
79 | AMBER_A700("Amber A700", R.style._ColorsTheme_Accent_Amber_A700, R.color._color_lib_amber_A700),
80 |
81 | ORANGE_A100("Orange A100", R.style._ColorsTheme_Accent_Orange_A100, R.color._color_lib_orange_A100),
82 | ORANGE_A200("Orange A200", R.style._ColorsTheme_Accent_Orange_A200, R.color._color_lib_orange_A200),
83 | ORANGE_A400("Orange A400", R.style._ColorsTheme_Accent_Orange_A400, R.color._color_lib_orange_A400),
84 | ORANGE_A700("Orange A700", R.style._ColorsTheme_Accent_Orange_A700, R.color._color_lib_orange_A700),
85 |
86 | DEEP_ORANGE_A100("Deep Orange A100", R.style._ColorsTheme_Accent_DeepOrange_A100, R.color._color_lib_deep_orange_A100),
87 | DEEP_ORANGE_A200("Deep Orange A200", R.style._ColorsTheme_Accent_DeepOrange_A200, R.color._color_lib_deep_orange_A200),
88 | DEEP_ORANGE_A400("Deep Orange A400", R.style._ColorsTheme_Accent_DeepOrange_A400, R.color._color_lib_deep_orange_A400),
89 | DEEP_ORANGE_A700("Deep Orange A700", R.style._ColorsTheme_Accent_DeepOrange_A700, R.color._color_lib_deep_orange_A700),
90 |
91 | ;
92 |
93 | private final String mId;
94 |
95 | @StyleRes private final int mTheme;
96 | @ColorRes private final int mAccentColorRes;
97 |
98 | AccentColor(String id, @StyleRes int theme, @ColorRes int accentColorRes) {
99 | mId = id;
100 | mTheme = theme;
101 | mAccentColorRes = accentColorRes;
102 | }
103 |
104 | public static AccentColor findById(@NonNull String id) {
105 | if (id == null) {
106 | throw new IllegalArgumentException("id cannot be null");
107 | }
108 |
109 | for (AccentColor color : values()) {
110 | if (color.getId().equals(id)) {
111 | return color;
112 | }
113 | }
114 |
115 | throw new IllegalArgumentException("An AccentColor with '" + id + "' does not exist");
116 | }
117 |
118 | public String getId() {
119 | return mId;
120 | }
121 |
122 | @StyleRes
123 | protected int getThemeRes() {
124 | return mTheme;
125 | }
126 |
127 | @ColorRes
128 | public int getAccentColorRes() {
129 | return mAccentColorRes;
130 | }
131 |
132 | @Override
133 | public String toString() {
134 | return mId;
135 | }
136 |
137 | @Override
138 | public void writeToParcel(Parcel dest, int flags) {
139 | dest.writeString(getId());
140 | }
141 |
142 | @Override
143 | public int describeContents() {
144 | return 0;
145 | }
146 |
147 | public static final Creator CREATOR = new Creator() {
148 | @Override
149 | public AccentColor createFromParcel(Parcel in) {
150 | return findById(in.readString());
151 | }
152 |
153 | @Override
154 | public AccentColor[] newArray(int size) {
155 | return new AccentColor[size];
156 | }
157 | };
158 | }
159 |
--------------------------------------------------------------------------------
/colors/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 | #F44336
8 | #E53935
9 | #D32F2F
10 | #C62828
11 | #B71C1C
12 |
13 | #FF8A80
14 | #FF5252
15 | #FF1744
16 | #D50000
17 |
18 |
21 | #E91E63
22 | #D81B60
23 | #C2185B
24 | #AD1457
25 | #880E4F
26 |
27 | #FF80AB
28 | #FF4081
29 | #F50057
30 | #C51162
31 |
32 |
35 | #9C27B0
36 | #8E24AA
37 | #7B1FA2
38 | #6A1B9A
39 | #4A148C
40 |
41 | #EA80FC
42 | #E040FB
43 | #D500F9
44 | #AA00FF
45 |
46 |
49 | #673AB7
50 | #5E35B1
51 | #512DA8
52 | #4527A0
53 | #311B92
54 |
55 | #B388FF
56 | #7C4DFF
57 | #651FFF
58 | #6200EA
59 |
60 |
63 | #3F51B5
64 | #3949AB
65 | #303F9F
66 | #283593
67 | #1A237E
68 |
69 | #8C9EFF
70 | #536DFE
71 | #3D5AFE
72 | #304FFE
73 |
74 |
77 | #2196F3
78 | #1E88E5
79 | #1976D2
80 | #1565C0
81 | #0D47A1
82 |
83 | #82B1FF
84 | #448AFF
85 | #2979FF
86 | #2962FF
87 |
88 |
91 | #03A9F4
92 | #039BE5
93 | #0288D1
94 | #0277BD
95 | #01579B
96 |
97 | #80D8FF
98 | #40C4FF
99 | #00B0FF
100 | #0091EA
101 |
102 |
105 | #00BCD4
106 | #00ACC1
107 | #0097A7
108 | #00838F
109 | #006064
110 |
111 | #84FFFF
112 | #18FFFF
113 | #00E5FF
114 | #00B8D4
115 |
116 |
119 | #009688
120 | #00897B
121 | #00796B
122 | #00695C
123 | #004D40
124 |
125 | #A7FFEB
126 | #64FFDA
127 | #1DE9B6
128 | #00BFA5
129 |
130 |
133 | #4CAF50
134 | #43A047
135 | #388E3C
136 | #2E7D32
137 | #1B5E20
138 |
139 | #B9F6CA
140 | #69F0AE
141 | #00E676
142 | #00C853
143 |
144 |
147 | #8BC34A
148 | #7CB342
149 | #689F38
150 | #558B2F
151 | #33691E
152 |
153 | #CCFF90
154 | #B2FF59
155 | #76FF03
156 | #64DD17
157 |
158 |
161 | #CDDC39
162 | #C0CA33
163 | #AFB42B
164 | #9E9D24
165 | #827717
166 |
167 | #F4FF81
168 | #EEFF41
169 | #C6FF00
170 | #AEEA00
171 |
172 |
175 | #FFEB3B
176 | #FDD835
177 | #FBC02D
178 | #F9A825
179 | #F57F17
180 |
181 | #FFFF8D
182 | #FFFF00
183 | #FFEA00
184 | #FFD600
185 |
186 |
189 | #FFC107
190 | #FFB300
191 | #FFA000
192 | #FF8F00
193 | #FF6F00
194 |
195 | #FFE57F
196 | #FFD740
197 | #FFC400
198 | #FFAB00
199 |
200 |
203 | #FF9800
204 | #FB8C00
205 | #F57C00
206 | #EF6C00
207 | #E65100
208 |
209 | #FFD180
210 | #FFAB40
211 | #FF9100
212 | #FF6D00
213 |
214 |
217 | #FF5722
218 | #F4511E
219 | #E64A19
220 | #D84315
221 | #BF360C
222 |
223 | #FF9E80
224 | #FF6E40
225 | #FF3D00
226 | #DD2C00
227 |
228 |
231 | #795548
232 | #6D4C41
233 | #5D4037
234 | #4E342E
235 | #3E2723
236 |
237 |
240 | #607D8B
241 | #546E7A
242 | #455A64
243 | #37474F
244 | #263238
245 |
246 |
249 | #9E9E9E
250 | #757575
251 | #616161
252 | #424242
253 | #212121
254 | #181818
255 |
256 |
257 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2017 Andrew Bailey
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/colors/src/main/java/com/marverenic/colors/PrimaryColor.java:
--------------------------------------------------------------------------------
1 | package com.marverenic.colors;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.support.annotation.ColorRes;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.StyleRes;
8 |
9 | public enum PrimaryColor implements Parcelable {
10 |
11 | RED_500("Red 500", R.style._ColorsTheme_Primary_Red_500, R.color._color_lib_red_500, R.color._color_lib_red_700),
12 | RED_600("Red 600", R.style._ColorsTheme_Primary_Red_600, R.color._color_lib_red_600, R.color._color_lib_red_800),
13 | RED_700("Red 700", R.style._ColorsTheme_Primary_Red_700, R.color._color_lib_red_700, R.color._color_lib_red_900),
14 | RED_800("Red 800", R.style._ColorsTheme_Primary_Red_800, R.color._color_lib_red_800, R.color._color_lib_red_900),
15 |
16 | PINK_500("Pink 500", R.style._ColorsTheme_Primary_Pink_500, R.color._color_lib_pink_500, R.color._color_lib_pink_700),
17 | PINK_600("Pink 600", R.style._ColorsTheme_Primary_Pink_600, R.color._color_lib_pink_600, R.color._color_lib_pink_800),
18 | PINK_700("Pink 700", R.style._ColorsTheme_Primary_Pink_700, R.color._color_lib_pink_700, R.color._color_lib_pink_900),
19 | PINK_800("Pink 800", R.style._ColorsTheme_Primary_Pink_800, R.color._color_lib_pink_800, R.color._color_lib_pink_900),
20 |
21 | PURPLE_500("Purple 500", R.style._ColorsTheme_Primary_Purple_500, R.color._color_lib_purple_500, R.color._color_lib_purple_700),
22 | PURPLE_600("Purple 600", R.style._ColorsTheme_Primary_Purple_600, R.color._color_lib_purple_600, R.color._color_lib_purple_800),
23 | PURPLE_700("Purple 700", R.style._ColorsTheme_Primary_Purple_700, R.color._color_lib_purple_700, R.color._color_lib_purple_900),
24 | PURPLE_800("Purple 800", R.style._ColorsTheme_Primary_Purple_800, R.color._color_lib_purple_800, R.color._color_lib_purple_900),
25 |
26 | DEEP_PURPLE_500("Deep Purple 500", R.style._ColorsTheme_Primary_DeepPurple_500, R.color._color_lib_deep_purple_500, R.color._color_lib_deep_purple_700),
27 | DEEP_PURPLE_600("Deep Purple 600", R.style._ColorsTheme_Primary_DeepPurple_600, R.color._color_lib_deep_purple_600, R.color._color_lib_deep_purple_800),
28 | DEEP_PURPLE_700("Deep Purple 700", R.style._ColorsTheme_Primary_DeepPurple_700, R.color._color_lib_deep_purple_700, R.color._color_lib_deep_purple_900),
29 | DEEP_PURPLE_800("Deep Purple 800", R.style._ColorsTheme_Primary_DeepPurple_800, R.color._color_lib_deep_purple_800, R.color._color_lib_deep_purple_900),
30 |
31 | INDIGO_500("Indigo 500", R.style._ColorsTheme_Primary_Indigo_500, R.color._color_lib_indigo_500, R.color._color_lib_indigo_700),
32 | INDIGO_600("Indigo 600", R.style._ColorsTheme_Primary_Indigo_600, R.color._color_lib_indigo_600, R.color._color_lib_indigo_800),
33 | INDIGO_700("Indigo 700", R.style._ColorsTheme_Primary_Indigo_700, R.color._color_lib_indigo_700, R.color._color_lib_indigo_900),
34 | INDIGO_800("Indigo 800", R.style._ColorsTheme_Primary_Indigo_800, R.color._color_lib_indigo_800, R.color._color_lib_indigo_900),
35 |
36 | BLUE_500("Blue 500", R.style._ColorsTheme_Primary_Blue_500, R.color._color_lib_blue_500, R.color._color_lib_blue_700),
37 | BLUE_600("Blue 600", R.style._ColorsTheme_Primary_Blue_600, R.color._color_lib_blue_600, R.color._color_lib_blue_800),
38 | BLUE_700("Blue 700", R.style._ColorsTheme_Primary_Blue_700, R.color._color_lib_blue_700, R.color._color_lib_blue_900),
39 | BLUE_800("Blue 800", R.style._ColorsTheme_Primary_Blue_800, R.color._color_lib_blue_800, R.color._color_lib_blue_900),
40 |
41 | LIGHT_BLUE_500("Light Blue 500", R.style._ColorsTheme_Primary_LightBlue_500, R.color._color_lib_light_blue_500, R.color._color_lib_light_blue_700),
42 | LIGHT_BLUE_600("Light Blue 600", R.style._ColorsTheme_Primary_LightBlue_600, R.color._color_lib_light_blue_600, R.color._color_lib_light_blue_800),
43 | LIGHT_BLUE_700("Light Blue 700", R.style._ColorsTheme_Primary_LightBlue_700, R.color._color_lib_light_blue_700, R.color._color_lib_light_blue_900),
44 | LIGHT_BLUE_800("Light Blue 800", R.style._ColorsTheme_Primary_LightBlue_800, R.color._color_lib_light_blue_800, R.color._color_lib_light_blue_900),
45 |
46 | CYAN_500("Cyan 500", R.style._ColorsTheme_Primary_Cyan_500, R.color._color_lib_cyan_500, R.color._color_lib_cyan_700),
47 | CYAN_600("Cyan 600", R.style._ColorsTheme_Primary_Cyan_600, R.color._color_lib_cyan_600, R.color._color_lib_cyan_800),
48 | CYAN_700("Cyan 700", R.style._ColorsTheme_Primary_Cyan_700, R.color._color_lib_cyan_700, R.color._color_lib_cyan_900),
49 | CYAN_800("Cyan 800", R.style._ColorsTheme_Primary_Cyan_800, R.color._color_lib_cyan_800, R.color._color_lib_cyan_900),
50 |
51 | TEAL_500("Teal 500", R.style._ColorsTheme_Primary_Teal_500, R.color._color_lib_teal_500, R.color._color_lib_teal_700),
52 | TEAL_600("Teal 600", R.style._ColorsTheme_Primary_Teal_600, R.color._color_lib_teal_600, R.color._color_lib_teal_800),
53 | TEAL_700("Teal 700", R.style._ColorsTheme_Primary_Teal_700, R.color._color_lib_teal_700, R.color._color_lib_teal_900),
54 | TEAL_800("Teal 800", R.style._ColorsTheme_Primary_Teal_800, R.color._color_lib_teal_800, R.color._color_lib_teal_900),
55 |
56 | GREEN_500("Green 500", R.style._ColorsTheme_Primary_Green_500, R.color._color_lib_green_500, R.color._color_lib_green_700),
57 | GREEN_600("Green 600", R.style._ColorsTheme_Primary_Green_600, R.color._color_lib_green_600, R.color._color_lib_green_800),
58 | GREEN_700("Green 700", R.style._ColorsTheme_Primary_Green_700, R.color._color_lib_green_700, R.color._color_lib_green_900),
59 | GREEN_800("Green 800", R.style._ColorsTheme_Primary_Green_800, R.color._color_lib_green_800, R.color._color_lib_green_900),
60 |
61 | LIGHT_GREEN_500("Light Green 500", R.style._ColorsTheme_Primary_LightGreen_500, R.color._color_lib_light_green_500, R.color._color_lib_light_green_700),
62 | LIGHT_GREEN_600("Light Green 600", R.style._ColorsTheme_Primary_LightGreen_600, R.color._color_lib_light_green_600, R.color._color_lib_light_green_800),
63 | LIGHT_GREEN_700("Light Green 700", R.style._ColorsTheme_Primary_LightGreen_700, R.color._color_lib_light_green_700, R.color._color_lib_light_green_900),
64 | LIGHT_GREEN_800("Light Green 800", R.style._ColorsTheme_Primary_LightGreen_800, R.color._color_lib_light_green_800, R.color._color_lib_light_green_900),
65 |
66 | LIME_500("Lime 500", R.style._ColorsTheme_Primary_Lime_500, R.color._color_lib_lime_500, R.color._color_lib_lime_700),
67 | LIME_600("Lime 600", R.style._ColorsTheme_Primary_Lime_600, R.color._color_lib_lime_600, R.color._color_lib_lime_800),
68 | LIME_700("Lime 700", R.style._ColorsTheme_Primary_Lime_700, R.color._color_lib_lime_700, R.color._color_lib_lime_900),
69 | LIME_800("Lime 800", R.style._ColorsTheme_Primary_Lime_800, R.color._color_lib_lime_800, R.color._color_lib_lime_900),
70 |
71 | YELLOW_500("Yellow 500", R.style._ColorsTheme_Primary_Yellow_500, R.color._color_lib_yellow_500, R.color._color_lib_yellow_700),
72 | YELLOW_600("Yellow 600", R.style._ColorsTheme_Primary_Yellow_600, R.color._color_lib_yellow_600, R.color._color_lib_yellow_800),
73 | YELLOW_700("Yellow 700", R.style._ColorsTheme_Primary_Yellow_700, R.color._color_lib_yellow_700, R.color._color_lib_yellow_900),
74 | YELLOW_800("Yellow 800", R.style._ColorsTheme_Primary_Yellow_800, R.color._color_lib_yellow_800, R.color._color_lib_yellow_900),
75 |
76 | AMBER_500("Amber 500", R.style._ColorsTheme_Primary_Amber_500, R.color._color_lib_amber_500, R.color._color_lib_amber_700),
77 | AMBER_600("Amber 600", R.style._ColorsTheme_Primary_Amber_600, R.color._color_lib_amber_600, R.color._color_lib_amber_800),
78 | AMBER_700("Amber 700", R.style._ColorsTheme_Primary_Amber_700, R.color._color_lib_amber_700, R.color._color_lib_amber_900),
79 | AMBER_800("Amber 800", R.style._ColorsTheme_Primary_Amber_800, R.color._color_lib_amber_800, R.color._color_lib_amber_900),
80 |
81 | ORANGE_500("Orange 500", R.style._ColorsTheme_Primary_Orange_500, R.color._color_lib_orange_500, R.color._color_lib_orange_700),
82 | ORANGE_600("Orange 600", R.style._ColorsTheme_Primary_Orange_600, R.color._color_lib_orange_600, R.color._color_lib_orange_800),
83 | ORANGE_700("Orange 700", R.style._ColorsTheme_Primary_Orange_700, R.color._color_lib_orange_700, R.color._color_lib_orange_900),
84 | ORANGE_800("Orange 800", R.style._ColorsTheme_Primary_Orange_800, R.color._color_lib_orange_800, R.color._color_lib_orange_900),
85 |
86 | DEEP_ORANGE_500("Deep Orange 500", R.style._ColorsTheme_Primary_DeepOrange_500, R.color._color_lib_deep_orange_500, R.color._color_lib_deep_orange_700),
87 | DEEP_ORANGE_600("Deep Orange 600", R.style._ColorsTheme_Primary_DeepOrange_600, R.color._color_lib_deep_orange_600, R.color._color_lib_deep_orange_800),
88 | DEEP_ORANGE_700("Deep Orange 700", R.style._ColorsTheme_Primary_DeepOrange_700, R.color._color_lib_deep_orange_700, R.color._color_lib_deep_orange_900),
89 | DEEP_ORANGE_800("Deep Orange 800", R.style._ColorsTheme_Primary_DeepOrange_800, R.color._color_lib_deep_orange_800, R.color._color_lib_deep_orange_900),
90 |
91 | BROWN_500("Brown 500", R.style._ColorsTheme_Primary_Brown_500, R.color._color_lib_brown_500, R.color._color_lib_brown_700),
92 | BROWN_600("Brown 600", R.style._ColorsTheme_Primary_Brown_600, R.color._color_lib_brown_600, R.color._color_lib_brown_800),
93 | BROWN_700("Brown 700", R.style._ColorsTheme_Primary_Brown_700, R.color._color_lib_brown_700, R.color._color_lib_brown_900),
94 | BROWN_800("Brown 800", R.style._ColorsTheme_Primary_Brown_800, R.color._color_lib_brown_800, R.color._color_lib_brown_900),
95 |
96 | BLUE_GREY_500("Blue Grey 500", R.style._ColorsTheme_Primary_BlueGrey_500, R.color._color_lib_blue_grey_500, R.color._color_lib_blue_grey_700),
97 | BLUE_GREY_600("Blue Grey 600", R.style._ColorsTheme_Primary_BlueGrey_600, R.color._color_lib_blue_grey_600, R.color._color_lib_blue_grey_800),
98 | BLUE_GREY_700("Blue Grey 700", R.style._ColorsTheme_Primary_BlueGrey_700, R.color._color_lib_blue_grey_700, R.color._color_lib_blue_grey_900),
99 | BLUE_GREY_800("Blue Grey 800", R.style._ColorsTheme_Primary_BlueGrey_800, R.color._color_lib_blue_grey_800, R.color._color_lib_blue_grey_900),
100 |
101 | Grey_500("Grey 500", R.style._ColorsTheme_Primary_Grey_500, R.color._color_lib_grey_500, R.color._color_lib_grey_700),
102 | Grey_600("Grey 600", R.style._ColorsTheme_Primary_Grey_600, R.color._color_lib_grey_600, R.color._color_lib_grey_800),
103 | Grey_700("Grey 700", R.style._ColorsTheme_Primary_Grey_700, R.color._color_lib_grey_700, R.color._color_lib_grey_900),
104 | Grey_800("Grey 800", R.style._ColorsTheme_Primary_Grey_800, R.color._color_lib_grey_500, R.color._color_lib_grey_900),
105 |
106 | BLACK("Grey 900", R.style._ColorsTheme_Primary_Grey_900, R.color._color_lib_grey_900, R.color._color_lib_grey_1000),
107 |
108 | ;
109 |
110 | private final String mId;
111 |
112 | @StyleRes private final int mTheme;
113 | @ColorRes private final int mPrimaryColor;
114 | @ColorRes private final int mPrimaryDarkColor;
115 |
116 | PrimaryColor(String id, @StyleRes int theme, @ColorRes int primaryColor, @ColorRes int primaryDarkColor) {
117 | mId = id;
118 | mTheme = theme;
119 | mPrimaryColor = primaryColor;
120 | mPrimaryDarkColor = primaryDarkColor;
121 | }
122 |
123 | public static PrimaryColor findById(@NonNull String id) {
124 | if (id == null) {
125 | throw new IllegalArgumentException("id cannot be null");
126 | }
127 |
128 | for (PrimaryColor color : values()) {
129 | if (color.getId().equals(id)) {
130 | return color;
131 | }
132 | }
133 |
134 | throw new IllegalArgumentException("A PrimaryColor with '" + id + "' does not exist");
135 | }
136 |
137 | public String getId() {
138 | return mId;
139 | }
140 |
141 | @StyleRes
142 | protected int getThemeRes() {
143 | return mTheme;
144 | }
145 |
146 | @ColorRes
147 | public int getPrimaryColorRes() {
148 | return mPrimaryColor;
149 | }
150 |
151 | @ColorRes
152 | public int getPrimaryDarkColorRes() {
153 | return mPrimaryDarkColor;
154 | }
155 |
156 | @Override
157 | public String toString() {
158 | return mId;
159 | }
160 |
161 | @Override
162 | public void writeToParcel(Parcel dest, int flags) {
163 | dest.writeString(getId());
164 | }
165 |
166 | @Override
167 | public int describeContents() {
168 | return 0;
169 | }
170 |
171 | public static final Creator CREATOR = new Creator() {
172 | @Override
173 | public PrimaryColor createFromParcel(Parcel in) {
174 | return findById(in.readString());
175 | }
176 |
177 | @Override
178 | public PrimaryColor[] newArray(int size) {
179 | return new PrimaryColor[size];
180 | }
181 | };
182 | }
183 |
--------------------------------------------------------------------------------
/colors/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
15 |
19 |
23 |
27 |
28 |
31 |
34 |
37 |
40 |
41 |
44 |
48 |
52 |
56 |
60 |
61 |
64 |
67 |
70 |
73 |
74 |
77 |
81 |
85 |
89 |
93 |
94 |
97 |
100 |
103 |
106 |
107 |
110 |
114 |
118 |
122 |
126 |
127 |
130 |
133 |
136 |
139 |
140 |
143 |
147 |
151 |
155 |
159 |
160 |
163 |
166 |
169 |
172 |
173 |
176 |
180 |
184 |
188 |
192 |
193 |
196 |
199 |
202 |
205 |
206 |
209 |
213 |
217 |
221 |
225 |
226 |
229 |
232 |
235 |
238 |
239 |
242 |
246 |
250 |
254 |
258 |
259 |
262 |
265 |
268 |
271 |
272 |
275 |
279 |
283 |
287 |
291 |
292 |
295 |
298 |
301 |
304 |
305 |
308 |
312 |
316 |
320 |
324 |
325 |
328 |
331 |
334 |
337 |
338 |
341 |
345 |
349 |
353 |
357 |
358 |
361 |
364 |
367 |
370 |
371 |
374 |
378 |
382 |
386 |
390 |
391 |
394 |
397 |
400 |
403 |
404 |
407 |
411 |
415 |
419 |
423 |
424 |
427 |
430 |
433 |
436 |
437 |
440 |
444 |
448 |
452 |
456 |
457 |
460 |
463 |
466 |
469 |
470 |
473 |
477 |
481 |
485 |
489 |
490 |
493 |
496 |
499 |
502 |
503 |
506 |
510 |
514 |
518 |
522 |
523 |
526 |
529 |
532 |
535 |
536 |
539 |
543 |
547 |
551 |
555 |
556 |
559 |
563 |
567 |
571 |
575 |
576 |
579 |
583 |
587 |
591 |
595 |
596 |
599 |
603 |
604 |
605 |
--------------------------------------------------------------------------------