diff options
author | tom79 <tschneider.ac@gmail.com> | 2019-05-04 18:28:55 +0200 |
---|---|---|
committer | tom79 <tschneider.ac@gmail.com> | 2019-05-04 18:28:55 +0200 |
commit | 7d1bbe5e5e59358ad71299e4d268d34c560709f7 (patch) | |
tree | c71da78b8782e7e70d093ae3bea44bfe1b6a8470 /app/src | |
parent | 1adfa71875224038c430872e87b3116442fbb24f (diff) | |
parent | 658ab3c166d12259dc8c7bfefed262cdc158da31 (diff) |
Merge remote-tracking branch 'origin/develop' into develop
Diffstat (limited to 'app/src')
54 files changed, 230 insertions, 67 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 7ca289aa0..bd6fcdd38 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -1039,6 +1039,7 @@ public abstract class BaseMainActivity extends BaseActivity 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_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_POPUP_PUSH, true); editor.apply(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index f3a4b0191..1b5bc28ef 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -1211,9 +1211,15 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt startActivity(intent); return true; case R.id.action_mute: - builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style); - builderInner.setTitle(stringArrayConf[0]); - doActionAccount = API.StatusAction.MUTE; + if (relationship.isMuting()) { + builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style); + builderInner.setTitle(stringArrayConf[4]); + doActionAccount = API.StatusAction.UNMUTE; + } else { + builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style); + builderInner.setTitle(stringArrayConf[0]); + doActionAccount = API.StatusAction.MUTE; + } break; case R.id.action_block: builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style); 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 eb4d47763..880dbbedf 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 @@ -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()); @@ -2445,7 +2449,7 @@ public class API { 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){ + }else if(type == DisplayNotificationsFragment.Type.POLL){ parameters.append("exclude_types[]=").append("reblog").append("&"); parameters.append("exclude_types[]=").append("follow").append("&"); parameters.append("exclude_types[]=").append("mention").append("&"); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/ManageTimelines.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/ManageTimelines.java index 476138c35..f4312bb96 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/ManageTimelines.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/ManageTimelines.java @@ -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; } 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 b6308bbd2..6f81fffaf 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,7 +90,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve MENTION, FAVORITE, BOOST, - POOL, + POLL, FOLLOW } 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/fragments/TabLayoutNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutNotificationsFragment.java index d52e54dae..48d349eac 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 @@ -229,7 +229,7 @@ public class TabLayoutNotificationsFragment extends Fragment { break; case 4: if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) - type = DisplayNotificationsFragment.Type.POOL; + type = DisplayNotificationsFragment.Type.POLL; else type = DisplayNotificationsFragment.Type.FOLLOW; break; 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..c0da1e198 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,10 +356,12 @@ 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"; 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"; @@ -457,6 +459,7 @@ public class Helper { MENTION, BOOST, FAV, + POLL, BACKUP, STORE, TOOT @@ -1011,6 +1014,10 @@ public class Helper { channelId = "channel_mention"; channelTitle = context.getString(R.string.channel_notif_mention); break; + case POLL: + channelId = "channel_poll"; + channelTitle = context.getString(R.string.channel_notif_poll); + break; case BACKUP: channelId = "channel_backup"; channelTitle = context.getString(R.string.channel_notif_backup); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java index b4c1e091a..15f39dd73 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java @@ -118,8 +118,9 @@ public class NotificationsSyncJob extends Job { boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, 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); //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 //No account connected, the service is stopped 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_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); final String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), null); final List<Notification> notifications = new ArrayList<>(); int pos = 0; @@ -167,6 +169,7 @@ public class NotificationsSyncJob extends Job { int newAdds = 0; int newMentions = 0; int newShare = 0; + int newPolls = 0; String notificationUrl = null; String title = null; final String message; @@ -229,11 +232,25 @@ public class NotificationsSyncJob extends Job { } } 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: } } - int allNotifCount = newFollows + newAdds + newMentions + newShare; + int allNotifCount = newFollows + newAdds + newMentions + newShare + newPolls; if( allNotifCount > 0){ //Some others notification int other = allNotifCount -1; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java index 9645944cd..30c75aaee 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java @@ -327,7 +327,8 @@ public class LiveNotificationService extends Service implements NetworkStateRece boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, 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; if (somethingToPush && notification != null) { switch (notification.getType()) { @@ -376,6 +377,17 @@ public class LiveNotificationService extends Service implements NetworkStateRece canSendBroadCast = false; } 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: } //Some others notification 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" > <Button - android:id="@+id/sound_backup" + android:id="@+id/sound_poll" android:gravity="center" style="@style/Base.Widget.AppCompat.Button.Colored" android:tint="@andr |