mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Added quest actions
This commit is contained in:
parent
057b734ee5
commit
a020bd6f2d
5 changed files with 19 additions and 5 deletions
|
|
@ -127,6 +127,8 @@
|
|||
<intent-filter>
|
||||
<action android:name="@string/accept_party_invite"/>
|
||||
<action android:name="@string/reject_party_invite"/>
|
||||
<action android:name="@string/accept_quest_invite"/>
|
||||
<action android:name="@string/reject_quest_invite"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receivers.TaskAlarmBootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class HabiticaFirebaseMessagingService extends FirebaseMessagingService {
|
|||
@Override
|
||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
||||
Log.d("test", "Notification Message Body: " + remoteMessage.getNotification().getBody());
|
||||
Log.d("test", "Notification Message Body: " + remoteMessage.getData().toString());
|
||||
Log.d("test", "Notification Message Body: " + remoteMessage.getData().get("identifier"));
|
||||
|
||||
PushNotificationManager pushNotificationManager = PushNotificationManager.getInstance(this);
|
||||
pushNotificationManager.displayNotification(remoteMessage);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class PushNotificationManager {
|
|||
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 = "questInvitation";
|
||||
public static String QUEST_BEGUN_PUSH_NOTIFICATION_KEY = "Your Quest has Begun";
|
||||
public static String QUEST_BEGUN_PUSH_NOTIFICATION_KEY = "questStarted";
|
||||
|
||||
@Inject
|
||||
public APIHelper apiHelper;
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ public class QuestInviteLocalNotification implements HabiticaLocalNotification {
|
|||
);
|
||||
notificationBuilder.addAction(R.drawable.ic_gryphon, "Accept", pendingIntentAccept);
|
||||
|
||||
Intent rejectInviteIntent = new Intent();
|
||||
Intent rejectInviteIntent = new Intent(context, LocalNotificationActionReceiver.class);
|
||||
rejectInviteIntent.setAction(res.getString(R.string.reject_quest_invite));
|
||||
PendingIntent pendingIntentReject = PendingIntent.getBroadcast(
|
||||
context,
|
||||
2000,
|
||||
acceptInviteIntent,
|
||||
rejectInviteIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
);
|
||||
notificationBuilder.addAction(R.drawable.ic_gryphon, "Reject", pendingIntentReject);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class LocalNotificationActionReceiver extends BroadcastReceiver implement
|
|||
|
||||
private void handleLocalNotificationAction(String action) {
|
||||
//@TODO: This is a good place for a factory and event emitter pattern
|
||||
|
||||
Log.v("test", action);
|
||||
if (action.equals(this.resources.getString(R.string.accept_party_invite))) {
|
||||
if (this.user.getInvitations().getParty() == null) return;
|
||||
String partyId = this.user.getInvitations().getParty().getId();
|
||||
|
|
@ -58,6 +58,18 @@ public class LocalNotificationActionReceiver extends BroadcastReceiver implement
|
|||
apiHelper.apiService.rejectGroupInvite(partyId)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {}, throwable -> {});
|
||||
} else if (action.equals(this.resources.getString(R.string.accept_quest_invite))) {
|
||||
if (this.user.getParty() == null) return;
|
||||
String partyId = this.user.getParty().getId();
|
||||
apiHelper.apiService.acceptQuest(partyId)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {}, throwable -> {});
|
||||
} else if (action.equals(this.resources.getString(R.string.reject_quest_invite))) {
|
||||
if (this.user.getParty() == null) return;
|
||||
String partyId = this.user.getParty().getId();
|
||||
apiHelper.apiService.rejectQuest(partyId)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(aVoid -> {}, throwable -> {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue