A swipe button for Android with a circular progress bar for async operations

Overview

ProSwipeButton

A swipe button for Android with a circular progress bar for async operations

Gradle

dependencies {
    ...
    compile 'in.shadowfax:proswipebutton:1.2.2'
}

Usage

  1. In your XML layout file, add this custom view
<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" />
  1. React to successful swipe on the button by adding a swipe listener
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);
            }
        });
  1. 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.
proSwipeBtn.showResultIcon(true); //if task succeeds
proSwipeBtn.showResultIcon(false); //if task fails

Customizations

You can customize the button via XML or programatically.

<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.

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.
Comments
  • Reset to original state.

    Reset to original state.

    If operation is successful then it should reverse the button just like if the case is unsuccessful. "https://github.com/shadowfaxtech/proSwipeButton/issues/8" No solution yet? And can we use it for commercial with your license?

    opened by MAdnanIjaz 4
  • Need for a reset function

    Need for a reset function

    There is not method to reset the proSwipeButton. Once the full swipe has ended the button can not be reseted to the original state. This means every button can only be used once.

    enhancement good first issue 
    opened by rittermobile 4
  • package name issues;

    package name issues;

    Good moring/noon/afternoon/evening,I saw this View on VisualStudio NuGet ; I download this package and is something happend on my Project; It's seem like the package name changed by xamarin , became the In.ShadowFax; (Last word has been cut,because it's the same as view name )
    but the Register path it's still" in.shadowfax.proswipebutton.ProSwipeButton"; That different led to my Activity Crash.... Could U plz to change the package name or the view name to make them different; Tks...

    opened by YuAJio 2
  • customizing the swipe distance

    customizing the swipe distance

    The button works GREAT!! thanks a lot But the only thing that keeping us from using it is that the user has to swipe for a long distance which is a little annoying.

    Would love if we can change the 0.85 percentage in this line: if (arrowHintContainer.getX() + arrowHintContainer.getWidth() > getWidth() * 0.85)

    enhancement 
    opened by AhmedBassiouny 2
  • Continuous animation better?

    Continuous animation better?

    Amazing work!

    A quick consideration: Do you think it would be better to have the swipe continuously animate and give the user the ability to order just by tapping the button? Swiping requires learning a new gesture and would cause some confusion. You don't want to confuse the user when they are about to give you money!

    I really like the swipe animation but I think buttons should be clicked and swipe should not be required.

    Great library so far!

    enhancement 
    opened by searchy2 2
  • Reset button

    Reset button

    Ok, the proSwipeBtn.showResultIcon(false); function can reset the swipe button but this is strange. When the asyncTask is correct, we send proSwipeBtn.showResultIcon(true); with the check icon, and after some time we send proSwipeBtn.showResultIcon(false); and at that point, the red error icon appears, which is rather destabilizing. It would be nice to have a real proSwipe Button reset function. Thank you very much in anticipation for your help and your reply Alain

    opened by gibus27 1
  • Reset function too

    Reset function too

    Hi, I read the last issue about the reset function. I can't find the showResult(false) function to use like : myProSwipeButton.showResult(false); Have you any example ? Thank a lot. Alain

    opened by gibus27 1
  • v1.1

    v1.1

    1. morphToCircle() is now public so the btn can now be morphed to circle programmatically without the user swiping the button.

    2. Added new method: performOnSwipe() to perform a successful swipe programmatically.

    opened by ishaangarg 0
  • Customization of result icon shape

    Customization of result icon shape

    Would be great to have the option to customize the shape of the icon after the Async task completes so that it does not have to be a circle but, for example could expand back to the shape of the swipe button.

    opened by agforte 0
  • Button Not visible at run time. Studio Preview coming

    Button Not visible at run time. Studio Preview coming

    I have integrated your proswipebutton class and it works fine. I have tried to integrate the same in fragment activty unfortunately its showing white space. see the screen attached. in studio preview like this https://lh3.googleusercontent.com/-gXZlIf27480/XCSk6IYYEdI/AAAAAAAADO8/pH27_khJkc8lv1fet0x7kV7zmJOVfA-MwCL0BGAYYCw/h154/2018-12-27.png mobile preview like this https://lh3.googleusercontent.com/-369T0y7-cX0/XCSk7FeuNAI/AAAAAAAADPA/x1Jamo2S-oEnv9nzX0q1zcojowewEJ7LACL0BGAYYCw/h211/2018-12-27.png Please help me where am doing wrong.

    Needs Info 
    opened by RameshbabuJaga 1
