├── .gitignore
├── LICENSE
├── Microchip.iml
├── README.md
├── Throttle.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── lint.xml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ └── com
│ │ └── mridang
│ │ └── throttle
│ │ ├── BatteryReceiver.java
│ │ ├── BootReceiver.java
│ │ ├── FrequencyManager.java
│ │ ├── HardwareService.java
│ │ ├── NotificationHandler.java
│ │ ├── PowerReceiver.java
│ │ ├── ProcessorManager.java
│ │ ├── SettingsActivity.java
│ │ └── ThrottleApplication.java
│ ├── lint.xml
│ └── res
│ ├── drawable-xhdpi
│ ├── i0.png
│ ├── i1.png
│ ├── i2.png
│ ├── i3.png
│ ├── i4.png
│ ├── i5.png
│ ├── i6.png
│ ├── i7.png
│ ├── i8.png
│ └── i9.png
│ ├── 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-v21
│ └── styles.xml
│ ├── values
│ ├── arrays.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── preferences.xml
├── build.gradle
├── colorPicker
├── build.gradle
├── colorPicker.iml
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── mridang
│ │ └── colorpicker
│ │ └── ColorPreference.java
│ └── res
│ ├── layout
│ ├── dash_dialog_colors.xml
│ └── dash_grid_item_color.xml
│ ├── values-v11
│ └── styles.xml
│ └── values
│ ├── attrs.xml
│ ├── styles.xml
│ └── swatches.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── icon.svg
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | /*/build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
--------------------------------------------------------------------------------
/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 {yyyy} {name of copyright owner}
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 |
--------------------------------------------------------------------------------
/Microchip.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Microchip - Memory Processor Monitor
2 | =============================================================================
3 |
4 | Microchip is an extremely small app that shows the processor usage as an icon in the status bar.
5 |
6 | It does one thing and aims to do it well without any excessive bloat. Microchip has a minimal memory footprint and is primarily active while the screen is on.
7 |
8 | For more information and screenshots, visit the Play store: https://play.google.com/store/apps/details?id=com.mridang.throttle
9 |
--------------------------------------------------------------------------------
/Throttle.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 'android-N'
5 | buildToolsVersion '24.0.0-rc1'
6 | defaultConfig {
7 | applicationId "com.mridang.throttle"
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 2
11 | versionName "1.1"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | productFlavors {
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile 'com.android.support:support-v4:24.0.0-alpha1'
26 | compile project(':colorPicker')
27 | compile 'ch.acra:acra:4.8.5'
28 | }
29 |
--------------------------------------------------------------------------------
/app/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/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 /Users/mridangagarwalla/Downloads/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
45 |
46 |
47 |
48 |
49 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/BatteryReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.preference.PreferenceManager;
7 | import android.util.Log;
8 |
9 | /**
10 | * Broadcast receiver class to help start or stop the traffic monitoring service when the phone's
11 | * battery level is low or okay.
12 | */
13 | public class BatteryReceiver extends BroadcastReceiver {
14 |
15 | /**
16 | * Receiver method for the phone boot that starts the traffic monitoring service
17 | */
18 | @Override
19 | public void onReceive(Context appContext, Intent ittIntent) {
20 | Log.v("BatteryReceiver", "Received a battery intent");
21 | if (PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("enabled", true) &&
22 | PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("lowpower", false)) {
23 | if (ittIntent.getAction().equals(Intent.ACTION_BATTERY_LOW)) {
24 | Log.i("BatteryReceiver", "Battery low. Stopping service");
25 | appContext.stopService(new Intent(appContext, HardwareService.class));
26 | } else {
27 | Log.i("BatteryReceiver", "Battery okay. Starting service");
28 | appContext.startService(new Intent(appContext, HardwareService.class));
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/BootReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.preference.PreferenceManager;
7 | import android.util.Log;
8 |
9 | /**
10 | * Broadcast receiver class to help start the traffic monitoring service when the phone boots up only
11 | * if the service is enabled.
12 | */
13 | public class BootReceiver extends BroadcastReceiver {
14 |
15 | /**
16 | * Receiver method for the phone boot that starts the traffic monitoring service
17 | */
18 | @Override
19 | public void onReceive(Context appContext, Intent bootIntent) {
20 | if (PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("enabled", true)) {
21 | Log.i("BatteryReceiver", "Device booted. Starting service");
22 | appContext.startService(new Intent(appContext, HardwareService.class));
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/FrequencyManager.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.FileNotFoundException;
6 | import java.io.IOException;
7 | import java.io.RandomAccessFile;
8 |
9 | /**
10 | * Manager class to read the processor usage from the cpufreq file and return the processor frequency
11 | */
12 | public class FrequencyManager {
13 |
14 | /**
15 | * The frequency statistics file from which the figures should be read repeatedly
16 | */
17 | private RandomAccessFile rafFrequency;
18 |
19 | public FrequencyManager() {
20 | try {
21 | rafFrequency = new RandomAccessFile("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");
22 | } catch (FileNotFoundException e) {
23 | throw new RuntimeException(e);
24 | }
25 | }
26 |
27 | /**
28 | * Returns the current CPU frequency in a human readable format by converting it into a Hz
29 | *
30 | * @return The current CPU frequency
31 | */
32 | public String getFrequency() {
33 | try {
34 | rafFrequency.seek(0);
35 | int hz = Integer.valueOf(rafFrequency.readLine());
36 | if (hz < 1000 * 1000) {
37 | return (hz / 1000) + " MHz";
38 | }
39 |
40 | final int a = (hz / 1000 / 1000);
41 | final int b = (hz / 1000 / 100) % 10;
42 | return a + "." + b + " GHz";
43 | } catch (IOException e) {
44 | Log.w("FrequencyManager", "Error reading the CPU frequency", e);
45 | return "";
46 | }
47 | }
48 |
49 | /**
50 | * Closes the processor statistics file from which the figures are be read repeatedly
51 | */
52 | public void destroy() {
53 |
54 | if (rafFrequency != null) {
55 | try {
56 | rafFrequency.close();
57 | } catch (IOException e) {
58 | Log.w("FrequencyManager", "Unable to successfully close the file");
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/HardwareService.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.app.NotificationManager;
4 | import android.app.PendingIntent;
5 | import android.app.Service;
6 | import android.content.BroadcastReceiver;
7 | import android.content.ComponentName;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.IntentFilter;
11 | import android.content.SharedPreferences;
12 | import android.graphics.Color;
13 | import android.os.Binder;
14 | import android.os.Build;
15 | import android.os.IBinder;
16 | import android.os.PowerManager;
17 | import android.preference.PreferenceManager;
18 | import android.support.v4.app.NotificationCompat;
19 | import android.util.Log;
20 |
21 | /**
22 | * Main service class that monitors the processor usage and updates the notification every second
23 | */
24 | public class HardwareService extends Service {
25 |
26 | /**
27 | * The constant defining the identifier of the notification that is to be shown
28 | */
29 | public static final int ID = 9001;
30 | /**
31 | * The identifier if the component that open from the settings activity
32 | */
33 | private static final String CMP = "com.android.settings.Settings$DevelopmentSettingsActivity";
34 | /**
35 | * The instance of the handler that updates the notification
36 | */
37 | private static NotificationHandler hndNotifier;
38 | /**
39 | * The instance of the manager of the notification services
40 | */
41 | private static NotificationManager mgrNotifications;
42 | /**
43 | * The instance of the notification builder to rebuild the notification
44 | */
45 | private static NotificationCompat.Builder notBuilder;
46 | /**
47 | * The instance of the binder class used by the activity
48 | */
49 | private final IBinder mBinder = new LocalBinder();
50 | /**
51 | * The instance of the broadcast receiver to handle power saver mode intents
52 | */
53 | private final BroadcastReceiver recSaver = new PowerReceiver();
54 | /**
55 | * The instance of the broadcast receiver to handle screen on/off intents
56 | */
57 | private BroadcastReceiver recScreen;
58 |
59 | /**
60 | * Initializes the service by getting instances of service managers and mainly setting up the
61 | * receiver to receive all the necessary intents that this service is supposed to handle.
62 | */
63 | @Override
64 | public void onCreate() {
65 |
66 | Log.i("HardwareService", "Creating the hardware service");
67 | super.onCreate();
68 | final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
69 |
70 | Intent ittSettings = new Intent();
71 | ittSettings.setComponent(new ComponentName("com.android.settings", CMP));
72 | PendingIntent pitSettings = PendingIntent.getActivity(this, 0, ittSettings, 0);
73 | notBuilder = new NotificationCompat.Builder(this);
74 | notBuilder.setSmallIcon(R.drawable.i0);
75 | notBuilder.setContentIntent(pitSettings);
76 | notBuilder.setOngoing(true);
77 | notBuilder.setWhen(0);
78 | notBuilder.setOnlyAlertOnce(true);
79 | notBuilder.setPriority(Integer.MAX_VALUE);
80 | notBuilder.setCategory(NotificationCompat.CATEGORY_SERVICE);
81 | setColor(settings.getInt("color", Color.TRANSPARENT));
82 | visibilityPublic(settings.getBoolean("lockscreen", true));
83 |
84 | Log.d("HardwareService", "Setting up the service manager and the broadcast receiver");
85 | mgrNotifications = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
86 | hndNotifier = new NotificationHandler(getApplicationContext(), notBuilder);
87 |
88 | if (settings.getBoolean("enabled", true)) {
89 | Log.d("HardwareService", "Screen on; showing the notification");
90 | hndNotifier.sendEmptyMessage(1);
91 | hndNotifier.sendEmptyMessage(2);
92 | }
93 | recScreen = new BroadcastReceiver() {
94 |
95 | /**
96 | * Handles the screen-on and the screen off intents to enable or disable the notification.
97 | * We don't want to show the notification if the screen is off.
98 | */
99 | @Override
100 | public void onReceive(Context ctxContext, Intent ittIntent) {
101 |
102 | if (ittIntent.getAction().equalsIgnoreCase(Intent.ACTION_SCREEN_OFF)) {
103 |
104 | Log.d("HardwareService", "Screen off; hiding the notification");
105 | hndNotifier.removeMessages(1);
106 | mgrNotifications.cancel(ID);
107 | } else {
108 |
109 | if (settings.getBoolean("enabled", true)) {
110 | Log.d("HardwareService", "Screen on; showing the notification");
111 | hndNotifier = new NotificationHandler(ctxContext, notBuilder);
112 | showNotification();
113 | }
114 | }
115 | }
116 | };
117 |
118 | IntentFilter ittScreen = new IntentFilter();
119 | ittScreen.addAction(Intent.ACTION_SCREEN_ON);
120 | ittScreen.addAction(Intent.ACTION_SCREEN_OFF);
121 | registerReceiver(recScreen, ittScreen);
122 |
123 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
124 | IntentFilter ittSaver = new IntentFilter();
125 | ittScreen.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
126 | registerReceiver(recSaver, ittSaver);
127 | }
128 | }
129 |
130 | /**
131 | * Called when the service is being stopped. It doesn't do much except clear the message queue of
132 | * the handler, hides the notification and unregisters the receivers.
133 | */
134 | @Override
135 | public void onDestroy() {
136 |
137 | Log.d("HardwareService", "Stopping the hardware service");
138 | unregisterReceiver(recScreen);
139 | unregisterReceiver(recSaver);
140 | hndNotifier.removeMessages(1);
141 | hndNotifier.removeMessages(2);
142 | mgrNotifications.cancel(ID);
143 | hndNotifier.destroy();
144 | }
145 |
146 | /**
147 | * Helper method that shows the notification by sending the handler a message and building the
148 | * notification. This is invoked when the preference is toggled.
149 | */
150 | public void showNotification() {
151 |
152 | Log.d("HardwareService", "Showing the notification");
153 | mgrNotifications.notify(ID, notBuilder.build());
154 | hndNotifier.removeMessages(1);
155 | hndNotifier.sendEmptyMessage(1);
156 | }
157 |
158 | /**
159 | * Helper method that hides the notification by clearing the handler messages and cancelling the
160 | * notification. This is invoked when the preference is toggled.
161 | */
162 | public void hideNotification() {
163 |
164 | Log.d("HardwareService", "Hiding the notification");
165 | mgrNotifications.cancel(ID);
166 | hndNotifier.removeMessages(1);
167 | }
168 |
169 | /**
170 | * Helper method that toggles the visibility of the notification on the locksreen depending on the
171 | * value of the preference in the activity
172 | *
173 | * @param visibility A boolean value indicating whether the notification should be visible on the
174 | * lockscreen
175 | */
176 | public void visibilityPublic(Boolean visibility) {
177 | if (visibility) {
178 | notBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
179 | } else {
180 | notBuilder.setVisibility(NotificationCompat.VISIBILITY_SECRET);
181 | }
182 | }
183 |
184 | /**
185 | * Helper method that sets the background color of the notification icon by parsing the RGB value
186 | * into an int.
187 | *
188 | * @param color The internal int representation of the RGB color to set as the background colour
189 | */
190 | public void setColor(Integer color) {
191 | notBuilder.setColor(color);
192 | }
193 |
194 | /**
195 | * Binder method to allow the settings activity to bind to the service so the notification can be
196 | * configured and updated while the activity is being toggles.
197 | *
198 | * @see android.app.Service#onBind(android.content.Intent)
199 | */
200 | @Override
201 | public IBinder onBind(Intent intReason) {
202 | return mBinder;
203 | }
204 |
205 | /**
206 | * Custom binder class used for allowing the preference activity to bind to this service so that it
207 | * may be configured on the fly
208 | */
209 | public class LocalBinder extends Binder {
210 |
211 | public HardwareService getServerInstance() {
212 | return HardwareService.this;
213 | }
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/NotificationHandler.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.app.ActivityManager;
4 | import android.app.ActivityManager.MemoryInfo;
5 | import android.app.NotificationManager;
6 | import android.content.Context;
7 | import android.os.Handler;
8 | import android.os.Message;
9 | import android.support.v4.app.NotificationCompat.Builder;
10 |
11 | /**
12 | * Handler class that runs every second to update the notification with the processor usage.
13 | */
14 | public class NotificationHandler extends Handler {
15 |
16 | /**
17 | * The object for holding the memory usage information and other stats
18 | */
19 | private final MemoryInfo memInformation = new MemoryInfo();
20 | /**
21 | * The instance of the context of the parent service
22 | */
23 | private final Context ctxContext;
24 | /**
25 | * The instance of the manager of the activity services
26 | */
27 | private final ActivityManager mgrActivity;
28 | /**
29 | * The instance of the manager of the processor usage
30 | */
31 | private final ProcessorManager mgrProcessor;
32 | /**
33 | * The instance of the manager of the clock frequency
34 | */
35 | private final FrequencyManager mgrFrequency;
36 | /**
37 | * The instance of the manager of the notification services
38 | */
39 | private final NotificationManager mgrNotifications;
40 | /**
41 | * The instance of the notification builder to rebuild the notification
42 | */
43 | private final Builder notBuilder;
44 |
45 | /**
46 | * Simple constructor to initialize the initial value of the previous
47 | */
48 | public NotificationHandler(Context ctxContext, Builder notBuilder) {
49 | this.mgrActivity = (ActivityManager) ctxContext.getSystemService(Context.ACTIVITY_SERVICE);
50 | this.mgrNotifications = (NotificationManager) ctxContext.getSystemService(Context.NOTIFICATION_SERVICE);
51 | this.mgrProcessor = new ProcessorManager();
52 | this.mgrFrequency = new FrequencyManager();
53 | this.ctxContext = ctxContext;
54 | this.notBuilder = notBuilder;
55 | }
56 |
57 | /**
58 | * Handler method that updates the notification icon with the current processor usage. It does
59 | * this by reading the /proc/stat file and specifically the of the first CPU row as are only
60 | * concerned with the cumulative processor utilization.
61 | */
62 | @Override
63 | public void handleMessage(Message msgMessage) {
64 | sendEmptyMessageDelayed(1, 2000L);
65 |
66 | mgrActivity.getMemoryInfo(memInformation);
67 | long lngFree = memInformation.availMem / 1048576L;
68 | long lngTotal = memInformation.totalMem / 1048576L;
69 | int intLevel = (int) ((100.0 * (lngFree / (lngTotal + 0.01))) / 25);
70 | Double dblPercent = mgrProcessor.getUsage();
71 | String strClock = mgrFrequency.getFrequency();
72 |
73 | notBuilder.setSmallIcon(R.drawable.i0 + (int) (dblPercent / 10));
74 | notBuilder.setContentTitle(ctxContext.getResources().getStringArray(R.array.usage)[intLevel]);
75 | notBuilder.setContentInfo(dblPercent.intValue() + "% @ " + strClock);
76 | notBuilder.setContentText(ctxContext.getString(R.string.memory, lngFree, lngTotal));
77 | mgrNotifications.notify(HardwareService.ID, notBuilder.build());
78 | }
79 |
80 | public void destroy() {
81 | mgrProcessor.destroy();
82 | mgrFrequency.destroy();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/PowerReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.os.Build;
8 | import android.os.PowerManager;
9 | import android.preference.PreferenceManager;
10 | import android.util.Log;
11 |
12 | /**
13 | * Broadcast receiver class to help start or stop the traffic monitoring service when the phone's
14 | * battery saver mode is enabled or disabled
15 | */
16 | public class PowerReceiver extends BroadcastReceiver {
17 |
18 | /**
19 | * Receiver method for the phone boot that starts the traffic monitoring service
20 | */
21 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
22 | @Override
23 | public void onReceive(Context appContext, Intent bootIntent) {
24 | Log.v("BatteryReceiver", "Received a power intent");
25 | if (PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("enabled", true) &&
26 | PreferenceManager.getDefaultSharedPreferences(appContext).getBoolean("lowpower", false)) {
27 | PowerManager mgrPower = (PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
28 | if (mgrPower.isPowerSaveMode()) {
29 | Log.i("BatteryReceiver", "Power saving mode enabled. Stopping service");
30 | appContext.stopService(new Intent(appContext, HardwareService.class));
31 | } else {
32 | Log.i("BatteryReceiver", "Power saving mode disabled. Starting service");
33 | appContext.startService(new Intent(appContext, HardwareService.class));
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/ProcessorManager.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.FileNotFoundException;
6 | import java.io.IOException;
7 | import java.io.RandomAccessFile;
8 |
9 | /**
10 | * Manager class to read the processor usage from the /proc/stat file and return the processor usage
11 | */
12 | public class ProcessorManager {
13 |
14 | /**
15 | * The processor statistics file from which the figures should be read repeatedly
16 | */
17 | private RandomAccessFile rafProcessor;
18 | /**
19 | * The value of the total processor utilization since the last update
20 | */
21 | private long lngPreviousTotal = 0L;
22 | /**
23 | * The value of the idle processor utilization since the last update
24 | */
25 | private long lngPreviousIdle = 0L;
26 |
27 | public ProcessorManager() {
28 | try {
29 | rafProcessor = new RandomAccessFile("/proc/stat", "r");
30 | } catch (FileNotFoundException e) {
31 | throw new RuntimeException(e);
32 | }
33 | }
34 |
35 | /**
36 | * Handler method that updates the notification icon with the current processor usage. It does
37 | * this by reading the /proc/stat file and specifically the of the first CPU row as are only
38 | * concerned with the cumulative processor utilization.
39 | */
40 | public double getUsage() {
41 | try {
42 | rafProcessor.seek(0);
43 | String strLine = rafProcessor.readLine();
44 | Log.v("HardwareService", strLine);
45 | String[] lstColumns = strLine.split(" ");
46 |
47 | long lngCurrentIdle = Long.parseLong(lstColumns[5]);
48 | long lngCurrentTotal = 0L;
49 |
50 | lstColumns[0] = lstColumns[1] = "0";
51 |
52 | for (String strStatistic : lstColumns) {
53 | lngCurrentTotal = lngCurrentTotal + Integer.parseInt(strStatistic);
54 | }
55 | long lngDifferenceIdle = lngCurrentIdle - lngPreviousIdle;
56 | long lngDifferenceTotal = lngCurrentTotal - lngPreviousTotal;
57 |
58 | lngPreviousIdle = lngCurrentIdle;
59 | lngPreviousTotal = lngCurrentTotal;
60 |
61 | long lngUsageDelta = lngDifferenceTotal - lngDifferenceIdle;
62 |
63 | Double dblPercent = 100.0 * (lngUsageDelta / (lngDifferenceTotal + 0.01));
64 | if (dblPercent < 0D) {
65 | Log.w("ProcessorManager", "Encountered a negative value of " + dblPercent);
66 | dblPercent = 0D;
67 | } else if (dblPercent > 100D) {
68 | Log.w("ProcessorManager", "Encountered a insane value of " + dblPercent);
69 | dblPercent = 100D;
70 | }
71 | Log.d("HardwareService", "Current processor usage is " + dblPercent);
72 | return dblPercent;
73 |
74 | } catch (Exception e) {
75 | Log.e("HardwareService", "Error processing line", e);
76 | }
77 |
78 | return 0D;
79 | }
80 |
81 | /**
82 | * Closes the processor statistics file from which the figures are be read repeatedly
83 | */
84 | public void destroy() {
85 |
86 | if (rafProcessor != null) {
87 | try {
88 | rafProcessor.close();
89 | } catch (IOException e) {
90 | Log.w("HardwareService", "Unable to successfully close the file");
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Intent;
5 | import android.content.ServiceConnection;
6 | import android.os.Bundle;
7 | import android.os.IBinder;
8 | import android.preference.Preference;
9 | import android.preference.Preference.OnPreferenceChangeListener;
10 | import android.preference.PreferenceActivity;
11 |
12 | /**
13 | * Settings activity that allows the user to start or stop the service and also change the polling
14 | * interval
15 | */
16 | public class SettingsActivity extends PreferenceActivity {
17 |
18 | private boolean isBounded;
19 | private HardwareService backgroundService;
20 |
21 | /**
22 | * Connection class between the activity and the service to be able to invoke service methods
23 | */
24 | private final ServiceConnection mConnection = new ServiceConnection() {
25 |
26 | public void onServiceDisconnected(ComponentName name) {
27 | isBounded = false;
28 | backgroundService = null;
29 | }
30 |
31 | public void onServiceConnected(ComponentName name, IBinder service) {
32 | isBounded = true;
33 | HardwareService.LocalBinder mLocalBinder = (HardwareService.LocalBinder) service;
34 | backgroundService = mLocalBinder.getServerInstance();
35 | }
36 | };
37 |
38 | /**
39 | * OnStart method of the activity that establishes a connection with the service by binding to it
40 | */
41 | @Override
42 | protected void onStart() {
43 | super.onStart();
44 | Intent serviceIntent = new Intent(getApplicationContext(), HardwareService.class);
45 | startService(serviceIntent);
46 | bindService(serviceIntent, mConnection, BIND_AUTO_CREATE);
47 | }
48 |
49 | /**
50 | * OnStop method of the activity that destroys the connection with the service by unbinding from it
51 | */
52 | @Override
53 | protected void onStop() {
54 | super.onStop();
55 | if (isBounded) {
56 | unbindService(mConnection);
57 | isBounded = false;
58 | }
59 | }
60 |
61 | /**
62 | * Post create method that bind each of the preferences to a listener so that updating the
63 | * preferences will fire the listeners to trigger updates to the notification
64 | */
65 | @SuppressWarnings("deprecation")
66 | @Override
67 | protected void onPostCreate(Bundle savedInstanceState) {
68 | super.onPostCreate(savedInstanceState);
69 | addPreferencesFromResource(R.xml.preferences);
70 |
71 | findPreference("enabled").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
72 |
73 | /**
74 | * Preference change listener that handles the starting and the stopping of the service
75 | * depending on whether the the switch is toggled or not.
76 | */
77 | @Override
78 | public boolean onPreferenceChange(Preference enabledPreference, Object newValue) {
79 | if ((Boolean) newValue) {
80 | backgroundService.showNotification();
81 | } else {
82 | backgroundService.hideNotification();
83 | }
84 | return true;
85 | }
86 | });
87 |
88 | findPreference("lockscreen").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
89 |
90 | /**
91 | * Preference change listener that handles whether the notification should be displayed
92 | * on the lockscreen depending on whether the the switch is toggled or not.
93 | */
94 | @Override
95 | public boolean onPreferenceChange(Preference enabledPreference, Object newValue) {
96 | backgroundService.visibilityPublic((Boolean) newValue);
97 | return true;
98 | }
99 | });
100 |
101 | findPreference("color").setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
102 |
103 | /**
104 | * Preference change listener that handles whether the notification should be displayed
105 | * on the lockscreen depending on whether the the switch is toggled or not.
106 | */
107 | @Override
108 | public boolean onPreferenceChange(Preference enabledPreference, Object newValue) {
109 | backgroundService.setColor((Integer) newValue);
110 | return true;
111 | }
112 | });
113 |
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mridang/throttle/ThrottleApplication.java:
--------------------------------------------------------------------------------
1 | package com.mridang.throttle;
2 |
3 | import android.app.Application;
4 |
5 | import org.acra.annotation.ReportsCrashes;
6 |
7 | @ReportsCrashes(
8 | resNotifTickerText = R.string.crash_notif_ticker_text,
9 | resNotifTitle = R.string.crash_notif_title,
10 | resNotifText = R.string.crash_notif_text,
11 | mailTo = "mridang.agarwalla+throttle@gmail.com"
12 | )
13 | public class ThrottleApplication extends Application {
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i0.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i5.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i6.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i7.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i8.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/i9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/drawable-xhdpi/i9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - Memory usage is currently high
5 | - Memory usage is currently normal
6 | - Memory usage is currently low
7 | - Memory usage is currently low
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Microchip
3 | Shows or hides the notification icon
4 | Enabled
5 | %1$dMB of %2$dMB memory free
6 | Show the notification in the lockscreen when the device is locked
7 | Publicly visible
8 | Disable on low battery
9 | Disable the notification and the service when the device\'s battery is low or when the power saving mode is enabled
10 | Background color of the notification icon
11 | Color
12 | Unexpected error, please send a report
13 | Throttle has crashed…
14 | Please click here to help fix the issue.
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
13 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | }
5 | dependencies {
6 | classpath 'com.android.tools.build:gradle:1.2.3'
7 | }
8 | }
9 |
10 | allprojects {
11 | repositories {
12 | jcenter()
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/colorPicker/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | android {
3 | compileSdkVersion 22
4 | buildToolsVersion '22.0.0'
5 | defaultConfig {
6 | minSdkVersion 14
7 | targetSdkVersion 22
8 | }
9 | buildTypes {
10 | release {
11 | minifyEnabled false
12 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
13 | }
14 | }
15 | productFlavors {
16 | }
17 | }
18 |
19 | dependencies {
20 | }
--------------------------------------------------------------------------------
/colorPicker/colorPicker.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/colorPicker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/colorPicker/src/main/java/com/mridang/colorpicker/ColorPreference.java:
--------------------------------------------------------------------------------
1 | package com.mridang.colorpicker;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Activity;
5 | import android.app.AlertDialog;
6 | import android.app.Dialog;
7 | import android.app.DialogFragment;
8 | import android.content.Context;
9 | import android.content.res.Resources;
10 | import android.content.res.TypedArray;
11 | import android.graphics.Color;
12 | import android.graphics.drawable.Drawable;
13 | import android.graphics.drawable.GradientDrawable;
14 | import android.os.Bundle;
15 | import android.preference.Preference;
16 | import android.util.AttributeSet;
17 | import android.util.TypedValue;
18 | import android.view.LayoutInflater;
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import android.widget.AdapterView;
22 | import android.widget.BaseAdapter;
23 | import android.widget.GridView;
24 | import android.widget.ImageView;
25 | import android.widget.TextView;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | /**
31 | Custom preference that allows the user to choose a color from a grid of pre-selected colors
32 | */
33 | public class ColorPreference extends Preference {
34 | private int[] mColorChoices = {};
35 | private int mValue = 0;
36 | private int mItemLayoutId = R.layout.dash_grid_item_color;
37 | private int mNumColumns = 5;
38 |
39 | public ColorPreference(Context context) {
40 | super(context);
41 | initAttrs(null, 0);
42 | }
43 |
44 | /*
45 | @see android.preference.Preference#Preference(android.content.Context, android.util.AttributeSet)
46 | */
47 | public ColorPreference(Context context, AttributeSet attrs) {
48 | super(context, attrs);
49 | initAttrs(attrs, 0);
50 | }
51 |
52 | /*
53 | @see android.preference.Preference#Preference(android.content.Context, android.util.AttributeSet, int)
54 | */
55 | public ColorPreference(Context context, AttributeSet attrs, int defStyle) {
56 | super(context, attrs, defStyle);
57 | initAttrs(attrs, defStyle);
58 | }
59 |
60 | /*
61 | @see android.preference.Preference#Preference(android.util.AttributeSet, int)
62 | */
63 | private void initAttrs(AttributeSet attrs, int defStyle) {
64 | TypedArray a = getContext().getTheme().obtainStyledAttributes(
65 | attrs, R.styleable.ColorPreference, defStyle, defStyle);
66 |
67 | try {
68 | mItemLayoutId = a.getResourceId(R.styleable.ColorPreference_itemLayout, mItemLayoutId);
69 | mNumColumns = a.getInteger(R.styleable.ColorPreference_numColumns, mNumColumns);
70 | int choicesResId = a.getResourceId(R.styleable.ColorPreference_choices,
71 | R.array.color_choices);
72 | if (choicesResId > 0) {
73 | String[] choices = a.getResources().getStringArray(choicesResId);
74 | mColorChoices = new int[choices.length];
75 | for (int i = 0; i < choices.length; i++) {
76 | mColorChoices[i] = Color.parseColor(choices[i]);
77 | }
78 | }
79 | } finally {
80 | a.recycle();
81 | }
82 |
83 | setWidgetLayoutResource(mItemLayoutId);
84 | }
85 |
86 | @SuppressWarnings("NullableProblems")
87 | @Override
88 | protected void onBindView(View view) {
89 | super.onBindView(view);
90 | View mPreviewView = view.findViewById(R.id.color_view);
91 | setColorViewValue(mPreviewView, mValue);
92 | }
93 |
94 | private void setValue(int value) {
95 | if (callChangeListener(value)) {
96 | mValue = value;
97 | persistInt(value);
98 | notifyChanged();
99 | }
100 | }
101 |
102 | @Override
103 | protected void onClick() {
104 | super.onClick();
105 |
106 | ColorDialogFragment fragment = ColorDialogFragment.newInstance();
107 | fragment.setPreference(this);
108 |
109 | Activity activity = (Activity) getContext();
110 | activity.getFragmentManager().beginTransaction()
111 | .add(fragment, getFragmentTag())
112 | .commit();
113 | }
114 |
115 | @Override
116 | protected void onAttachedToActivity() {
117 | super.onAttachedToActivity();
118 |
119 | Activity activity = (Activity) getContext();
120 | ColorDialogFragment fragment = (ColorDialogFragment) activity
121 | .getFragmentManager().findFragmentByTag(getFragmentTag());
122 | if (fragment != null) {
123 | // re-bind preference to fragment
124 | fragment.setPreference(this);
125 | }
126 | }
127 |
128 | @Override
129 | protected Object onGetDefaultValue(TypedArray a, int index) {
130 | return a.getInt(index, 0);
131 | }
132 |
133 | @Override
134 | protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
135 | setValue(restoreValue ? getPersistedInt(0) : (Integer) defaultValue);
136 | }
137 |
138 | private String getFragmentTag() {
139 | return "color_" + getKey();
140 | }
141 |
142 | private int getValue() {
143 | return mValue;
144 | }
145 |
146 | public static class ColorDialogFragment extends DialogFragment {
147 | private ColorPreference mPreference;
148 | private ColorGridAdapter mAdapter;
149 | private GridView mColorGrid;
150 |
151 | public ColorDialogFragment() {
152 | }
153 |
154 | public static ColorDialogFragment newInstance() {
155 | return new ColorDialogFragment();
156 | }
157 |
158 | public void setPreference(ColorPreference preference) {
159 | mPreference = preference;
160 | tryBindLists();
161 | }
162 |
163 | @Override
164 | public void onAttach(Activity activity) {
165 | super.onAttach(activity);
166 | tryBindLists();
167 | }
168 |
169 | @SuppressLint("InflateParams")
170 | @Override
171 | public Dialog onCreateDialog(Bundle savedInstanceState) {
172 | LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
173 | View rootView = layoutInflater.inflate(R.layout.dash_dialog_colors, null);
174 |
175 | mColorGrid = (GridView) rootView.findViewById(R.id.color_grid);
176 |
177 | mColorGrid.setNumColumns(mPreference.mNumColumns);
178 |
179 | mColorGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
180 | @Override
181 | public void onItemClick(AdapterView> listView, View view,
182 | int position, long itemId) {
183 | mPreference.setValue(mAdapter.getItem(position));
184 | dismiss();
185 | }
186 | });
187 |
188 | tryBindLists();
189 |
190 | return new AlertDialog.Builder(getActivity())
191 | .setView(rootView)
192 | .create();
193 | }
194 |
195 | private void tryBindLists() {
196 | if (mPreference == null) {
197 | return;
198 | }
199 |
200 | if (isAdded() && mAdapter == null) {
201 | mAdapter = new ColorGridAdapter();
202 | }
203 |
204 | if (mAdapter != null && mColorGrid != null) {
205 | mAdapter.setSelectedColor(mPreference.getValue());
206 | mColorGrid.setAdapter(mAdapter);
207 | }
208 | }
209 |
210 | private class ColorGridAdapter extends BaseAdapter {
211 | private final List mChoices = new ArrayList<>();
212 | private int mSelectedColor;
213 |
214 | private ColorGridAdapter() {
215 | for (int color : mPreference.mColorChoices) {
216 | mChoices.add(color);
217 | }
218 | }
219 |
220 | @Override
221 | public int getCount() {
222 | return mChoices.size();
223 | }
224 |
225 | @Override
226 | public Integer getItem(int position) {
227 | return mChoices.get(position);
228 | }
229 |
230 | @Override
231 | public long getItemId(int position) {
232 | return mChoices.get(position);
233 | }
234 |
235 | @Override
236 | public View getView(int position, View convertView, ViewGroup container) {
237 | if (convertView == null) {
238 | convertView = LayoutInflater.from(getActivity())
239 | .inflate(mPreference.mItemLayoutId, container, false);
240 | }
241 |
242 | int color = getItem(position);
243 | setColorViewValue(convertView.findViewById(R.id.color_view), color);
244 | convertView.setBackgroundColor(color == mSelectedColor
245 | ? 0x6633b5e5 : 0);
246 |
247 | return convertView;
248 | }
249 |
250 | public void setSelectedColor(int selectedColor) {
251 | mSelectedColor = selectedColor;
252 | notifyDataSetChanged();
253 | }
254 | }
255 | }
256 |
257 | private static void setColorViewValue(View view, int color) {
258 | if (view instanceof ImageView) {
259 | ImageView imageView = (ImageView) view;
260 | Resources res = imageView.getContext().getResources();
261 |
262 | Drawable currentDrawable = imageView.getDrawable();
263 | GradientDrawable colorChoiceDrawable;
264 | if (currentDrawable != null && currentDrawable instanceof GradientDrawable) {
265 | // Reuse drawable
266 | colorChoiceDrawable = (GradientDrawable) currentDrawable;
267 | } else {
268 | colorChoiceDrawable = new GradientDrawable();
269 | colorChoiceDrawable.setShape(GradientDrawable.OVAL);
270 | }
271 |
272 | // Set stroke to dark version of color
273 | int darkenedColor = Color.rgb(
274 | Color.red(color) * 192 / 256,
275 | Color.green(color) * 192 / 256,
276 | Color.blue(color) * 192 / 256);
277 |
278 | colorChoiceDrawable.setColor(color);
279 | colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(
280 | TypedValue.COMPLEX_UNIT_DIP, 1, res.getDisplayMetrics()), darkenedColor);
281 | imageView.setImageDrawable(colorChoiceDrawable);
282 | } else if (view instanceof TextView) {
283 | ((TextView) view).setTextColor(color);
284 | }
285 | }
286 | }
--------------------------------------------------------------------------------
/colorPicker/src/main/res/layout/dash_dialog_colors.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/colorPicker/src/main/res/layout/dash_grid_item_color.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
--------------------------------------------------------------------------------
/colorPicker/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/colorPicker/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/colorPicker/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/colorPicker/src/main/res/values/swatches.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | - #33b5e5
4 | - #aa66cc
5 | - #99cc00
6 | - #ffbb33
7 | - #ff4444
8 | - #0099cc
9 | - #9933cc
10 | - #669900
11 | - #ff8800
12 | - #cc0000
13 | - #ffffff
14 | - #eeeeee
15 | - #cccccc
16 | - #888888
17 |
18 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mridang/microchip/7793055bccc1a5fd6749c78c4ee48b36d7c9b14a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':colorPicker'
3 |
--------------------------------------------------------------------------------