From 8e05975b10fa8092abe98ddaef6c551b367a4cd7 Mon Sep 17 00:00:00 2001 From: Kevin Murphy Date: Thu, 16 Feb 2017 14:40:48 +0000 Subject: [PATCH 1/2] Added option to stop icon pulsing. Added null check for activity in create method. Removed unneeded test classes --- .../main/java/com/tapadoo/alerter/Alert.java | 22 ++++++++++++---- .../java/com/tapadoo/alerter/Alerter.java | 17 ++++++++++++ .../example/ExampleInstrumentedTest.java | 26 ------------------- 3 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 app/src/androidTest/java/com/tapadoo/example/ExampleInstrumentedTest.java diff --git a/alerter/src/main/java/com/tapadoo/alerter/Alert.java b/alerter/src/main/java/com/tapadoo/alerter/Alert.java index 14f912b..610281c 100644 --- a/alerter/src/main/java/com/tapadoo/alerter/Alert.java +++ b/alerter/src/main/java/com/tapadoo/alerter/Alert.java @@ -30,7 +30,6 @@ * * @author Kevin Murphy, Tapadoo, Dublin, Ireland, Europe, Earth. * @since 26/01/2016 - * **/ public class Alert extends FrameLayout implements View.OnClickListener, Animation.AnimationListener { @@ -53,6 +52,8 @@ public class Alert extends FrameLayout implements View.OnClickListener, Animatio private long duration = DISPLAY_TIME_IN_SECONDS; + private boolean enableIconPulse = true; + /** * Flag to ensure we only set the margins once */ @@ -187,10 +188,12 @@ public void onAnimationStart(final Animation animation) { @Override public void onAnimationEnd(final Animation animation) { //Start the Icon Animation once the Alert is settled - try { - ivIcon.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.alerter_pulse)); - } catch (Exception ex) { - Log.e(getClass().getSimpleName(), Log.getStackTraceString(ex)); + if (enableIconPulse) { + try { + ivIcon.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.alerter_pulse)); + } catch (Exception ex) { + Log.e(getClass().getSimpleName(), Log.getStackTraceString(ex)); + } } //Start the Handler to clean up the Alert @@ -359,6 +362,15 @@ public void setDuration(final long duration) { this.duration = duration; } + /** + * Set if the Icon should pulse or not + * + * @param shouldPulse True if the icon should be animated + */ + public void pulseIcon(final boolean shouldPulse) { + this.enableIconPulse = shouldPulse; + } + /** * Get the screen height in pixels * diff --git a/alerter/src/main/java/com/tapadoo/alerter/Alerter.java b/alerter/src/main/java/com/tapadoo/alerter/Alerter.java index 30af499..c3146aa 100644 --- a/alerter/src/main/java/com/tapadoo/alerter/Alerter.java +++ b/alerter/src/main/java/com/tapadoo/alerter/Alerter.java @@ -40,6 +40,10 @@ private Alerter() { * @return This Alerter */ public static Alerter create(@NonNull final Activity activity) { + if (activity == null) { + throw new IllegalArgumentException("Activity cannot be null!"); + } + final Alerter alerter = new Alerter(); //Clear Current Alert, if one is Active @@ -215,6 +219,19 @@ public Alerter setDuration(@NonNull final long milliseconds) { return this; } + /** + * Enable or Disable Icon Pulse Animations + * + * @param pulse True if the icon should pulse + * @return This Alerter + */ + public Alerter enableIconPulse(final boolean pulse) { + if (getAlert() != null) { + getAlert().pulseIcon(pulse); + } + return this; + } + /** * Gets the Alert associated with the Alerter * diff --git a/app/src/androidTest/java/com/tapadoo/example/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/tapadoo/example/ExampleInstrumentedTest.java deleted file mode 100644 index a1ff518..0000000 --- a/app/src/androidTest/java/com/tapadoo/example/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.tapadoo.alerter; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumentation test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.tapadoo.alerter", appContext.getPackageName()); - } -} From 4b1fc3fde4750f06644aa65078c22a6dd6649313 Mon Sep 17 00:00:00 2001 From: Kevin Murphy Date: Thu, 16 Feb 2017 14:51:07 +0000 Subject: [PATCH 2/2] Bumped version number --- README.md | 2 +- alerter/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42ed3e7..92fc366 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ A work in progress... ```groovy dependecies { - compile 'com.tapadoo.android:alerter:1.0.0' + compile 'com.tapadoo.android:alerter:1.0.1' } ``` diff --git a/alerter/build.gradle b/alerter/build.gradle index 1e526e8..a4236f5 100644 --- a/alerter/build.gradle +++ b/alerter/build.gradle @@ -11,7 +11,7 @@ apply plugin: "maven-publish" apply from: rootProject.file('quality.gradle') def final String PACKAGE_NAME = "com.tapadoo.android" -def final String VERSION = "1.0.0" +def final String VERSION = "1.0.1" def final String DESCRIPTION = "An Android Alerting Library" def final String GITHUB_URL = "https://github.com/Tapadoo/Alerter"