├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
└── runConfigurations.xml
├── ColorPrefUtil.gif
├── ColorPrefUtilLogo.png
├── ColorPrefUtil_sample2.gif
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── akndmr
│ │ └── github
│ │ └── io
│ │ └── colorprefutil
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── akndmr
│ │ │ └── github
│ │ │ └── io
│ │ │ └── colorprefutil
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_assignment.xml
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── akndmr
│ └── github
│ └── io
│ └── colorprefutil
│ └── ExampleUnitTest.java
├── build.gradle
├── colorprefutil
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── akndmr
│ │ └── github
│ │ └── io
│ │ └── colorprefutil
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── akndmr
│ │ │ └── github
│ │ │ └── io
│ │ │ └── colorprefutil
│ │ │ └── ColorPrefUtil.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── akndmr
│ └── github
│ └── io
│ └── colorprefutil
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ColorPrefUtil.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/ColorPrefUtil.gif
--------------------------------------------------------------------------------
/ColorPrefUtilLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/ColorPrefUtilLogo.png
--------------------------------------------------------------------------------
/ColorPrefUtil_sample2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/ColorPrefUtil_sample2.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Akın Demir
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ColorPrefUtil
2 |
3 |
4 | ColorPrefUtil for Android
5 |
6 | Easily change theme & background or text colors of views&layouts. [API >= 19]
7 |
8 |
9 |
10 |  []( https://android-arsenal.com/details/1/7502 )     
11 |
12 |
13 |
14 | ------------
15 |
16 |
17 | **Sample Preview:**
18 |
19 | 
20 |
21 |
22 | ------------
23 |
24 |
25 | ## **Setup**
26 |
27 | **Gradle**
28 |
29 | **Step 1.** Add the JitPack repository to your build file
30 |
31 | Add it in your root build.gradle at the end of repositories:
32 | ```
33 | allprojects {
34 | repositories {
35 | ...
36 | maven { url 'https://jitpack.io' }
37 | }
38 | }
39 | ```
40 |
41 | **Step 2.** Add the dependency
42 | ```
43 | dependencies {
44 | implementation 'com.github.akndmr:ColorPrefUtil:1.0.1'
45 | }
46 | ```
47 |
48 | ------------
49 |
50 |
51 | ## [](https://github.com/akndmr/ColorPrefUtil/blob/master/README.md#usage)**Usage**
52 |
53 | For a complete sample, check **app** folder.
54 |
55 | #### [](https://github.com/akndmr/ColorPrefUtil/blob/master/README.md#changing-theme)**Changing Theme**
56 |
57 | First, you need to set different styles for different color themes - if you want to change theme(setTheme(R.style.id)).
58 |
59 | **styles.xml**
60 |
61 |
67 |
68 |
73 |
74 | **MainActivity.java**
75 |
76 | @Override
77 | protected void onCreate(Bundle savedInstanceState) {
78 | super.onCreate(savedInstanceState);
79 |
80 | // Set theme before setContentView
81 | mSharedPreferences = getSharedPreferences(PREF_COLOR, MODE_PRIVATE);
82 | int themeSelected = mSharedPreferences.getInt(THEME_SELECTED, R.style.AppTheme);
83 | ColorPrefUtil.changeThemeStyle(this, themeSelected);
84 |
85 | setContentView(R.layout.activity_main);
86 |
87 | //...
88 | }
89 |
90 |
91 |
92 | ------------
93 |
94 |
95 | #### [](https://github.com/akndmr/ColorPrefUtil/blob/master/README.md#changing-backgroundcolor-of-single-or-all-views)**Changing BackgroundColor of Single View and All Views**
96 |
97 | **MainActivity.java**
98 |
99 | int selectedBackgroundColorId;
100 |
101 | @Override
102 | protected void onCreate(Bundle savedInstanceState) {
103 | super.onCreate(savedInstanceState);
104 |
105 | // Get selected colorId from preferences, if null, use default background color(colorPrimary)
106 | selectedBackgroundColorId = mSharedPreferences.getInt(COLOR_SELECTED, R.color.colorPrimary);
107 |
108 | // Single view
109 | mButton = findViewById(R.id.button);
110 | ColorPrefUtil.changeBackgroundColorOfSingleView(this, mButton, selectedBackgroundColorId);
111 |
112 | // All views inside parent layout
113 | mConstraintLayout = findViewById(R.id.cl_container);
114 | ColorPrefUtil.changeBackgroundColorOfChildViews(this, mConstraintLayout, selectedBackgroundColorId);
115 | }
116 |
117 |
118 | ------------
119 |
120 |
121 | **Changing Text Color of Single View and All Views**
122 |
123 | // All views inside given parent layout
124 | ColorPrefUtil.changeTextColorOfChildViews(this, mConstraintLayout, textColorId, hintColorId);
125 |
126 | // Single view
127 | ColorPrefUtil.changeTextColorOfSingleView(this, mTextView, textColorId, hintColorId);
128 |
129 | ------------
130 |
131 |
132 | **Changing Tint Color of Icons (ImageView)**
133 |
134 | ColorPrefUtil.changeTintColorOfIcon(this, mImageViewIcon, iconTintColorId);
135 |
136 | ------------
137 |
138 |
139 | **Changing Background Drawable of Single View and All Views**
140 | *You can set custom background drawables for views.*
141 |
142 | ColorPrefUtil.changeBackgroundDrawableOfChildViews(this, mConstraintLayout, backgroundColorId);
143 | ColorPrefUtil.changeBackgroundDrawableOfSingleView(this, mButton, backgroundDrawableId);
144 |
145 | ------------
146 |
147 |
148 | **Changing Item Colors of NavigationView**
149 | *Change icon tint color and text colors of Nav view.*
150 |
151 | ColorPrefUtil.changeColorOfItemsOfNavView(mNavigationView, iconColorId, textColorId);
152 |
153 | ------------
154 |
155 |
156 | **Changing Colors of TabLayout**
157 | *Change TabLayout background, selected tab, indicator, text colors.*
158 |
159 | ColorPrefUtil.changeColorOfTabLayout(this, mTabLayout, backgroundColorId, selectedTabColorId, indicatorColorId, textColorId);
160 |
161 |
162 |
163 | ------------
164 |
165 |
166 | **LICENSE**
167 |
168 | MIT License
169 |
170 | Copyright (c) 2019 Akın Demir
171 |
172 | Permission is hereby granted, free of charge, to any person obtaining a copy
173 | of this software and associated documentation files (the "Software"), to deal
174 | in the Software without restriction, including without limitation the rights
175 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
176 | copies of the Software, and to permit persons to whom the Software is
177 | furnished to do so, subject to the following conditions:
178 |
179 | The above copyright notice and this permission notice shall be included in all
180 | copies or substantial portions of the Software.
181 |
182 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
183 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
184 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
185 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
186 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
187 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
188 | SOFTWARE.
189 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "akndmr.github.io.colorprefutil"
7 | minSdkVersion 19
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | vectorDrawables.useSupportLibrary = true
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | buildToolsVersion '28.0.3'
21 | }
22 |
23 | dependencies {
24 | implementation fileTree(include: ['*.jar'], dir: 'libs')
25 | implementation 'com.android.support:appcompat-v7:28.0.0'
26 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
27 | testImplementation 'junit:junit:4.12'
28 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
30 | implementation project(path: ':colorprefutil')
31 | implementation 'com.android.support:recyclerview-v7:28.0.0'
32 | implementation 'com.android.support:design:28.0.0'
33 | }
34 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/akndmr/github/io/colorprefutil/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("akndmr.github.io.colorprefutil", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/akndmr/github/io/colorprefutil/MainActivity.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import android.content.SharedPreferences;
4 | import android.support.constraint.ConstraintLayout;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | public class MainActivity extends AppCompatActivity implements View.OnClickListener{
17 |
18 | public static final String PREF_COLOR = "pref_color";
19 | public static final String COLOR_SELECTED = "color_selected";
20 | public static final String COLOR_LIGHT_SELECTED = "color_light_selected";
21 | public static final String THEME_SELECTED = "theme_selected";
22 |
23 | int colorSelected, colorSelectedLight;
24 |
25 | SharedPreferences mSharedPreferences;
26 | SharedPreferences.Editor editor;
27 |
28 | Button mButton, mButtonAsphalt, mButtonBlue, mButtonRed, mButtonThemeGreen, mButtonThemePurple;
29 | ConstraintLayout mConstraintLayout;
30 | TextView mTextView;
31 | EditText mEditText;
32 | ImageView mImageViewIcon;
33 | TabLayout mTabLayout;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 |
39 | // Set theme before setContentView
40 | mSharedPreferences = getSharedPreferences(PREF_COLOR, MODE_PRIVATE);
41 | int themeSelected = mSharedPreferences.getInt(THEME_SELECTED, R.style.AppTheme);
42 | ColorPrefUtil.changeThemeStyle(this, themeSelected);
43 |
44 | setContentView(R.layout.activity_main);
45 |
46 | editor = mSharedPreferences.edit();
47 | colorSelected = mSharedPreferences.getInt(COLOR_SELECTED, R.color.colorPrimary);
48 | colorSelectedLight = mSharedPreferences.getInt(COLOR_LIGHT_SELECTED, R.color.textColor);
49 |
50 |
51 | bindViews();
52 | bindListeners();
53 |
54 | ColorPrefUtil.changeColorOfTabLayout(this, mTabLayout, colorSelected, colorSelectedLight, R.color.textColor, R.color.textColor);
55 | // ColorPrefUtil.changeTextColorOfChildViews(this, mConstraintLayout, colorSelected, colorSelectedLight);
56 | ColorPrefUtil.changeTextColorOfSingleView(this, mTextView, colorSelected, colorSelectedLight);
57 | ColorPrefUtil.changeTextColorOfSingleView(this, mEditText, colorSelected, colorSelectedLight);
58 | ColorPrefUtil.changeTintColorOfIcon(this, mImageViewIcon, colorSelected);
59 | ColorPrefUtil.changeBackgroundColorOfSingleView(this, mButton, colorSelected);
60 | }
61 |
62 | public void bindViews(){
63 | mTabLayout = findViewById(R.id.tabLayout);
64 | mConstraintLayout = findViewById(R.id.cl_container);
65 | mImageViewIcon = findViewById(R.id.imageView);
66 | mButtonAsphalt = findViewById(R.id.btnAsphalt);
67 | mButtonBlue = findViewById(R.id.btnBlue);
68 | mButtonRed = findViewById(R.id.btnRed);
69 | mButtonThemeGreen = findViewById(R.id.btnThemeGreen);
70 | mButtonThemePurple = findViewById(R.id.btnThemePurple);
71 | mButton = findViewById(R.id.button);
72 | mTextView = findViewById(R.id.textView);
73 | mEditText = findViewById(R.id.editText);
74 | }
75 |
76 | public void bindListeners(){
77 | mButtonAsphalt.setOnClickListener(this);
78 | mButtonBlue.setOnClickListener(this);
79 | mButtonRed.setOnClickListener(this);
80 | mButtonThemeGreen.setOnClickListener(this);
81 | mButtonThemePurple.setOnClickListener(this);
82 | }
83 |
84 | @Override
85 | public void onClick(View v) {
86 |
87 | switch (v.getId()){
88 | case R.id.btnAsphalt:
89 | editor.putInt(COLOR_SELECTED, R.color.colorAsphalt);
90 | editor.putInt(COLOR_LIGHT_SELECTED, R.color.colorAsphaltLight);
91 | editor.commit();
92 | //showMessage("btnAsphalt");
93 | recreate();
94 | break;
95 | case R.id.btnBlue:
96 | editor.putInt(COLOR_SELECTED, R.color.colorBlue);
97 | editor.putInt(COLOR_LIGHT_SELECTED, R.color.colorBlueLight);
98 | editor.commit();
99 | //showMessage("btnBlue");
100 | recreate();
101 | break;
102 | case R.id.btnRed:
103 | editor.putInt(COLOR_SELECTED, R.color.colorRed);
104 | editor.putInt(COLOR_LIGHT_SELECTED, R.color.colorRedLight);
105 | editor.commit();
106 | //showMessage("btnRed");
107 | recreate();
108 | break;
109 | case R.id.btnThemeGreen:
110 | editor.putInt(THEME_SELECTED, R.style.AppTheme);
111 | editor.commit();
112 | //showMessage("Green theme selected");
113 | recreate();
114 | break;
115 | case R.id.btnThemePurple:
116 | editor.putInt(THEME_SELECTED, R.style.AppThemePurple);
117 | editor.commit();
118 | //showMessage("Purple theme selected");
119 | recreate();
120 | break;
121 |
122 | }
123 | }
124 |
125 | private void showMessage(String message){
126 | Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_assignment.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
32 |
33 |
42 |
43 |
55 |
56 |
64 |
65 |
69 |
70 |
74 |
75 |
79 |
80 |
81 |
90 |
91 |
100 |
101 |
110 |
111 |
122 |
123 |
134 |
135 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1abc9c
4 | #16a085
5 | #f39c12
6 | #ffffff
7 |
8 | #B53471
9 | #6F1E51
10 | #9980FA
11 |
12 | #2980b9
13 | #94c6e7
14 | #c0392b
15 | #f8c9c4
16 | #2c3e50
17 | #688aac
18 |
19 | #cccccc
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ColorPrefUtil
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/akndmr/github/io/colorprefutil/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.3.0'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/colorprefutil/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/colorprefutil/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 19
10 | targetSdkVersion 28
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 |
30 | implementation 'com.android.support:appcompat-v7:28.0.0'
31 | implementation 'com.android.support:design:28.0.0'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/colorprefutil/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/colorprefutil/src/androidTest/java/akndmr/github/io/colorprefutil/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("akndmr.github.io.colorprefutil.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/colorprefutil/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/colorprefutil/src/main/java/akndmr/github/io/colorprefutil/ColorPrefUtil.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import android.content.Context;
4 | import android.content.res.ColorStateList;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.design.widget.NavigationView;
8 | import android.support.design.widget.TabLayout;
9 | import android.support.v4.content.ContextCompat;
10 | import android.support.v4.graphics.drawable.DrawableCompat;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.EditText;
14 | import android.widget.ImageView;
15 | import android.widget.TextView;
16 |
17 | /**
18 | * Created by Akın DEMİR on 25.01.2019.
19 | */
20 | public class ColorPrefUtil {
21 |
22 | /**
23 | * Change activity theme
24 | * Call this before @setContentView
25 | *
26 | * @param styleId is your custom style id
27 | * eg. R.style.AppThemeBlue
28 | */
29 | public static void changeThemeStyle(@NonNull Context context, @NonNull Integer styleId){
30 | context.setTheme(styleId);
31 | }
32 |
33 |
34 | /**
35 | * Change backgroundColor (android:background) of child views
36 | * This applies to each childView of given parent
37 | *
38 | * @param parentView is the parent view
39 | * @param colorId is the background color id (eg. R.color.bg)
40 | */
41 | public static void changeBackgroundColorOfChildViews(@NonNull Context context, @NonNull ViewGroup parentView, @NonNull Integer colorId){
42 | for(int i=0; i < parentView.getChildCount(); i++){
43 | parentView.getChildAt(i).setBackgroundColor(ContextCompat.getColor(context, colorId));
44 | }
45 | }
46 |
47 |
48 | /**
49 | * Change backgroundColor (android:background) of view
50 | *
51 | * @param view is the view
52 | * @param colorId is the background color id (eg. R.color.bg)
53 | */
54 | public static void changeBackgroundColorOfSingleView(@NonNull Context context, @NonNull View view, @NonNull Integer colorId){
55 | view.setBackgroundColor(ContextCompat.getColor(context, colorId));
56 | }
57 |
58 |
59 | /**
60 | * Change textColor (android:textColor) of child views
61 | * This applies to each TextView and EditText childs of given parent
62 | *
63 | * @param parentView is the parent view
64 | * @param textColorId is the text color of TextView or EditText
65 | * @param hintColorId is the hint text color of TextView or EditText
66 | * if @hintColorId is null, it gets default hint text color
67 | */
68 | public static void changeTextColorOfChildViews(@NonNull Context context, @NonNull ViewGroup parentView, @NonNull Integer textColorId, @Nullable Integer hintColorId){
69 | for(int i=0; i < parentView.getChildCount(); i++){
70 | View v = parentView.getChildAt(i);
71 |
72 | if(v instanceof EditText){
73 | ((EditText)v).setTextColor(ContextCompat.getColor(context, textColorId));
74 | if(hintColorId != null){
75 | ((EditText)v).setHintTextColor(ContextCompat.getColor(context, hintColorId));
76 | }
77 | }
78 | else if(v instanceof TextView){
79 | ((TextView)v).setTextColor(ContextCompat.getColor(context, textColorId));
80 | if(hintColorId != null){
81 | ((TextView)v).setHintTextColor(ContextCompat.getColor(context, hintColorId));
82 | }
83 | }
84 | }
85 | }
86 |
87 |
88 |
89 | /**
90 | * Change textColor (android:textColor) of child views
91 | * This applies to each TextView and EditText childs of given parent
92 | *
93 | * @param view is the view either TextView or EditText
94 | * @param textColorId is the text color of TextView or EditText
95 | * @param hintColorId is the hint text color of TextView or EditText
96 | * if @hintColorId is null, it gets default theme hint text color
97 | */
98 | public static void changeTextColorOfSingleView(@NonNull Context context, @NonNull View view, @NonNull Integer textColorId, @Nullable Integer hintColorId){
99 | if(view instanceof EditText){
100 | ((EditText)view).setTextColor(ContextCompat.getColor(context, textColorId));
101 | if(hintColorId != null){
102 | ((EditText)view).setHintTextColor(ContextCompat.getColor(context, hintColorId));
103 | }
104 | }
105 | else if(view instanceof TextView){
106 | ((TextView)view).setTextColor(ContextCompat.getColor(context, textColorId));
107 | if(hintColorId != null){
108 | ((TextView)view).setHintTextColor(ContextCompat.getColor(context, hintColorId));
109 | }
110 | }
111 | }
112 |
113 |
114 | /**
115 | * Change backgroundDrawable (android:background) of child views
116 | * This applies to each childView of given parent
117 | *
118 | * @param parentView is the parent view
119 | * @param drawableId is the background drawable id (eg. R.drawable.image1)
120 | */
121 | public static void changeBackgroundDrawableOfChildViews(@NonNull Context context, @NonNull ViewGroup parentView, @NonNull Integer drawableId){
122 | for(int i=0; i < parentView.getChildCount(); i++){
123 | parentView.getChildAt(i).setBackground(ContextCompat.getDrawable(context, drawableId));
124 | }
125 | }
126 |
127 |
128 | /**
129 | * Change backgroundDrawable (android:background) of single view
130 | *
131 | * @param view is the view
132 | * @param drawableId is the background drawable id (eg. R.drawable.image1)
133 | */
134 | public static void changeBackgroundDrawableOfSingleView(@NonNull Context context, @NonNull View view, @NonNull Integer drawableId){
135 | view.setBackground(ContextCompat.getDrawable(context, drawableId));
136 | }
137 |
138 |
139 | /**
140 | * Change tint color of an icon (android:tint)
141 | * For #API < 21 add "vectorDrawables.useSupportLibrary = true"
142 | * inside defaultConfig block in build.gradle
143 | *
144 | * @param icon is the icon imageview
145 | * @param tintColorId is the background color id (eg. R.color.accent)
146 | */
147 | public static void changeTintColorOfIcon(@NonNull Context context, @NonNull ImageView icon, @NonNull Integer tintColorId){
148 |
149 | DrawableCompat.setTint(
150 | icon.getDrawable(),
151 | ContextCompat.getColor(context, tintColorId)
152 | );
153 | }
154 |
155 |
156 | /**
157 | * Change icon tint and text colors of NavigationView
158 | *
159 | * @param iconColorId is the icon tint color id
160 | * @param textColorId is the text color. If null, #iconColorId will apply
161 | */
162 | public static void changeColorOfItemsOfNavView(@NonNull NavigationView navigationView, @NonNull Integer iconColorId, @Nullable Integer textColorId){
163 |
164 | if(textColorId != null){
165 | ColorStateList colorStateListIcon = ColorStateList.valueOf(iconColorId);
166 | ColorStateList colorStateListText = ColorStateList.valueOf(textColorId);
167 | navigationView.setItemIconTintList(colorStateListIcon);
168 | navigationView.setItemTextColor(colorStateListText);
169 | }
170 | else{
171 | ColorStateList colorStateList = ColorStateList.valueOf(iconColorId);
172 | navigationView.setItemIconTintList(colorStateList);
173 | navigationView.setItemTextColor(colorStateList);
174 | }
175 | }
176 |
177 |
178 | /**
179 | * Change icon tint and text colors of NavigationView
180 | *
181 | * @param backgroundColorId is the color TabLayout's background
182 | * @param tabNormalTextColorId is the normal text color
183 | * @param tabSelectedTextColorId is the selected tab text color
184 | */
185 | public static void changeColorOfTabLayout(@NonNull Context context, @NonNull TabLayout tabLayout, @NonNull Integer backgroundColorId,
186 | @NonNull Integer tabNormalTextColorId,
187 | @NonNull Integer tabSelectedTextColorId,
188 | @NonNull Integer tabSelectedIndicatorColorId){
189 | tabLayout.setBackgroundColor(ContextCompat.getColor(context, backgroundColorId));
190 | tabLayout.setTabTextColors(ContextCompat.getColor(context, tabNormalTextColorId), ContextCompat.getColor(context, tabSelectedTextColorId));
191 | tabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(context, tabSelectedIndicatorColorId));
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/colorprefutil/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ColorPrefUtil
3 |
4 |
--------------------------------------------------------------------------------
/colorprefutil/src/test/java/akndmr/github/io/colorprefutil/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package akndmr.github.io.colorprefutil;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/akndmr/ColorPrefUtil/6bc483bfe6f3f1602ef3fe27287a7cbd94a1fde5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 25 17:14:10 EET 2019
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-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':colorprefutil'
2 |
--------------------------------------------------------------------------------