From 04032a2a76f59208dced9e0ce953d4fe4386235b Mon Sep 17 00:00:00 2001 From: Kasun Date: Fri, 19 Apr 2019 19:33:54 +0530 Subject: [PATCH] add polls category to notification tab --- .../fr/gouv/etalab/mastodon/client/API.java | 11 +++++++++ .../DisplayNotificationsFragment.java | 1 + .../TabLayoutNotificationsFragment.java | 24 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index 805f1842c..3025bfd36 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -2422,15 +2422,25 @@ public class API { parameters.append("exclude_types[]=").append("follow").append("&"); parameters.append("exclude_types[]=").append("favourite").append("&"); parameters.append("exclude_types[]=").append("reblog").append("&"); + parameters.append("exclude_types[]=").append("poll").append("&"); parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); params.put("exclude_types[]", parameters.toString()); }else if(type == DisplayNotificationsFragment.Type.FAVORITE){ parameters.append("exclude_types[]=").append("follow").append("&"); parameters.append("exclude_types[]=").append("mention").append("&"); parameters.append("exclude_types[]=").append("reblog").append("&"); + parameters.append("exclude_types[]=").append("poll").append("&"); parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); params.put("exclude_types[]", parameters.toString()); }else if(type == DisplayNotificationsFragment.Type.BOOST){ + parameters.append("exclude_types[]=").append("follow").append("&"); + parameters.append("exclude_types[]=").append("mention").append("&"); + parameters.append("exclude_types[]=").append("favourite").append("&"); + parameters.append("exclude_types[]=").append("poll").append("&"); + parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); + params.put("exclude_types[]", parameters.toString()); + }else if(type == DisplayNotificationsFragment.Type.POOL){ + parameters.append("exclude_types[]=").append("reblog").append("&"); parameters.append("exclude_types[]=").append("follow").append("&"); parameters.append("exclude_types[]=").append("mention").append("&"); parameters.append("exclude_types[]=").append("favourite").append("&"); @@ -2440,6 +2450,7 @@ public class API { parameters.append("exclude_types[]=").append("reblog").append("&"); parameters.append("exclude_types[]=").append("mention").append("&"); parameters.append("exclude_types[]=").append("favourite").append("&"); + parameters.append("exclude_types[]=").append("poll").append("&"); parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(16)); params.put("exclude_types[]", parameters.toString()); } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java index 388f1d3b4..b6308bbd2 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java @@ -90,6 +90,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve MENTION, FAVORITE, BOOST, + POOL, FOLLOW } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutNotificationsFragment.java index 2924b5b79..e1d0f2f63 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutNotificationsFragment.java @@ -65,6 +65,7 @@ public class TabLayoutNotificationsFragment extends Fragment { TabLayout.Tab tabMention = tabLayout.newTab(); TabLayout.Tab tabFav = tabLayout.newTab(); TabLayout.Tab tabBoost = tabLayout.newTab(); + TabLayout.Tab tabPoll = tabLayout.newTab(); TabLayout.Tab tabFollow = tabLayout.newTab(); tabMention.setCustomView(R.layout.tab_badge); @@ -72,6 +73,8 @@ public class TabLayoutNotificationsFragment extends Fragment { tabFav.setCustomView(R.layout.tab_badge); if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) tabBoost.setCustomView(R.layout.tab_badge); + if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) + tabPoll.setCustomView(R.layout.tab_badge); tabFollow.setCustomView(R.layout.tab_badge); @@ -96,6 +99,13 @@ public class TabLayoutNotificationsFragment extends Fragment { iconBoost = tabBoost.getCustomView().findViewById(R.id.tab_icon); iconBoost.setImageResource(R.drawable.ic_repeat_notif_tab); } + + ImageView iconPoll =null; + if( tabPoll.getCustomView() != null) { + iconPoll = tabPoll.getCustomView().findViewById(R.id.tab_icon); + iconPoll.setImageResource(R.drawable.ic_view_list_poll_notif); + } + @SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") ImageView iconFollow = tabFollow.getCustomView().findViewById(R.id.tab_icon); iconFollow.setImageResource(R.drawable.ic_follow_notif_tab); @@ -107,6 +117,8 @@ public class TabLayoutNotificationsFragment extends Fragment { tabLayout.addTab(tabFav); if( tabBoost.getCustomView() != null) tabLayout.addTab(tabBoost); + if( tabPoll.getCustomView() != null) + tabLayout.addTab(tabPoll); tabLayout.addTab(tabFollow); if (theme == THEME_BLACK) @@ -120,6 +132,8 @@ public class TabLayoutNotificationsFragment extends Fragment { iconFav.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); if( iconBoost != null) iconBoost.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); + if( iconPoll != null) + iconPoll.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); iconFollow.setColorFilter(ContextCompat.getColor(context, R.color.action_light_header), PorterDuff.Mode.SRC_IN); } else { iconMention.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); @@ -127,6 +141,8 @@ public class TabLayoutNotificationsFragment extends Fragment { iconFav.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); if( iconBoost != null) iconBoost.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); + if( iconPoll != null) + iconPoll.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); iconFollow.setColorFilter(ContextCompat.getColor(context, R.color.dark_text), PorterDuff.Mode.SRC_IN); } @@ -207,8 +223,14 @@ public class TabLayoutNotificationsFragment extends Fragment { type = DisplayNotificationsFragment.Type.BOOST; break; case 4: - type = DisplayNotificationsFragment.Type.FOLLOW; + if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) + type = DisplayNotificationsFragment.Type.POOL; + else + type = DisplayNotificationsFragment.Type.FOLLOW; break; + case 5: + if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) + type = DisplayNotificationsFragment.Type.FOLLOW; default: break;