From 6f4e9233b8bcda7054c505fb00f780e27e794b84 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 28 Jul 2022 00:31:48 +1000 Subject: Remove Block User menu option in ViewUserDetailActivity since Reddit does not allow 3rd-party apps access this API now. --- .../activities/ViewUserDetailActivity.java | 26 -------------- .../infinityforreddit/apis/RedditAPI.java | 5 --- .../infinityforreddit/user/BlockUser.java | 40 ---------------------- 3 files changed, 71 deletions(-) delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/user/BlockUser.java (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index b59ef604..ddf997c9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -116,7 +116,6 @@ import ml.docilealligator.infinityforreddit.post.PostPagingSource; import ml.docilealligator.infinityforreddit.readpost.InsertReadPost; import ml.docilealligator.infinityforreddit.subreddit.ParseSubredditData; import ml.docilealligator.infinityforreddit.subreddit.SubredditData; -import ml.docilealligator.infinityforreddit.user.BlockUser; import ml.docilealligator.infinityforreddit.user.FetchUserData; import ml.docilealligator.infinityforreddit.user.UserDao; import ml.docilealligator.infinityforreddit.user.UserData; @@ -1112,7 +1111,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele if (username.equals(mAccountName)) { menu.findItem(R.id.action_send_private_message_view_user_detail_activity).setVisible(false); menu.findItem(R.id.action_report_view_user_detail_activity).setVisible(false); - menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false); } else { menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false); } @@ -1180,30 +1178,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele reportIntent.setData(Uri.parse("https://www.reddithelp.com/en/categories/rules-reporting/account-and-community-restrictions/what-should-i-do-if-i-see-something-i")); startActivity(reportIntent); return true; - } else if (itemId == R.id.action_block_user_view_user_detail_activity) { - if (mAccessToken == null) { - Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show(); - return true; - } - - new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme) - .setTitle(R.string.block_user) - .setMessage(R.string.are_you_sure) - .setPositiveButton(R.string.yes, (dialogInterface, i) - -> BlockUser.blockUser(mOauthRetrofit, mAccessToken, username, new BlockUser.BlockUserListener() { - @Override - public void success() { - Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_success, Toast.LENGTH_SHORT).show(); - } - - @Override - public void failed() { - Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_failed, Toast.LENGTH_SHORT).show(); - } - })) - .setNegativeButton(R.string.no, null) - .show(); - return true; } else if (itemId == R.id.action_edit_profile_view_user_detail_activity) { startActivity(new Intent(this, EditProfileActivity.class)); return true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 826dc663..2c75a17c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -251,11 +251,6 @@ public interface RedditAPI { @POST("/api/compose") Call composePrivateMessage(@HeaderMap Map headers, @FieldMap Map params); - - @FormUrlEncoded - @POST("api/block_user") - Call blockUser(@HeaderMap Map headers, @FieldMap Map params); - @GET("r/{subredditName}/api/user_flair_v2.json?raw_json=1") Call getUserFlairs(@HeaderMap Map headers, @Path("subredditName") String subredditName); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/BlockUser.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/BlockUser.java deleted file mode 100644 index c7a7207e..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/BlockUser.java +++ /dev/null @@ -1,40 +0,0 @@ -package ml.docilealligator.infinityforreddit.user; - -import androidx.annotation.NonNull; - -import java.util.HashMap; -import java.util.Map; - -import ml.docilealligator.infinityforreddit.apis.RedditAPI; -import ml.docilealligator.infinityforreddit.utils.APIUtils; -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; -import retrofit2.Retrofit; - -public class BlockUser { - public interface BlockUserListener { - void success(); - void failed(); - } - - public static void blockUser(Retrofit oauthRetrofit, String accessToken, String username, BlockUserListener blockUserListener) { - Map params = new HashMap<>(); - params.put(APIUtils.NAME_KEY, username); - oauthRetrofit.create(RedditAPI.class).blockUser(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback() { - @Override - public void onResponse(@NonNull Call call, @NonNull Response response) { - if (response.isSuccessful()) { - blockUserListener.success(); - } else { - blockUserListener.failed(); - } - } - - @Override - public void onFailure(@NonNull Call call, @NonNull Throwable t) { - blockUserListener.failed(); - } - }); - } -} -- cgit v1.2.3