From 892948246681bba9f00ffdd2061f996baf29ac96 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 10 Sep 2023 21:29:40 +0200 Subject: [PATCH] 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