Skip to content

Commit

Permalink
Merge pull request Tapadoo#87 from Tapadoo/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
kpmmmurphy authored Sep 18, 2017
2 parents 82cb688 + 9ccf9ee commit 4e91375
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.

## 2.0.1 - 18/09/2017
* Added Progress Bar colour change methods
* Fixed crashes on icon loading

## 2.0.0 - 07/02/2017
* Added isShowing method
* Added additional icon setting methods
* Added styling methods
* added progress bar

## 1.0.9 - 27/06/2017
* Added Swipe to Dismiss
* Added setAlertBackgroundColor to allow the use of color ints
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all content.

```groovy
dependencies {
compile 'com.tapadoo.android:alerter:2.0.0'
compile 'com.tapadoo.android:alerter:2.0.1'
}
```

Expand Down Expand Up @@ -187,6 +187,7 @@ Alerter.create(ExampleActivity.this)
.setTitle("Alert Title")
.setText("Alert text...")
.enableProgress(true)
.setProgressColorRes(R.color.colorAccent)
.show();
```

Expand Down
4 changes: 0 additions & 4 deletions alerter/CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion alerter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "2.0.0"
def final String VERSION = "2.0.1"
def final String DESCRIPTION = "An Android Alerting Library"
def final String GITHUB_URL = "https://github.com/Tapadoo/Alerter"

Expand Down
29 changes: 26 additions & 3 deletions alerter/src/main/java/com/tapadoo/alerter/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.LightingColorFilter;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.annotation.StyleRes;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.content.res.AppCompatResources;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
Expand Down Expand Up @@ -45,6 +48,7 @@ public class Alert extends FrameLayout implements View.OnClickListener, Animatio
* The amount of time the alert will be visible on screen in seconds
*/
private static final long DISPLAY_TIME_IN_SECONDS = 3000;
private static final int MUL = 0xFF000000;

//UI
private FrameLayout flClickShield;
Expand Down Expand Up @@ -229,6 +233,8 @@ public void run() {
}

if (enableProgress && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
pbProgress.setVisibility(View.VISIBLE);

final ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 100);
valueAnimator.setDuration(duration);
valueAnimator.setInterpolator(new LinearInterpolator());
Expand Down Expand Up @@ -468,8 +474,7 @@ public ImageView getIcon() {
* @param iconId Drawable resource id of the icon to use in the Alert
*/
public void setIcon(@DrawableRes final int iconId) {
final Drawable iconDrawable = VectorDrawableCompat.create(getContext().getResources(), iconId, null);
ivIcon.setImageDrawable(iconDrawable);
ivIcon.setImageDrawable(AppCompatResources.getDrawable(getContext(), iconId));
}

/**
Expand Down Expand Up @@ -551,6 +556,24 @@ public void setEnableProgress(final boolean enableProgress) {
this.enableProgress = enableProgress;
}

/**
* Set the Progress bar color from a color resource
*
* @param color The color resource
*/
public void setProgressColorRes(@ColorRes final int color) {
pbProgress.getProgressDrawable().setColorFilter(new LightingColorFilter(MUL, ContextCompat.getColor(getContext(), color)));
}

/**
* Set the Progress bar color from a color resource
*
* @param color The color resource
*/
public void setProgressColorInt(@ColorInt final int color) {
pbProgress.getProgressDrawable().setColorFilter(new LightingColorFilter(MUL, color));
}

/**
* Set the alert's listener to be fired on the alert being fully shown
*
Expand Down
28 changes: 28 additions & 0 deletions alerter/src/main/java/com/tapadoo/alerter/Alerter.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,34 @@ public Alerter enableProgress(final boolean enable) {
return this;
}

/**
* Set the Progress bar color from a color resource
*
* @param color The color resource
* @return This Alerter
*/
public Alerter setProgressColorRes(@ColorRes final int color) {
if (getAlert() != null) {
getAlert().setProgressColorRes(color);
}

return this;
}

/**
* Set the Progress bar color from a color resource
*
* @param color The color resource
* @return This Alerter
*/
public Alerter setProgressColorInt(@ColorInt final int color) {
if (getAlert() != null) {
getAlert().setProgressColorInt(color);
}

return this;
}

/**
* Gets the Alert associated with the Alerter
*
Expand Down
1 change: 1 addition & 0 deletions alerter/src/main/res/layout/alerter_alert_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/alerter_progress_bar_size"
android:visibility="gone"
android:layout_gravity="bottom"
tools:progress="45"/>

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/tapadoo/example/ExampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void showAlertColoured() {
private void showAlertWithIcon() {
Alerter.create(ExampleActivity.this)
.setText("Alert text...")
.setIcon(R.drawable.alerter_ic_face)
.setIcon(R.drawable.alerter_ic_mail_outline)
.show();
}

Expand Down Expand Up @@ -168,6 +168,7 @@ private void showAlertWithProgress() {
.setTitle("Alert Title")
.setText("Alert text...")
.enableProgress(true)
.setProgressColorRes(R.color.colorPrimary)
.show();
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/alerter_ic_mail_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8l8,5 8,-5v10zM12,11L4,6h16l-8,5z"/>
</vector>

0 comments on commit 4e91375

Please sign in to comment.