diff --git a/Habitica/res/values/strings.xml b/Habitica/res/values/strings.xml
index a80079ffc..f8ea6fd5a 100644
--- a/Habitica/res/values/strings.xml
+++ b/Habitica/res/values/strings.xml
@@ -377,6 +377,10 @@ To start, which parts of your life do you want to improve?
ACCEPT_PARTY_INVITE
- ACCEPT_PARTY_INVITE
+ REJECT_PARTY_INVITE
+ ACCEPT_GUILD_INVITE
+ REJECT_GUILD_INVITE
+ ACCEPT_QUEST_INVITE
+ REJECT_QUEST_INVITE
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/GuildInviteLocalNotification.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/GuildInviteLocalNotification.java
new file mode 100644
index 000000000..b259874ab
--- /dev/null
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/GuildInviteLocalNotification.java
@@ -0,0 +1,56 @@
+package com.habitrpg.android.habitica.helpers.notifications;
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.support.v4.app.NotificationCompat;
+
+import com.habitrpg.android.habitica.R;
+import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver;
+
+/**
+ * Created by keithholliday on 7/1/16.
+ */
+public class GuildInviteLocalNotification implements HabiticaLocalNotification {
+ @Override
+ public void notifyLocally(Context context, String title, String message) {
+ Uri path = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+
+ NotificationCompat.Builder notificationBuilder =
+ new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.ic_gryphon)
+ .setContentTitle(title)
+ .setContentText(message)
+ .setAutoCancel(true)
+ .setSound(path);
+
+ Resources res = context.getResources();
+
+ Intent acceptInviteIntent = new Intent(context, LocalNotificationActionReceiver.class);
+ acceptInviteIntent.setAction(res.getString(R.string.accept_guild_invite));
+ PendingIntent pendingIntentAccept = PendingIntent.getBroadcast(
+ context,
+ 3000,
+ acceptInviteIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT
+ );
+ notificationBuilder.addAction(R.drawable.ic_gryphon, "Accept", pendingIntentAccept);
+
+ Intent rejectInviteIntent = new Intent();
+ rejectInviteIntent.setAction(res.getString(R.string.reject_guild_invite));
+ PendingIntent pendingIntentReject = PendingIntent.getBroadcast(
+ context,
+ 2000,
+ acceptInviteIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT
+ );
+ notificationBuilder.addAction(R.drawable.ic_gryphon, "Reject", pendingIntentReject);
+
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
+ notificationManager.notify(10, notificationBuilder.build());
+ }
+}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java
index c5da1e695..9cc361ed4 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java
@@ -19,6 +19,12 @@ public class HabiticaLocalNotificationFactory {
return new ReceivedGemsGiftLocalNotification();
} else if (notificationType.contains(PushNotificationManager.RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY)) {
return new ReceivedSubscriptionGiftLocalNotification();
+ } else if (notificationType.contains(PushNotificationManager.GUILD_INVITE_PUSH_NOTIFICATION_KEY)) {
+ return new GuildInviteLocalNotification();
+ } else if (notificationType.contains(PushNotificationManager.QUEST_INVITE_PUSH_NOTIFICATION_KEY)) {
+ return new QuestInviteLocalNotification();
+ } else if (notificationType.contains(PushNotificationManager.QUEST_BEGUN_PUSH_NOTIFICATION_KEY)) {
+ return new QuestBegunLocalNotification();
}
return null;
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.java
index fbfc9d612..d3cf80124 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.java
@@ -24,9 +24,12 @@ public class PushNotificationManager {
private static PushNotificationManager instance = null;
private static String DEVICE_TOKEN_PREFERENCE_STRING = "device-token-preference-string";
public static String PARTY_INVITE_PUSH_NOTIFICATION_KEY = "Invited To Party";
- public static String RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY = "New Message from test33@test.com:";
+ public static String RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY = "New Message from";
public static String RECEIVED_GEMS_PUSH_NOTIFICATION_KEY = "Gems";
public static String RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY = "Subscription";
+ public static String GUILD_INVITE_PUSH_NOTIFICATION_KEY = "Guild";
+ public static String QUEST_INVITE_PUSH_NOTIFICATION_KEY = "Quest Invitation";
+ public static String QUEST_BEGUN_PUSH_NOTIFICATION_KEY = "Your Quest has Begun";
@Inject
public APIHelper apiHelper;
@@ -103,6 +106,12 @@ public class PushNotificationManager {
key = "preference_push_gifted_gems";
} else if (type.contains(RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY)) {
key = "preference_push_gifted_subscription";
+ } else if (type.contains(GUILD_INVITE_PUSH_NOTIFICATION_KEY)) {
+ key = "preference_push_invited_to_guild";
+ } else if (type.contains(QUEST_INVITE_PUSH_NOTIFICATION_KEY)) {
+ key = "preference_push_invited_to_quest";
+ } else if (type.contains(QUEST_BEGUN_PUSH_NOTIFICATION_KEY)) {
+ key = "preference_push_your_quest_has_begun";
}
return sharedPreferences.getBoolean(key, true);
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestBegunLocalNotification.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestBegunLocalNotification.java
new file mode 100644
index 000000000..579382076
--- /dev/null
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestBegunLocalNotification.java
@@ -0,0 +1,42 @@
+package com.habitrpg.android.habitica.helpers.notifications;
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.support.v4.app.NotificationCompat;
+
+import com.habitrpg.android.habitica.R;
+import com.habitrpg.android.habitica.ui.activities.MainActivity;
+
+/**
+ * Created by keithholliday on 7/1/16.
+ */
+public class QuestBegunLocalNotification implements HabiticaLocalNotification {
+ @Override
+ public void notifyLocally(Context context, String title, String message) {
+ Uri path = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+
+ NotificationCompat.Builder notificationBuilder =
+ new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.ic_gryphon)
+ .setContentTitle(title)
+ .setContentText(message)
+ .setAutoCancel(true)
+ .setSound(path);
+
+ Intent intent = new Intent(context, MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(
+ context,
+ 3000,
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT
+ );
+ notificationBuilder.setContentIntent(pendingIntent);
+
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
+ notificationManager.notify(10, notificationBuilder.build());
+ }
+}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestInviteLocalNotification.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestInviteLocalNotification.java
new file mode 100644
index 000000000..1dbb43639
--- /dev/null
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/QuestInviteLocalNotification.java
@@ -0,0 +1,56 @@
+package com.habitrpg.android.habitica.helpers.notifications;
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.support.v4.app.NotificationCompat;
+
+import com.habitrpg.android.habitica.R;
+import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver;
+
+/**
+ * Created by keithholliday on 7/1/16.
+ */
+public class QuestInviteLocalNotification implements HabiticaLocalNotification {
+ @Override
+ public void notifyLocally(Context context, String title, String message) {
+ Uri path = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+
+ NotificationCompat.Builder notificationBuilder =
+ new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.ic_gryphon)
+ .setContentTitle(title)
+ .setContentText(message)
+ .setAutoCancel(true)
+ .setSound(path);
+
+ Resources res = context.getResources();
+
+ Intent acceptInviteIntent = new Intent(context, LocalNotificationActionReceiver.class);
+ acceptInviteIntent.setAction(res.getString(R.string.accept_quest_invite));
+ PendingIntent pendingIntentAccept = PendingIntent.getBroadcast(
+ context,
+ 3000,
+ acceptInviteIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT
+ );
+ notificationBuilder.addAction(R.drawable.ic_gryphon, "Accept", pendingIntentAccept);
+
+ Intent rejectInviteIntent = new Intent();
+ rejectInviteIntent.setAction(res.getString(R.string.reject_quest_invite));
+ PendingIntent pendingIntentReject = PendingIntent.getBroadcast(
+ context,
+ 2000,
+ acceptInviteIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT
+ );
+ notificationBuilder.addAction(R.drawable.ic_gryphon, "Reject", pendingIntentReject);
+
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
+ notificationManager.notify(10, notificationBuilder.build());
+ }
+}