├── .gitignore
├── .idea
├── checkstyle-idea.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── kotlinc.xml
├── misc.xml
├── modules.xml
├── qaplug_profiles.xml
├── runConfigurations.xml
└── vcs.xml
├── .travis.yml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ebanx
│ │ └── swipebutton
│ │ ├── SwipeButtonInstrumentedTest.kt
│ │ ├── SwipeButtonResultRobot.kt
│ │ ├── SwipeButtonTestRobot.kt
│ │ └── utils
│ │ └── CenterSwipeAction.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ebanx
│ │ │ └── swipebutton
│ │ │ ├── EbanxToggleButton.java
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── ic_lock_open_black_24dp.png
│ │ └── ic_lock_outline_black_24dp.png
│ │ ├── drawable-xhdpi
│ │ ├── ic_lock_open_black_24dp.png
│ │ └── ic_lock_outline_black_24dp.png
│ │ ├── drawable-xxhdpi
│ │ ├── ic_lock_open_black_24dp.png
│ │ └── ic_lock_outline_black_24dp.png
│ │ ├── drawable
│ │ ├── shape_button.xml
│ │ ├── shape_button2.xml
│ │ ├── shape_button3.xml
│ │ ├── shape_button_squared.xml
│ │ ├── shape_rounded.xml
│ │ ├── shape_rounded2.xml
│ │ └── shape_squared.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── content_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── ebanx
│ └── swipebutton
│ └── ExampleUnitTest.java
├── build.gradle
├── gnag-build.sh
├── gradle.properties
├── gradle
├── buildWithTravis.sh
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── swipe-button
├── .gitignore
├── build.gradle
├── checkstyle.xml
├── pmd.xml
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── ebanx
│ └── swipebtn
│ ├── DimentionUtils.java
│ ├── OnActiveListener.java
│ ├── OnStateChangeListener.java
│ ├── SwipeButton.java
│ └── TouchUtils.java
└── res
├── drawable
├── shape_button.xml
└── shape_rounded.xml
└── values
├── attrs.xml
└── strings.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/qaplug_profiles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
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 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | jdk: oraclejdk8
3 | sudo: false
4 | addons:
5 | apt:
6 | packages:
7 | - lynx
8 | android:
9 | components:
10 | - platform-tools
11 | - tools
12 | - build-tools-26.0.2
13 | - android-26
14 | - android-22
15 | - extra-android-m2repository
16 | - sys-img-armeabi-v7a-android-22
17 | before_install: chmod +x gradle/buildWithTravis.sh
18 | before_script:
19 | - android list targets
20 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
21 | - emulator -avd test -no-audio -no-window &
22 | - android-wait-for-emulator
23 | - adb shell input keyevent 82 &
24 |
25 | script:
26 | - ./gradlew clean build connectedCheck
27 | after_failure: lynx -dump app/build/outputs/gnag/gnag.html
28 | after_success:
29 | - ./gradle/buildWithTravis.sh
30 | env:
31 | global:
32 | - secure: TZ11ozcJozynKr37pRPY2METtIEsDav//mE7wiCEumM4W59QMMnVqjJGTxBipbAuAX36PnEg0/jZbHfXjVJ4py9tGIDB3nlDULqRN/0Ddko/y4gzPQLVpvD22UU0N6g/r0tTJ4H775nxWF07Jw4nohtit7GVZS9Z/dgYvSFE7r2blnflzBBqqRZ2godE0r+8oZV6bRqpo/XxLEqiaBJS7cNbfZIKb+EnwPPuslA4ZdqPAM6U8rV43rzP4oi0M0Z+33s8D/ppDNhU6fPtt8cLIpJaMR5hLowg/U1y919Gp6wpA75Ttx9wZuxBFeAyJxKhJ0O5Myt21Soyw4blayUqqba3i/Nh+voNogwa9JUWzG/AOPDRQqCqKG0yswoRiKfTprSS6w487E1mHpLygftkaTAYKU3HYE/MZl8VYw6FUBC3QSNL5IJ/K8+k5K+Q9xwRBh9W57sclDcAq4fchrH4SKnYQ4GwFpLzyZBblL02ya+wi1kFxLlyHHPZNV/ZLAFG5uc/q1xfs3G6IPcjaRDWk2Ole0vTfqoCV1BVGKJ4+/M4XC+A6ML09CyOYzyu0mZFqWBzyCN3k3Up9sP+ysA9Et28ZO2JbCass3EV8hn1kF4eGwLgOtRpklZCttwLYPqmMjZQeFevF5+QRSZC80eHjf7kxQDwdBMja+dQS3xrIyE=
33 | - secure: LPWlPox2p8IiKQ8McuuK9e5jkuizp5A2m1nRjyGaq0FYyZD0rQ/AipiE6J25uyemxw11ZyJwno5pdrqytTQxDP2M4hVxMKU5vqvjVrVPDkSfTc0/xjW6efA+F2TBMzQavwANgS4y0OkKe18yZMPva/5sW9JbAuhbVDZn+rjRgoc7BSjX/xqw1QFmAmQXAfNxaUxpBmXSQbiZX67bFem9C77Ymhcd4bwvVu67ukVEQ+BhJw94y95j7enUBA9ioMQN8LIMH+/2U+YwHgQKaBYDQ1Y4PTxfOD8lis7z9m5ODXjCIEINJ2DXv4LM91oGtffQDftX+7P8J8oOF+p5AQWH85xgQh4bsuvRDJo0KXrUkTZ5knx76t+po9pxuLes3Mt0ykqAs5orpMBFPB6xYM7GWmzrGdIIHa4QdwmQyu8DyLCbRn3uCaIsEmxu6t+QOlEG9fEqog+TrRoPoM9ExzXQ9hyDAAqjhEVemhaqv5u8jjNtsV6s2MZyBEdH/BMbKEx9eBCsGCi5k++FPnIWB8ekUSsN8NUZvUXLZ3+7nEvLHjRBBonlJGuVuRjYpsOoCcaDvN3BVfDjA7+Ps7Y7Ci8SitzTYC/YLPNBp91oCjX7kDG13nOFgSiWZaUBrdekB5ush4TPxf4UOZuPHjadFin+c03iFn3cWKJo+Fd/66OLPV0=
34 | - secure: AHJQRYhNggAH/SSrIMjqTLZYyjc5BFQV8utlyF11sDmraWCs5IN0ZXc5CpKFQHwLgJjx5gObuHErXOSHDE5M9g/OM2OO5/hTnOSYC9xxNMmPtHf0J7rUnG/j4tICMWPjBsL/s7mZCxBMJ/AFNW2DGslIQDaSZJFENVvCehWZakDOV9pnZbYia47FJWwdW977OMKd/q3jOOSVMcSo6ZRNfjUyBe8gCW3oTJFh1N1EAhFog6xSnK45DoVW5cU6uWowVVsI39iUalmmUmCLm55w75IqmNTFcm7JHEdU/wbV034qI1GK3Oe6PSUQgC6JVBqw4ssjnp3qhAP6SeDA5UJNBcDplWMcqbIBVxfOp48QqWlgLEGp/uyr6KTYb+ZupKFVAEFXEgOUnNMXfJ51bwDBgFVdcy9n8QyIJn1tX5+Gj36C6kMBHIMgGraUZ+AT7ZMHfTrByD78Qk169/a379VsKPnf/ft6XzARXXbu87qJ0kHWbC7ugDeCfjjCUCLQ6rf3sdLj1TzK/qpvOj185wOyv+s0zUfFFuekXRux9itC0CDOgxw8XE0Li/Sp9SGfoN77m97bSy6+IHuM2RDKCleICC3fedwPPZVA0UdL6uL+bfBuHQK9/H6qV/xlJN+PDf6MbDCnsMsChp6VUBAHt/r1+K/ebB2nXzgdrDN9HCzZzuo=
35 | - secure: eC9/LKrCGhhP4xlePSHQ1K6XPhO4dNHwFfCDLeML/zzsOfyB9bENRfcoqrZ2GZ3UWigga8X8+lWVK2R+feRjNYrdR7oPXmvHwptSXS5+ECSkvAh5dusLIVKhDnsMsyXzSLV2eP8KMNGt6oBx28v4o9GtXTyLE9zIGQqeMEtwA0BRoqyE5MxEj6KWrwauNuKBfOQ/cdYN71KVwZ7VEA/2QhHvsfbNb9HEgzwy+mtPufOz6nucNfrR3Rwk5x+Kt9etOrdzWiX6rRtML7uN/IHXp2vbxHDgEaxmtrgQduqGRMacarvHiloU3QFIHvqszjGwspySJ/eZLPqELwmBBNGZmwUj6OrcDs9vG8gYHXneTXlNCLHJVLIEHxm+lYGejsPkytSUSNX1LtJnXuAaE9Z2BFudTx0pYKdWdMQZ/Ne2pUKTNZMyrMBfEazia9EeVd9C6DCqebXEjuM4w3y5kkigNhHvNKqH88GztcYXuxQ98saHIg9srHs6bavWp86sX+5FOWltTX3ZaQpMQJpAQoxI8S6gi/O1E17tqYmNWWW4Sh7yqB6IkgC6mciCD2UNCaLFiNeRirsK6M6TIun8oHXOTT1gG9ADPflflIU0xy/alCnC8T9hNiiGtsAmDMFdNQvvRQRwLpBb0MKE0gQASCjQZ0/18RWyZOO9bsUGuIq4IcA=
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [  ](https://bintray.com/ebanx/maven/swipe-button/_latestVersion) [](https://travis-ci.org/ebanx/swipe-button)
2 |
3 | # Swipe-Button
4 |
5 | 
6 |
7 | Library of an android button activated by swipe.
8 |
9 | - Easy to use.
10 | - Makes your app look great
11 | - Better UX in sensitive button
12 |
13 |
14 | ## Installation
15 |
16 | compile 'com.ebanx:swipe-button:[latestVersion]'
17 |
18 | ## How to use
19 |
20 | Add the button in your layout file and customize it the way you like it.
21 |
22 |
46 |
47 | ### Setting the sliding button size
48 | You can set the size of the moving part of the button by changing the app:button_image_width and app:button_image_height properties.
49 |
50 | ### Setting the text part size
51 | You can set the size of the fixed part of the button by setting the text size of the setting the padding in this part.
52 |
53 | ### Listening for changes
54 | You can set a listener for state changes
55 |
56 | SwipeButton enableButton = (SwipeButton) findViewById(R.id.swipe_btn);
57 | enableButton.setOnStateChangeListener(new OnStateChangeListener() {
58 | @Override
59 | public void onStateChange(boolean active) {
60 | Toast.makeText(MainActivity.this, "State: " + active, Toast.LENGTH_SHORT).show();
61 | }
62 | });
63 |
64 | Or listen for the activation of the button
65 |
66 | swipeButtonNoState.setOnActiveListener(new OnActiveListener() {
67 | @Override
68 | public void onActive() {
69 | Toast.makeText(MainActivity.this, "Active!", Toast.LENGTH_SHORT).show();
70 | }
71 | });
72 |
73 | ## Configure XML
74 |
75 | - button_image_width: Change the width of the moving part of the button
76 | - button_image_height: Change the height of the moving part of the button
77 | - inner_text: Text in the center of the button. It disapears when swiped
78 | - inner_text_color: Color of the text
79 | - inner_text_size: Size of the text
80 | - inner_text_[direction]_padding: Sets the padding of the text inside the button. You can set how big this part of the button will by setting text size and padding.
81 | - button_image_disabled: Icon of the button when disabled. This is the initial state.
82 | - button_image_enabled: Icon of the button when disabled. This is the initial expanded state.
83 | - button_[direction]_padding: Sets the padding of the button the slide with the touch. You can set how big the button will be by setting the image and the padding
84 | - initial_state: Initial state. Default state is disabled.
85 | - has_activate_state: Set if the button stops in the "active" state. If false, the button will only come back to the initial state after swiped until the end of its way. Use OnActiveListener if you set the parameter to false.
86 | - button_trail_enabled: Set trailing effect enabled.
87 | - button_trail_drawable: Set the color of the trailing effect.
88 |
89 | ## CodePen
90 | If you would like to see a front-end version of this button you can check a codepen in this link:
91 |
92 | - http://codepen.io/gpressutto5/pen/NjJobG
93 | - https://codepen.io/issamu/pen/NgPOKb (with Safari fix)
94 |
95 | ## Bugs and features
96 | For bugs, feature requests, and discussion please use [GitHub Issues](https://github.com/ebanx/swipe-button/issues).
97 |
98 | ## Credits
99 |
100 | - Design: [Diego Martins](https://dribbble.com/diegomartins)
101 | - Development: [Leandro Borges Ferreira](https://github.com/leandroBorgesFerreira), [Vinicius Nadin](https://github.com/viniciato), [Rahul Kumar](https://github.com/rahulk11)
102 | - Codepen: [Guilherme Pressuto](https://github.com/gpressutto5)
103 | - Codepen: [João Issamu Francisco](https://github.com/joaoissamu)
104 |
105 | ### And that's it! Enjoy!
106 |
107 | > Written with [StackEdit](https://stackedit.io/).
108 |
109 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 26
7 | buildToolsVersion "26.0.2"
8 | defaultConfig {
9 | applicationId "com.ebanx.swipebutton"
10 | minSdkVersion 19
11 | targetSdkVersion 26
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | lintOptions {
24 | abortOnError false
25 |
26 | // Bug in the android sdk https://github.com/square/okio/issues/58
27 | // remove this on android O (it will include the missing packages).
28 | warning 'InvalidPackage'
29 | }
30 |
31 | }
32 |
33 | dependencies {
34 | def supportVersion = "26.1.0"
35 |
36 | compile fileTree(include: ['*.jar'], dir: 'libs')
37 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
38 | exclude group: 'com.android.support', module: 'support-annotations'
39 | })
40 |
41 | compile "com.android.support:appcompat-v7:$supportVersion"
42 | compile "com.android.support:design:$supportVersion"
43 | testCompile 'junit:junit:4.12'
44 | compile project(':swipe-button')
45 | // compile 'com.ebanx:swipe-button:0.7.0'
46 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
47 |
48 | }
49 | repositories {
50 | mavenCentral()
51 | }
52 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/leandroferreira/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ebanx/swipebutton/SwipeButtonInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton
2 |
3 | import android.app.KeyguardManager
4 | import android.content.Context
5 | import android.support.test.rule.ActivityTestRule
6 | import android.view.WindowManager
7 | import com.ebanx.swipebtn.SwipeButton
8 | import kotlinx.android.synthetic.main.content_main.*
9 | import org.junit.Before
10 | import org.junit.Rule
11 | import org.junit.Test
12 |
13 | class SwipeButtonInstrumentedTest {
14 |
15 | @Rule
16 | @JvmField
17 | val activityTest = ActivityTestRule(MainActivity::class.java)
18 |
19 | @Suppress("DEPRECATION")
20 | @Before
21 | fun setUp() {
22 | // activityTest.activity.runOnUiThread {
23 | // val mKG = activityTest.activity.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
24 | // val mLock = mKG.newKeyguardLock(Context.KEYGUARD_SERVICE)
25 | // mLock.disableKeyguard()
26 | //
27 | // //turn the screen on
28 | // activityTest.activity.window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
29 | // WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
30 | // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
31 | // WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
32 | // WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON)
33 | // }
34 | }
35 |
36 | @Test
37 | fun shouldSetEnabledAfterSwipe() {
38 | test {
39 | enableButton()
40 | } result {
41 | checkButtonIsEnabled(activityTest.activity.swipeBtnDisabled as SwipeButton)
42 | }
43 | }
44 |
45 | @Test
46 | fun shouldSetDisabledAfterClick() {
47 | test {
48 | enableButton()
49 | disableButton()
50 | } result {
51 | checkButtonIsDisabled(activityTest.activity.swipeBtnDisabled as SwipeButton)
52 | }
53 | }
54 |
55 | @Test
56 | fun shouldCreateButtonCorrectly() {
57 | test { } result {
58 | checkButtonIsDisabled(activityTest.activity.swipeBtnDisabled as SwipeButton)
59 | checkButtonIsEnabled(activityTest.activity.swipeBtnEnabled as SwipeButton)
60 | shouldBeginWithRightText("SWIPE")
61 | }
62 | }
63 |
64 | @Test
65 | fun shouldNotAcceptSwipeFromOutsideMovingPart() {
66 | test {
67 | enableFromMidOfButton()
68 | } result {
69 | checkButtonIsDisabled(activityTest.activity.swipeBtnDisabled as SwipeButton)
70 | }
71 | }
72 |
73 | fun test(func: SwipeButtonTestRobot.() -> Unit) = SwipeButtonTestRobot().apply { func() }
74 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ebanx/swipebutton/SwipeButtonResultRobot.kt:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton
2 |
3 | import android.support.test.espresso.Espresso.onView
4 | import android.support.test.espresso.assertion.ViewAssertions.matches
5 | import android.support.test.espresso.matcher.ViewMatchers.*
6 | import com.ebanx.swipebtn.SwipeButton
7 | import junit.framework.Assert
8 | import org.hamcrest.Matchers.allOf
9 |
10 | /**
11 | * Created by vinicius on 13/06/17.
12 | */
13 | class SwipeButtonResultRobot {
14 |
15 | fun checkButtonIsEnabled(swipeButton: SwipeButton) {
16 | Assert.assertTrue(swipeButton.isActive)
17 | }
18 |
19 | fun checkButtonIsDisabled(swipeButton: SwipeButton) {
20 | Assert.assertFalse(swipeButton.isActive)
21 | }
22 |
23 | fun shouldBeginWithRightText(title: String) {
24 | onView(withText(title)).check(matches(isDisplayed()))
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ebanx/swipebutton/SwipeButtonTestRobot.kt:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton
2 |
3 | import android.support.test.espresso.Espresso.onView
4 | import android.support.test.espresso.ViewAction
5 | import android.support.test.espresso.action.CoordinatesProvider
6 | import android.support.test.espresso.action.GeneralLocation
7 | import android.support.test.espresso.action.Press
8 | import android.support.test.espresso.action.Swipe
9 | import android.support.test.espresso.action.ViewActions.click
10 | import android.support.test.espresso.action.ViewActions.swipeRight
11 | import android.support.test.espresso.matcher.ViewMatchers.withId
12 | import ebanx.com.ego.utils.CenterSwipeAction
13 |
14 | /**
15 | * Created by vinicius on 13/06/17.
16 | */
17 | class SwipeButtonTestRobot {
18 |
19 | fun enableButton() : SwipeButtonTestRobot {
20 | onView(withId(R.id.swipeBtnDisabled)).perform(swipeRight())
21 | return this
22 | }
23 |
24 | fun disableButton() : SwipeButtonTestRobot {
25 | onView(withId(R.id.swipeBtnDisabled)).perform(click())
26 | return this
27 | }
28 |
29 | fun enableFromMidOfButton() : SwipeButtonTestRobot {
30 | onView(withId(R.id.swipeBtnDisabled)).perform(swipeFromCenterToRight())
31 | return this
32 | }
33 |
34 | private fun swipeFromCenterToRight(): ViewAction {
35 | val endCoordProvide = CoordinatesProvider { view ->
36 | val coordinates = GeneralLocation.CENTER.calculateCoordinates(view)
37 | coordinates[0] = 1500f
38 | coordinates
39 | }
40 | return CenterSwipeAction(Swipe.FAST,
41 | GeneralLocation.CENTER,
42 | endCoordProvide,
43 | Press.FINGER)
44 | }
45 |
46 | infix fun result(func: SwipeButtonResultRobot.() -> Unit) = SwipeButtonResultRobot().apply { func() }
47 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ebanx/swipebutton/utils/CenterSwipeAction.kt:
--------------------------------------------------------------------------------
1 | package ebanx.com.ego.utils
2 |
3 | import android.support.test.espresso.PerformException
4 | import android.support.test.espresso.UiController
5 | import android.support.test.espresso.ViewAction
6 | import android.support.test.espresso.action.CoordinatesProvider
7 | import android.support.test.espresso.action.PrecisionDescriber
8 | import android.support.test.espresso.action.Swiper
9 | import android.support.test.espresso.matcher.ViewMatchers
10 | import android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
11 | import android.support.test.espresso.util.HumanReadables
12 | import android.view.View
13 | import android.view.ViewConfiguration
14 | import org.hamcrest.Matcher
15 |
16 | class CenterSwipeAction(private val swiper: Swiper,
17 | private val startCoordProvide: CoordinatesProvider,
18 | private val endCoordProvide: CoordinatesProvider,
19 | private val precDesc: PrecisionDescriber) : ViewAction {
20 |
21 | override fun getConstraints(): Matcher {
22 | return withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)
23 | }
24 |
25 | override fun getDescription(): String {
26 | return "swipe from middle of screen"
27 | }
28 |
29 | @Suppress("CatchRuntimeException")
30 | override fun perform(uiController: UiController, view: View) {
31 | val startCoord = startCoordProvide.calculateCoordinates(view)
32 | val finalCoord = endCoordProvide.calculateCoordinates(view)
33 | val precision = precDesc.describePrecision()
34 |
35 | // you could try this for several times until Swiper.Status is achieved or try count is reached
36 | try {
37 | swiper.sendSwipe(uiController, startCoord, finalCoord, precision)
38 | } catch (re: RuntimeException) {
39 | throw PerformException.Builder()
40 | .withActionDescription(this.description)
41 | .withViewDescription(HumanReadables.describe(view))
42 | .withCause(re)
43 | .build()
44 | }
45 |
46 | // ensures that the swipe has been run.
47 | uiController.loopMainThreadForAtLeast(ViewConfiguration.getPressedStateDuration().toLong())
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ebanx/swipebutton/EbanxToggleButton.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ValueAnimator;
6 | import android.content.Context;
7 | import android.graphics.Canvas;
8 | import android.support.v4.content.ContextCompat;
9 | import android.util.AttributeSet;
10 | import android.view.Gravity;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.animation.AccelerateDecelerateInterpolator;
14 | import android.widget.Button;
15 | import android.widget.RelativeLayout;
16 |
17 | /**
18 | * Created by leandroferreira on 07/03/17.
19 | */
20 |
21 | public class EbanxToggleButton extends RelativeLayout {
22 |
23 | private boolean isClicked;
24 | private Button mSwipeButton;
25 | private int initialButtonWidth;
26 | private int animationButtonWidth;
27 |
28 | public EbanxToggleButton(Context context) {
29 | super(context);
30 |
31 | init(context);
32 | }
33 |
34 | public EbanxToggleButton(Context context, AttributeSet attrs) {
35 | super(context, attrs);
36 |
37 | init(context);
38 | }
39 |
40 | public EbanxToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
41 | super(context, attrs, defStyleAttr);
42 |
43 | init(context);
44 | }
45 |
46 | public EbanxToggleButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
47 | super(context, attrs, defStyleAttr, defStyleRes);
48 |
49 | init(context);
50 | }
51 |
52 | private void init(Context context){
53 | isClicked = false;
54 |
55 | mSwipeButton = new Button(context);
56 | mSwipeButton.setText(null);
57 | mSwipeButton.setBackground(ContextCompat.getDrawable(context, R.drawable.shape_button));
58 |
59 | LayoutParams layoutParamsButton = new LayoutParams(
60 | ViewGroup.LayoutParams.WRAP_CONTENT,
61 | ViewGroup.LayoutParams.MATCH_PARENT);
62 |
63 | layoutParamsButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
64 | layoutParamsButton.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
65 |
66 |
67 |
68 | addView(mSwipeButton, layoutParamsButton);
69 |
70 |
71 | OnClickListener clickListener = new OnClickListener() {
72 | @Override
73 | public void onClick(View v) {
74 | if(!isClicked){
75 | animateCheck();
76 | isClicked = true;
77 | } else{
78 | animateUncheck();
79 | isClicked = false;
80 | }
81 | }
82 | };
83 |
84 | setOnClickListener(clickListener);
85 | mSwipeButton.setOnClickListener(clickListener);
86 |
87 | }
88 |
89 | @Override
90 | public void onDraw(Canvas canvas){
91 | super.onDraw(canvas);
92 |
93 | initialButtonWidth = mSwipeButton.getWidth();
94 | animationButtonWidth = getWidth();
95 | }
96 |
97 | private void animateCheck(){
98 | final ValueAnimator expandAnimator = ValueAnimator.ofInt(initialButtonWidth, animationButtonWidth);
99 | expandAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
100 | @Override
101 | public void onAnimationUpdate(ValueAnimator animation) {
102 | mSwipeButton.setWidth((Integer) animation.getAnimatedValue());
103 | }
104 | });
105 |
106 | expandAnimator.addListener(new Animator.AnimatorListener() {
107 | @Override
108 | public void onAnimationStart(Animator animation) {
109 | setGravity(Gravity.LEFT);
110 | }
111 |
112 | @Override
113 | public void onAnimationEnd(Animator animation) {
114 |
115 | }
116 |
117 | @Override
118 | public void onAnimationCancel(Animator animation) {
119 |
120 | }
121 |
122 | @Override
123 | public void onAnimationRepeat(Animator animation) {
124 |
125 | }
126 | });
127 |
128 | final ValueAnimator shirinkAnimator = ValueAnimator.ofInt(animationButtonWidth, initialButtonWidth);
129 | shirinkAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
130 | @Override
131 | public void onAnimationUpdate(ValueAnimator animation) {
132 | mSwipeButton.setWidth((Integer) animation.getAnimatedValue());
133 | }
134 | });
135 | shirinkAnimator.addListener(new Animator.AnimatorListener() {
136 | @Override
137 | public void onAnimationStart(Animator animation) {
138 | setGravity(Gravity.RIGHT);
139 | }
140 |
141 | @Override
142 | public void onAnimationEnd(Animator animation) {
143 | }
144 |
145 | @Override
146 | public void onAnimationCancel(Animator animation) {
147 |
148 | }
149 |
150 | @Override
151 | public void onAnimationRepeat(Animator animation) {
152 |
153 | }
154 | });
155 |
156 | final AnimatorSet animatorSet = new AnimatorSet();
157 | animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
158 | animatorSet.playSequentially(expandAnimator, shirinkAnimator);
159 |
160 | animatorSet.addListener(getClickableListener());
161 |
162 | animatorSet.start();
163 | }
164 |
165 | private void animateUncheck(){
166 | final ValueAnimator expandAnimator = ValueAnimator.ofInt(initialButtonWidth, animationButtonWidth);
167 | expandAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
168 | @Override
169 | public void onAnimationUpdate(ValueAnimator animation) {
170 | mSwipeButton.setWidth((Integer) animation.getAnimatedValue());
171 | }
172 | });
173 |
174 | expandAnimator.addListener(new Animator.AnimatorListener() {
175 | @Override
176 | public void onAnimationStart(Animator animation) {
177 | setGravity(Gravity.RIGHT);
178 | }
179 |
180 | @Override
181 | public void onAnimationEnd(Animator animation) {
182 | }
183 |
184 | @Override
185 | public void onAnimationCancel(Animator animation) {
186 |
187 | }
188 |
189 | @Override
190 | public void onAnimationRepeat(Animator animation) {
191 |
192 | }
193 | });
194 |
195 | final ValueAnimator shirinkAnimator = ValueAnimator.ofInt(animationButtonWidth, initialButtonWidth);
196 | shirinkAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
197 | @Override
198 | public void onAnimationUpdate(ValueAnimator animation) {
199 | mSwipeButton.setWidth((Integer) animation.getAnimatedValue());
200 | }
201 | });
202 |
203 |
204 |
205 | shirinkAnimator.addListener(new Animator.AnimatorListener() {
206 | @Override
207 | public void onAnimationStart(Animator animation) {
208 | setGravity(Gravity.LEFT);
209 | }
210 |
211 | @Override
212 | public void onAnimationEnd(Animator animation) {
213 | }
214 |
215 | @Override
216 | public void onAnimationCancel(Animator animation) {
217 |
218 | }
219 |
220 | @Override
221 | public void onAnimationRepeat(Animator animation) {
222 |
223 | }
224 | });
225 |
226 | final AnimatorSet animatorSet = new AnimatorSet();
227 | animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
228 | animatorSet.playSequentially(expandAnimator, shirinkAnimator);
229 |
230 | animatorSet.addListener(getClickableListener());
231 |
232 | animatorSet.start();
233 | }
234 |
235 | private Animator.AnimatorListener getClickableListener(){
236 | return new Animator.AnimatorListener() {
237 | @Override
238 | public void onAnimationStart(Animator animation) {
239 | setClickable(false);
240 | mSwipeButton.setClickable(false);
241 | }
242 |
243 | @Override
244 | public void onAnimationEnd(Animator animation) {
245 | setClickable(true);
246 | mSwipeButton.setClickable(true);
247 | }
248 |
249 | @Override
250 | public void onAnimationCancel(Animator animation) {}
251 |
252 | @Override
253 | public void onAnimationRepeat(Animator animation) {}
254 | };
255 | }
256 |
257 | }
258 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ebanx/swipebutton/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton
2 |
3 | import android.os.Bundle
4 | import android.support.v4.content.ContextCompat
5 | import android.support.v7.app.AppCompatActivity
6 | import android.widget.Toast
7 | import kotlinx.android.synthetic.main.content_main.*
8 |
9 | class MainActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_main)
14 |
15 | swipeBtnEnabled.background = ContextCompat.getDrawable(this, R.drawable.shape_button2)
16 | swipeBtnEnabled.setSlidingButtonBackground(ContextCompat.getDrawable(this, R.drawable.shape_rounded2))
17 |
18 | swipeBtnEnabled.setOnStateChangeListener { active ->
19 | Toast.makeText(this@MainActivity, "State: " + active, Toast.LENGTH_SHORT).show()
20 | if (active) {
21 | swipeBtnEnabled.setButtonBackground(ContextCompat.getDrawable(this@MainActivity, R.drawable.shape_button))
22 | } else {
23 | swipeBtnEnabled.setButtonBackground(ContextCompat.getDrawable(this@MainActivity, R.drawable.shape_button3))
24 | }
25 | }
26 |
27 | // swipeBtnDisabled.setDisabledStateNotAnimated()
28 | swipeBtnEnabled.setEnabledStateNotAnimated()
29 |
30 | swipeNoState.setOnActiveListener { Toast.makeText(this@MainActivity, "Active!", Toast.LENGTH_SHORT).show() }
31 |
32 | toggleBtn.setOnClickListener {
33 | if (!swipeBtnEnabled.isActive) {
34 | swipeBtnEnabled.toggleState()
35 | }
36 | }
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_lock_open_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-hdpi/ic_lock_open_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_lock_outline_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-hdpi/ic_lock_outline_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_lock_open_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-xhdpi/ic_lock_open_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_lock_outline_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-xhdpi/ic_lock_outline_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_lock_open_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-xxhdpi/ic_lock_open_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_lock_outline_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/drawable-xxhdpi/ic_lock_outline_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_button_squared.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_rounded.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_rounded2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_squared.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
36 |
37 |
60 |
61 |
62 |
63 |
84 |
85 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #000
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SwipeButton
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/ebanx/swipebutton/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebutton;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.10'
5 | repositories {
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.1'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
13 | classpath 'com.btkelly:gnag:1.3.2'
14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 |
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | jcenter()
24 | google()
25 | }
26 |
27 | subprojects {
28 | tasks.withType(Javadoc).all { enabled = false }
29 | }
30 | }
31 |
32 | task clean(type: Delete) {
33 | delete rootProject.buildDir
34 | }
35 |
--------------------------------------------------------------------------------
/gnag-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -ev
3 |
4 | if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
5 | ./gradlew gnagCheck --no-daemon
6 | else
7 | ./gradlew gnagReport -PauthToken="${GNAG_AUTH_TOKEN}" -PissueNumber="${TRAVIS_PULL_REQUEST}" --no-daemon
8 | fi
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/buildWithTravis.sh:
--------------------------------------------------------------------------------
1 | if [ "$TRAVIS_TAG" == "" ]; then
2 | echo -e 'Build Branch'
3 | ./gradlew build
4 | elif [ "$TRAVIS_TAG" != "" ]; then
5 | echo -e 'Build Branch for tag: Tag ['$TRAVIS_TAG']'
6 | ./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build bintrayUpload
7 | else
8 | echo -e 'WARN: Should not be here ./gradlew clean'
9 | fi
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ebanx/swipe-button/ae46883b10cb9f92ebb0cf4b9a627f6e177153cb/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 03 17:13:50 BRT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 ':app', ':swipe-button'
2 |
--------------------------------------------------------------------------------
/swipe-button/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/swipe-button/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 | apply plugin: 'gnag'
5 |
6 | version = '0.8.3'
7 | group = 'com.ebanx'
8 |
9 | android {
10 | compileSdkVersion 26
11 | buildToolsVersion "26.0.2"
12 |
13 | defaultConfig {
14 | minSdkVersion 16
15 | targetSdkVersion 26
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 |
21 | }
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 |
29 | lintOptions {
30 | abortOnError false
31 |
32 | // Bug in the android sdk https://github.com/square/okio/issues/58
33 | // remove this on android O (it will include the missing packages).
34 | warning 'InvalidPackage'
35 | }
36 | }
37 |
38 | gnag {
39 | checkstyle {
40 | enabled true
41 | reporterConfig project.file('checkstyle.xml')
42 | }
43 | pmd {
44 | enabled true
45 | reporterConfig project.file('pmd.xml')
46 | }
47 | findbugs {
48 | enabled false
49 | }
50 | androidLint {
51 | enabled true
52 | severity 'Error'
53 | }
54 | github {
55 | repoName 'ebanx/swipe-button'
56 | }
57 | }
58 |
59 | dependencies {
60 | compile fileTree(dir: 'libs', include: ['*.jar'])
61 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
62 | exclude group: 'com.android.support', module: 'support-annotations'
63 | })
64 | compile 'com.android.support:appcompat-v7:26.0.0'
65 | testCompile 'junit:junit:4.12'
66 | }
67 |
68 | if (project.hasProperty("android")) { // Android libraries
69 | task sourcesJar(type: Jar) {
70 | classifier = 'sources'
71 | from android.sourceSets.main.java.srcDirs
72 | }
73 |
74 | task javadoc(type: Javadoc) {
75 | source = android.sourceSets.main.java.srcDirs
76 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
77 | }
78 | } else { // Java libraries
79 | task sourcesJar(type: Jar, dependsOn: classes) {
80 | classifier = 'sources'
81 | from sourceSets.main.allSource
82 | }
83 | }
84 |
85 | task javadocJar(type: Jar, dependsOn: javadoc) {
86 | classifier = 'javadoc'
87 | from javadoc.destinationDir
88 | }
89 |
90 | artifacts {
91 | archives javadocJar
92 | archives sourcesJar
93 | }
94 |
95 | install {
96 | repositories.mavenInstaller {
97 | pom.project {
98 | name 'SwipeButton'
99 | description 'A Button enabled by swipe'
100 | url 'https://github.com/ebanx/swipe-button/'
101 | inceptionYear '2017'
102 |
103 | packaging 'aar'
104 | groupId 'com.ebanx'
105 | artifactId 'swipe-button'
106 | version '0.8.3'
107 |
108 | licenses {
109 | license {
110 | name 'The Apache Software License, Version 2.0'
111 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
112 | distribution 'repo'
113 | }
114 | }
115 | scm {
116 | connection 'git@github.com:ebanx/swipe-button.git'
117 | url 'https://github.com/ebanx/swipe-button/'
118 |
119 | }
120 | developers {
121 | developer {
122 | name 'Leandro Borges Ferreira'
123 | }
124 | }
125 | }
126 | }
127 | }
128 |
129 | // Configure gradle-bintray-plugin (for publishing releases)
130 | bintray {
131 | configurations = ['archives']
132 |
133 | publish = true
134 |
135 | pkg {
136 | repo = 'maven'
137 | name = 'swipe-button'
138 | userOrg = 'ebanx'
139 | licenses = ['Apache-2.0']
140 | labels = ['customview', 'spinner']
141 | websiteUrl = 'https://github.com/ebanx/swipe-button/'
142 | issueTrackerUrl = 'https://github.com/ebanx/swipe-button/issues'
143 | vcsUrl = 'https://github.com/ebanx/swipe-button.git'
144 | publicDownloadNumbers = true
145 | }
146 |
147 | }
148 |
149 | if (project.hasProperty('bintrayUser') && project.hasProperty('bintrayKey')) {
150 | bintray.user = project.bintrayUser
151 | bintray.key = project.bintrayKey
152 | }
153 |
154 | repositories {
155 | mavenCentral()
156 | }
157 |
--------------------------------------------------------------------------------
/swipe-button/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
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 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
--------------------------------------------------------------------------------
/swipe-button/pmd.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
24 |
25 | POM rule set file
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 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/swipe-button/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/leandroferreira/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/swipe-button/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/swipe-button/src/main/java/com/ebanx/swipebtn/DimentionUtils.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebtn;
2 |
3 | import android.content.Context;
4 |
5 | final class DimentionUtils {
6 |
7 | private DimentionUtils() {
8 | }
9 |
10 | static float converPixelsToSp(float px, Context context) {
11 | return px / context.getResources().getDisplayMetrics().scaledDensity;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/swipe-button/src/main/java/com/ebanx/swipebtn/OnActiveListener.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebtn;
2 |
3 | public interface OnActiveListener {
4 | void onActive();
5 | }
6 |
--------------------------------------------------------------------------------
/swipe-button/src/main/java/com/ebanx/swipebtn/OnStateChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebtn;
2 |
3 | public interface OnStateChangeListener {
4 | void onStateChange(boolean active);
5 | }
6 |
--------------------------------------------------------------------------------
/swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebtn;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.AnimatorSet;
6 | import android.animation.ObjectAnimator;
7 | import android.animation.ValueAnimator;
8 | import android.annotation.TargetApi;
9 | import android.content.Context;
10 | import android.content.res.TypedArray;
11 | import android.graphics.Color;
12 | import android.graphics.drawable.Drawable;
13 | import android.support.annotation.NonNull;
14 | import android.support.v4.content.ContextCompat;
15 | import android.util.AttributeSet;
16 | import android.view.Gravity;
17 | import android.view.MotionEvent;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.view.animation.AccelerateDecelerateInterpolator;
21 | import android.widget.ImageView;
22 | import android.widget.LinearLayout;
23 | import android.widget.RelativeLayout;
24 | import android.widget.TextView;
25 |
26 | /**
27 | * Created by leandroferreira on 07/03/17.
28 | */
29 |
30 | public class SwipeButton extends RelativeLayout {
31 |
32 | private static final int ENABLED = 0;
33 | private static final int DISABLED = 1;
34 |
35 | private ImageView swipeButtonInner;
36 | private float initialX;
37 | private boolean active;
38 | private TextView centerText;
39 | private ViewGroup background;
40 |
41 | private Drawable disabledDrawable;
42 | private Drawable enabledDrawable;
43 |
44 | private OnStateChangeListener onStateChangeListener;
45 | private OnActiveListener onActiveListener;
46 |
47 | private int collapsedWidth;
48 | private int collapsedHeight;
49 |
50 | private LinearLayout layer;
51 | private boolean trailEnabled = false;
52 | private boolean hasActivationState;
53 |
54 | private float buttonLeftPadding;
55 | private float buttonTopPadding;
56 | private float buttonRightPadding;
57 | private float buttonBottomPadding;
58 |
59 | public SwipeButton(Context context) {
60 | super(context);
61 |
62 | init(context, null, -1, -1);
63 | }
64 |
65 | public SwipeButton(Context context, AttributeSet attrs) {
66 | super(context, attrs);
67 |
68 | init(context, attrs, -1, -1);
69 | }
70 |
71 | public SwipeButton(Context context, AttributeSet attrs, int defStyleAttr) {
72 | super(context, attrs, defStyleAttr);
73 |
74 | init(context, attrs, defStyleAttr, -1);
75 | }
76 |
77 | @TargetApi(21)
78 | public SwipeButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
79 | super(context, attrs, defStyleAttr, defStyleRes);
80 |
81 | init(context, attrs, defStyleAttr, defStyleRes);
82 | }
83 |
84 | public boolean isActive() {
85 | return active;
86 | }
87 |
88 | public void setText(String text) {
89 | centerText.setText(text);
90 | }
91 |
92 | public void setBackground(Drawable drawable) {
93 | background.setBackground(drawable);
94 | }
95 |
96 | public void setSlidingButtonBackground(Drawable drawable) {
97 | background.setBackground(drawable);
98 | }
99 |
100 | public void setDisabledDrawable(Drawable drawable) {
101 | disabledDrawable = drawable;
102 |
103 | if (!active) {
104 | swipeButtonInner.setImageDrawable(drawable);
105 | }
106 | }
107 |
108 | public void setButtonBackground(Drawable buttonBackground) {
109 | if (buttonBackground != null) {
110 | swipeButtonInner.setBackground(buttonBackground);
111 | }
112 | }
113 |
114 | public void setEnabledDrawable(Drawable drawable) {
115 | enabledDrawable = drawable;
116 |
117 | if (active) {
118 | swipeButtonInner.setImageDrawable(drawable);
119 | }
120 | }
121 |
122 | public void setOnStateChangeListener(OnStateChangeListener onStateChangeListener) {
123 | this.onStateChangeListener = onStateChangeListener;
124 | }
125 |
126 | public void setOnActiveListener(OnActiveListener onActiveListener) {
127 | this.onActiveListener = onActiveListener;
128 | }
129 |
130 | public void setInnerTextPadding(int left, int top, int right, int bottom) {
131 | centerText.setPadding(left, top, right, bottom);
132 | }
133 |
134 | public void setSwipeButtonPadding(int left, int top, int right, int bottom) {
135 | swipeButtonInner.setPadding(left, top, right, bottom);
136 | }
137 |
138 | public void setHasActivationState(boolean hasActivationState) {
139 | this.hasActivationState = hasActivationState;
140 | }
141 |
142 | private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
143 | hasActivationState = true;
144 |
145 | background = new RelativeLayout(context);
146 |
147 | LayoutParams layoutParamsView = new LayoutParams(
148 | ViewGroup.LayoutParams.MATCH_PARENT,
149 | ViewGroup.LayoutParams.WRAP_CONTENT);
150 |
151 | layoutParamsView.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
152 |
153 | addView(background, layoutParamsView);
154 |
155 | final TextView centerText = new TextView(context);
156 | this.centerText = centerText;
157 | centerText.setGravity(Gravity.CENTER);
158 |
159 | LayoutParams layoutParams = new LayoutParams(
160 | ViewGroup.LayoutParams.WRAP_CONTENT,
161 | ViewGroup.LayoutParams.WRAP_CONTENT);
162 |
163 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
164 |
165 | background.addView(centerText, layoutParams);
166 |
167 | final ImageView swipeButton = new ImageView(context);
168 | this.swipeButtonInner = swipeButton;
169 |
170 | if (attrs != null && defStyleAttr == -1 && defStyleRes == -1) {
171 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeButton,
172 | defStyleAttr, defStyleRes);
173 |
174 | collapsedWidth = (int) typedArray.getDimension(R.styleable.SwipeButton_button_image_width,
175 | ViewGroup.LayoutParams.WRAP_CONTENT);
176 | collapsedHeight = (int) typedArray.getDimension(R.styleable.SwipeButton_button_image_height,
177 | ViewGroup.LayoutParams.WRAP_CONTENT);
178 | trailEnabled = typedArray.getBoolean(R.styleable.SwipeButton_button_trail_enabled,
179 | false);
180 | Drawable trailingDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_trail_drawable);
181 |
182 | Drawable backgroundDrawable = typedArray.getDrawable(R.styleable.SwipeButton_inner_text_background);
183 |
184 | if (backgroundDrawable != null) {
185 | background.setBackground(backgroundDrawable);
186 | } else {
187 | background.setBackground(ContextCompat.getDrawable(context, R.drawable.shape_rounded));
188 | }
189 |
190 | if (trailEnabled) {
191 | layer = new LinearLayout(context);
192 |
193 | if (trailingDrawable != null) {
194 | layer.setBackground(trailingDrawable);
195 | } else {
196 | layer.setBackground(typedArray.getDrawable(R.styleable.SwipeButton_button_background));
197 | }
198 |
199 | layer.setGravity(Gravity.START);
200 | layer.setVisibility(View.GONE);
201 | background.addView(layer, layoutParamsView);
202 | }
203 |
204 | centerText.setText(typedArray.getText(R.styleable.SwipeButton_inner_text));
205 | centerText.setTextColor(typedArray.getColor(R.styleable.SwipeButton_inner_text_color,
206 | Color.WHITE));
207 |
208 | float textSize = DimentionUtils.converPixelsToSp(
209 | typedArray.getDimension(R.styleable.SwipeButton_inner_text_size, 0), context);
210 |
211 | if (textSize != 0) {
212 | centerText.setTextSize(textSize);
213 | } else {
214 | centerText.setTextSize(12);
215 | }
216 |
217 | disabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_disabled);
218 | enabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_enabled);
219 | float innerTextLeftPadding = typedArray.getDimension(
220 | R.styleable.SwipeButton_inner_text_left_padding, 0);
221 | float innerTextTopPadding = typedArray.getDimension(
222 | R.styleable.SwipeButton_inner_text_top_padding, 0);
223 | float innerTextRightPadding = typedArray.getDimension(
224 | R.styleable.SwipeButton_inner_text_right_padding, 0);
225 | float innerTextBottomPadding = typedArray.getDimension(
226 | R.styleable.SwipeButton_inner_text_bottom_padding, 0);
227 |
228 | int initialState = typedArray.getInt(R.styleable.SwipeButton_initial_state, DISABLED);
229 |
230 | if (initialState == ENABLED) {
231 | LayoutParams layoutParamsButton = new LayoutParams(
232 | ViewGroup.LayoutParams.MATCH_PARENT,
233 | ViewGroup.LayoutParams.WRAP_CONTENT);
234 |
235 | layoutParamsButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
236 | layoutParamsButton.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
237 |
238 | swipeButtonInner.setImageDrawable(enabledDrawable);
239 |
240 | addView(swipeButtonInner, layoutParamsButton);
241 |
242 | active = true;
243 | } else {
244 | LayoutParams layoutParamsButton = new LayoutParams(collapsedWidth, collapsedHeight);
245 |
246 | layoutParamsButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
247 | layoutParamsButton.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
248 |
249 | swipeButtonInner.setImageDrawable(disabledDrawable);
250 |
251 | addView(swipeButtonInner, layoutParamsButton);
252 |
253 | active = false;
254 | }
255 |
256 | centerText.setPadding((int) innerTextLeftPadding,
257 | (int) innerTextTopPadding,
258 | (int) innerTextRightPadding,
259 | (int) innerTextBottomPadding);
260 |
261 | Drawable buttonBackground = typedArray.getDrawable(R.styleable.SwipeButton_button_background);
262 |
263 | if (buttonBackground != null) {
264 | swipeButtonInner.setBackground(buttonBackground);
265 | } else {
266 | swipeButtonInner.setBackground(ContextCompat.getDrawable(context, R.drawable.shape_button));
267 | }
268 |
269 | buttonLeftPadding = typedArray.getDimension(R.styleable.SwipeButton_button_left_padding, 0);
270 | buttonTopPadding = typedArray.getDimension(R.styleable.SwipeButton_button_top_padding, 0);
271 | buttonRightPadding = typedArray.getDimension(R.styleable.SwipeButton_button_right_padding, 0);
272 | buttonBottomPadding = typedArray.getDimension(R.styleable.SwipeButton_button_bottom_padding, 0);
273 |
274 | swipeButtonInner.setPadding((int) buttonLeftPadding,
275 | (int) buttonTopPadding,
276 | (int) buttonRightPadding,
277 | (int) buttonBottomPadding);
278 |
279 | hasActivationState = typedArray.getBoolean(R.styleable.SwipeButton_has_activate_state, true);
280 |
281 | typedArray.recycle();
282 | }
283 |
284 | setOnTouchListener(getButtonTouchListener());
285 | }
286 |
287 | private OnTouchListener getButtonTouchListener() {
288 | return new OnTouchListener() {
289 | @Override
290 | public boolean onTouch(View v, MotionEvent event) {
291 | switch (event.getAction()) {
292 | case MotionEvent.ACTION_DOWN:
293 | return !TouchUtils.isTouchOutsideInitialPosition(event, swipeButtonInner);
294 | case MotionEvent.ACTION_MOVE:
295 | if (initialX == 0) {
296 | initialX = swipeButtonInner.getX();
297 | }
298 |
299 | if (event.getX() > swipeButtonInner.getWidth() / 2 &&
300 | event.getX() + swipeButtonInner.getWidth() / 2 < getWidth()) {
301 | swipeButtonInner.setX(event.getX() - swipeButtonInner.getWidth() / 2);
302 | centerText.setAlpha(1 - 1.3f * (swipeButtonInner.getX() + swipeButtonInner.getWidth()) / getWidth());
303 | setTrailingEffect();
304 | }
305 |
306 | if (event.getX() + swipeButtonInner.getWidth() / 2 > getWidth() &&
307 | swipeButtonInner.getX() + swipeButtonInner.getWidth() / 2 < getWidth()) {
308 | swipeButtonInner.setX(getWidth() - swipeButtonInner.getWidth());
309 | }
310 |
311 | if (event.getX() < swipeButtonInner.getWidth() / 2) {
312 | swipeButtonInner.setX(0);
313 | }
314 |
315 | return true;
316 | case MotionEvent.ACTION_UP:
317 | if (active) {
318 | collapseButton();
319 | } else {
320 | if (swipeButtonInner.getX() + swipeButtonInner.getWidth() > getWidth() * 0.9) {
321 | if (hasActivationState) {
322 | expandButton();
323 | } else if (onActiveListener != null) {
324 | onActiveListener.onActive();
325 | moveButtonBack();
326 | }
327 | } else {
328 | moveButtonBack();
329 | }
330 | }
331 |
332 | return true;
333 | }
334 |
335 | return false;
336 | }
337 | };
338 | }
339 |
340 | private void expandButton() {
341 | final ValueAnimator positionAnimator =
342 | ValueAnimator.ofFloat(swipeButtonInner.getX(), 0);
343 | positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
344 | @Override
345 | public void onAnimationUpdate(ValueAnimator animation) {
346 | float x = (Float) positionAnimator.getAnimatedValue();
347 | swipeButtonInner.setX(x);
348 | }
349 | });
350 |
351 |
352 | final ValueAnimator widthAnimator = ValueAnimator.ofInt(
353 | swipeButtonInner.getWidth(),
354 | getWidth());
355 |
356 | widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
357 | @Override
358 | public void onAnimationUpdate(ValueAnimator animation) {
359 | ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
360 | params.width = (Integer) widthAnimator.getAnimatedValue();
361 | swipeButtonInner.setLayoutParams(params);
362 | }
363 | });
364 |
365 |
366 | AnimatorSet animatorSet = new AnimatorSet();
367 | animatorSet.addListener(new AnimatorListenerAdapter() {
368 | @Override
369 | public void onAnimationEnd(Animator animation) {
370 | super.onAnimationEnd(animation);
371 |
372 | active = true;
373 | swipeButtonInner.setImageDrawable(enabledDrawable);
374 |
375 | if (onStateChangeListener != null) {
376 | onStateChangeListener.onStateChange(active);
377 | }
378 |
379 | if (onActiveListener != null) {
380 | onActiveListener.onActive();
381 | }
382 | }
383 | });
384 |
385 | animatorSet.playTogether(positionAnimator, widthAnimator);
386 | animatorSet.start();
387 | }
388 |
389 | private void moveButtonBack() {
390 | final ValueAnimator positionAnimator =
391 | ValueAnimator.ofFloat(swipeButtonInner.getX(), 0);
392 | positionAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
393 | positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
394 | @Override
395 | public void onAnimationUpdate(ValueAnimator animation) {
396 | float x = (Float) positionAnimator.getAnimatedValue();
397 | swipeButtonInner.setX(x);
398 | setTrailingEffect();
399 | }
400 | });
401 |
402 | positionAnimator.addListener(new AnimatorListenerAdapter() {
403 | @Override
404 | public void onAnimationEnd(Animator animation) {
405 | super.onAnimationEnd(animation);
406 | if (layer!=null) {
407 | layer.setVisibility(View.GONE);
408 | }
409 | }
410 | });
411 |
412 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(
413 | centerText, "alpha", 1);
414 |
415 | positionAnimator.setDuration(200);
416 |
417 | AnimatorSet animatorSet = new AnimatorSet();
418 | animatorSet.playTogether(objectAnimator, positionAnimator);
419 | animatorSet.start();
420 | }
421 |
422 | private void collapseButton() {
423 | int finalWidth;
424 |
425 | if (collapsedWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
426 | finalWidth = swipeButtonInner.getHeight();
427 | } else {
428 | finalWidth = collapsedWidth;
429 | }
430 |
431 | final ValueAnimator widthAnimator = ValueAnimator.ofInt(swipeButtonInner.getWidth(), finalWidth);
432 |
433 | widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
434 | @Override
435 | public void onAnimationUpdate(ValueAnimator animation) {
436 | ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
437 | params.width = (Integer) widthAnimator.getAnimatedValue();
438 | swipeButtonInner.setLayoutParams(params);
439 | setTrailingEffect();
440 | }
441 | });
442 |
443 | widthAnimator.addListener(new AnimatorListenerAdapter() {
444 | @Override
445 | public void onAnimationEnd(Animator animation) {
446 | super.onAnimationEnd(animation);
447 | active = false;
448 | swipeButtonInner.setImageDrawable(disabledDrawable);
449 | if (onStateChangeListener != null) {
450 | onStateChangeListener.onStateChange(active);
451 | }
452 | if (layer!=null) {
453 | layer.setVisibility(View.GONE);
454 | }
455 | }
456 | });
457 |
458 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(
459 | centerText, "alpha", 1);
460 |
461 | AnimatorSet animatorSet = new AnimatorSet();
462 |
463 | animatorSet.playTogether(objectAnimator, widthAnimator);
464 | animatorSet.start();
465 | }
466 |
467 | public void setEnabledStateNotAnimated() {
468 | swipeButtonInner.setX(0);
469 |
470 | ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
471 | params.width = ViewGroup.LayoutParams.MATCH_PARENT;
472 | swipeButtonInner.setLayoutParams(params);
473 |
474 | swipeButtonInner.setImageDrawable(enabledDrawable);
475 | active = true;
476 | centerText.setAlpha(0);
477 | }
478 |
479 | public void setDisabledStateNotAnimated() {
480 | ViewGroup.LayoutParams params = swipeButtonInner.getLayoutParams();
481 | params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
482 |
483 | collapsedWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
484 |
485 | swipeButtonInner.setImageDrawable(disabledDrawable);
486 | active = false;
487 | centerText.setAlpha(1);
488 |
489 | swipeButtonInner.setPadding((int) buttonLeftPadding,
490 | (int) buttonTopPadding,
491 | (int) buttonRightPadding,
492 | (int) buttonBottomPadding);
493 |
494 | swipeButtonInner.setLayoutParams(params);
495 | }
496 |
497 | private void setTrailingEffect() {
498 | if (trailEnabled) {
499 | layer.setVisibility(View.VISIBLE);
500 | layer.setLayoutParams(new RelativeLayout.LayoutParams(
501 | (int) (swipeButtonInner.getX() + swipeButtonInner.getWidth() / 3), centerText.getHeight()));
502 | }
503 | }
504 |
505 | public void setTrailBackground(@NonNull Drawable trailingDrawable) {
506 | if (trailEnabled) {
507 | layer.setBackground(trailingDrawable);
508 | }
509 | }
510 |
511 | public void toggleState() {
512 | if (isActive()) {
513 | collapseButton();
514 | } else {
515 | expandButton();
516 | }
517 | }
518 |
519 | public void setCenterTextColor(Context context, int color) {
520 | centerText.setTextColor(context.getResources().getColor(color));
521 | }
522 | }
523 |
--------------------------------------------------------------------------------
/swipe-button/src/main/java/com/ebanx/swipebtn/TouchUtils.java:
--------------------------------------------------------------------------------
1 | package com.ebanx.swipebtn;
2 |
3 | import android.view.MotionEvent;
4 | import android.view.View;
5 |
6 | final class TouchUtils {
7 | private TouchUtils() {
8 | }
9 |
10 | static boolean isTouchOutsideInitialPosition(MotionEvent event, View view) {
11 | return event.getX() > view.getX() + view.getWidth();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/swipe-button/src/main/res/drawable/shape_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/swipe-button/src/main/res/drawable/shape_rounded.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/swipe-button/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/swipe-button/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | swipebtn
3 |
4 | If you set trail enabled, you must set a value to button_trail_drawable.
5 |
6 |
--------------------------------------------------------------------------------