Skip to content

Reverse #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 104 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,104 +1,106 @@
# ProSwipeButton
A swipe button for Android with a circular progress bar for async operations

![](https://raw.githubusercontent.com/shadowfaxtech/proSwipeButton/master/proSwipeButton_demo.gif)

# Gradle
```
dependencies {
...
compile 'in.shadowfax:proswipebutton:1.1'
}
```

# Usage
1. In your XML layout file, add this custom view
```xml
<in.shadowfax.proswipebutton.ProSwipeButton
android:id="@+id/awesome_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:bg_color="@android:color/holo_blue_dark"
app:btn_text="Place Order" />
```

2. React to successful swipe on the button by adding a swipe listener
```java
ProSwipeButton proSwipeBtn = (ProSwipeButton) findViewById(R.id.awesome_btn);
proSwipeBtn.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
@Override
public void onSwipeConfirm() {
// user has swiped the btn. Perform your async operation now
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// task success! show TICK icon in ProSwipeButton
proSwipeBtn.showResultIcon(true); // false if task failed
}
}, 2000);
}
});
```

3. After the async task is completed, tell the ProSwipeButton to show a result icon.
Either a tick for a successful async operation or cross for a failed async operation.

```java
proSwipeBtn.showResultIcon(true); //if task succeeds
proSwipeBtn.showResultIcon(false); //if task fails
```

# Customizations

You can customize the button via XML or programatically.

```XML
<in.shadowfax.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:arrow_color="#33FFFFFF"
app:bg_color="@android:color/holo_blue_dark"
app:btn_radius="2dp"
app:btn_text="Place Order"
app:text_color="@android:color/white"
app:text_size="12sp" />
```
New: set distance the user must swipe to activate the button.

```JAVA
proswipebutton.setSwipeDistance(0.6f);
```

Feel free to raise feature requests via the issue tracker for more customizations or just send in a PR :)

# Sample
Clone the repository and check out the `app` module.

# License

```
MIT License

Copyright (c) 2017 Shadowfax Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# ProSwipeButton
A swipe button for Android with a circular progress bar for async operations

![](https://raw.githubusercontent.com/jefryjacky/proSwipeButton/master/demo.gif)

# Gradle
```
dependencies {
...
implementation 'smart.ui:proswipebutton:1.3.2'
}
```

# Usage
1. In your XML layout file, add this custom view
```xml
<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/awesome_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:bg_color="@android:color/holo_blue_dark"
app:btn_text="Place Order" />
```

2. React to successful swipe on the button by adding a swipe listener
```java
ProSwipeButton proSwipeBtn = (ProSwipeButton) findViewById(R.id.awesome_btn);
proSwipeBtn.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
@Override
public void onSwipeConfirm() {
// user has swiped the btn. Perform your async operation now
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// task success! show TICK icon in ProSwipeButton
proSwipeBtn.showResultIcon(true); // false if task failed
}
}, 2000);
}
});
```

3. After the async task is completed, tell the ProSwipeButton to show a result icon.
Either a tick for a successful async operation or cross for a failed async operation.

```java
proSwipeBtn.showResultIcon(true); //if task succeeds
proSwipeBtn.showResultIcon(false); //if task fails
```

# Customizations

You can customize the button via XML or programatically.

```XML
<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:arrow_color="#33FFFFFF"
app:bg_color="@android:color/holo_blue_dark"
app:btn_radius="2dp"
app:btn_text="Place Order"
app:text_color="@android:color/white"
app:text_size="12sp"
app:reverse="true" />
```
New: set distance the user must swipe to activate the button.

```JAVA
proswipebutton.setSwipeDistance(0.6f);
```

Feel free to raise feature requests via the issue tracker for more customizations or just send in a PR :)

# Sample
Clone the repository and check out the `app` module.

# License

```
MIT License

Copyright (c) 2019

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.shadowfax.proswipebutton_app;
package smart.ui.proswipebutton_app;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.shadowfax.proswipebutton_app">
package="smart.ui.proswipebutton_app">

<application
android:allowBackup="true"
Expand All @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="in.shadowfax.proswipebutton_app.MainActivity">
<activity android:name="smart.ui.proswipebutton_app.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package in.shadowfax.proswipebutton_app;
package smart.ui.proswipebutton_app;

