Version 4.0.1. Block users. Show report menu item even in anonymous mode. Remove Crashy.

This commit is contained in:
Alex Ning 2020-07-29 14:24:27 +08:00
parent cdf7eaba26
commit 2c03eb8d15
17 changed files with 134 additions and 154 deletions

View File

@ -6,8 +6,8 @@ android {
applicationId "ml.docilealligator.infinityforreddit" applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 36 versionCode 37
versionName "4.0.0" versionName "4.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions { javaCompileOptions {
annotationProcessorOptions { annotationProcessorOptions {
@ -94,10 +94,6 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'me.zhanghai.android.fastscroll:library:1.1.2' implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
implementation "com.thefuntasty.hauler:core:3.1.0" 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' implementation 'com.github.Piasy:BigImageViewer:1.6.5'
def toroVersion = '3.7.0.2010003' def toroVersion = '3.7.0.2010003'

View File

@ -327,15 +327,6 @@
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" /> android:resource="@xml/file_paths" />
</provider> </provider>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="com.crazylegend.crashyreporter.initializer.CrashyInitializer"
android:value="androidx.startup" />
</provider>
<service <service
android:name=".Service.SubmitPostService" android:name=".Service.SubmitPostService"

View File

@ -312,4 +312,9 @@ public interface RedditAPI {
@FormUrlEncoded @FormUrlEncoded
@POST("/api/compose") @POST("/api/compose")
Call<String> composePrivateMessage(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> composePrivateMessage(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@FormUrlEncoded
@POST("api/block_user")
Call<String> blockUser(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
} }

View File

@ -213,6 +213,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
if (view != null) { if (view != null) {
view.setMinimumDpi(80); view.setMinimumDpi(80);
view.setQuickScaleEnabled(true);
view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() {
@Override @Override

View File

@ -542,8 +542,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
hideItem.setVisible(true); hideItem.setVisible(true);
hideItem.setTitle(R.string.action_hide_post); hideItem.setTitle(R.string.action_hide_post);
} }
mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true);
} else { } else {
saveItem.setVisible(false); saveItem.setVisible(false);
hideItem.setVisible(false); hideItem.setVisible(false);
@ -1440,6 +1438,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
flairBottomSheetFragment.show(getSupportFragmentManager(), flairBottomSheetFragment.getTag()); flairBottomSheetFragment.show(getSupportFragmentManager(), flairBottomSheetFragment.getTag());
return true; return true;
case R.id.action_report_view_post_detail_activity: 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 intent = new Intent(this, ReportActivity.class);
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName()); intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName()); intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName());

View File

@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -56,29 +57,30 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask; 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.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.DeleteThing; import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.User.FetchUserData;
import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment; import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment; 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.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; 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.UserDao;
import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.User.UserData;
import ml.docilealligator.infinityforreddit.User.UserViewModel;
import ml.docilealligator.infinityforreddit.User.UserFollowing; import ml.docilealligator.infinityforreddit.User.UserFollowing;
import ml.docilealligator.infinityforreddit.User.UserViewModel;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
@ -653,10 +655,44 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
} }
return true; return true;
case R.id.action_send_private_message_view_user_detail_activity: 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); Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username); pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
startActivity(pmIntent); startActivity(pmIntent);
return true; 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; return false;
} }

View File

