├── .github
└── FUNDING.yml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── app-kotlin
├── .gitignore
├── AndroidManifest.xml
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── kotlin
│ └── com
│ │ └── github
│ │ └── pwittchen
│ │ └── gesture
│ │ └── kotlinapp
│ │ ├── GestureActivity.kt
│ │ └── GestureRxActivity.kt
│ └── res
│ ├── layout
│ └── main.xml
│ ├── menu
│ └── main_menu.xml
│ ├── 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
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── app
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── pwittchen
│ │ └── gesture
│ │ └── app
│ │ ├── GestureActivity.java
│ │ └── GestureRxActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-ldpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── layout
│ └── main.xml
│ ├── menu
│ └── main_menu.xml
│ └── values
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── config
├── quality.gradle
└── quality
│ ├── checkstyle
│ ├── checkstyle.xml
│ └── suppressions.xml
│ ├── findbugs
│ └── findbugs-filter.xml
│ ├── lint
│ └── lint.xml
│ └── pmd
│ └── pmd-ruleset.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── github
│ │ └── pwittchen
│ │ └── gesture
│ │ └── library
│ │ ├── Gesture.java
│ │ ├── GestureEvent.java
│ │ └── GestureListener.java
│ └── test
│ └── java
│ └── com
│ └── github
│ └── pwittchen
│ └── gesture
│ └── library
│ └── GestureTest.java
├── maven_push.gradle
├── proguard.cfg
├── settings.gradle
└── update_javadocs.sh
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [pwittchen]
2 | custom: ['https://paypal.me/pwittchen']
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /local.properties
3 | /.idea
4 | /.DS_Store
5 | /build
6 | *.iml
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | android:
4 | components:
5 | - tools
6 | - platform-tools
7 | - build-tools-28
8 | - android-28
9 | - extra-android-support
10 | - extra-android-m2repository
11 | licenses:
12 | - android-sdk-license-5be876d5
13 | - android-sdk-license-c81a61d9
14 | - 'android-sdk-preview-license-.+'
15 | - 'android-sdk-license-.+'
16 | - 'google-gdk-license-.+'
17 |
18 | jdk: oraclejdk8
19 |
20 | before_install:
21 | - yes | sdkmanager "platforms;android-27"
22 |
23 | install:
24 | - true
25 |
26 | script:
27 | - ./gradlew clean build check test
28 |
29 | cache:
30 | directories:
31 | - $HOME/.m2
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | CHANGELOG
2 | =========
3 |
4 | v. 0.1.1
5 | --------
6 | *12 Mar 2020*
7 | - updated project dependencies
8 | - updated build configuration
9 |
10 |
11 | v. 0.1.0
12 | --------
13 | *07 Jan 2018*
14 |
15 | - migrated library to RxJava2.x as a separate artifact
16 | - bumped Gradle to v. 3.0
17 | - updated project dependencies
18 | - added Retrolambda to sample java app
19 |
20 | v. 0.0.1
21 | --------
22 | *15 Mar 2016*
23 |
24 | First release of the library.
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | gesture [](http://android-arsenal.com/details/1/3326)
2 | =======
3 |
4 | detects gestures on Android with listener and RxJava Observable.
5 |
6 | This project is a fork of [better-gesture-detector](https://github.com/Polidea/better-gesture-detector) by [Polidea](https://github.com/Polidea).
7 |
8 | JavaDoc: http://pwittchen.github.io/gesture/RxJava2.x
9 |
10 | | Current Branch | Branch | Artifact Id | Build Status | Maven Central |
11 | |:--------------:|:-------:|:-----------:|:-------------:|:-------------:|
12 | | | [`RxJava1.x`](https://github.com/pwittchen/gesture/tree/RxJava1.x) | `gesture` | [](https://travis-ci.org/pwittchen/gesture) |  |
13 | | :ballot_box_with_check: | [`RxJava2.x`](https://github.com/pwittchen/gesture/tree/RxJava2.x) | `gesture-rx2` | [](https://travis-ci.org/pwittchen/gesture) |  |
14 |
15 | Contents
16 | --------
17 | - [Usage](#usage)
18 | - [Imperative way - Listener](#imperative-way---listener)
19 | - [Reactive way - RxJava](#reactive-way---rxjava)
20 | - [Examples](#examples)
21 | - [Download](#download)
22 | - [Tests](#tests)
23 | - [Code style](#code-style)
24 | - [Static code analysis](#static-code-analysis)
25 | - [Credits](#credits)
26 | - [License](#license)
27 |
28 | Usage
29 | -----
30 |
31 | ### Imperative way - Listener
32 |
33 | **Step 1**: Create `Gesture` attribute in the `Activity`:
34 |
35 | ```java
36 | private Gesture gesture;
37 | ```
38 |
39 | **Step 2**: Initialize `Gesture` object and add `GestureListner`:
40 |
41 | ```java
42 | gesture = new Gesture();
43 |
44 | gesture.addListener(new GestureListener() {
45 | @Override public void onPress(MotionEvent motionEvent) {
46 | textView.setText("press");
47 | }
48 |
49 | @Override public void onTap(MotionEvent motionEvent) {
50 | textView.setText("tap");
51 | }
52 |
53 | @Override public void onDrag(MotionEvent motionEvent) {
54 | textView.setText("drag");
55 | }
56 |
57 | @Override public void onMove(MotionEvent motionEvent) {
58 | textView.setText("move");
59 | }
60 |
61 | @Override public void onRelease(MotionEvent motionEvent) {
62 | textView.setText("release");
63 | }
64 |
65 | @Override public void onLongPress(MotionEvent motionEvent) {
66 | textView.setText("longpress");
67 | }
68 |
69 | @Override public void onMultiTap(MotionEvent motionEvent, int clicks) {
70 | textView.setText("multitap [" + clicks + "]");
71 | }
72 | });
73 | ```
74 |
75 | **Step 3**: Override `dispatchTouchEvent(MotionEvent)` method:
76 |
77 | ```java
78 | @Override public boolean dispatchTouchEvent(MotionEvent event) {
79 | gesture.dispatchTouchEvent(event);
80 | return super.dispatchTouchEvent(event);
81 | }
82 | ```
83 |
84 | ### Reactive way - RxJava
85 |
86 | **Step 1**: Create `Gesture` attribute and `Subscription` in the `Activity`:
87 |
88 | ```java
89 | private Gesture gesture;
90 | private Disposable subscription;
91 | ```
92 |
93 | **Step 2**: Initialize `Gesture` object and subscribe RxJava `Observable`:
94 |
95 | ```java
96 | gesture = new Gesture();
97 |
98 | subscription = gesture.observe()
99 | .subscribeOn(Schedulers.computation())
100 | .observeOn(AndroidSchedulers.mainThread())
101 | .subscribe(event -> {
102 | textView.setText(event.toString());
103 | });
104 | ```
105 |
106 | `GestureEvent` is an enum with the following API:
107 |
108 | ```java
109 | public enum GestureEvent {
110 | ON_PRESS,
111 | ON_TAP,
112 | ON_DRAG,
113 | ON_MOVE,
114 | ON_RELEASE,
115 | ON_LONG_PRESS,
116 | ON_MULTI_TAP;
117 |
118 | int getClicks();
119 | GestureEvent withClicks(int clicks);
120 | }
121 | ```
122 |
123 | **Step 3**: Override `dispatchTouchEvent(MotionEvent)` method:
124 |
125 | ```java
126 | @Override public boolean dispatchTouchEvent(MotionEvent event) {
127 | gesture.dispatchTouchEvent(event);
128 | return super.dispatchTouchEvent(event);
129 | }
130 | ```
131 |
132 | **Step 4**: Don't forget to dispose subscription when it's no longer needed:
133 |
134 | ```java
135 | @Override protected void onPause() {
136 | super.onPause();
137 | if (subscription != null && !subscription.isDisposed()) {
138 | subscription.dispose();
139 | }
140 | }
141 | ```
142 |
143 | Examples
144 | --------
145 |
146 | Exemplary application is located in `app` directory of this repository.
147 |
148 | If you would like to see sample app in Kotlin, check `app-kotlin` directory.
149 |
150 | Download
151 | --------
152 |
153 | latest version: 
154 |
155 | replace `x.y.z` with the latest version
156 |
157 | You can depend on library through Maven:
158 |
159 | ```xml
160 |
161 | com.github.pwittchen
162 | gesture-rx2
163 | x.y.z
164 |
165 | ```
166 |
167 | or through Gradle:
168 |
169 | ```groovy
170 | dependencies {
171 | compile 'com.github.pwittchen:gesture-rx2:x.y.z'
172 | }
173 | ```
174 |
175 | Tests
176 | -----
177 |
178 | To execute unit tests run:
179 |
180 | ```
181 | ./gradlew test
182 | ```
183 |
184 | Code style
185 | ----------
186 |
187 | Code style used in the project is called `SquareAndroid` from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles.
188 |
189 | Static code analysis
190 | --------------------
191 |
192 | Static code analysis runs Checkstyle, FindBugs, PMD and Lint. It can be executed with command:
193 |
194 | ```
195 | ./gradlew check
196 | ```
197 |
198 | Reports from analysis are generated in `library/build/reports/` directory.
199 |
200 | Credits
201 | -------
202 |
203 | Initial code base for this project is provided by [Polidea](https://github.com/Polidea).
204 |
205 | License
206 | -------
207 |
208 | Copyright 2012 Polidea
209 | Copyright 2016 Piotr Wittchen
210 |
211 | Licensed under the Apache License, Version 2.0 (the "License");
212 | you may not use this file except in compliance with the License.
213 | You may obtain a copy of the License at
214 |
215 | http://www.apache.org/licenses/LICENSE-2.0
216 |
217 | Unless required by applicable law or agreed to in writing, software
218 | distributed under the License is distributed on an "AS IS" BASIS,
219 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
220 | See the License for the specific language governing permissions and
221 |
--------------------------------------------------------------------------------
/app-kotlin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app-kotlin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app-kotlin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | buildToolsVersion rootProject.ext.buildToolsVersion
8 |
9 | defaultConfig {
10 | multiDexEnabled true
11 | applicationId "com.github.pwittchen.gesture.kotlinapp"
12 | minSdkVersion rootProject.ext.minSdkVersionApps
13 | targetSdkVersion rootProject.ext.compileSdkVersion
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | sourceSets {
26 | main.java.srcDirs += 'src/main/kotlin'
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation project(':library')
32 | implementation deps.rxandroid2
33 | implementation deps.appcompatv7
34 | implementation deps.kotlinstdlib
35 | }
36 |
37 | buildscript {
38 | repositories {
39 | mavenCentral()
40 | jcenter()
41 | google()
42 | }
43 | dependencies {
44 | classpath deps.kotlingradleplugin
45 | }
46 | }
47 | repositories {
48 | mavenCentral()
49 | jcenter()
50 | google()
51 | }
52 |
--------------------------------------------------------------------------------
/app-kotlin/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 /home/piotr/Development/android/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 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/kotlin/com/github/pwittchen/gesture/kotlinapp/GestureActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.pwittchen.gesture.kotlinapp
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import android.view.Menu
7 | import android.view.MenuItem
8 | import android.view.MotionEvent
9 | import com.github.pwittchen.gesture.library.Gesture
10 | import com.github.pwittchen.gesture.library.GestureListener
11 | import kotlinx.android.synthetic.main.main.textView
12 |
13 | class GestureActivity : AppCompatActivity() {
14 | private var gesture: Gesture? = null
15 | public override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | setContentView(R.layout.main)
18 |
19 | gesture = Gesture()
20 |
21 | (gesture as Gesture).addListener(object : GestureListener {
22 | override fun onPress(motionEvent: MotionEvent) {
23 | textView.text = "press"
24 | }
25 |
26 | override fun onTap(motionEvent: MotionEvent) {
27 | textView.text = "tap"
28 | }
29 |
30 | override fun onDrag(motionEvent: MotionEvent) {
31 | textView.text = "drag"
32 | }
33 |
34 | override fun onMove(motionEvent: MotionEvent) {
35 | textView.text = "move"
36 | }
37 |
38 | override fun onRelease(motionEvent: MotionEvent) {
39 | textView.text = "release"
40 | }
41 |
42 | override fun onLongPress(motionEvent: MotionEvent) {
43 | textView.text = "longpress"
44 | }
45 |
46 | override fun onMultiTap(motionEvent: MotionEvent, clicks: Int) {
47 | textView.text = "multitap [$clicks]"
48 | }
49 | })
50 | }
51 |
52 | override fun dispatchTouchEvent(event: MotionEvent): Boolean {
53 | gesture!!.dispatchTouchEvent(event)
54 | return super.dispatchTouchEvent(event)
55 | }
56 |
57 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
58 | menuInflater.inflate(R.menu.main_menu, menu)
59 | return true
60 | }
61 |
62 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
63 | when (item.itemId) {
64 | R.id.listener -> {
65 | }
66 | R.id.rx -> {
67 | val intent = Intent(this, GestureRxActivity::class.java)
68 | startActivity(intent)
69 | }
70 | }
71 | return true
72 | }
73 | }
--------------------------------------------------------------------------------
/app-kotlin/src/main/kotlin/com/github/pwittchen/gesture/kotlinapp/GestureRxActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.pwittchen.gesture.kotlinapp
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.view.Menu
6 | import android.view.MenuItem
7 | import android.view.MotionEvent
8 | import com.github.pwittchen.gesture.library.Gesture
9 | import com.github.pwittchen.gesture.library.GestureEvent
10 | import io.reactivex.android.schedulers.AndroidSchedulers
11 | import io.reactivex.disposables.Disposable
12 | import io.reactivex.schedulers.Schedulers
13 | import kotlinx.android.synthetic.main.main.*
14 |
15 | class GestureRxActivity : AppCompatActivity() {
16 | private var gesture: Gesture? = null
17 | private var subscription: Disposable? = null
18 |
19 | public override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContentView(R.layout.main)
22 | gesture = Gesture()
23 |
24 | subscription = (gesture as Gesture).observe()
25 | .subscribeOn(Schedulers.computation())
26 | .observeOn(AndroidSchedulers.mainThread())
27 | .subscribe { event ->
28 | val msg = event.toString()
29 | if (event == GestureEvent.ON_MULTI_TAP) {
30 | textView.text = msg + String.format(" [%d]", event.clicks)
31 | } else {
32 | textView.text = msg
33 | }
34 | }
35 | }
36 |
37 | override fun dispatchTouchEvent(event: MotionEvent): Boolean {
38 | (gesture as Gesture).dispatchTouchEvent(event)
39 | return super.dispatchTouchEvent(event)
40 | }
41 |
42 | override fun onPause() {
43 | super.onPause()
44 | safelyDispose(subscription)
45 | }
46 |
47 | private fun safelyDispose(disposable: Disposable?) {
48 | if (disposable != null && !disposable.isDisposed) {
49 | disposable.dispose()
50 | }
51 | }
52 |
53 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
54 | menuInflater.inflate(R.menu.main_menu, menu)
55 | return true
56 | }
57 |
58 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
59 | when (item.itemId) {
60 | R.id.listener -> onBackPressed()
61 | R.id.rx -> {
62 | }
63 | }
64 | return true
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app-kotlin/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app-kotlin/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app-kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app-kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app-kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Gesture kotlin
3 | Listener
4 | Rx
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app-kotlin/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.compileSdkVersion
5 | buildToolsVersion rootProject.ext.buildToolsVersion
6 |
7 | defaultConfig {
8 | multiDexEnabled true
9 | applicationId "com.github.pwittchen.gesture.app"
10 | minSdkVersion rootProject.ext.minSdkVersionApps
11 | targetSdkVersion rootProject.ext.compileSdkVersion
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
18 | }
19 | }
20 |
21 | compileOptions {
22 | sourceCompatibility JavaVersion.VERSION_1_8
23 | targetCompatibility JavaVersion.VERSION_1_8
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation project(':library')
29 | implementation deps.rxandroid2
30 | implementation deps.appcompatv7
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/pwittchen/gesture/app/GestureActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.pwittchen.gesture.app;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.MotionEvent;
9 | import android.widget.TextView;
10 | import com.github.pwittchen.gesture.library.Gesture;
11 | import com.github.pwittchen.gesture.library.GestureListener;
12 |
13 | public class GestureActivity extends AppCompatActivity {
14 | private Gesture gesture;
15 | private TextView textView;
16 |
17 | @Override public void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.main);
20 | textView = (TextView) findViewById(R.id.textView);
21 | gesture = new Gesture();
22 | gesture.addListener(new GestureListener() {
23 | @Override public void onPress(MotionEvent motionEvent) {
24 | textView.setText("press");
25 | }
26 |
27 | @Override public void onTap(MotionEvent motionEvent) {
28 | textView.setText("tap");
29 | }
30 |
31 | @Override public void onDrag(MotionEvent motionEvent) {
32 | textView.setText("drag");
33 | }
34 |
35 | @Override public void onMove(MotionEvent motionEvent) {
36 | textView.setText("move");
37 | }
38 |
39 | @Override public void onRelease(MotionEvent motionEvent) {
40 | textView.setText("release");
41 | }
42 |
43 | @Override public void onLongPress(MotionEvent motionEvent) {
44 | textView.setText("longpress");
45 | }
46 |
47 | @Override public void onMultiTap(MotionEvent motionEvent, int clicks) {
48 | textView.setText("multitap [" + clicks + "]");
49 | }
50 | });
51 | }
52 |
53 | @Override public boolean dispatchTouchEvent(MotionEvent event) {
54 | gesture.dispatchTouchEvent(event);
55 | return super.dispatchTouchEvent(event);
56 | }
57 |
58 | @Override public boolean onCreateOptionsMenu(Menu menu) {
59 | getMenuInflater().inflate(R.menu.main_menu, menu);
60 | return true;
61 | }
62 |
63 | @Override public boolean onOptionsItemSelected(MenuItem item) {
64 | switch (item.getItemId()) {
65 | case R.id.listener:
66 | break;
67 | case R.id.rx:
68 | final Intent intent = new Intent(this, GestureRxActivity.class);
69 | startActivity(intent);
70 | break;
71 | }
72 | return true;
73 | }
74 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/pwittchen/gesture/app/GestureRxActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.pwittchen.gesture.app;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 | import android.view.MotionEvent;
8 | import android.widget.TextView;
9 | import com.github.pwittchen.gesture.library.Gesture;
10 | import com.github.pwittchen.gesture.library.GestureEvent;
11 | import io.reactivex.android.schedulers.AndroidSchedulers;
12 | import io.reactivex.disposables.Disposable;
13 | import io.reactivex.schedulers.Schedulers;
14 | import java.util.Locale;
15 |
16 | public class GestureRxActivity extends AppCompatActivity {
17 | private Gesture gesture;
18 | private TextView textView;
19 | private Disposable subscription;
20 |
21 | @Override public void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.main);
24 | textView = (TextView) findViewById(R.id.textView);
25 | gesture = new Gesture();
26 | subscription = gesture.observe()
27 | .subscribeOn(Schedulers.computation())
28 | .observeOn(AndroidSchedulers.mainThread())
29 | .subscribe(event -> {
30 | final String msg = event.toString();
31 | if (event.equals(GestureEvent.ON_MULTI_TAP)) {
32 | textView.setText(
33 | msg.concat(String.format(Locale.getDefault(), " [%d]", event.getClicks())));
34 | } else {
35 | textView.setText(msg);
36 | }
37 | });
38 | }
39 |
40 | @Override public boolean dispatchTouchEvent(MotionEvent event) {
41 | gesture.dispatchTouchEvent(event);
42 | return super.dispatchTouchEvent(event);
43 | }
44 |
45 | @Override protected void onPause() {
46 | super.onPause();
47 | safelyDispose(subscription);
48 | }
49 |
50 | private void safelyDispose(Disposable disposable) {
51 | if (disposable != null && !disposable.isDisposed()) {
52 | disposable.dispose();
53 | }
54 | }
55 |
56 | @Override public boolean onCreateOptionsMenu(Menu menu) {
57 | getMenuInflater().inflate(R.menu.main_menu, menu);
58 | return true;
59 | }
60 |
61 | @Override public boolean onOptionsItemSelected(MenuItem item) {
62 | switch (item.getItemId()) {
63 | case R.id.listener:
64 | onBackPressed();
65 | break;
66 | case R.id.rx:
67 | break;
68 | }
69 | return true;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app/src/main/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Gesture
5 | Listener
6 | Rx
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'io.codearte.nexus-staging'
2 |
3 | ext {
4 | minSdkVersion = 9
5 | minSdkVersionApps = 14
6 | compileSdkVersion = 28
7 | buildToolsVersion = '28.0.3'
8 | gradleVersion = '3.0.1'
9 | kotlinVersion = '1.4.0'
10 | }
11 |
12 | ext.deps = [rxjava2 : 'io.reactivex.rxjava2:rxjava:2.2.19',
13 | rxandroid2 : 'io.reactivex.rxjava2:rxandroid:2.1.1',
14 | appcompatv7 : 'com.android.support:appcompat-v7:28.0.0',
15 | junit : 'junit:junit:4.13',
16 | mockitocore : 'org.mockito:mockito-core:3.5.2',
17 | truth : 'com.google.truth:truth:1.0.1',
18 | kotlinstdlib : "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
19 | kotlingradleplugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"]
20 |
21 | buildscript {
22 | repositories {
23 | mavenCentral()
24 | jcenter()
25 | google()
26 | maven {
27 | url 'https://plugins.gradle.org/m2/'
28 | }
29 | }
30 |
31 | dependencies {
32 | classpath 'com.android.tools.build:gradle:3.6.3'
33 | classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0"
34 | // NOTE: Do not place your application dependencies here; they belong
35 | // in the individual module build.gradle files
36 | }
37 | }
38 |
39 | allprojects {
40 | repositories {
41 | mavenCentral()
42 | jcenter()
43 | google()
44 | }
45 | }
46 |
47 | def getRepositoryUsername() {
48 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
49 | }
50 |
51 | def getRepositoryPassword() {
52 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
53 | }
54 |
55 | nexusStaging {
56 | packageGroup = GROUP //optional if packageGroup == project.getGroup()
57 | stagingProfileId = "9add401d06ecc9" //when not defined will be got from server using "packageGroup"
58 | username = getRepositoryUsername()
59 | password = getRepositoryPassword()
60 | }
--------------------------------------------------------------------------------
/config/quality.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'checkstyle'
2 | apply plugin: 'pmd'
3 |
4 | // Add checkstyle, findbugs, pmd and lint to the check task.
5 | check.dependsOn 'checkstyle', 'pmd', 'lint'
6 |
7 | checkstyle {
8 | toolVersion = "6.0"
9 | }
10 |
11 | task checkstyle(type: Checkstyle) {
12 | configFile file("${project.rootDir}/config/quality/checkstyle/checkstyle.xml")
13 | configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
14 | source 'src'
15 | include '**/*.java'
16 | exclude '**/gen/**'
17 | classpath = files()
18 | }
19 |
20 | task pmd(type: Pmd) {
21 | ignoreFailures = false
22 | ruleSetFiles = files("${project.rootDir}/config/quality/pmd/pmd-ruleset.xml")
23 | ruleSets = []
24 |
25 | source 'src'
26 | include '**/*.java'
27 | exclude '**/gen/**'
28 |
29 | reports {
30 | xml.enabled = false
31 | html.enabled = true
32 | xml {
33 | destination file("$project.buildDir/reports/pmd/pmd.xml")
34 | }
35 | html {
36 | destination file("$project.buildDir/reports/pmd/pmd.html")
37 | }
38 | }
39 | }
40 |
41 | android {
42 | lintOptions {
43 | abortOnError false
44 | xmlReport false
45 | htmlReport true
46 | lintConfig file("${project.rootDir}/config/quality/lint/lint.xml")
47 | htmlOutput file("$project.buildDir/reports/lint/lint-result.html")
48 | xmlOutput file("$project.buildDir/reports/lint/lint-result.xml")
49 | }
50 | }
--------------------------------------------------------------------------------
/config/quality/checkstyle/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
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 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/config/quality/checkstyle/suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/config/quality/findbugs/findbugs-filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/config/quality/lint/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/config/quality/pmd/pmd-ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | Custom ruleset for Android application
8 |
9 | .*/R.java
10 | .*/gen/.*
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=0.1.1
2 | VERSION_CODE=3
3 | GROUP=com.github.pwittchen
4 |
5 | POM_DESCRIPTION=detects gestures on Android with listener and RxJava Observable.
6 | POM_URL=https://github.com/pwittchen/gesture
7 | POM_SCM_URL=https://github.com/pwittchen/gesture
8 | POM_SCM_CONNECTION=scm:git@github.com:pwittchen/gesture.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:pwittchen/gesture.git
10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=pwittchen
14 | POM_DEVELOPER_NAME=Piotr Wittchen
15 |
16 | org.gradle.daemon=true
17 | org.gradle.jvmargs=-XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m -XX:MaxHeapSize=2048
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pwittchen/gesture/68f419dd1f5e5fadcc1e58e7c719d5691db4b1ed/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Feb 25 06:54:53 CET 2020
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-6.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin, switch paths to Windows format before running java
129 | if $cygwin ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply from: '../config/quality.gradle'
3 | apply from: '../maven_push.gradle'
4 |
5 | android {
6 | compileSdkVersion rootProject.ext.compileSdkVersion
7 | buildToolsVersion rootProject.ext.buildToolsVersion
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.ext.minSdkVersion
11 | targetSdkVersion rootProject.ext.compileSdkVersion
12 | multiDexEnabled true
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | api deps.rxjava2
27 | testImplementation deps.junit
28 | testImplementation deps.truth
29 | testImplementation deps.mockitocore
30 | }
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=gesture
2 | POM_ARTIFACT_ID=gesture-rx2
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/library/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 /home/piotr/Development/android/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 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library/src/main/java/com/github/pwittchen/gesture/library/Gesture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Polidea
3 | * Copyright 2016 Piotr Wittchen
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.github.pwittchen.gesture.library;
18 |
19 | import android.os.Handler;
20 | import android.view.MotionEvent;
21 | import io.reactivex.Emitter;
22 | import io.reactivex.Observable;
23 | import io.reactivex.ObservableEmitter;
24 | import io.reactivex.ObservableOnSubscribe;
25 |
26 | public class Gesture {
27 | private static final int DEFAULT_PRESS_TIMEOUT = 100;
28 | private static final int DEFAULT_TAP_TIMEOUT = 300;
29 | private static final int DEFAULT_MOVE_EPSILON = 4;
30 | private static final long DEFAULT_LONG_PRESS_TIMEOUT = 500;
31 |
32 | private int pressTimeout = DEFAULT_PRESS_TIMEOUT;
33 | private int tapTimeout = DEFAULT_TAP_TIMEOUT;
34 | private int moveEpsilon = DEFAULT_MOVE_EPSILON;
35 | private long longPressTimeout = DEFAULT_LONG_PRESS_TIMEOUT;
36 |
37 | private Runnable tapHandler;
38 | private Runnable pressHandler;
39 | private Runnable longPressHandler;
40 |
41 | private long prevTouchTime;
42 | private float prevTouchY;
43 | private float prevTouchX;
44 |
45 | private boolean dragging;
46 | private boolean moving;
47 | private int clicks = 0;
48 |
49 | private Handler handler;
50 | private GestureListener listener;
51 | private Emitter emitter;
52 |
53 | public Gesture() {
54 | this.handler = new Handler();
55 | }
56 |
57 | public void addListener(GestureListener listener) {
58 | checkNotNull(listener, "listener == null");
59 | this.listener = listener;
60 | }
61 |
62 | public Observable observe() {
63 | this.listener = createReactiveListener();
64 | return Observable.create(new ObservableOnSubscribe() {
65 | @Override public void subscribe(ObservableEmitter emitter) throws Exception {
66 | Gesture.this.emitter = emitter;
67 | }
68 | });
69 | }
70 |
71 | public void dispatchTouchEvent(final MotionEvent motionEvent) {
72 | checkNotNull(motionEvent, "motionEvent == null");
73 |
74 | float dx = motionEvent.getX() - prevTouchX;
75 | float dy = motionEvent.getY() - prevTouchY;
76 | long dt = System.currentTimeMillis() - prevTouchTime;
77 | handler.removeCallbacks(longPressHandler);
78 | longPressHandler = null;
79 |
80 | switch (motionEvent.getAction()) {
81 | case MotionEvent.ACTION_DOWN:
82 | onActionDown(motionEvent, dt);
83 | break;
84 | case MotionEvent.ACTION_UP:
85 | onActionUp(motionEvent, dt);
86 | break;
87 | case MotionEvent.ACTION_MOVE:
88 | onActionMove(motionEvent, dx, dy);
89 | break;
90 | case MotionEvent.ACTION_CANCEL:
91 | onActionCancel(motionEvent);
92 | break;
93 | default:
94 | break;
95 | }
96 |
97 | prevTouchX = motionEvent.getX();
98 | prevTouchY = motionEvent.getY();
99 | }
100 |
101 | private void onActionDown(final MotionEvent motionEvent, long dt) {
102 | dragging = false;
103 | moving = false;
104 |
105 | if (tapHandler != null) {
106 | clicks++;
107 | handler.removeCallbacks(tapHandler);
108 | tapHandler = null;
109 | }
110 |
111 | handler.removeCallbacks(pressHandler);
112 |
113 | pressHandler = new Runnable() {
114 | @Override public void run() {
115 | onPress(motionEvent);
116 | }
117 | };
118 |
119 | handler.postDelayed(pressHandler, pressTimeout);
120 |
121 | longPressHandler = new Runnable() {
122 | @Override public void run() {
123 | onLongPress(motionEvent);
124 | }
125 | };
126 |
127 | handler.postDelayed(longPressHandler, longPressTimeout);
128 | prevTouchTime += dt;
129 | }
130 |
131 | private void onActionUp(final MotionEvent motionEvent, long dt) {
132 | if (dt > tapTimeout || moving || dragging) {
133 | onRelease(motionEvent);
134 | return;
135 | }
136 |
137 | tapHandler = new Runnable() {
138 | @Override public void run() {
139 | handler.removeCallbacks(longPressHandler);
140 | longPressHandler = null;
141 | onTap(motionEvent, clicks);
142 | }
143 | };
144 |
145 | handler.postDelayed(tapHandler, tapTimeout - dt);
146 | prevTouchTime += dt;
147 | }
148 |
149 | private void onActionMove(MotionEvent motionEvent, float dx, float dy) {
150 | if (Math.abs(dx) > moveEpsilon || Math.abs(dy) > moveEpsilon || dragging || moving) {
151 | if (pressHandler == null && !moving) {
152 | dragging = true;
153 | }
154 |
155 | handler.removeCallbacks(tapHandler);
156 | tapHandler = null;
157 | handler.removeCallbacks(pressHandler);
158 | pressHandler = null;
159 | handler.removeCallbacks(longPressHandler);
160 | longPressHandler = null;
161 | moving = true;
162 |
163 | if (dragging) {
164 | onDrag(motionEvent);
165 | } else {
166 | onMove(motionEvent);
167 | }
168 | }
169 | }
170 |
171 | private void onActionCancel(MotionEvent motionEvent) {
172 | handler.removeCallbacks(pressHandler);
173 | pressHandler = null;
174 | handler.removeCallbacks(tapHandler);
175 | tapHandler = null;
176 | handler.removeCallbacks(longPressHandler);
177 | longPressHandler = null;
178 | onRelease(motionEvent);
179 | }
180 |
181 | private void onRelease(MotionEvent motionEvent) {
182 | clicks = 0;
183 | listener.onRelease(motionEvent);
184 | }
185 |
186 | private void onDrag(MotionEvent motionEvent) {
187 | clicks = 0;
188 | listener.onDrag(motionEvent);
189 | }
190 |
191 | private void onMove(MotionEvent motionEvent) {
192 | clicks = 0;
193 | listener.onMove(motionEvent);
194 | }
195 |
196 | private void onTap(MotionEvent motionEvent, int clicks) {
197 | tapHandler = null;
198 | if (clicks == 0) {
199 | listener.onTap(motionEvent);
200 | } else {
201 | listener.onMultiTap(motionEvent, clicks + 1);
202 | }
203 | this.clicks = 0;
204 | }
205 |
206 | private void onLongPress(MotionEvent motionEvent) {
207 | clicks = 0;
208 | longPressHandler = null;
209 | listener.onLongPress(motionEvent);
210 | }
211 |
212 | private void onPress(MotionEvent motionEvent) {
213 | pressHandler = null;
214 | listener.onPress(motionEvent);
215 | }
216 |
217 | private GestureListener createReactiveListener() {
218 | return new GestureListener() {
219 | @Override public void onPress(MotionEvent motionEvent) {
220 | onNextSafely(GestureEvent.ON_PRESS);
221 | }
222 |
223 | @Override public void onTap(MotionEvent motionEvent) {
224 | onNextSafely(GestureEvent.ON_TAP);
225 | }
226 |
227 | @Override public void onDrag(MotionEvent motionEvent) {
228 | onNextSafely(GestureEvent.ON_DRAG);
229 | }
230 |
231 | @Override public void onMove(MotionEvent motionEvent) {
232 | onNextSafely(GestureEvent.ON_MOVE);
233 | }
234 |
235 | @Override public void onRelease(MotionEvent motionEvent) {
236 | onNextSafely(GestureEvent.ON_RELEASE);
237 | }
238 |
239 | @Override public void onLongPress(MotionEvent motionEvent) {
240 | onNextSafely(GestureEvent.ON_LONG_PRESS);
241 | }
242 |
243 | @Override public void onMultiTap(MotionEvent motionEvent, int clicks) {
244 | onNextSafely(GestureEvent.ON_MULTI_TAP.withClicks(clicks));
245 | }
246 | };
247 | }
248 |
249 | private void onNextSafely(final GestureEvent gestureEvent) {
250 | if (emitter != null) {
251 | emitter.onNext(gestureEvent);
252 | }
253 | }
254 |
255 | public int getPressTimeout() {
256 | return pressTimeout;
257 | }
258 |
259 | public void setPressTimeout(int pressTimeout) {
260 | this.pressTimeout = pressTimeout;
261 | }
262 |
263 | public int getTapTimeout() {
264 | return tapTimeout;
265 | }
266 |
267 | public void setTapTimeout(int tapTimeout) {
268 | this.tapTimeout = tapTimeout;
269 | }
270 |
271 | public int getMoveEpsilon() {
272 | return moveEpsilon;
273 | }
274 |
275 | public void setMoveEpsilon(int moveEpsilon) {
276 | this.moveEpsilon = moveEpsilon;
277 | }
278 |
279 | public long getLongPressTimeout() {
280 | return longPressTimeout;
281 | }
282 |
283 | public void setLongPressTimeout(long longPressTimeout) {
284 | this.longPressTimeout = longPressTimeout;
285 | }
286 |
287 | private void checkNotNull(Object object, String message) {
288 | if (object == null) {
289 | throw new IllegalArgumentException(message);
290 | }
291 | }
292 | }
293 |
--------------------------------------------------------------------------------
/library/src/main/java/com/github/pwittchen/gesture/library/GestureEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Polidea
3 | * Copyright 2016 Piotr Wittchen
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.github.pwittchen.gesture.library;
18 |
19 | public enum GestureEvent {
20 | ON_PRESS,
21 | ON_TAP,
22 | ON_DRAG,
23 | ON_MOVE,
24 | ON_RELEASE,
25 | ON_LONG_PRESS,
26 | ON_MULTI_TAP;
27 |
28 | private int clicks = 1;
29 |
30 | public int getClicks() {
31 | return clicks;
32 | }
33 |
34 | public GestureEvent withClicks(int clicks) {
35 | this.clicks = clicks;
36 | return this;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/github/pwittchen/gesture/library/GestureListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Polidea
3 | * Copyright 2016 Piotr Wittchen
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.github.pwittchen.gesture.library;
18 |
19 | import android.view.MotionEvent;
20 |
21 | public interface GestureListener {
22 |
23 | void onPress(MotionEvent motionEvent);
24 |
25 | void onTap(MotionEvent motionEvent);
26 |
27 | void onDrag(MotionEvent motionEvent);
28 |
29 | void onMove(MotionEvent motionEvent);
30 |
31 | void onRelease(MotionEvent motionEvent);
32 |
33 | void onLongPress(MotionEvent motionEvent);
34 |
35 | void onMultiTap(MotionEvent motionEvent, int clicks);
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/test/java/com/github/pwittchen/gesture/library/GestureTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 Polidea
3 | * Copyright 2016 Piotr Wittchen
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.github.pwittchen.gesture.library;
18 |
19 | import android.view.MotionEvent;
20 | import org.junit.Before;
21 | import org.junit.Test;
22 | import org.junit.runner.RunWith;
23 | import org.mockito.Mock;
24 | import org.mockito.junit.MockitoJUnitRunner;
25 |
26 | @RunWith(MockitoJUnitRunner.class) public class GestureTest {
27 |
28 | private Gesture gesture;
29 | private GestureEvent gestureEvent;
30 | @Mock private MotionEvent motionEventDown;
31 | @Mock private MotionEvent motionEventMove;
32 | @Mock private MotionEvent motionEventUp;
33 |
34 | @Before public void setUp() {
35 | gesture = new Gesture();
36 | }
37 |
38 | @Test(expected = IllegalArgumentException.class)
39 | public void shouldThrowAnExceptionWhenListenerIsNull() {
40 | gesture.addListener(null);
41 | }
42 |
43 | @Test(expected = IllegalArgumentException.class)
44 | public void shouldThrowAnExceptionWhenMotionEventIsNull() {
45 | gesture.dispatchTouchEvent(null);
46 | }
47 |
48 | @Test public void shouldAddLListener() {
49 | gesture.addListener(new GestureListener() {
50 | @Override public void onPress(MotionEvent motionEvent) {
51 | gestureEvent = GestureEvent.ON_PRESS;
52 | }
53 |
54 | @Override public void onTap(MotionEvent motionEvent) {
55 | gestureEvent = GestureEvent.ON_TAP;
56 | }
57 |
58 | @Override public void onDrag(MotionEvent motionEvent) {
59 | gestureEvent = GestureEvent.ON_DRAG;
60 | }
61 |
62 | @Override public void onMove(MotionEvent motionEvent) {
63 | gestureEvent = GestureEvent.ON_MOVE;
64 | }
65 |
66 | @Override public void onRelease(MotionEvent motionEvent) {
67 | gestureEvent = GestureEvent.ON_RELEASE;
68 | }
69 |
70 | @Override public void onLongPress(MotionEvent motionEvent) {
71 | gestureEvent = GestureEvent.ON_LONG_PRESS;
72 | }
73 |
74 | @Override public void onMultiTap(MotionEvent motionEvent, int clicks) {
75 | gestureEvent = GestureEvent.ON_MULTI_TAP.withClicks(clicks);
76 | }
77 | });
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/maven_push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | scm {
66 | url POM_SCM_URL
67 | connection POM_SCM_CONNECTION
68 | developerConnection POM_SCM_DEV_CONNECTION
69 | }
70 |
71 | licenses {
72 | license {
73 | name POM_LICENCE_NAME
74 | url POM_LICENCE_URL
75 | distribution POM_LICENCE_DIST
76 | }
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | signing {
91 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92 | sign configurations.archives
93 | }
94 |
95 | task androidJavadocs(type: Javadoc) {
96 | source = android.sourceSets.main.java.srcDirs
97 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
98 | failOnError = false
99 | }
100 |
101 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
102 | classifier = 'javadoc'
103 | from androidJavadocs.destinationDir
104 | }
105 |
106 | task androidSourcesJar(type: Jar) {
107 | classifier = 'sources'
108 | from android.sourceSets.main.java.sourceFiles
109 | }
110 |
111 | artifacts {
112 | archives androidSourcesJar
113 | archives androidJavadocsJar
114 | }
115 | }
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library', ':app-kotlin'
2 |
--------------------------------------------------------------------------------
/update_javadocs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # update javadocs for RxJava2.x
4 | git checkout RxJava2.x
5 | ./gradlew clean androidJavadocs
6 | git checkout gh-pages
7 | rm -rf javadoc/RxJava2.x/*
8 | cp -avr library/build/docs/javadoc/* ./javadoc/RxJava2.x
9 | git add -A
10 | git commit -m "updating JavaDoc for RxJava2.x"
11 | rm -rf library/build/docs
12 | echo "javadocs for RxJava2.x updated"
13 |
14 | echo "javadocs for nd RxJava2.x updated - now you can push your changes"
--------------------------------------------------------------------------------