From 3b96fb9bb7e9925a514f7955b626d9b3779e5836 Mon Sep 17 00:00:00 2001 From: Kasun Date: Sat, 4 May 2019 16:28:58 +0530 Subject: [PATCH] poll notifications 1/3 add polls to notification settings --- .../SettingsNotificationsFragment.java | 22 +++++++++++++ .../gouv/etalab/mastodon/helper/Helper.java | 1 + .../fragment_settings_notifications.xml | 32 +++++++++++++++++-- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java index 8860ba66c..8f83e08c6 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java @@ -105,6 +105,7 @@ public class SettingsNotificationsFragment extends Fragment { boolean notif_ask = sharedpreferences.getBoolean(Helper.SET_NOTIF_ASK, true); boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); + boolean notif_poll = sharedpreferences.getBoolean(Helper.SET_NOTIF_POLL, true); boolean notif_wifi = sharedpreferences.getBoolean(Helper.SET_WIFI_ONLY, false); boolean notif_silent = sharedpreferences.getBoolean(Helper.SET_NOTIF_SILENT, false); @@ -120,6 +121,7 @@ public class SettingsNotificationsFragment extends Fragment { final CheckBox set_notif_follow_ask = rootView.findViewById(R.id.set_notif_follow_ask); final CheckBox set_notif_follow_mention = rootView.findViewById(R.id.set_notif_follow_mention); final CheckBox set_notif_follow_share = rootView.findViewById(R.id.set_notif_follow_share); + final CheckBox set_notif_follow_poll = rootView.findViewById(R.id.set_notif_follow_poll); final CheckBox set_notif_hometimeline = rootView.findViewById(R.id.set_notif_hometimeline); @@ -134,6 +136,7 @@ public class SettingsNotificationsFragment extends Fragment { final Button sound_fav = rootView.findViewById(R.id.sound_fav); final Button sound_follow = rootView.findViewById(R.id.sound_follow); final Button sound_mention = rootView.findViewById(R.id.sound_mention); + final Button sound_poll = rootView.findViewById(R.id.sound_poll); final Button sound_backup = rootView.findViewById(R.id.sound_backup); final Button sound_media = rootView.findViewById(R.id.sound_media); Button set_notif_sound = rootView.findViewById(R.id.set_notif_sound); @@ -184,6 +187,16 @@ public class SettingsNotificationsFragment extends Fragment { } }); + sound_poll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS); + intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName()); + intent.putExtra(Settings.EXTRA_CHANNEL_ID, "channel_poll"); + startActivity(intent); + } + }); + sound_backup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -332,6 +345,7 @@ public class SettingsNotificationsFragment extends Fragment { set_notif_follow_ask.setChecked(notif_ask); set_notif_follow_mention.setChecked(notif_mention); set_notif_follow_share.setChecked(notif_share); + set_notif_follow_poll.setChecked(notif_poll); set_notif_hometimeline.setChecked(notif_hometimeline); switchCompatWIFI.setChecked(notif_wifi); @@ -385,6 +399,14 @@ public class SettingsNotificationsFragment extends Fragment { editor.apply(); } }); + set_notif_follow_poll.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putBoolean(Helper.SET_NOTIF_POLL, set_notif_follow_poll.isChecked()); + editor.apply(); + } + }); switchCompatWIFI.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 8903463ce..f41cee810 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -356,6 +356,7 @@ public class Helper { public static final String SET_NOTIF_ASK = "set_notif_follow_ask"; public static final String SET_NOTIF_MENTION = "set_notif_follow_mention"; public static final String SET_NOTIF_SHARE = "set_notif_follow_share"; + public static final String SET_NOTIF_POLL = "set_notif_follow_poll"; public static final String SET_NOTIF_FOLLOW_FILTER = "set_notif_follow_filter"; 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"; diff --git a/app/src/main/res/layout/fragment_settings_notifications.xml b/app/src/main/res/layout/fragment_settings_notifications.xml index 299ae4679..2874eb9c6 100644 --- a/app/src/main/res/layout/fragment_settings_notifications.xml +++ b/app/src/main/res/layout/fragment_settings_notifications.xml @@ -165,11 +165,11 @@ android:orientation="horizontal" >