poll notifications 2/3
fix notifications not showing for polls
This commit is contained in:
parent
3b96fb9bb7
commit
d55b7aac1b
|
@ -1079,6 +1079,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
editor.putBoolean(Helper.SET_NOTIF_ASK, set_push_notification.isChecked());
|
editor.putBoolean(Helper.SET_NOTIF_ASK, set_push_notification.isChecked());
|
||||||
editor.putBoolean(Helper.SET_NOTIF_MENTION, set_push_notification.isChecked());
|
editor.putBoolean(Helper.SET_NOTIF_MENTION, set_push_notification.isChecked());
|
||||||
editor.putBoolean(Helper.SET_NOTIF_SHARE, set_push_notification.isChecked());
|
editor.putBoolean(Helper.SET_NOTIF_SHARE, set_push_notification.isChecked());
|
||||||
|
editor.putBoolean(Helper.SET_NOTIF_POLL, set_push_notification.isChecked());
|
||||||
// editor.putBoolean(Helper.SET_NOTIF_HOMETIMELINE, set_push_hometimeline.isChecked());
|
// editor.putBoolean(Helper.SET_NOTIF_HOMETIMELINE, set_push_hometimeline.isChecked());
|
||||||
editor.putBoolean(Helper.SET_POPUP_PUSH, true);
|
editor.putBoolean(Helper.SET_POPUP_PUSH, true);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
|
@ -458,6 +458,7 @@ public class Helper {
|
||||||
MENTION,
|
MENTION,
|
||||||
BOOST,
|
BOOST,
|
||||||
FAV,
|
FAV,
|
||||||
|
POLL,
|
||||||
BACKUP,
|
BACKUP,
|
||||||
STORE,
|
STORE,
|
||||||
TOOT
|
TOOT
|
||||||
|
@ -1012,6 +1013,10 @@ public class Helper {
|
||||||
channelId = "channel_mention";
|
channelId = "channel_mention";
|
||||||
channelTitle = context.getString(R.string.channel_notif_mention);
|
channelTitle = context.getString(R.string.channel_notif_mention);
|
||||||
break;
|
break;
|
||||||
|
case POLL:
|
||||||
|
channelId = "channel_poll";
|
||||||
|
channelTitle = context.getString(R.string.channel_notif_poll);
|
||||||
|
break;
|
||||||
case BACKUP:
|
case BACKUP:
|
||||||
channelId = "channel_backup";
|
channelId = "channel_backup";
|
||||||
channelTitle = context.getString(R.string.channel_notif_backup);
|
channelTitle = context.getString(R.string.channel_notif_backup);
|
||||||
|
|
|
@ -118,8 +118,9 @@ public class NotificationsSyncJob extends Job {
|
||||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||||
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||||
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||||
|
boolean notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true);
|
||||||
//User disagree with all notifications
|
//User disagree with all notifications
|
||||||
if( !notif_follow && !notif_add && !notif_mention && !notif_share)
|
if( !notif_follow && !notif_add && !notif_mention && !notif_share && !notif_poll)
|
||||||
return; //Nothing is done
|
return; //Nothing is done
|
||||||
//No account connected, the service is stopped
|
//No account connected, the service is stopped
|
||||||
if(!Helper.isLoggedIn(getContext()))
|
if(!Helper.isLoggedIn(getContext()))
|
||||||
|
@ -151,6 +152,7 @@ public class NotificationsSyncJob extends Job {
|
||||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||||
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||||
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||||
|
boolean notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true);
|
||||||
final String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), null);
|
final String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), null);
|
||||||
final List<Notification> notifications = new ArrayList<>();
|
final List<Notification> notifications = new ArrayList<>();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -167,6 +169,7 @@ public class NotificationsSyncJob extends Job {
|
||||||
int newAdds = 0;
|
int newAdds = 0;
|
||||||
int newMentions = 0;
|
int newMentions = 0;
|
||||||
int newShare = 0;
|
int newShare = 0;
|
||||||
|
int newPolls = 0;
|
||||||
String notificationUrl = null;
|
String notificationUrl = null;
|
||||||
String title = null;
|
String title = null;
|
||||||
final String message;
|
final String message;
|
||||||
|
@ -229,11 +232,25 @@ public class NotificationsSyncJob extends Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "poll":
|
||||||
|
notifType = Helper.NotifType.POLL;
|
||||||
|
if(notif_poll){
|
||||||
|
newPolls++;
|
||||||
|
if( notificationUrl == null){
|
||||||
|
notificationUrl = notification.getAccount().getAvatar();
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
if (notification.getAccount().getId() != null && notification.getAccount().getId().equals(userId))
|
||||||
|
title = getContext().getString(R.string.notif_poll_self);
|
||||||
|
else
|
||||||
|
title = getContext().getString(R.string.notif_poll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int allNotifCount = newFollows + newAdds + newMentions + newShare;
|
int allNotifCount = newFollows + newAdds + newMentions + newShare + newPolls;
|
||||||
if( allNotifCount > 0){
|
if( allNotifCount > 0){
|
||||||
//Some others notification
|
//Some others notification
|
||||||
int other = allNotifCount -1;
|
int other = allNotifCount -1;
|
||||||
|
|
|
@ -327,7 +327,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
||||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||||
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||||
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||||
boolean somethingToPush = (notif_follow || notif_add || notif_mention || notif_share);
|
boolean notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true);
|
||||||
|
boolean somethingToPush = (notif_follow || notif_add || notif_mention || notif_share || notif_poll);
|
||||||
String title = null;
|
String title = null;
|
||||||
if (somethingToPush && notification != null) {
|
if (somethingToPush && notification != null) {
|
||||||
switch (notification.getType()) {
|
switch (notification.getType()) {
|
||||||
|
@ -376,6 +377,17 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
||||||
canSendBroadCast = false;
|
canSendBroadCast = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "poll":
|
||||||
|
notifType = Helper.NotifType.POLL;
|
||||||
|
if (notif_poll) {
|
||||||
|
if (notification.getAccount().getId() != null && notification.getAccount().getId().equals(userId))
|
||||||
|
title = getString(R.string.notif_poll_self);
|
||||||
|
else
|
||||||
|
title = getString(R.string.notif_poll);
|
||||||
|
} else {
|
||||||
|
canSendBroadCast = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
//Some others notification
|
//Some others notification
|
||||||
|
|
|
@ -918,6 +918,7 @@
|
||||||
<string name="vote">Vote</string>
|
<string name="vote">Vote</string>
|
||||||
<string name="poll_not_private">A poll cannot be attached to a direct message!</string>
|
<string name="poll_not_private">A poll cannot be attached to a direct message!</string>
|
||||||
<string name="notif_poll">A poll you have voted in has ended</string>
|
<string name="notif_poll">A poll you have voted in has ended</string>
|
||||||
|
<string name="notif_poll_self">A poll you tooted has ended</string>
|
||||||
<string name="settings_category_notif_customize">Customize</string>
|
<string name="settings_category_notif_customize">Customize</string>
|
||||||
<string name="settings_category_notif_categories">Categories</string>
|
<string name="settings_category_notif_categories">Categories</string>
|
||||||
<string name="settings_category_notif_news">News</string>
|
<string name="settings_category_notif_news">News</string>
|
||||||
|
|
Loading…
Reference in New Issue