@ -409,7 +409,7 @@ public class CustomThemeWrapper {
public int getAwardedCommentBackgroundColor() { public int getAwardedCommentBackgroundColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR, return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.AWARDED_COMMENT_BACKGROUND_COLOR,
getDefaultColor("#FFF162", "#FF6400", "#FF6400")); getDefaultColor("#FFFFFF", "#242424", "#000000"));
} }
public int getNavBarColor() { public int getNavBarColor() {
@ -550,7 +550,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = true; customTheme.isLightNavBar = true;
@ -635,7 +635,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424");
customTheme.navBarColor = Color.parseColor("#121212"); customTheme.navBarColor = Color.parseColor("#121212");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -720,7 +720,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000");
customTheme.navBarColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -805,7 +805,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF");
customTheme.isLightStatusBar = true; customTheme.isLightStatusBar = true;
customTheme.isLightNavBar = true; customTheme.isLightNavBar = true;
@ -890,7 +890,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424");
customTheme.navBarColor = Color.parseColor("#121212"); customTheme.navBarColor = Color.parseColor("#121212");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -975,7 +975,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000");
customTheme.navBarColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -1060,7 +1060,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.navBarColor = Color.parseColor("#FFFFFF"); customTheme.navBarColor = Color.parseColor("#FFFFFF");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = true; customTheme.isLightNavBar = true;
@ -1145,7 +1145,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#242424");
customTheme.navBarColor = Color.parseColor("#121212"); customTheme.navBarColor = Color.parseColor("#121212");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -1230,7 +1230,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#000000");
customTheme.navBarColor = Color.parseColor("#000000"); customTheme.navBarColor = Color.parseColor("#000000");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -1315,7 +1315,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#21C561");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FF6400"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#393A59");
customTheme.navBarColor = Color.parseColor("#393A59"); customTheme.navBarColor = Color.parseColor("#393A59");
customTheme.isLightStatusBar = false; customTheme.isLightStatusBar = false;
customTheme.isLightNavBar = false; customTheme.isLightNavBar = false;
@ -1400,7 +1400,7 @@ public class CustomThemeWrapper {
customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D"); customTheme.sentMessageBackgroundColor = Color.parseColor("#31BF7D");
customTheme.sendMessageIconColor = Color.parseColor("#4185F4"); customTheme.sendMessageIconColor = Color.parseColor("#4185F4");
customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA"); customTheme.fullyCollapsedCommentBackgroundColor = Color.parseColor("#8EDFBA");
customTheme.awardedCommentBackgroundColor = Color.parseColor("#FFF162"); customTheme.awardedCommentBackgroundColor = Color.parseColor("#C0F0F4");
customTheme.navBarColor = Color.parseColor("#D48AE0"); customTheme.navBarColor = Color.parseColor("#D48AE0");
customTheme.isLightStatusBar = true; customTheme.isLightStatusBar = true;
customTheme.isLightNavBar = true; customTheme.isLightNavBar = true;

View File

@ -131,6 +131,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
if (view != null) { if (view != null) {
view.setMinimumDpi(80); view.setMinimumDpi(80);
view.setQuickScaleEnabled(true);
view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() {
@Override @Override

View File

@ -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;
}
}

View File

@ -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<CrashReportsRecyclerViewAdapter.CrashReportViewHolder> {
private List<String> crashReports;
public CrashReportsRecyclerViewAdapter(List<String> 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;
}
}
}

View File

@ -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<String, String> params = new HashMap<>();
params.put(APIUtils.NAME_KEY, username);
oauthRetrofit.create(RedditAPI.class).blockUser(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
blockUserListener.success();
} else {
blockUserListener.failed();
}
}
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
blockUserListener.failed();
}
});
}
}

View File

