From ded7cdb51f4f92a83b9d84ef49f1a88b33135c4b Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 17 Dec 2017 11:10:49 +0100 Subject: [PATCH] Prepares muting notifications parameter --- .../main/java/fr/gouv/etalab/mastodon/client/API.java | 5 +++++ .../gouv/etalab/mastodon/client/Entities/Account.java | 10 +++++++++- .../etalab/mastodon/client/Entities/Relationship.java | 9 +++++++++ .../mastodon/fragments/DisplayAccountsFragment.java | 7 ++++--- 4 files changed, 27 insertions(+), 4 deletions(-) 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 8ba3ecd66..dc6b61bfb 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 @@ -1800,6 +1800,11 @@ public class API { relationship.setFollowed_by(Boolean.valueOf(resobj.get("followed_by").toString())); relationship.setBlocking(Boolean.valueOf(resobj.get("blocking").toString())); relationship.setMuting(Boolean.valueOf(resobj.get("muting").toString())); + try { + relationship.setMuting_notifications(Boolean.valueOf(resobj.get("muting_notifications").toString())); + }catch (Exception ignored){ + relationship.setMuting_notifications(true); + } relationship.setRequested(Boolean.valueOf(resobj.get("requested").toString())); } catch (JSONException e) { setDefaultError(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Account.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Account.java index e42eeb358..48c6eb1b9 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Account.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Account.java @@ -61,7 +61,7 @@ public class Account implements Parcelable { private followAction followType = followAction.NOTHING; private boolean isMakingAction = false; private Account moved_to_account; - + private boolean muting_notifications; public followAction getFollowType() { return followType; @@ -87,6 +87,14 @@ public class Account implements Parcelable { this.moved_to_account = moved_to_account; } + public boolean isMuting_notifications() { + return muting_notifications; + } + + public void setMuting_notifications(boolean muting_notifications) { + this.muting_notifications = muting_notifications; + } + public enum followAction{ FOLLOW, NOT_FOLLOW, diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Relationship.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Relationship.java index 01c51c74f..cca8878fb 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Relationship.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Relationship.java @@ -27,6 +27,7 @@ public class Relationship { private boolean blocking; private boolean muting; private boolean requested; + private boolean muting_notifications; public String getId() { return id; @@ -75,4 +76,12 @@ public class Relationship { public void setRequested(boolean requested) { this.requested = requested; } + + public boolean isMuting_notifications() { + return muting_notifications; + } + + public void setMuting_notifications(boolean muting_notifications) { + this.muting_notifications = muting_notifications; + } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java index 98b9ee4fe..a03a912cd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java @@ -201,7 +201,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou } swipeRefreshLayout.setRefreshing(false); firstLoad = false; - if( type != RetrieveAccountsAsyncTask.Type.BLOCKED && type != RetrieveAccountsAsyncTask.Type.MUTED) + if( type != RetrieveAccountsAsyncTask.Type.BLOCKED ) new RetrieveManyRelationshipsAsyncTask(context, accounts,DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @@ -224,6 +224,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou account.setFollowType(Account.followAction.NOTHING); continue; } + account.setMuting_notifications(relationship.isMuting_notifications()); if( account.getId().equals(relationship.getId())){ if( relationship.isFollowing()) account.setFollowType(Account.followAction.FOLLOW); @@ -231,9 +232,9 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou account.setFollowType(Account.followAction.NOT_FOLLOW); if(relationship.isBlocking()) account.setFollowType(Account.followAction.BLOCK); - else if(relationship.isMuting()) + else if(relationship.isMuting()) { account.setFollowType(Account.followAction.MUTE); - else if(relationship.isRequested()) + }else if(relationship.isRequested()) account.setFollowType(Account.followAction.REQUEST_SENT); break; }