From b570c8d9467c713507d65621ad7567079318b75b Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 10 Sep 2023 21:19:50 +0200 Subject: [PATCH 1/3] feat: add mutes fragment --- .../requests/accounts/GetAccountMutes.java | 12 +++++++ .../android/fragments/ProfileFragment.java | 6 ++++ .../account_list/MutesListFragment.java | 36 +++++++++++++++++++ mastodon/src/main/res/menu/profile_own.xml | 1 + mastodon/src/main/res/values/strings_sk.xml | 2 ++ 5 files changed, 57 insertions(+) create mode 100644 mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java create mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java new file mode 100644 index 000000000..94d9dc374 --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java @@ -0,0 +1,12 @@ +package org.joinmastodon.android.api.requests.accounts; + +import com.google.gson.reflect.TypeToken; + +import org.joinmastodon.android.api.requests.HeaderPaginationRequest; +import org.joinmastodon.android.model.Account; + +public class GetAccountMutes extends HeaderPaginationRequest{ + public GetAccountMutes(){ + super(HttpMethod.GET, "/mutes/", new TypeToken<>(){}); + } +} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 951bd14c6..a8bc0418c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -62,6 +62,7 @@ import org.joinmastodon.android.api.requests.instance.GetInstance; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.account_list.FollowerListFragment; import org.joinmastodon.android.fragments.account_list.FollowingListFragment; +import org.joinmastodon.android.fragments.account_list.MutesListFragment; import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment; import org.joinmastodon.android.fragments.settings.SettingsServerFragment; import org.joinmastodon.android.model.Account; @@ -827,6 +828,11 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList args.putString("profileDisplayUsername", account.getDisplayUsername()); } Nav.go(getActivity(), ListsFragment.class, args); + }else if(id==R.id.mutes){ + final Bundle args=new Bundle(); + args.putString("account", accountID); + args.putParcelable("targetAccount", Parcels.wrap(account)); + Nav.go(getActivity(), MutesListFragment.class, args); }else if(id==R.id.followed_hashtags){ Bundle args=new Bundle(); args.putString("account", accountID); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java new file mode 100644 index 000000000..b19fcbb97 --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java @@ -0,0 +1,36 @@ +package org.joinmastodon.android.fragments.account_list; + +import android.net.Uri; +import android.os.Bundle; + +import org.joinmastodon.android.R; +import org.joinmastodon.android.api.requests.HeaderPaginationRequest; +import org.joinmastodon.android.api.requests.accounts.GetAccountMutes; +import org.joinmastodon.android.model.Account; +import org.joinmastodon.android.ui.viewholders.AccountViewHolder; + +public class MutesListFragment extends AccountRelatedAccountListFragment{ + + @Override + public void onCreate(Bundle savedInstanceState){ + super.onCreate(savedInstanceState); + setTitle(R.string.sk_muted_account); + } + + @Override + public HeaderPaginationRequest onCreateRequest(String maxID, int count){ + return new GetAccountMutes(); + } + + @Override + protected void onConfigureViewHolder(AccountViewHolder holder){ + super.onConfigureViewHolder(holder); + holder.setStyle(AccountViewHolder.AccessoryType.NONE, false); + } + + @Override + public Uri getWebUri(Uri.Builder base) { + return super.getWebUri(base).buildUpon() + .appendPath("/mutes").build(); + } +} diff --git a/mastodon/src/main/res/menu/profile_own.xml b/mastodon/src/main/res/menu/profile_own.xml index 61543c3e5..3904a5ad8 100644 --- a/mastodon/src/main/res/menu/profile_own.xml +++ b/mastodon/src/main/res/menu/profile_own.xml @@ -7,6 +7,7 @@ + \ No newline at end of file diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 17f7c76c8..8a0e2696e 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -392,4 +392,6 @@ %d minutes %d hours %d days + Muted accounts + Mutes \ No newline at end of file From 892948246681bba9f00ffdd2061f996baf29ac96 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 10 Sep 2023 21:29:40 +0200 Subject: [PATCH 2/3] feat: add blocks fragment --- .../requests/accounts/GetAccountBlocks.java | 12 ++++++ .../android/fragments/ProfileFragment.java | 6 +++ .../account_list/BlocksListFragment.java | 37 +++++++++++++++++++ mastodon/src/main/res/menu/profile_own.xml | 1 + mastodon/src/main/res/values/strings_sk.xml | 2 + 5 files changed, 58 insertions(+) create mode 100644 mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java create mode 100644 mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java new file mode 100644 index 000000000..64a493e43 --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java @@ -0,0 +1,12 @@ +package org.joinmastodon.android.api.requests.accounts; + +import com.google.gson.reflect.TypeToken; + +import org.joinmastodon.android.api.requests.HeaderPaginationRequest; +import org.joinmastodon.android.model.Account; + +public class GetAccountBlocks extends HeaderPaginationRequest{ + public GetAccountBlocks(){ + super(HttpMethod.GET, "/blocks", new TypeToken<>(){}); + } +} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index a8bc0418c..4138e2a25 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -60,6 +60,7 @@ import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed; import org.joinmastodon.android.api.requests.accounts.UpdateAccountCredentials; import org.joinmastodon.android.api.requests.instance.GetInstance; import org.joinmastodon.android.api.session.AccountSessionManager; +import org.joinmastodon.android.fragments.account_list.BlocksListFragment; import org.joinmastodon.android.fragments.account_list.FollowerListFragment; import org.joinmastodon.android.fragments.account_list.FollowingListFragment; import org.joinmastodon.android.fragments.account_list.MutesListFragment; @@ -833,6 +834,11 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList args.putString("account", accountID); args.putParcelable("targetAccount", Parcels.wrap(account)); Nav.go(getActivity(), MutesListFragment.class, args); + }else if(id==R.id.blocks){ + final Bundle args=new Bundle(); + args.putString("account", accountID); + args.putParcelable("targetAccount", Parcels.wrap(account)); + Nav.go(getActivity(), BlocksListFragment.class, args); }else if(id==R.id.followed_hashtags){ Bundle args=new Bundle(); args.putString("account", accountID); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java new file mode 100644 index 000000000..0e984d23b --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java @@ -0,0 +1,37 @@ +package org.joinmastodon.android.fragments.account_list; + +import android.net.Uri; +import android.os.Bundle; + +import org.joinmastodon.android.R; +import org.joinmastodon.android.api.requests.HeaderPaginationRequest; +import org.joinmastodon.android.api.requests.accounts.GetAccountBlocks; +import org.joinmastodon.android.api.requests.accounts.GetAccountMutes; +import org.joinmastodon.android.model.Account; +import org.joinmastodon.android.ui.viewholders.AccountViewHolder; + +public class BlocksListFragment extends AccountRelatedAccountListFragment{ + + @Override + public void onCreate(Bundle savedInstanceState){ + super.onCreate(savedInstanceState); + setTitle(R.string.sk_blocked_account); + } + + @Override + public HeaderPaginationRequest onCreateRequest(String maxID, int count){ + return new GetAccountBlocks(); + } + + @Override + protected void onConfigureViewHolder(AccountViewHolder holder){ + super.onConfigureViewHolder(holder); + holder.setStyle(AccountViewHolder.AccessoryType.NONE, false); + } + + @Override + public Uri getWebUri(Uri.Builder base) { + return super.getWebUri(base).buildUpon() + .appendPath("/blocks").build(); + } +} diff --git a/mastodon/src/main/res/menu/profile_own.xml b/mastodon/src/main/res/menu/profile_own.xml index 3904a5ad8..03228d9c6 100644 --- a/mastodon/src/main/res/menu/profile_own.xml +++ b/mastodon/src/main/res/menu/profile_own.xml @@ -8,6 +8,7 @@ + \ No newline at end of file diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 8a0e2696e..ba1c5542f 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -394,4 +394,6 @@ %d days Muted accounts Mutes + Blocked accounts + Blocks \ No newline at end of file From e274cf89c0a833bd55c12525167a55006995f70e Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 10 Sep 2023 21:31:06 +0200 Subject: [PATCH 3/3] refactor: add query params --- .../android/api/requests/accounts/GetAccountBlocks.java | 6 +++++- .../android/api/requests/accounts/GetAccountMutes.java | 6 +++++- .../android/fragments/account_list/BlocksListFragment.java | 2 +- .../android/fragments/account_list/MutesListFragment.java | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java index 64a493e43..16d0403a4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountBlocks.java @@ -6,7 +6,11 @@ import org.joinmastodon.android.api.requests.HeaderPaginationRequest; import org.joinmastodon.android.model.Account; public class GetAccountBlocks extends HeaderPaginationRequest{ - public GetAccountBlocks(){ + public GetAccountBlocks(String maxID, int limit){ super(HttpMethod.GET, "/blocks", new TypeToken<>(){}); + if(maxID!=null) + addQueryParameter("max_id", maxID); + if(limit>0) + addQueryParameter("limit", limit+""); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java index 94d9dc374..966b36c51 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/GetAccountMutes.java @@ -6,7 +6,11 @@ import org.joinmastodon.android.api.requests.HeaderPaginationRequest; import org.joinmastodon.android.model.Account; public class GetAccountMutes extends HeaderPaginationRequest{ - public GetAccountMutes(){ + public GetAccountMutes(String maxID, int limit){ super(HttpMethod.GET, "/mutes/", new TypeToken<>(){}); + if(maxID!=null) + addQueryParameter("max_id", maxID); + if(limit>0) + addQueryParameter("limit", limit+""); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java index 0e984d23b..38a4c80b7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/BlocksListFragment.java @@ -20,7 +20,7 @@ public class BlocksListFragment extends AccountRelatedAccountListFragment{ @Override public HeaderPaginationRequest onCreateRequest(String maxID, int count){ - return new GetAccountBlocks(); + return new GetAccountBlocks(maxID, count); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java index b19fcbb97..35ff5a4fb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/MutesListFragment.java @@ -19,7 +19,7 @@ public class MutesListFragment extends AccountRelatedAccountListFragment{ @Override public HeaderPaginationRequest onCreateRequest(String maxID, int count){ - return new GetAccountMutes(); + return new GetAccountMutes(maxID, count); } @Override