diff --git a/README.md b/README.md
index 20872bc..db35e18 100644
--- a/README.md
+++ b/README.md
@@ -1,104 +1,106 @@
-# ProSwipeButton
-A swipe button for Android with a circular progress bar for async operations
-
-
-# Gradle
-```
-dependencies {
- ...
- compile 'in.shadowfax:proswipebutton:1.1'
-}
-```
-
-# Usage
-1. In your XML layout file, add this custom view
-```xml
-
-```
-
-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
-
-```
-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
+
+
+
+# Gradle
+```
+dependencies {
+ ...
+ implementation 'smart.ui:proswipebutton:1.3.2'
+}
+```
+
+# Usage
+1. In your XML layout file, add this custom view
+```xml
+
+```
+
+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
+
+```
+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.
```
diff --git a/app/src/androidTest/java/in/shadowfax/proswipebutton_app/ExampleInstrumentedTest.java b/app/src/androidTest/java/smart/ui/proswipebutton_app/ExampleInstrumentedTest.java
similarity index 94%
rename from app/src/androidTest/java/in/shadowfax/proswipebutton_app/ExampleInstrumentedTest.java
rename to app/src/androidTest/java/smart/ui/proswipebutton_app/ExampleInstrumentedTest.java
index 74d3848..5df2af9 100644
--- a/app/src/androidTest/java/in/shadowfax/proswipebutton_app/ExampleInstrumentedTest.java
+++ b/app/src/androidTest/java/smart/ui/proswipebutton_app/ExampleInstrumentedTest.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton_app;
+package smart.ui.proswipebutton_app;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2eec2dc..d6e42c0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="smart.ui.proswipebutton_app">
-
+
diff --git a/app/src/main/java/in/shadowfax/proswipebutton_app/MainActivity.java b/app/src/main/java/smart/ui/proswipebutton_app/MainActivity.java
similarity index 54%
rename from app/src/main/java/in/shadowfax/proswipebutton_app/MainActivity.java
rename to app/src/main/java/smart/ui/proswipebutton_app/MainActivity.java
index 820f489..e65339b 100644
--- a/app/src/main/java/in/shadowfax/proswipebutton_app/MainActivity.java
+++ b/app/src/main/java/smart/ui/proswipebutton_app/MainActivity.java
@@ -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 {
@@ -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() {
@@ -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);
+ }
+ });
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 017f510..7bd7175 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -5,16 +5,16 @@
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">
-
-
+
+
+
+
diff --git a/proswipebutton/src/test/java/in/shadowfax/proswipebutton/ExampleUnitTest.java b/app/src/test/java/smart/ui/proswipebutton_app/ExampleUnitTest.java
similarity index 90%
rename from proswipebutton/src/test/java/in/shadowfax/proswipebutton/ExampleUnitTest.java
rename to app/src/test/java/smart/ui/proswipebutton_app/ExampleUnitTest.java
index 612e102..b5491bc 100644
--- a/proswipebutton/src/test/java/in/shadowfax/proswipebutton/ExampleUnitTest.java
+++ b/app/src/test/java/smart/ui/proswipebutton_app/ExampleUnitTest.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton;
+package smart.ui.proswipebutton_app;
import org.junit.Test;
diff --git a/demo.gif b/demo.gif
new file mode 100644
index 0000000..5ea4df8
Binary files /dev/null and b/demo.gif differ
diff --git a/proSwipeButton_demo.gif b/proSwipeButton_demo.gif
deleted file mode 100644
index 248092b..0000000
Binary files a/proSwipeButton_demo.gif and /dev/null differ
diff --git a/proswipebutton/build.gradle b/proswipebutton/build.gradle
index 0e3f990..53ee098 100644
--- a/proswipebutton/build.gradle
+++ b/proswipebutton/build.gradle
@@ -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 = 'ishaan.garg@shadowfax.in'
+ developerName = 'Jefry Jacky'
+ developerEmail = 'jefryjacky@gmail.com'
licenseName = 'The MIT License (MIT)'
licenseUrl = 'https://opensource.org/licenses/MIT'
@@ -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"
diff --git a/proswipebutton/src/androidTest/java/in/shadowfax/proswipebutton/ExampleInstrumentedTest.java b/proswipebutton/src/androidTest/java/smart/ui/proswipebutton/ExampleInstrumentedTest.java
similarity index 95%
rename from proswipebutton/src/androidTest/java/in/shadowfax/proswipebutton/ExampleInstrumentedTest.java
rename to proswipebutton/src/androidTest/java/smart/ui/proswipebutton/ExampleInstrumentedTest.java
index 2644c4f..941cb82 100644
--- a/proswipebutton/src/androidTest/java/in/shadowfax/proswipebutton/ExampleInstrumentedTest.java
+++ b/proswipebutton/src/androidTest/java/smart/ui/proswipebutton/ExampleInstrumentedTest.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton;
+package smart.ui.proswipebutton;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
diff --git a/proswipebutton/src/main/AndroidManifest.xml b/proswipebutton/src/main/AndroidManifest.xml
index e18b972..332fed1 100644
--- a/proswipebutton/src/main/AndroidManifest.xml
+++ b/proswipebutton/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="smart.ui.proswipebutton">
diff --git a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/Constants.java b/proswipebutton/src/main/java/smart/ui/proswipebutton/Constants.java
similarity index 79%
rename from proswipebutton/src/main/java/in/shadowfax/proswipebutton/Constants.java
rename to proswipebutton/src/main/java/smart/ui/proswipebutton/Constants.java
index d00b802..413e74d 100644
--- a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/Constants.java
+++ b/proswipebutton/src/main/java/smart/ui/proswipebutton/Constants.java
@@ -1,6 +1,6 @@
-package in.shadowfax.proswipebutton;
+package smart.ui.proswipebutton;
-import static in.shadowfax.proswipebutton.UiUtils.dpToPx;
+import static smart.ui.proswipebutton.UiUtils.dpToPx;
/**
* Created by shadow-admin on 22/2/18.
diff --git a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/ProSwipeButton.java b/proswipebutton/src/main/java/smart/ui/proswipebutton/ProSwipeButton.java
similarity index 81%
rename from proswipebutton/src/main/java/in/shadowfax/proswipebutton/ProSwipeButton.java
rename to proswipebutton/src/main/java/smart/ui/proswipebutton/ProSwipeButton.java
index 11a61e9..a30931d 100644
--- a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/ProSwipeButton.java
+++ b/proswipebutton/src/main/java/smart/ui/proswipebutton/ProSwipeButton.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton;
+package smart.ui.proswipebutton;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
@@ -29,14 +29,14 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
-import static in.shadowfax.proswipebutton.Constants.BTN_INIT_RADIUS;
-import static in.shadowfax.proswipebutton.Constants.BTN_MORPHED_RADIUS;
-import static in.shadowfax.proswipebutton.Constants.DEFAULT_SWIPE_DISTANCE;
-import static in.shadowfax.proswipebutton.Constants.DEFAULT_TEXT_SIZE;
-import static in.shadowfax.proswipebutton.Constants.MORPH_ANIM_DURATION;
-import static in.shadowfax.proswipebutton.UiUtils.animateFadeHide;
-import static in.shadowfax.proswipebutton.UiUtils.animateFadeShow;
-import static in.shadowfax.proswipebutton.UiUtils.dpToPx;
+import static smart.ui.proswipebutton.Constants.BTN_INIT_RADIUS;
+import static smart.ui.proswipebutton.Constants.BTN_MORPHED_RADIUS;
+import static smart.ui.proswipebutton.Constants.DEFAULT_SWIPE_DISTANCE;
+import static smart.ui.proswipebutton.Constants.DEFAULT_TEXT_SIZE;
+import static smart.ui.proswipebutton.Constants.MORPH_ANIM_DURATION;
+import static smart.ui.proswipebutton.UiUtils.animateFadeHide;
+import static smart.ui.proswipebutton.UiUtils.animateFadeShow;
+import static smart.ui.proswipebutton.UiUtils.dpToPx;
/**
* Created by shadow-admin on 24/10/17.
@@ -72,6 +72,7 @@ public class ProSwipeButton extends RelativeLayout {
@Nullable
private OnSwipeListener swipeListener = null;
private float swipeDistance = DEFAULT_SWIPE_DISTANCE;
+ private boolean reverse;
public ProSwipeButton(Context context) {
super(context);
@@ -107,6 +108,7 @@ private void setAttrs(Context context, AttributeSet attrs) {
arrowColorInt = a.getColor(R.styleable.ProSwipeButton_arrow_color, ContextCompat.getColor(context, R.color.proswipebtn_translucent_white));
btnRadius = a.getFloat(R.styleable.ProSwipeButton_btn_radius, BTN_INIT_RADIUS);
textSize = a.getDimensionPixelSize(R.styleable.ProSwipeButton_text_size, (int) DEFAULT_TEXT_SIZE);
+ reverse = a.getBoolean(R.styleable.ProSwipeButton_reverse, false);
} finally {
a.recycle();
}
@@ -127,6 +129,14 @@ protected void onFinishInflate() {
arrow1 = view.findViewById(R.id.iv_arrow1);
arrow2 = view.findViewById(R.id.iv_arrow2);
+ if(reverse){
+ arrow1.setScaleX(-1);
+ arrow2.setScaleX(-1);
+ final RelativeLayout.LayoutParams layoutParams = (LayoutParams) arrowHintContainer.getLayoutParams();
+ layoutParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
+ arrowHintContainer.setLayoutParams(layoutParams);
+ }
+
tintArrowHint();
contentTv.setText(btnText);
contentTv.setTextColor(textColorInt);
@@ -148,21 +158,17 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
case MotionEvent.ACTION_MOVE:
// Movement logic here
- if (event.getX() > arrowHintContainer.getWidth() / 2 &&
- event.getX() + arrowHintContainer.getWidth() / 2 < getWidth() &&
- (event.getX() < arrowHintContainer.getX() + arrowHintContainer.getWidth() || arrowHintContainer.getX() != 0)) {
+ if (shouldMoveTheHint(event)) {
// snaps the hint to user touch, only if the touch is within hint width or if it has already been displaced
arrowHintContainer.setX(event.getX() - arrowHintContainer.getWidth() / 2);
}
- if (arrowHintContainer.getX() + arrowHintContainer.getWidth() > getWidth() &&
- arrowHintContainer.getX() + arrowHintContainer.getWidth() / 2 < getWidth()) {
+ if (isReachingMaximum()) {
// allows the hint to go up to a max of btn container width
arrowHintContainer.setX(getWidth() - arrowHintContainer.getWidth());
}
- if (event.getX() < arrowHintContainer.getWidth() / 2 &&
- arrowHintContainer.getX() > 0) {
+ if (isReachingMinimum(event)) {
// allows the hint to go up to a min of btn container starting
arrowHintContainer.setX(0);
}
@@ -170,10 +176,10 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
case MotionEvent.ACTION_UP:
//Release logic here
- if (arrowHintContainer.getX() + arrowHintContainer.getWidth() > getWidth() * swipeDistance) {
+ if (isPerformSuccessfulySwipe()) {
// swipe completed, fly the hint away!
performSuccessfulSwipe();
- } else if (arrowHintContainer.getX() <= 0) {
+ } else if (isClickWithoutSwipe()) {
// upon click without swipe
startFwdAnim();
} else {
@@ -188,6 +194,49 @@ public boolean onTouch(View v, MotionEvent event) {
});
}
+ private boolean shouldMoveTheHint(MotionEvent event){
+ boolean insideMovingRange = event.getX() > arrowHintContainer.getWidth() / 2 &&
+ event.getX() + arrowHintContainer.getWidth() / 2 < getWidth();
+ if(reverse){
+ return insideMovingRange &&
+ (event.getX() > arrowHintContainer.getX() || arrowHintContainer.getX() != getWidth() - arrowHintContainer.getWidth());
+ } else {
+ return insideMovingRange &&
+ (event.getX() < arrowHintContainer.getX() + arrowHintContainer.getWidth() || arrowHintContainer.getX() != 0);
+ }
+ }
+
+ private boolean isReachingMaximum(){
+ return arrowHintContainer.getX() + arrowHintContainer.getWidth() > getWidth() &&
+ arrowHintContainer.getX() + arrowHintContainer.getWidth() / 2 < getWidth();
+ }
+
+ private boolean isReachingMinimum(MotionEvent event){
+ if(reverse) {
+ return arrowHintContainer.getX() < arrowHintContainer.getWidth() / 2 &&
+ arrowHintContainer.getX() > 0;
+ } else {
+ return event.getX() < arrowHintContainer.getWidth() / 2 &&
+ arrowHintContainer.getX() > 0;
+ }
+ }
+
+ private boolean isPerformSuccessfulySwipe(){
+ if(reverse){
+ return arrowHintContainer.getX() < getWidth() - (getWidth() * swipeDistance);
+ } else {
+ return arrowHintContainer.getX() + arrowHintContainer.getWidth() > getWidth() * swipeDistance;
+ }
+ }
+
+ private boolean isClickWithoutSwipe(){
+ if(reverse){
+ return arrowHintContainer.getX() >= getWidth() - arrowHintContainer.getWidth();
+ } else {
+ return arrowHintContainer.getX() <= 0;
+ }
+ }
+
private void performSuccessfulSwipe() {
if (swipeListener != null)
swipeListener.onSwipeConfirm();
@@ -202,7 +251,8 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
private void animateHintBack() {
final ValueAnimator positionAnimator =
- ValueAnimator.ofFloat(arrowHintContainer.getX(), 0);
+ reverse ? ValueAnimator.ofFloat(arrowHintContainer.getX(), getWidth() - arrowHintContainer.getWidth())
+ : ValueAnimator.ofFloat(arrowHintContainer.getX(), 0);
positionAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
@@ -218,7 +268,9 @@ public void onAnimationUpdate(ValueAnimator animation) {
private void startFwdAnim() {
if (isEnabled()) {
- TranslateAnimation animation = new TranslateAnimation(0, getMeasuredWidth(), 0, 0);
+ TranslateAnimation animation =
+ reverse ? new TranslateAnimation(0, 0 - getMeasuredWidth(), 0, 0)
+ : new TranslateAnimation(0, getMeasuredWidth(), 0, 0);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setDuration(1000);
animation.setAnimationListener(new Animation.AnimationListener() {
@@ -245,7 +297,9 @@ public void onAnimationRepeat(Animation animation) {
* animate entry of hint from the left-most edge
*/
private void startHintInitAnim() {
- TranslateAnimation anim = new TranslateAnimation(-arrowHintContainer.getWidth(), 0, 0, 0);
+ TranslateAnimation anim =
+ reverse ? new TranslateAnimation(arrowHintContainer.getWidth(), 0, 0, 0)
+ : new TranslateAnimation(-arrowHintContainer.getWidth(), 0, 0, 0);
anim.setDuration(500);
arrowHintContainer.startAnimation(anim);
}
@@ -382,7 +436,7 @@ public void showResultIcon(boolean isSuccess, boolean shouldReset) {
public void run() {
animateFadeHide(context, failureIcon);
morphToRect();
- arrowHintContainer.setX(0);
+ arrowHintContainer.setX(reverse ?getWidth() - arrowHintContainer.getWidth() :0);
animateFadeShow(context, arrowHintContainer);
animateFadeShow(context, contentTv);
}
diff --git a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/UiUtils.java b/proswipebutton/src/main/java/smart/ui/proswipebutton/UiUtils.java
similarity index 96%
rename from proswipebutton/src/main/java/in/shadowfax/proswipebutton/UiUtils.java
rename to proswipebutton/src/main/java/smart/ui/proswipebutton/UiUtils.java
index 992fb7d..956739a 100644
--- a/proswipebutton/src/main/java/in/shadowfax/proswipebutton/UiUtils.java
+++ b/proswipebutton/src/main/java/smart/ui/proswipebutton/UiUtils.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton;
+package smart.ui.proswipebutton;
import android.content.Context;
import android.content.res.Resources;
diff --git a/proswipebutton/src/main/res/values/attrs.xml b/proswipebutton/src/main/res/values/attrs.xml
index c91adbc..ff1d233 100644
--- a/proswipebutton/src/main/res/values/attrs.xml
+++ b/proswipebutton/src/main/res/values/attrs.xml
@@ -7,5 +7,6 @@
+
\ No newline at end of file
diff --git a/app/src/test/java/in/shadowfax/proswipebutton_app/ExampleUnitTest.java b/proswipebutton/src/test/java/smart/ui/proswipebutton/ExampleUnitTest.java
similarity index 89%
rename from app/src/test/java/in/shadowfax/proswipebutton_app/ExampleUnitTest.java
rename to proswipebutton/src/test/java/smart/ui/proswipebutton/ExampleUnitTest.java
index f38741b..b3e0543 100644
--- a/app/src/test/java/in/shadowfax/proswipebutton_app/ExampleUnitTest.java
+++ b/proswipebutton/src/test/java/smart/ui/proswipebutton/ExampleUnitTest.java
@@ -1,4 +1,4 @@
-package in.shadowfax.proswipebutton_app;
+package smart.ui.proswipebutton;
import org.junit.Test;