From 2c03eb8d15e40a8fc949a07a3a46e5f829674d61 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 29 Jul 2020 14:24:27 +0800 Subject: [PATCH] Version 4.0.1. Block users. Show report menu item even in anonymous mode. Remove Crashy. --- app/build.gradle | 8 +-- app/src/main/AndroidManifest.xml | 9 ---- .../infinityforreddit/API/RedditAPI.java | 5 ++ .../Activity/ViewImageOrGifActivity.java | 1 + .../Activity/ViewPostDetailActivity.java | 6 ++- .../Activity/ViewUserDetailActivity.java | 48 ++++++++++++++--- .../CustomTheme/CustomThemeWrapper.java | 24 ++++----- .../ViewRedditGalleryImageOrGifFragment.java | 1 + .../Settings/CrashReportsFragment.java | 54 ------------------- .../CrashReportsRecyclerViewAdapter.java | 46 ---------------- .../infinityforreddit/User/BlockUser.java | 40 ++++++++++++++ .../infinityforreddit/Utils/APIUtils.java | 6 ++- .../res/layout/fragment_view_imgur_images.xml | 3 +- .../res/menu/view_post_detail_activity.xml | 3 +- .../res/menu/view_user_detail_activity.xml | 22 +++++--- app/src/main/res/values/strings.xml | 7 ++- app/src/main/res/xml/about_preferences.xml | 5 -- 17 files changed, 134 insertions(+), 154 deletions(-) delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java delete mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/User/BlockUser.java diff --git a/app/build.gradle b/app/build.gradle index f33760bd..9bed2fff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "ml.docilealligator.infinityforreddit" minSdkVersion 21 targetSdkVersion 29 - versionCode 36 - versionName "4.0.0" + versionCode 37 + versionName "4.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { @@ -94,10 +94,6 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.6' implementation 'me.zhanghai.android.fastscroll:library:1.1.2' implementation "com.thefuntasty.hauler:core:3.1.0" - // androidX startup for auto-init - implementation "androidx.startup:startup-runtime:1.0.0-alpha01" - //crashy - implementation 'com.github.CraZyLegenD:Crashy:1.0.5' implementation 'com.github.Piasy:BigImageViewer:1.6.5' def toroVersion = '3.7.0.2010003' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 64082b4a..809a15c4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -327,15 +327,6 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> - - - composePrivateMessage(@HeaderMap Map headers, @FieldMap Map params); + + + @FormUrlEncoded + @POST("api/block_user") + Call blockUser(@HeaderMap Map headers, @FieldMap Map params); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java index 5cea5c59..9152c1be 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java @@ -213,6 +213,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa if (view != null) { view.setMinimumDpi(80); + view.setQuickScaleEnabled(true); view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java index 0fbc96b2..362eae60 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java @@ -542,8 +542,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS hideItem.setVisible(true); hideItem.setTitle(R.string.action_hide_post); } - - mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true); } else { saveItem.setVisible(false); hideItem.setVisible(false); @@ -1440,6 +1438,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS flairBottomSheetFragment.show(getSupportFragmentManager(), flairBottomSheetFragment.getTag()); return true; case R.id.action_report_view_post_detail_activity: + if (mAccessToken == null) { + Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show(); + return true; + } Intent intent = new Intent(this, ReportActivity.class); intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName()); intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index 426f6504..1ceed6e1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.content.res.Resources; +import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -56,29 +57,30 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener; import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; +import ml.docilealligator.infinityforreddit.BottomSheetFragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; -import ml.docilealligator.infinityforreddit.User.FetchUserData; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.PostFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.PostLayoutBottomSheetFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.SortTimeBottomSheetFragment; -import ml.docilealligator.infinityforreddit.BottomSheetFragment.UserThingSortTypeBottomSheetFragment; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.Message.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; +import ml.docilealligator.infinityforreddit.User.BlockUser; +import ml.docilealligator.infinityforreddit.User.FetchUserData; import ml.docilealligator.infinityforreddit.User.UserDao; import ml.docilealligator.infinityforreddit.User.UserData; -import ml.docilealligator.infinityforreddit.User.UserViewModel; import ml.docilealligator.infinityforreddit.User.UserFollowing; +import ml.docilealligator.infinityforreddit.User.UserViewModel; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; @@ -653,10 +655,44 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } return true; case R.id.action_send_private_message_view_user_detail_activity: + if (mAccessToken == null) { + Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show(); + return true; + } + Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class); pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username); startActivity(pmIntent); return true; + case R.id.action_report_view_user_detail_activity: + Intent reportIntent = new Intent(this, LinkResolverActivity.class); + 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; + case 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; } return false; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java index 3a30ba62..7dd17c41 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -409,7 +409,7 @@ public class CustomThemeWrapper { public int getAwardedCommentBackgroundColor() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR, - getDefaultColor("#FFF162", "#FF6400", "#FF6400")); + getDefaultColor("#FFFFFF", "#242424", "#000000")); } public int getNavBarColor() { @@ -550,7 +550,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = true; @@ -635,7 +635,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424"); customTheme.navBarColor = Color.parseColor("#121212"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -720,7 +720,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -805,7 +805,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.isLightStatusBar = true; customTheme.isLightNavBar = true; @@ -890,7 +890,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424"); customTheme.navBarColor = Color.parseColor("#121212"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -975,7 +975,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1060,7 +1060,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = true; @@ -1145,7 +1145,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424"); customTheme.navBarColor = Color.parseColor("#121212"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1230,7 +1230,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1315,7 +1315,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#393A59"); customTheme.navBarColor = Color.parseColor("#393A59"); customTheme.isLightStatusBar = false; customTheme.isLightNavBar = false; @@ -1400,7 +1400,7 @@ public class CustomThemeWrapper { customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); - customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); + customTheme.awardedCommentBackgroundColor = Color.parseColor("#C0F0F4"); customTheme.navBarColor = Color.parseColor("#D48AE0"); customTheme.isLightStatusBar = true; customTheme.isLightNavBar = true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java index 0b466749..015e57c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewRedditGalleryImageOrGifFragment.java @@ -131,6 +131,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { if (view != null) { view.setMinimumDpi(80); + view.setQuickScaleEnabled(true); view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java deleted file mode 100644 index 04bdc0e9..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java +++ /dev/null @@ -1,54 +0,0 @@ -package ml.docilealligator.infinityforreddit.Settings; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.crazylegend.crashyreporter.CrashyReporter; - -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; - -public class CrashReportsFragment extends Fragment { - - @BindView(R.id.recycler_view_crash_reports_fragment) - RecyclerView recyclerView; - private Activity activity; - private CrashReportsRecyclerViewAdapter adapter; - private LinearLayoutManager linearLayoutManager; - - public CrashReportsFragment() { - // Required empty public constructor - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_crash_reports, container, false); - - ButterKnife.bind(this, rootView); - - adapter = new CrashReportsRecyclerViewAdapter(CrashyReporter.INSTANCE.getLogsAsStrings()); - linearLayoutManager = new LinearLayoutManager(activity); - recyclerView.setLayoutManager(linearLayoutManager); - recyclerView.setAdapter(adapter); - - return rootView; - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); - this.activity = (Activity) context; - } -} \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java deleted file mode 100644 index 82c43795..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -package ml.docilealligator.infinityforreddit.Settings; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -import java.util.List; - -import ml.docilealligator.infinityforreddit.R; - -class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter { - private List crashReports; - - public CrashReportsRecyclerViewAdapter(List crashReports) { - this.crashReports = crashReports; - } - - @NonNull - @Override - public CrashReportViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new CrashReportViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_crash_report, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull CrashReportViewHolder holder, int position) { - holder.crashReportTextView.setText(crashReports.get(holder.getAdapterPosition())); - } - - @Override - public int getItemCount() { - return crashReports == null ? 0 : crashReports.size(); - } - - class CrashReportViewHolder extends RecyclerView.ViewHolder { - TextView crashReportTextView; - - public CrashReportViewHolder(@NonNull View itemView) { - super(itemView); - crashReportTextView = (TextView) itemView; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/User/BlockUser.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/BlockUser.java new file mode 100644 index 00000000..ca6dd1d1 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/BlockUser.java @@ -0,0 +1,40 @@ +package ml.docilealligator.infinityforreddit.User; + +import androidx.annotation.NonNull; + +import java.util.HashMap; +import java.util.Map; + +import ml.docilealligator.infinityforreddit.API.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(); + } + }); + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java index 1b00e57a..f824eafa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java @@ -35,13 +35,13 @@ public class APIUtils { public static final String DURATION_KEY = "duration"; public static final String DURATION = "permanent"; public static final String SCOPE_KEY = "scope"; - public static final String SCOPE = "identity edit flair history modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread"; + public static final String SCOPE = "identity edit flair history modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread creddits modcontributors modmail modothers livemanage account modself"; public static final String ACCESS_TOKEN_KEY = "access_token"; public static final String AUTHORIZATION_KEY = "Authorization"; public static final String AUTHORIZATION_BASE = "bearer "; public static final String USER_AGENT_KEY = "User-Agent"; - public static final String USER_AGENT = "android:ml.docilealligator.infinityforreddit:v3.2.0 (by /u/Hostilenemy)"; + public static final String USER_AGENT = "android:ml.docilealligator.infinityforreddit:v4.0.1 (by /u/Hostilenemy)"; public static final String GRANT_TYPE_KEY = "grant_type"; public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; @@ -95,6 +95,8 @@ public class APIUtils { public static final String SUBJECT_KEY = "subject"; public static final String TO_KEY = "to"; + public static final String NAME_KEY = "name"; + public static Map getHttpBasicAuthHeader() { Map params = new HashMap<>(); String credentials = String.format("%s:%s", APIUtils.CLIENT_ID, ""); diff --git a/app/src/main/res/layout/fragment_view_imgur_images.xml b/app/src/main/res/layout/fragment_view_imgur_images.xml index 20110897..36286c05 100644 --- a/app/src/main/res/layout/fragment_view_imgur_images.xml +++ b/app/src/main/res/layout/fragment_view_imgur_images.xml @@ -16,8 +16,7 @@ + android:layout_height="match_parent" /> + app:showAsAction="never" /> - - + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 447922e7..05c1c9de 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -68,6 +68,7 @@ See Removed Set as Wallpaper Send Private Message + Block User Error occurred when parsing the JSON response Error Retrieving the token @@ -441,8 +442,6 @@ r/Infinity_For_Reddit Share Share this app to other people if you enjoy it - Crash Reports - See the error logs and send them to me when you report bugs Infinity For Reddit Version %s Customization @@ -850,4 +849,8 @@ If you have 2-factor authentication enabled, kindly type your password like the following: <password>:<2FA code>.\nExample: yourpass:123456 + Block User + Blocked + Failed to block user + diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml index 6561eec3..a73f9aaa 100644 --- a/app/src/main/res/xml/about_preferences.xml +++ b/app/src/main/res/xml/about_preferences.xml @@ -45,11 +45,6 @@ app:title="@string/settings_share_title" app:summary="@string/settings_share_summary" /> - -