@ -35,13 +35,13 @@ public class APIUtils {
public static final String DURATION_KEY = "duration"; public static final String DURATION_KEY = "duration";
public static final String DURATION = "permanent"; public static final String DURATION = "permanent";
public static final String SCOPE_KEY = "scope"; 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 ACCESS_TOKEN_KEY = "access_token";
public static final String AUTHORIZATION_KEY = "Authorization"; public static final String AUTHORIZATION_KEY = "Authorization";
public static final String AUTHORIZATION_BASE = "bearer "; public static final String AUTHORIZATION_BASE = "bearer ";
public static final String USER_AGENT_KEY = "User-Agent"; 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_KEY = "grant_type";
public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; 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 SUBJECT_KEY = "subject";
public static final String TO_KEY = "to"; public static final String TO_KEY = "to";
public static final String NAME_KEY = "name";
public static Map<String, String> getHttpBasicAuthHeader() { public static Map<String, String> getHttpBasicAuthHeader() {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
String credentials = String.format("%s:%s", APIUtils.CLIENT_ID, ""); String credentials = String.format("%s:%s", APIUtils.CLIENT_ID, "");

View File

@ -16,8 +16,7 @@
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/image_view_view_imgur_image_fragment" android:id="@+id/image_view_view_imgur_image_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
app:quickScaleEnabled="false" />
<LinearLayout <LinearLayout
android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment" android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment"

View File

@ -79,8 +79,7 @@
android:id="@+id/action_report_view_post_detail_activity" android:id="@+id/action_report_view_post_detail_activity"
android:orderInCategory="12" android:orderInCategory="12"
android:title="@string/action_report" android:title="@string/action_report"
app:showAsAction="never" app:showAsAction="never" />
android:visible="false"/>
<item <item
android:id="@+id/action_see_removed_view_post_detail_activity" android:id="@+id/action_see_removed_view_post_detail_activity"

View File

@ -32,15 +32,25 @@
android:title="@string/action_change_post_layout" android:title="@string/action_change_post_layout"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_share_view_user_detail_activity"
android:orderInCategory="6"
android:title="@string/action_share"
app:showAsAction="never" />
<item <item
android:id="@+id/action_send_private_message_view_user_detail_activity" android:id="@+id/action_send_private_message_view_user_detail_activity"
android:orderInCategory="6" android:orderInCategory="6"
android:title="@string/action_send_private_message" android:title="@string/action_send_private_message"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_share_view_user_detail_activity"
android:orderInCategory="7"
android:title="@string/action_share"
app:showAsAction="never" />
<item
android:id="@+id/action_report_view_user_detail_activity"
android:orderInCategory="8"
android:title="@string/action_report" />
<item
android:id="@+id/action_block_user_view_user_detail_activity"
android:orderInCategory="9"
android:title="@string/action_block_user" />
</menu> </menu>

View File

@ -68,6 +68,7 @@
<string name="action_see_removed">See Removed</string> <string name="action_see_removed">See Removed</string>
<string name="action_set_wallpaper">Set as Wallpaper</string> <string name="action_set_wallpaper">Set as Wallpaper</string>
<string name="action_send_private_message">Send Private Message</string> <string name="action_send_private_message">Send Private Message</string>
<string name="action_block_user">Block User</string>
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string> <string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
<string name="retrieve_token_error">Error Retrieving the token</string> <string name="retrieve_token_error">Error Retrieving the token</string>
@ -441,8 +442,6 @@
<string name="settings_subreddit_summary">r/Infinity_For_Reddit</string> <string name="settings_subreddit_summary">r/Infinity_For_Reddit</string>
<string name="settings_share_title">Share</string> <string name="settings_share_title">Share</string>
<string name="settings_share_summary">Share this app to other people if you enjoy it</string> <string name="settings_share_summary">Share this app to other people if you enjoy it</string>
<string name="settings_crash_reports_title">Crash Reports</string>
<string name="settings_crash_reports_summary">See the error logs and send them to me when you report bugs</string>
<string name="settings_version_title">Infinity For Reddit</string> <string name="settings_version_title">Infinity For Reddit</string>
<string name="settings_version_summary">Version %s</string> <string name="settings_version_summary">Version %s</string>
<string name="settings_category_customization_title">Customization</string> <string name="settings_category_customization_title">Customization</string>
@ -850,4 +849,8 @@
<string name="login_activity_2fa_prompt">If you have 2-factor authentication enabled, kindly type your password like the following: &lt;password&gt;:&lt;2FA code&gt;.\nExample: yourpass:123456</string> <string name="login_activity_2fa_prompt">If you have 2-factor authentication enabled, kindly type your password like the following: &lt;password&gt;:&lt;2FA code&gt;.\nExample: yourpass:123456</string>
<string name="block_user">Block User</string>
<string name="block_user_success">Blocked</string>
<string name="block_user_failed">Failed to block user</string>
</resources> </resources>

View File

@ -45,11 +45,6 @@
app:title="@string/settings_share_title" app:title="@string/settings_share_title"
app:summary="@string/settings_share_summary" /> app:summary="@string/settings_share_summary" />
<Preference
app:title="@string/settings_crash_reports_title"
app:summary="@string/settings_crash_reports_summary"
app:fragment="ml.docilealligator.infinityforreddit.Settings.CrashReportsFragment" />
<Preference <Preference
android:key="version" android:key="version"
app:title="@string/settings_version_title" app:title="@string/settings_version_title"