import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import in.shadowfax.proswipebutton.ProSwipeButton;
import smart.ui.proswipebutton.ProSwipeButton;

public class MainActivity extends AppCompatActivity {

Expand All @@ -15,6 +15,8 @@ protected void onCreate(Bundle savedInstanceState) {

final ProSwipeButton proSwipeBtn = findViewById(R.id.proswipebutton_main);
final ProSwipeButton proSwipeBtnError = findViewById(R.id.proswipebutton_main_error);
final ProSwipeButton reverseProSwipeBtn = findViewById(R.id.proswipebutton_main_reverse);
final ProSwipeButton reverseProSwipeBtnError = findViewById(R.id.proswipebutton_main_reverse_error);
proSwipeBtn.setSwipeDistance(0.5f);

proSwipeBtn.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
Expand Down Expand Up @@ -42,5 +44,31 @@ public void run() {
}, 2000);
}
});

reverseProSwipeBtn.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
@Override
public void onSwipeConfirm() {
// user has swiped the btn. Perform your async operation now
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
reverseProSwipeBtn.showResultIcon(true, true);
}
}, 2000);
}
});

reverseProSwipeBtnError.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
@Override
public void onSwipeConfirm() {
// user has swiped the btn. Perform your async operation now
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
reverseProSwipeBtnError.showResultIcon(false, true);
}
}, 2000);
}
});
}
}
23 changes: 20 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,38 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="in.shadowfax.proswipebutton_app.MainActivity">
tools:context="smart.ui.proswipebutton_app.MainActivity">

<in.shadowfax.proswipebutton.ProSwipeButton
<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:btn_text="Place Order" />

<in.shadowfax.proswipebutton.ProSwipeButton
<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:bg_color="@android:color/holo_blue_dark"
app:btn_text="Place Order" />

<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main_reverse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:btn_text="Place Order"
app:reverse="true"/>

<smart.ui.proswipebutton.ProSwipeButton
android:id="@+id/proswipebutton_main_reverse_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:bg_color="@android:color/holo_blue_dark"
app:btn_text="Place Order"
app:reverse="true"/>

</LinearLayout>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.shadowfax.proswipebutton;
package smart.ui.proswipebutton_app;

import org.junit.Test;

Expand Down
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed proSwipeButton_demo.gif
Binary file not shown.
24 changes: 14 additions & 10 deletions proswipebutton/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
apply plugin: 'com.android.library'

ext {
bintrayRepo = 'proswipebutton'
bintrayName = 'proswipebutton'
bintrayRepo = 'UI'
bintrayName = 'proSwipeButton'

publishedGroupId = 'in.shadowfax'
publishedGroupId = 'smart.ui'
libraryName = 'proswipebutton'
artifact = 'proswipebutton'

libraryDescription = 'A swipe button with progress indicator for Android'

siteUrl = 'https://github.com/shadowfaxtech/proSwipeButton'
gitUrl = 'https://github.com/shadowfaxtech/proSwipeButton.git'
siteUrl = 'https://github.com/jefryjacky/proSwipeButton'
gitUrl = 'https://github.com/jefryjacky/proSwipeButton.git'

libraryVersion = '1.2'
libraryVersion = '1.3.2'

developerId = 'developerId'
developerName = 'Ishaan Garg'
developerEmail = '[email protected]'
developerName = 'Jefry Jacky'
developerEmail = '[email protected]'

licenseName = 'The MIT License (MIT)'
licenseUrl = 'https://opensource.org/licenses/MIT'
Expand All @@ -27,11 +27,15 @@ ext {
android {
compileSdkVersion 26

def majorVersion = 1
def minorVersion = 3
def releaseVersion = 2

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 6
versionName "1.2"
versionCode ((majorVersion * 1000000) + (minorVersion * 1000) + releaseVersion)
versionName majorVersion.toString() +"."+ minorVersion.toString() +"."+ releaseVersion.toString()
vectorDrawables.useSupportLibrary = true

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.shadowfax.proswipebutton;
package smart.ui.proswipebutton;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
Expand Down
2 changes: 1 addition & 1 deletion proswipebutton/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="in.shadowfax.proswipebutton">
package="smart.ui.proswipebutton">

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">
Expand Down
Loading