Releases(v1.2.2)
  • v1.2.2(Jun 12, 2018)

  • v1.2.1(Jun 5, 2018)

  • v1.2(May 24, 2018)

    1. New: adding .setEnabled(false) on ProSwipeButton will now turn it grey, lower opacity & not animate the arrow forward on initialisation, if the button was initialised in a disabled state.
    2. New: On popular demand, we now have a new method .showResultIcon(boolean isSuccess, boolean shouldReset) to allow developer to expand / reset the button back again after showing a success or failure icon.
    Source code(tar.gz)
    Source code(zip)
  • 1.1(Mar 28, 2018)

    1. NEW: performOnSwipe() to programmatically swipe the button & call its attached onSwipeListener.
    2. morphToCircle() is now allowed so the button can be morphed without calling the attached onSwipeListener.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Mar 23, 2018)

    What's new?

    1. Swipe distance can now be configured from java
    2. Fix: Swipe hint arrow will no longer animate continuously if the parent layout has an animating view.

    What's broken?

    1. Small UI issue: When user swipes button & it changes to LOADING state, then the hint arrow is briefly visible while the loading circular progress bar is shown.
    Source code(tar.gz)
    Source code(zip)
Owner
Shadowfax Technologies
Logistics startup for end-to-end delivery solutions
Shadowfax Technologies
SwipeBack for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swipe gesture

SwipeBack SwipeBack is for Android Activities to do pretty the same as the android "back-button" will do, but in a really intuitive way by using a swi

Hannes Dorfmann 697 Dec 14, 2022
SystemUiController - Android Ui color controller (status bar, navigation bar)

SystemUiController Android system ui color controller (status bar, navigation bar) Download implementation "land.sungbin:systemuicontroller:${version}

Ji Sungbin 8 Dec 3, 2022
Utility functions to perform dynamic operations on Android.

Dynamic Utils A collection of static methods and packages to perform dynamic operations on Android 2.3 (API 9) and above. Since v0.4.0, it uses 26.x.x

Pranav Pandey 95 Dec 25, 2022
Pop animation with circular dust effect for any view updation

Popview-Android Pop animation with circular dust effect for any view updation Getting Started In your build.gradle dependencies { compile 'rb.popv

R B Krishna 489 Dec 28, 2022
Android Library to implement simple touch/tap/swipe gestures

SimpleFingerGestures An android library to implement simple 1 or 2 finger gestures easily Example Library The library is inside the libSFG folder Samp

Arnav Gupta 315 Dec 21, 2022
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

Jake Klinker 1.3k Nov 25, 2022
Android swipe-to-dismiss mini-library and sample code

Android Swipe-to-Dismiss Sample Code Sample code that shows how to make ListView or other views support the swipe-to-dismiss Android UI pattern. See t

Roman Nurik 1.3k Dec 29, 2022
Android jetpack compose swipe library

Swiper for Android Jetpack Compose Android Jetpack Compose swipe library. Downlo

null 32 Dec 10, 2022
A player/ recorder visualizer with the swipe to seek functionality.

iiVisu A player/ recorder visualizer with the swipe to seek functionality. Demo Setup Step 1. Add the JitPack repository to your build file Add it in

Iman Irandoost 126 Nov 25, 2022
A simple implementation of swipe card like StreetView

A simple implementation of swipe card like StreetView!! DONATIONS This project needs you! If you would like to support this project's further developm

Michele Lacorte 831 Jan 4, 2023
Card with swipe options in Jetpack Compose

SwipeableActionCard Card with swipe options in Jetpack Compose Tutorial: Click Here Import SwipeableActionCard library Add this in project level build

Harsh Mahajan 1 Nov 23, 2021
ExpandableSelector is an Android library created to show a list of Button/ImageButton widgets inside a animated container which can be collapsed or expanded.

ExpandableSelector ExpandableSelector is an Android library created to show a list of Button/ImageButton widgets inside a animated container which can

Karumi 699 Nov 19, 2022
Squishy button effect with kotlin

Squishy Usage Add squishy() modifier on your composable element. Text( text = "Squishhhhyyyyy", modifier = Modifier .size(200.dp, 100.dp

null 43 Jul 9, 2022
A util for setting status bar style on Android App.

StatusBarUtil A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). 中文版点我 Sample Download StatusBarUtil-Demo Chang

Jaeger 8.8k Jan 7, 2023
SmileyRating is a simple rating bar for android. It displays animated smileys as rating icon.

Smiley Rating SmileyRating is a simple rating bar for android. It displays animated smileys as rating icon. Drawn completely using android canvas Insp

Sujith Niraikulathan 1.1k Dec 22, 2022
An Index Side Bar With Wave Effect

WaveSideBar You can use WaveSideBar in the contacts page of your application. Refer to AlexLiuSheng/AnimSideBar. Screenshot Include the WaveSideBar to

郭佳哲 1.3k Dec 12, 2022
🪄 It's a library that helps you customize your notification bar

NotificationBarCustom ?? It's a library that helps you customize your notification bar Demo Contrast(white) Contrast(black) Transparent Setup Add it i

박상선 8 Sep 7, 2022
MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team

MIUI 原生通知图标 Fix the native notification bar icon function abandoned by the MIUI

Fankesyooni 189 Jan 4, 2023
Implementation of the fragment with the ability to display indeterminate progress indicator when you are waiting for the initial data.

Android-ProgressFragment Implementation of the fragment with the ability to display indeterminate progress indicator when you are waiting for the init

Evgeny Shishkin 813 Nov 11, 2022