poll notifications 3/3

add polls filter to notifications tab
This commit is contained in:
Kasun 2019-05-04 16:38:23 +05:30
parent d55b7aac1b
commit 1198664c6f
5 changed files with 28 additions and 2 deletions

View File

@ -2396,7 +2396,7 @@ public class API {
return apiResponse;
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean notif_follow, notif_add, notif_mention, notif_share;
boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll;
StringBuilder parameters = new StringBuilder();
if( type == DisplayNotificationsFragment.Type.ALL){
if( display) {
@ -2404,11 +2404,13 @@ public class API {
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true);
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true);
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true);
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL_FILTER, true);
}else{
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true);
}
@ -2420,6 +2422,8 @@ public class API {
parameters.append("exclude_types[]=").append("reblog").append("&");
if( !notif_mention )
parameters.append("exclude_types[]=").append("mention").append("&");
if( !notif_poll )
parameters.append("exclude_types[]=").append("poll").append("&");
if( parameters.length() > 0) {
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16));
params.put("exclude_types[]", parameters.toString());

View File

@ -82,7 +82,7 @@ public class ManageTimelines {
private List listTimeline;
private boolean notif_follow, notif_add, notif_mention, notif_share;
private boolean notif_follow, notif_add, notif_mention, notif_share, notif_poll;
public int getPosition() {
@ -435,14 +435,21 @@ public class ManageTimelines {
final MenuItem itemFollow = menu.findItem(R.id.action_follow);
final MenuItem itemMention = menu.findItem(R.id.action_mention);
final MenuItem itemBoost = menu.findItem(R.id.action_boost);
final MenuItem itemPoll = menu.findItem(R.id.action_poll);
notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, true);
notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true);
notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true);
notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true);
notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL_FILTER, true);
itemFavourite.setChecked(notif_add);
itemFollow.setChecked(notif_follow);
itemMention.setChecked(notif_mention);
itemBoost.setChecked(notif_share);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
itemPoll.setChecked(notif_poll);
else
itemPoll.setVisible(false);
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu menu) {
@ -495,6 +502,13 @@ public class ManageTimelines {
itemBoost.setChecked(notif_share);
editor.apply();
break;
case R.id.action_poll:
editor = sharedpreferences.edit();
notif_poll = !notif_poll;
editor.putBoolean(Helper.SET_NOTIF_POLL_FILTER, notif_poll);
itemPoll.setChecked(notif_poll);
editor.apply();
break;
}
return false;
}

View File

@ -361,6 +361,7 @@ public class Helper {
public static final String SET_NOTIF_ADD_FILTER = "set_notif_follow_add_filter";
public static final String SET_NOTIF_MENTION_FILTER = "set_notif_follow_mention_filter";
public static final String SET_NOTIF_SHARE_FILTER = "set_notif_follow_share_filter";
public static final String SET_NOTIF_POLL_FILTER = "set_notif_follow_poll_filter";
public static final String SET_FILTER_REGEX_HOME = "set_filter_regex_home";
public static final String SET_FILTER_REGEX_LOCAL = "set_filter_regex_local";
public static final String SET_FILTER_REGEX_PUBLIC = "set_filter_regex_public";

View File

@ -27,4 +27,10 @@
android:title="@string/reblog"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always" />
<item
android:id="@+id/action_poll"
android:checkable="true"
android:title="@string/polls"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always" />
</menu>

View File

@ -906,6 +906,7 @@
<!-- end languages -->
<string name="poll">Poll</string>
<string name="polls">Polls</string>
<string name="create_poll">Create a poll</string>
<string name="poll_choice_1">Choice 1</string>
<string name="poll_choice_2">Choice 2</string>