From e98eefe2cc3b8a220e89e9b7433d9539ea0e10e8 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Thu, 29 Oct 2015 16:38:50 +0100 Subject: [PATCH] Added notification for errors and warnings --- .../abit/notification/ErrorNotification.java | 41 +++++++++++++++++++ .../res/drawable/ic_notification_error.xml | 9 ++++ .../ic_notification_proof_of_work.xml | 9 ++++ .../res/drawable/ic_notification_warning.xml | 9 ++++ 4 files changed, 68 insertions(+) create mode 100644 app/src/main/java/ch/dissem/apps/abit/notification/ErrorNotification.java create mode 100644 app/src/main/res/drawable/ic_notification_error.xml create mode 100644 app/src/main/res/drawable/ic_notification_proof_of_work.xml create mode 100644 app/src/main/res/drawable/ic_notification_warning.xml diff --git a/app/src/main/java/ch/dissem/apps/abit/notification/ErrorNotification.java b/app/src/main/java/ch/dissem/apps/abit/notification/ErrorNotification.java new file mode 100644 index 0000000..d14aa78 --- /dev/null +++ b/app/src/main/java/ch/dissem/apps/abit/notification/ErrorNotification.java @@ -0,0 +1,41 @@ +package ch.dissem.apps.abit.notification; + +import android.content.Context; +import android.support.v7.app.NotificationCompat; + +import ch.dissem.apps.abit.R; + +/** + * Created by chrigu on 29.10.15. + */ +public class ErrorNotification extends AbstractNotification { + public static final int ERROR_NOTIFICATION_ID = 4; + + private NotificationCompat.Builder builder; + + public ErrorNotification(Context ctx) { + super(ctx); + builder = new NotificationCompat.Builder(ctx); + builder.setContentTitle(ctx.getString(R.string.app_name)) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + } + + public ErrorNotification setWarning(int resId, Object... args) { + builder.setSmallIcon(R.drawable.ic_notification_warning) + .setContentText(ctx.getString(resId, args)); + notification = builder.build(); + return this; + } + + public ErrorNotification setError(int resId, Object... args) { + builder.setSmallIcon(R.drawable.ic_notification_error) + .setContentText(ctx.getString(resId, args)); + notification = builder.build(); + return this; + } + + @Override + protected int getNotificationId() { + return ERROR_NOTIFICATION_ID; + } +} diff --git a/app/src/main/res/drawable/ic_notification_error.xml b/app/src/main/res/drawable/ic_notification_error.xml new file mode 100644 index 0000000..bc132bb --- /dev/null +++ b/app/src/main/res/drawable/ic_notification_error.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notification_proof_of_work.xml b/app/src/main/res/drawable/ic_notification_proof_of_work.xml new file mode 100644 index 0000000..c64f014 --- /dev/null +++ b/app/src/main/res/drawable/ic_notification_proof_of_work.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notification_warning.xml b/app/src/main/res/drawable/ic_notification_warning.xml new file mode 100644 index 0000000..0510991 --- /dev/null +++ b/app/src/main/res/drawable/ic_notification_warning.xml @@ -0,0 +1,9 @@ + + +