8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Creative Commons Legal Code
2 |
3 | CC0 1.0 Universal
4 |
5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12 | HEREUNDER.
13 |
14 | Statement of Purpose
15 |
16 | The laws of most jurisdictions throughout the world automatically confer
17 | exclusive Copyright and Related Rights (defined below) upon the creator
18 | and subsequent owner(s) (each and all, an "owner") of an original work of
19 | authorship and/or a database (each, a "Work").
20 |
21 | Certain owners wish to permanently relinquish those rights to a Work for
22 | the purpose of contributing to a commons of creative, cultural and
23 | scientific works ("Commons") that the public can reliably and without fear
24 | of later claims of infringement build upon, modify, incorporate in other
25 | works, reuse and redistribute as freely as possible in any form whatsoever
26 | and for any purposes, including without limitation commercial purposes.
27 | These owners may contribute to the Commons to promote the ideal of a free
28 | culture and the further production of creative, cultural and scientific
29 | works, or to gain reputation or greater distribution for their Work in
30 | part through the use and efforts of others.
31 |
32 | For these and/or other purposes and motivations, and without any
33 | expectation of additional consideration or compensation, the person
34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35 | is an owner of Copyright and Related Rights in the Work, voluntarily
36 | elects to apply CC0 to the Work and publicly distribute the Work under its
37 | terms, with knowledge of his or her Copyright and Related Rights in the
38 | Work and the meaning and intended legal effect of CC0 on those rights.
39 |
40 | 1. Copyright and Related Rights. A Work made available under CC0 may be
41 | protected by copyright and related or neighboring rights ("Copyright and
42 | Related Rights"). Copyright and Related Rights include, but are not
43 | limited to, the following:
44 |
45 | i. the right to reproduce, adapt, distribute, perform, display,
46 | communicate, and translate a Work;
47 | ii. moral rights retained by the original author(s) and/or performer(s);
48 | iii. publicity and privacy rights pertaining to a person's image or
49 | likeness depicted in a Work;
50 | iv. rights protecting against unfair competition in regards to a Work,
51 | subject to the limitations in paragraph 4(a), below;
52 | v. rights protecting the extraction, dissemination, use and reuse of data
53 | in a Work;
54 | vi. database rights (such as those arising under Directive 96/9/EC of the
55 | European Parliament and of the Council of 11 March 1996 on the legal
56 | protection of databases, and under any national implementation
57 | thereof, including any amended or successor version of such
58 | directive); and
59 | vii. other similar, equivalent or corresponding rights throughout the
60 | world based on applicable law or treaty, and any national
61 | implementations thereof.
62 |
63 | 2. Waiver. To the greatest extent permitted by, but not in contravention
64 | of, applicable law, Affirmer hereby overtly, fully, permanently,
65 | irrevocably and unconditionally waives, abandons, and surrenders all of
66 | Affirmer's Copyright and Related Rights and associated claims and causes
67 | of action, whether now known or unknown (including existing as well as
68 | future claims and causes of action), in the Work (i) in all territories
69 | worldwide, (ii) for the maximum duration provided by applicable law or
70 | treaty (including future time extensions), (iii) in any current or future
71 | medium and for any number of copies, and (iv) for any purpose whatsoever,
72 | including without limitation commercial, advertising or promotional
73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74 | member of the public at large and to the detriment of Affirmer's heirs and
75 | successors, fully intending that such Waiver shall not be subject to
76 | revocation, rescission, cancellation, termination, or any other legal or
77 | equitable action to disrupt the quiet enjoyment of the Work by the public
78 | as contemplated by Affirmer's express Statement of Purpose.
79 |
80 | 3. Public License Fallback. Should any part of the Waiver for any reason
81 | be judged legally invalid or ineffective under applicable law, then the
82 | Waiver shall be preserved to the maximum extent permitted taking into
83 | account Affirmer's express Statement of Purpose. In addition, to the
84 | extent the Waiver is so judged Affirmer hereby grants to each affected
85 | person a royalty-free, non transferable, non sublicensable, non exclusive,
86 | irrevocable and unconditional license to exercise Affirmer's Copyright and
87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the
88 | maximum duration provided by applicable law or treaty (including future
89 | time extensions), (iii) in any current or future medium and for any number
90 | of copies, and (iv) for any purpose whatsoever, including without
91 | limitation commercial, advertising or promotional purposes (the
92 | "License"). The License shall be deemed effective as of the date CC0 was
93 | applied by Affirmer to the Work. Should any part of the License for any
94 | reason be judged legally invalid or ineffective under applicable law, such
95 | partial invalidity or ineffectiveness shall not invalidate the remainder
96 | of the License, and in such case Affirmer hereby affirms that he or she
97 | will not (i) exercise any of his or her remaining Copyright and Related
98 | Rights in the Work or (ii) assert any associated claims and causes of
99 | action with respect to the Work, in either case contrary to Affirmer's
100 | express Statement of Purpose.
101 |
102 | 4. Limitations and Disclaimers.
103 |
104 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
105 | surrendered, licensed or otherwise affected by this document.
106 | b. Affirmer offers the Work as-is and makes no representations or
107 | warranties of any kind concerning the Work, express, implied,
108 | statutory or otherwise, including without limitation warranties of
109 | title, merchantability, fitness for a particular purpose, non
110 | infringement, or the absence of latent or other defects, accuracy, or
111 | the present or absence of errors, whether or not discoverable, all to
112 | the greatest extent permissible under applicable law.
113 | c. Affirmer disclaims responsibility for clearing rights of other persons
114 | that may apply to the Work or any use thereof, including without
115 | limitation any person's Copyright and Related Rights in the Work.
116 | Further, Affirmer disclaims responsibility for obtaining any necessary
117 | consents, permissions or other rights required for any use of the
118 | Work.
119 | d. Affirmer understands and acknowledges that Creative Commons is not a
120 | party to this document and has no duty or obligation with respect to
121 | this CC0 or use of the Work.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # fliclib-android
2 |
3 | This SDK library can be used to create your own functionality for flic buttons. Buy buttons at https://flic.io.
4 | See the tutorial at https://partners.flic.io/partners/developers/android-tutorial for more info.
5 |
--------------------------------------------------------------------------------
/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 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/docs/allclasses-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
66 |
67 |
68 |
69 |
70 |
Package
71 |
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
72 |
73 |
Interfaces (italic)
74 |
Classes
75 |
Enums
76 |
Exceptions
77 |
Errors
78 |
Annotation Types
79 |
80 |
81 |
82 |
Class/Interface
83 |
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
84 |
85 |
Class inheritance diagram
86 |
Direct Subclasses
87 |
All Known Subinterfaces
88 |
All Known Implementing Classes
89 |
Class/interface declaration
90 |
Class/interface description
91 |
92 |
93 |
Nested Class Summary
94 |
Field Summary
95 |
Constructor Summary
96 |
Method Summary
97 |
98 |
99 |
Field Detail
100 |
Constructor Detail
101 |
Method Detail
102 |
103 |
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
104 |
105 |
106 |
Annotation Type
107 |
Each annotation type has its own separate page with the following sections:
108 |
109 |
Annotation Type declaration
110 |
Annotation Type description
111 |
Required Element Summary
112 |
Optional Element Summary
113 |
Element Detail
114 |
115 |
116 |
117 |
Enum
118 |
Each enum has its own separate page with the following sections:
119 |
120 |
Enum declaration
121 |
Enum description
122 |
Enum Constant Summary
123 |
Enum Constant Detail
124 |
125 |
126 |
127 |
Tree (Class Hierarchy)
128 |
There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
129 |
130 |
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
131 |
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
132 |
133 |
134 |
135 |
Deprecated API
136 |
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
137 |
138 |
139 |
Index
140 |
The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
141 |
142 |
143 |
Prev/Next
144 |
These links take you to the next or previous class, interface, package, or related page.
145 |
146 |
147 |
Frames/No Frames
148 |
These links show and hide the HTML frames. All pages are available with or without frames.
149 |
150 |
151 |
All Classes
152 |
The All Classes link shows all classes and interfaces except non-static nested types.
153 |
154 |
155 |
Serialized Form
156 |
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
To receive button clicks that also works in the case the app is not currently running, you
75 | can set up a broadcast receiver extending FlicBroadcastReceiver.
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/fliclib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fliclib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 19
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:22.1.1'
24 | }
25 |
--------------------------------------------------------------------------------
/fliclib/fliclib.iml:
--------------------------------------------------------------------------------
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 |
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 |
--------------------------------------------------------------------------------
/fliclib/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 C:\Users\Emil\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/fliclib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/fliclib/src/main/aidl/io/flic/lib/IFlicLibCallbackInterface.aidl:
--------------------------------------------------------------------------------
1 | // Internal class used for communication with the Flic Application
2 |
3 | package io.flic.lib;
4 |
5 | interface IFlicLibCallbackInterface {
6 | void onConnect(String mac);
7 | void onReady(String mac);
8 | void onDisconnect(String mac, int flicError);
9 | void onConnectionFailed(String mac, int status);
10 |
11 | void onReadRemoteRSSI(String mac, int rssi, int status);
12 | void onButtonUpOrDown(String mac, boolean wasQueued, int timeDiff, int action);
13 | void onButtonClickOrHold(String mac, boolean wasQueued, int timeDiff, int action);
14 | void onButtonSingleOrDoubleClick(String mac, boolean wasQueued, int timeDiff, int action);
15 | void onButtonSingleOrDoubleClickOrHold(String mac, boolean wasQueued, int timeDiff, int action);
16 |
17 | void onButtonRemoved(String mac);
18 | }
19 |
--------------------------------------------------------------------------------
/fliclib/src/main/aidl/io/flic/lib/IFlicLibInterface.aidl:
--------------------------------------------------------------------------------
1 | // Internal class used for communication with the Flic Application
2 |
3 | package io.flic.lib;
4 |
5 | import io.flic.lib.IFlicLibCallbackInterface;
6 |
7 | interface IFlicLibInterface {
8 | long registerCallback(IFlicLibCallbackInterface cb, String appId, String appSecret, String appName);
9 | void unregisterCallback(long id);
10 |
11 | void listenForConnectionCallbacks(long id, String mac);
12 | void unListenForConnectionCallbacks(long id, String mac);
13 | void setButtonCallbacks(long id, String mac, int flags);
14 | int getConnectionStatus(long id, String mac);
15 | String getColor(long id, String mac);
16 | boolean readRemoteRSSI(long id, String mac);
17 | void setActiveMode(long id, String mac, boolean activeMode);
18 | void grabExclusivity(long id, String mac);
19 | void releaseExclusivity(long id, String mac);
20 |
21 | boolean validateIntent(long id, in Bundle bundle);
22 | List listButtons(long id);
23 | void removeButton(long id, String mac);
24 | void registerListenForBroadcast(long id, String mac, int flags);
25 |
26 | String getName(long id, String mac);
27 | }
28 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/AppCredentialsNotProvidedException.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Exception thrown when app credentials were not provided.
5 | */
6 | public class AppCredentialsNotProvidedException extends RuntimeException {
7 | AppCredentialsNotProvidedException(String s) {
8 | super(s);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/DB.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.database.Cursor;
6 | import android.database.sqlite.SQLiteDatabase;
7 | import android.database.sqlite.SQLiteOpenHelper;
8 |
9 | import java.util.ArrayList;
10 | import java.util.HashMap;
11 |
12 | /**
13 | * Created by Emil on 2015-09-06.
14 | */
15 | class DB extends SQLiteOpenHelper {
16 | private static final String TAG = "DB";
17 | private static final int DATABASE_VERSION = 1;
18 |
19 | private static final String DATABASE_NAME = "fliclib";
20 | private static final String BUTTONS_TABLE_NAME = "buttons";
21 | private static final String BUTTONS_TABLE_CREATE =
22 | "CREATE TABLE " + BUTTONS_TABLE_NAME + " (mac TEXT UNIQUE);";
23 |
24 | public DB(Context context) {
25 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
26 | }
27 |
28 | @Override
29 | public void onCreate(SQLiteDatabase db) {
30 | db.execSQL(BUTTONS_TABLE_CREATE);
31 | }
32 |
33 | @Override
34 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
35 |
36 | }
37 |
38 | public synchronized ArrayList getButtons() {
39 | SQLiteDatabase db = this.getWritableDatabase();
40 | ArrayList list = new ArrayList<>();
41 | Cursor query = db.query(BUTTONS_TABLE_NAME, null, null, null, null, null, null);
42 | query.moveToFirst();
43 | if (!query.isAfterLast()) {
44 | do {
45 | String mac = query.getString(query.getColumnIndex("mac"));
46 | list.add(mac);
47 | } while(query.moveToNext());
48 | }
49 | query.close();
50 | db.close();
51 |
52 | return list;
53 | }
54 |
55 | public synchronized void addButton(String mac) {
56 | SQLiteDatabase db = this.getWritableDatabase();
57 | ContentValues values = new ContentValues();
58 | values.put("mac", mac);
59 | db.insertWithOnConflict(BUTTONS_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
60 | db.close();
61 | }
62 |
63 | public synchronized void removeButton(String mac) {
64 | SQLiteDatabase db = this.getWritableDatabase();
65 | db.delete(BUTTONS_TABLE_NAME, "mac = ?", new String[] { mac });
66 | db.close();
67 | }
68 | }
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicAppNotInstalledException.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Exception thrown when the Flic App was not installed
5 | */
6 | public class FlicAppNotInstalledException extends RuntimeException {
7 | FlicAppNotInstalledException(String s) {
8 | super(s);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicBroadcastReceiver.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.util.Log;
7 |
8 | /**
9 | * Broadcast receiver for events from the Flic App.
10 | * Extend this class and implement the methods you want to get events for.
11 | * To activate events, call {@link FlicButton#registerListenForBroadcast(int)}.
12 | * See also {@link FlicBroadcastReceiverFlags}.
13 | */
14 | public abstract class FlicBroadcastReceiver extends BroadcastReceiver {
15 | private static final String TAG = "FlicBroadcastReceiver";
16 |
17 | public final void onReceive(final Context context, final Intent intent) {
18 | if (!FlicManager.hasSetAppCredentials()) {
19 | onRequestAppCredentials(context);
20 | }
21 | FlicManager.getInstance(context, new FlicManagerInitializedCallback() {
22 | @Override
23 | public void onInitialized(FlicManager manager) {
24 | if (!manager.validateIntent(intent)) {
25 | Log.d(TAG, "Invalid intent received");
26 | return;
27 | }
28 |
29 | String deviceId = intent.getStringExtra(FlicIntentExtras.BUTTON_ID);
30 | FlicButton button = manager.getButtonByDeviceId(deviceId);
31 | if (button == null) { // For removed
32 | button = new FlicButton(manager, deviceId);
33 | }
34 |
35 | String value = intent.getStringExtra(FlicIntentExtras.VALUE);
36 |
37 | switch (intent.getStringExtra(FlicIntentExtras.TYPE)) {
38 | case FlicIntentTypes.UP_OR_DOWN:
39 | onButtonUpOrDown(context, button, intent.getBooleanExtra(FlicIntentExtras.WAS_QUEUED, false), intent.getIntExtra(FlicIntentExtras.TIME_DIFF, 0), value.equals(FlicIntentValues.UP), value.equals(FlicIntentValues.DOWN));
40 | break;
41 | case FlicIntentTypes.CLICK_OR_HOLD:
42 | onButtonClickOrHold(context, button, intent.getBooleanExtra(FlicIntentExtras.WAS_QUEUED, false), intent.getIntExtra(FlicIntentExtras.TIME_DIFF, 0), value.equals(FlicIntentValues.CLICK), value.equals(FlicIntentValues.HOLD));
43 | break;
44 | case FlicIntentTypes.SINGLE_OR_DOUBLE_CLICK:
45 | onButtonSingleOrDoubleClick(context, button, intent.getBooleanExtra(FlicIntentExtras.WAS_QUEUED, false), intent.getIntExtra(FlicIntentExtras.TIME_DIFF, 0), value.equals(FlicIntentValues.SINGLE_CLICK), value.equals(FlicIntentValues.DOUBLE_CLICK));
46 | break;
47 | case FlicIntentTypes.SINGLE_OR_DOUBLE_CLICK_OR_HOLD:
48 | onButtonSingleOrDoubleClickOrHold(context, button, intent.getBooleanExtra(FlicIntentExtras.WAS_QUEUED, false), intent.getIntExtra(FlicIntentExtras.TIME_DIFF, 0), value.equals(FlicIntentValues.SINGLE_CLICK), value.equals(FlicIntentValues.DOUBLE_CLICK), value.equals(FlicIntentValues.HOLD));
49 | break;
50 | case FlicIntentTypes.REMOVED:
51 | onButtonRemoved(context, button);
52 | button.forgotten = true;
53 | break;
54 | }
55 | }
56 | });
57 | }
58 |
59 | /**
60 | * Sets app credentials.
61 | *
62 | * In this method, call {@link FlicManager#setAppCredentials(String, String, String)} and set the appropriate app credentials.
63 | *
64 | * @param context The Context in which the receiver is running
65 | */
66 | protected abstract void onRequestAppCredentials(Context context);
67 |
68 | /**
69 | * Called when the button was pressed or released.
70 | *
71 | * @param context The Context in which the receiver is running
72 | * @param button The button
73 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
74 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
75 | * @param isUp True if up, else false
76 | * @param isDown True if down, else false
77 | */
78 | public void onButtonUpOrDown(Context context, FlicButton button, boolean wasQueued, int timeDiff, boolean isUp, boolean isDown) {}
79 |
80 | /**
81 | * Used for the scenario where you want to listen on button click and hold.
82 | *
83 | * @param context The Context in which the receiver is running
84 | * @param button The button
85 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
86 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
87 | * @param isClick True if click, else false
88 | * @param isHold True if hold, else false
89 | */
90 | public void onButtonClickOrHold(Context context, FlicButton button, boolean wasQueued, int timeDiff, boolean isClick, boolean isHold) {}
91 |
92 | /**
93 | * Used for the scenario where you want to listen on single click and double click.
94 | * Single clicks might be delayed for up to 0.5 seconds because we can't be sure if it was rather a double click or not until then.
95 | *
96 | * @param context The Context in which the receiver is running
97 | * @param button The button
98 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
99 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
100 | * @param isSingleClick True if single click, else false
101 | * @param isDoubleClick True if double click, else false
102 | */
103 | public void onButtonSingleOrDoubleClick(Context context, FlicButton button, boolean wasQueued, int timeDiff, boolean isSingleClick, boolean isDoubleClick) {}
104 |
105 | /**
106 | * Used for the scenario where you want to listen on single click, double click and hold.
107 | * Single clicks might be delayed for up to 0.5 seconds because we can't be sure if it was rather a double click or not until then.
108 | *
109 | * @param context The Context in which the receiver is running
110 | * @param button The button
111 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
112 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
113 | * @param isSingleClick True if single click, else false
114 | * @param isDoubleClick True if double click, else false
115 | * @param isHold True if hold, else false
116 | */
117 | public void onButtonSingleOrDoubleClickOrHold(Context context, FlicButton button, boolean wasQueued, int timeDiff, boolean isSingleClick, boolean isDoubleClick, boolean isHold) {}
118 |
119 | /**
120 | * Called when the button was removed in the Flic App, or when the user disconnected this app from the button in the Flic App (if so the button can be grabbed again as usual).
121 | * This object cannot be used any more once this method has returned.
122 | *
123 | * @param context The Context in which the receiver is running.
124 | * @param button The button
125 | */
126 | public void onButtonRemoved(Context context, FlicButton button) {}
127 | }
128 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicBroadcastReceiverFlags.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Used in {@link FlicButton#registerListenForBroadcast(int)} to tell which events you want to listen for.
5 | * If you are concerned about low latencies and performance, only register the flags you actually use.
6 | * These can be bitwise-or'ed together.
7 | */
8 | public class FlicBroadcastReceiverFlags {
9 | public static final int NONE = 0;
10 | public static final int UP_OR_DOWN = 1;
11 | public static final int CLICK_OR_HOLD = 2;
12 | public static final int CLICK_OR_DOUBLE_CLICK = 4;
13 | public static final int CLICK_OR_DOUBLE_CLICK_OR_HOLD = 8;
14 | public static final int REMOVED = 16;
15 | public static final int ALL = 31;
16 | }
17 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicButtonCallback.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * FlicButtonCallback
5 | *
6 | * Callbacks for button updates. You should extend this class and implement the callbacks you want.
7 | */
8 | public class FlicButtonCallback {
9 | /**
10 | * Called when the Bluetooth connection has just been started.
11 | * It's not ready for use yet however - {@link FlicButtonCallback#onConnectionCompleted(FlicButton)} will be called when ready.
12 | *
13 | * @param button The button
14 | */
15 | public void onConnectionStarted(FlicButton button) {}
16 |
17 | /**
18 | * Called if there was a problem establishing a Bluetooth connection to the button. Happens very rarely.
19 | *
20 | * @param button The button
21 | * @param status A Bluetooth GATT status.
22 | */
23 | public void onConnectionFailed(FlicButton button, int status) {}
24 |
25 | /**
26 | * Called when the Bluetooth connection was disconnected, for example if the button becomes out of range or the user manually disconnecting this button in the Flic Application.
27 | *
28 | * @param button The button
29 | */
30 | public void onDisconnect(FlicButton button) {}
31 |
32 | /**
33 | * Called when the connection to the button has been established and is ready to use.
34 | *
35 | * @param button The button
36 | */
37 | public void onConnectionCompleted(FlicButton button) {}
38 |
39 | /**
40 | * Called as a result of {@link FlicButton#readRemoteRSSI()}.
41 | *
42 | * @param button The button
43 | * @param rssi RSSI value for the remote device
44 | * @param status 0 if the RSSI was read successfully
45 | */
46 | public void onReadRemoteRSSI(FlicButton button, int rssi, int status) {}
47 |
48 | /**
49 | * Called when the button was pressed or released.
50 | *
51 | * @param button The button
52 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
53 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
54 | * @param isUp True if up, else false
55 | * @param isDown True if down, else false
56 | */
57 | public void onButtonUpOrDown(FlicButton button, boolean wasQueued, int timeDiff, boolean isUp, boolean isDown) {}
58 |
59 | /**
60 | * Used for the scenario where you want to listen on button click and hold.
61 | *
62 | * @param button The button
63 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
64 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
65 | * @param isClick True if click, else false
66 | * @param isHold True if hold, else false
67 | */
68 | public void onButtonClickOrHold(FlicButton button, boolean wasQueued, int timeDiff, boolean isClick, boolean isHold) {}
69 |
70 | /**
71 | * Used for the scenario where you want to listen on single click and double click.
72 | * Single clicks might be delayed for up to 0.5 seconds because we can't be sure if it was rather a double click or not until then.
73 | *
74 | * @param button The button
75 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
76 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
77 | * @param isSingleClick True if single click, else false
78 | * @param isDoubleClick True if double click, else false
79 | */
80 | public void onButtonSingleOrDoubleClick(FlicButton button, boolean wasQueued, int timeDiff, boolean isSingleClick, boolean isDoubleClick) {}
81 |
82 | /**
83 | * Used for the scenario where you want to listen on single click, double click and hold.
84 | * Single clicks might be delayed for up to 0.5 seconds because we can't be sure if it was rather a double click or not until then.
85 | *
86 | * @param button The button
87 | * @param wasQueued If the event was locally queued in the button because it was disconnected. After the connection is completed, the event will be sent with this parameter set to true.
88 | * @param timeDiff If the event was queued, the timeDiff will be the number of seconds since the event happened.
89 | * @param isSingleClick True if single click, else false
90 | * @param isDoubleClick True if double click, else false
91 | * @param isHold True if hold, else false
92 | */
93 | public void onButtonSingleOrDoubleClickOrHold(FlicButton button, boolean wasQueued, int timeDiff, boolean isSingleClick, boolean isDoubleClick, boolean isHold) {}
94 |
95 | /**
96 | * Called when the button was removed in the Flic App, or when the user disconnected this app from the button in the Flic App (if so the button can be grabbed again as usual).
97 | * This object cannot be used any more once this method has returned.
98 | *
99 | * @param button The button
100 | */
101 | public void onButtonRemoved(FlicButton button) {}
102 | }
103 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicButtonCallbackFlags.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Used in {@link FlicButton#setFlicButtonCallbackFlags(int)} to tell which events you want to listen for.
5 | * If you are concerned about low latencies and performance, only register the flags you actually use.
6 | * These can be bitwise-or'ed together.
7 | */
8 | public class FlicButtonCallbackFlags {
9 | public static final int NONE = 0;
10 | public static final int UP_OR_DOWN = 1;
11 | public static final int CLICK_OR_HOLD = 2;
12 | public static final int CLICK_OR_DOUBLE_CLICK = 4;
13 | public static final int CLICK_OR_DOUBLE_CLICK_OR_HOLD = 8;
14 | public static final int ALL = 15;
15 | }
16 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicIntentExtras.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Intent extras of flic event intents.
5 | */
6 | class FlicIntentExtras {
7 | /**
8 | * Contains the button identifier (Bluetooth Address).
9 | */
10 | public static final String BUTTON_ID = "buttonId";
11 |
12 | /**
13 | * Contains the type of this event.
14 | * See {@link FlicIntentTypes} for possible values.
15 | */
16 | public static final String TYPE = "type";
17 |
18 | /**
19 | * Contains the value of this event, unless {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#REMOVED}.
20 | * See {@link FlicIntentValues} for possible values.
21 | */
22 | public static final String VALUE = "value";
23 |
24 | /**
25 | * Contains a boolean whether the event was queued or not on the Flic button.
26 | * The event will be queued on the button if it is not connected when it is pressed.
27 | * This will not be present if {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#REMOVED}.
28 | */
29 | public static final String WAS_QUEUED = "wasQueued";
30 |
31 | /**
32 | * If the event was queued (see {@link FlicIntentExtras#WAS_QUEUED}, contains the number of seconds since the event happened.
33 | * This will not be present if {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#REMOVED}.
34 | */
35 | public static final String TIME_DIFF = "timeDiff";
36 | }
37 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicIntentTypes.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Represents possible values for the intent extra {@link FlicIntentExtras#TYPE}.
5 | */
6 | class FlicIntentTypes {
7 | /**
8 | * Indicates that the button was pressed or released.
9 | * See {@link FlicIntentValues#UP} and {@link FlicIntentValues#DOWN}.
10 | */
11 | public static final String UP_OR_DOWN = "UP_OR_DOWN";
12 |
13 | /**
14 | * Indicates that the button was clicked or held.
15 | * See {@link FlicIntentValues#CLICK} and {@link FlicIntentValues#HOLD}.
16 | */
17 | public static final String CLICK_OR_HOLD = "CLICK_OR_HOLD";
18 |
19 | /**
20 | * Indicates that the button was single- or double clicked.
21 | * See {@link FlicIntentValues#SINGLE_CLICK} and {@link FlicIntentValues#DOUBLE_CLICK}.
22 | */
23 | public static final String SINGLE_OR_DOUBLE_CLICK = "SINGLE_OR_DOUBLE_CLICK";
24 |
25 | /**
26 | * Indicates that the button was single- or double clicked or held.
27 | * See {@link FlicIntentValues#SINGLE_CLICK}, {@link FlicIntentValues#DOUBLE_CLICK} and {@link FlicIntentValues#HOLD}.
28 | */
29 | public static final String SINGLE_OR_DOUBLE_CLICK_OR_HOLD = "SINGLE_OR_DOUBLE_CLICK_OR_HOLD";
30 |
31 | /**
32 | * Indicates that this app for this button was released by the user in the Flic app.
33 | *
34 | * This broadcast receiver will no longer receive intents for this button, until {@link FlicButton#registerListenForBroadcast(int)} is called again.
35 | */
36 | public static final String REMOVED = "REMOVED";
37 | }
38 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicIntentValues.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * Represents possible values of {@link FlicIntentExtras#VALUE}.
5 | */
6 | class FlicIntentValues {
7 | /**
8 | * Indicates that the button was released.
9 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#UP_OR_DOWN}.
10 | */
11 | public static final String UP = "UP";
12 |
13 | /**
14 | * Indicates that the button was pressed.
15 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#UP_OR_DOWN}.
16 | */
17 | public static final String DOWN = "DOWN";
18 |
19 | /**
20 | * Indicates that the button was clicked.
21 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#CLICK_OR_HOLD}.
22 | */
23 | public static final String CLICK = "CLICK";
24 |
25 | /**
26 | * Indicates that the button was hold for half a second.
27 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#CLICK_OR_HOLD} or {@link FlicIntentTypes#SINGLE_OR_DOUBLE_CLICK_OR_HOLD}.
28 | */
29 | public static final String HOLD = "HOLD";
30 |
31 | /**
32 | * Indicates that the button was single clicked.
33 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#SINGLE_OR_DOUBLE_CLICK} or {@link FlicIntentTypes#SINGLE_OR_DOUBLE_CLICK_OR_HOLD}.
34 | */
35 | public static final String SINGLE_CLICK = "SINGLE_CLICK";
36 |
37 | /**
38 | * Indicates that the button was double clicked.
39 | * Possible value for {@link FlicIntentExtras#VALUE} when {@link FlicIntentExtras#TYPE} is {@link FlicIntentTypes#SINGLE_OR_DOUBLE_CLICK} or {@link FlicIntentTypes#SINGLE_OR_DOUBLE_CLICK_OR_HOLD}.
40 | */
41 | public static final String DOUBLE_CLICK = "DOUBLE_CLICK";
42 | }
43 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicManagerInitializedCallback.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * FlicManagerInitializedCallback.
7 | */
8 | public interface FlicManagerInitializedCallback {
9 | /**
10 | * Called once when the manager has been initialized.
11 | * This is called on the UI thread shortly after {@link FlicManager#getInstance(Context, FlicManagerInitializedCallback)}
12 | * or {@link FlicManager#getInstance(Context, FlicManagerInitializedCallback, FlicManagerUninitializedCallback)} was called.
13 | *
14 | * @param manager The manager
15 | */
16 | void onInitialized(FlicManager manager);
17 | }
18 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/FlicManagerUninitializedCallback.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | /**
4 | * FlicManagerUninitializedCallback
5 | */
6 | public class FlicManagerUninitializedCallback {
7 | /**
8 | * Called when the manager was uninitialized.
9 | *
10 | * @param manager The manager
11 | */
12 | public void onUninitialized(FlicManager manager) {
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/fliclib/src/main/java/io/flic/lib/Utils.java:
--------------------------------------------------------------------------------
1 | package io.flic.lib;
2 |
3 | import java.security.MessageDigest;
4 | import java.security.NoSuchAlgorithmException;
5 |
6 | /**
7 | * Created by Emil on 2015-09-06.
8 | */
9 | class Utils {
10 | public static byte[] hexToBytes(String s) {
11 | int len = s.length();
12 | byte[] data = new byte[len / 2];
13 | for (int i = 0; i < len; i += 2) {
14 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
15 | + Character.digit(s.charAt(i + 1), 16));
16 | }
17 | return data;
18 | }
19 |
20 | public static MessageDigest createSHA256() {
21 | MessageDigest md = null;
22 | try {
23 | md = MessageDigest.getInstance("SHA-256");
24 | } catch (NoSuchAlgorithmException e) {
25 | e.printStackTrace();
26 | }
27 | return md;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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/jjshay/fliclib-android/ddfbfebfd5090bb2cc80a7e66c613134ffc4071a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Sep 10 12:42:56 CEST 2015
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.4-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':fliclib'
2 |
--------------------------------------------------------------------------------