aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-09 08:57:04 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-09 08:57:04 +0000
commit1179cb50fa939c296e14233a9e8109babefe8760 (patch)
tree716d7d35b6410ecc61012137f644eab1c01afc65 /app/src/main
parent17fc426ecb9c3b5c7cf8ada5231ab150248fbb21 (diff)
downloadinfinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar.gz
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar.bz2
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar.lz
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar.xz
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.tar.zst
infinity-for-reddit-1179cb50fa939c296e14233a9e8109babefe8760.zip
Browse posts and search posts are now available in anonymous mode.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AccountRecyclerViewAdapter.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java85
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java62
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java36
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java2
-rw-r--r--app/src/main/res/values/strings.xml1
9 files changed, 190 insertions, 54 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AccountRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AccountRecyclerViewAdapter.java
index cde80fab..7aba25a7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AccountRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AccountRecyclerViewAdapter.java
@@ -77,20 +77,29 @@ class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerVie
holder.usernameTextView.setText(R.string.add_account);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
} else if(position == mAccounts.size() + 1) {
- holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
- mGlide.load(R.drawable.ic_outline_public_24px)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
- .into(holder.profileImageGifImageView);
- holder.usernameTextView.setText(R.string.anonymous_account);
- holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
- } else if(position == mAccounts.size() + 2){
+ if(mCurrentAccountName != null) {
+ holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
+ mGlide.load(R.drawable.ic_outline_public_24px)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
+ .into(holder.profileImageGifImageView);
+ holder.usernameTextView.setText(R.string.anonymous_account);
+ holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
+ } else {
+ holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
+ mGlide.load(R.drawable.ic_outline_settings_24px)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
+ .into(holder.profileImageGifImageView);
+ holder.usernameTextView.setText(R.string.manage_accounts);
+ holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected());
+ }
+ } else if(position == mAccounts.size() + 2) {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_settings_24px)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
.into(holder.profileImageGifImageView);
holder.usernameTextView.setText(R.string.manage_accounts);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected());
- } else if(mCurrentAccountName != null) {
+ } else {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_block_24px)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
@@ -107,7 +116,7 @@ class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerVie
return 1;
} else {
if(mCurrentAccountName == null) {
- return mAccounts.size() + 3;
+ return mAccounts.size() + 2;
} else {
return mAccounts.size() + 4;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java
index ec736a95..b1e7816b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java
@@ -19,7 +19,7 @@ class FetchPost {
static void fetchPost(Retrofit oauthRetrofit, String id, String accessToken, Locale locale, FetchPostListener fetchPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
- Call<String> postCall = api.getPost(id, RedditUtils.getOAuthHeader(accessToken));
+ Call<String> postCall = api.getPostOauth(id, RedditUtils.getOAuthHeader(accessToken));
postCall.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 7fb79cc9..a2e19cdc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -297,8 +297,13 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
loadUserData();
- mAccountNameTextView.setText(mAccountName);
- mKarmaTextView.setText(getString(R.string.karma_info, mKarma));
+ if(mAccessToken != null) {
+ mKarmaTextView.setText(getString(R.string.karma_info, mKarma));
+ mAccountNameTextView.setText(mAccountName);
+ } else {
+ mKarmaTextView.setText(R.string.press_here_to_login);
+ mAccountNameTextView.setText(R.string.anonymous_account);
+ }
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
glide.load(mProfileImageUrl)
@@ -516,6 +521,30 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@NonNull
@Override
public Fragment getItem(int position) {
+ if(mAccessToken == null) {
+ if(position == 0) {
+ PostFragment fragment = new PostFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ bundle.putString(PostFragment.EXTRA_NAME, "popular");
+ bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_HOT);
+ bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER);
+ bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ fragment.setArguments(bundle);
+ return fragment;
+ } else {
+ PostFragment fragment = new PostFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ bundle.putString(PostFragment.EXTRA_NAME, "all");
+ bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_HOT);
+ bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER);
+ bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ fragment.setArguments(bundle);
+ return fragment;
+ }
+ }
+
if (position == 0) {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
@@ -619,34 +648,54 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
}
void changeSortType(String sortType) {
- switch (viewPager.getCurrentItem()) {
- case 0:
- frontPagePostFragment.changeSortType(sortType);
- break;
- case 1:
+ if(mAccessToken == null) {
+ if(viewPager.getCurrentItem() == 0) {
popularPostFragment.changeSortType(sortType);
- break;
- case 2:
+ } else {
allPostFragment.changeSortType(sortType);
+ }
+ } else {
+ switch (viewPager.getCurrentItem()) {
+ case 0:
+ frontPagePostFragment.changeSortType(sortType);
+ break;
+ case 1:
+ popularPostFragment.changeSortType(sortType);
+ break;
+ case 2:
+ allPostFragment.changeSortType(sortType);
+ }
}
}
public void refresh() {
- switch (viewPager.getCurrentItem()) {
- case 0:
- if(frontPagePostFragment != null) {
- ((FragmentCommunicator) frontPagePostFragment).refresh();
- }
- break;
- case 1:
+ if(mAccessToken == null) {
+ if(viewPager.getCurrentItem() == 0) {
if(popularPostFragment != null) {
((FragmentCommunicator) popularPostFragment).refresh();
}
- break;
- case 2:
+ } else {
if(allPostFragment != null) {
((FragmentCommunicator) allPostFragment).refresh();
}
+ }
+ } else {
+ switch (viewPager.getCurrentItem()) {
+ case 0:
+ if(frontPagePostFragment != null) {
+ ((FragmentCommunicator) frontPagePostFragment).refresh();
+ }
+ break;
+ case 1:
+ if(popularPostFragment != null) {
+ ((FragmentCommunicator) popularPostFragment).refresh();
+ }
+ break;
+ case 2:
+ if(allPostFragment != null) {
+ ((FragmentCommunicator) allPostFragment).refresh();
+ }
+ }
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
index a0f42bbb..e471435f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
@@ -53,8 +53,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
this.retrofit = retrofit;
this.accessToken = accessToken;
this.locale = locale;
- paginationNetworkStateLiveData = new MutableLiveData();
- initialLoadStateLiveData = new MutableLiveData();
+ paginationNetworkStateLiveData = new MutableLiveData<>();
+ initialLoadStateLiveData = new MutableLiveData<>();
hasPostLiveData = new MutableLiveData<>();
this.postType = postType;
this.sortType = sortType;
@@ -284,7 +284,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
private void loadSubredditPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) {
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, lastItem, RedditUtils.getOAuthHeader(accessToken));
+
+ Call<String> getPost;
+ if(accessToken == null) {
+ getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, lastItem);
+ } else {
+ getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType, lastItem, RedditUtils.getOAuthHeader(accessToken));
+ }
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@@ -356,7 +362,14 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
String after = lastItem == null ? params.key : lastItem;
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, after, RedditUtils.getOAuthHeader(accessToken));
+
+ Call<String> getPost;
+ if(accessToken == null) {
+ getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, after);
+ } else {
+ getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType, after, RedditUtils.getOAuthHeader(accessToken));
+ }
+
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@@ -394,7 +407,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
private void loadUserPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) {
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> getPost = api.getUserBestPosts(subredditOrUserName, lastItem, RedditUtils.getOAuthHeader(accessToken));
+
+ Call<String> getPost;
+ if(accessToken == null) {
+ getPost = api.getUserBestPosts(subredditOrUserName, lastItem);
+ } else {
+ getPost = api.getUserBestPostsOauth(subredditOrUserName, lastItem, RedditUtils.getOAuthHeader(accessToken));
+ }
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@@ -447,7 +466,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
String after = lastItem == null ? params.key : lastItem;
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> getPost = api.getUserBestPosts(subredditOrUserName, after, RedditUtils.getOAuthHeader(accessToken));
+
+ Call<String> getPost;
+ if(accessToken == null) {
+ getPost = api.getUserBestPosts(subredditOrUserName, after);
+ } else {
+ getPost = api.getUserBestPostsOauth(subredditOrUserName, after, RedditUtils.getOAuthHeader(accessToken));
+ }
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@@ -488,9 +513,18 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost;
if(subredditOrUserName == null) {
- getPost = api.searchPosts(query, null, sortType, RedditUtils.getOAuthHeader(accessToken));
+ if(accessToken == null) {
+ getPost = api.searchPosts(query, lastItem, sortType);
+ } else {
+ getPost = api.searchPostsOauth(query, lastItem, sortType, RedditUtils.getOAuthHeader(accessToken));
+ }
} else {
- getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, null, RedditUtils.getOAuthHeader(accessToken));
+ if(accessToken == null) {
+ getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, lastItem);
+ } else {
+ getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query, lastItem,
+ RedditUtils.getOAuthHeader(accessToken));
+ }
}
getPost.enqueue(new Callback<String>() {
@@ -548,9 +582,17 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost;
if(subredditOrUserName == null) {
- getPost = api.searchPosts(query, after, sortType, RedditUtils.getOAuthHeader(accessToken));
+ if(accessToken == null) {
+ getPost = api.searchPosts(query, after, sortType);
+ } else {
+ getPost = api.searchPostsOauth(query, after, sortType, RedditUtils.getOAuthHeader(accessToken));
+ }
} else {
- getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, after, RedditUtils.getOAuthHeader(accessToken));
+ if(accessToken == null) {
+ getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, after);
+ } else {
+ getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query, after, RedditUtils.getOAuthHeader(accessToken));
+ }
}
getPost.enqueue(new Callback<String>() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index 3baa0c59..2506dde8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -200,8 +200,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
});
- factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
- getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter);
+ if(accessToken == null) {
+ factory = new PostViewModel.Factory(mRetrofit, accessToken,
+ getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter);
+ } else {
+ factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
+ getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter);
+ }
} else if(postType == PostDataSource.TYPE_SUBREDDIT) {
String subredditName = getArguments().getString(EXTRA_NAME);
@@ -224,8 +229,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
});
- factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
- getResources().getConfiguration().locale, subredditName, postType, sortType, filter);
+ if(accessToken == null) {
+ factory = new PostViewModel.Factory(mRetrofit, accessToken,
+ getResources().getConfiguration().locale, subredditName, postType, sortType, filter);
+ } else {
+ factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
+ getResources().getConfiguration().locale, subredditName, postType, sortType, filter);
+ }
} else if(postType == PostDataSource.TYPE_USER) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
@@ -251,8 +261,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
});
- factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
- getResources().getConfiguration().locale, username, postType, sortType, filter);
+ if(accessToken == null) {
+ factory = new PostViewModel.Factory(mRetrofit, accessToken,
+ getResources().getConfiguration().locale, username, postType, sortType, filter);
+ } else {
+ factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
+ getResources().getConfiguration().locale, username, postType, sortType, filter);
+ }
} else {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, redditDataRoomDatabase,
accessToken, postType, true, new PostRecyclerViewAdapter.Callback() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
index f0a9ac5b..89d848c1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
@@ -39,18 +39,28 @@ public interface RedditAPI {
Call<String> voteThing(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@GET("comments/{id}.json?raw_json=1")
- Call<String> getPost(@Path("id") String id, @HeaderMap Map<String, String> headers);
+ Call<String> getPostOauth(@Path("id") String id, @HeaderMap Map<String, String> headers);
+
+ @GET("comments/{id}.json?raw_json=1")
+ Call<String> getPost(@Path("id") String id);
@GET("{sortType}?raw_json=1")
Call<String> getBestPosts(@Path("sortType") String sortType, @Query("after") String lastItem, @HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25")
+ Call<String> getSubredditBestPostsOauth(@Path("subredditName") String subredditName, @Path("sortType") String sortType,
+ @Query("after") String lastItem, @HeaderMap Map<String, String> headers);
+
+ @GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25")
Call<String> getSubredditBestPosts(@Path("subredditName") String subredditName, @Path("sortType") String sortType,
- @Query("after") String lastItem, @HeaderMap Map<String, String> headers);
+ @Query("after") String lastItem);
@GET("user/{username}/submitted.json?raw_json=1&limit=25")
- Call<String> getUserBestPosts(@Path("username") String username, @Query("after") String lastItem,
- @HeaderMap Map<String, String> headers);
+ Call<String> getUserBestPostsOauth(@Path("username") String username, @Query("after") String lastItem,
+ @HeaderMap Map<String, String> headers);
+
+ @GET("user/{username}/submitted.json?raw_json=1&limit=25")
+ Call<String> getUserBestPosts(@Path("username") String username, @Query("after") String lastItem);
@GET("user/{username}/about.json?raw_json=1")
Call<String> getUserData(@Path("username") String username);
@@ -72,12 +82,19 @@ public interface RedditAPI {
Call<String> searchUsers(@Query("q") String profileName, @Query("after") String after, @Query("sort") String sort);
@GET("search.json?raw_json=1&type=link&include_over_18=on")
- Call<String> searchPosts(@Query("q") String query, @Query("after") String after, @Query("sort") String sort,
- @HeaderMap Map<String, String> headers);
+ Call<String> searchPostsOauth(@Query("q") String query, @Query("after") String after, @Query("sort") String sort,
+ @HeaderMap Map<String, String> headers);
+
+ @GET("search.json?raw_json=1&type=link&include_over_18=on")
+ Call<String> searchPosts(@Query("q") String query, @Query("after") String after, @Query("sort") String sort);
+
+ @GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on")
+ Call<String> searchPostsInSpecificSubredditOauth(@Path("subredditName") String subredditName, @Query("q") String query,
+ @Query("after") String after, @HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on")
Call<String> searchPostsInSpecificSubreddit(@Path("subredditName") String subredditName, @Query("q") String query,
- @Query("after") String after, @HeaderMap Map<String, String> headers);
+ @Query("after") String after);
@FormUrlEncoded
@POST("api/comment")
@@ -102,7 +119,10 @@ public interface RedditAPI {
Call<String> getRules(@Path("subredditName") String subredditName);
@GET("/comments/{id}.json?raw_json=1")
- Call<String> getPostAndCommentsById(@Path("id") String id, @HeaderMap Map<String, String> headers);
+ Call<String> getPostAndCommentsByIdOauth(@Path("id") String id, @HeaderMap Map<String, String> headers);
+
+ @GET("/comments/{id}.json?raw_json=1")
+ Call<String> getPostAndCommentsById(@Path("id") String id);
@Multipart
@POST(".")
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java
index 60b90560..d55b227b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java
@@ -439,7 +439,7 @@ class SubmitPost {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
- Call<String> getPostCall = api.getPost(postId, RedditUtils.getOAuthHeader(accessToken));
+ Call<String> getPostCall = api.getPostOauth(postId, RedditUtils.getOAuthHeader(accessToken));
getPostCall.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
index 6c0390da..40f6bc07 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java
@@ -201,7 +201,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
RedditAPI api = mOauthRetrofit.create(RedditAPI.class);
- Call<String> postAndComments = api.getPostAndCommentsById(subredditId, RedditUtils.getOAuthHeader(accessToken));
+ Call<String> postAndComments = api.getPostAndCommentsByIdOauth(subredditId, RedditUtils.getOAuthHeader(accessToken));
postAndComments.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1234b405..32b68cbd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -176,4 +176,5 @@
<string name="anonymous_account">Anonymous</string>
<string name="manage_accounts">Manage accounts</string>
<string name="log_out">Log out</string>
+ <string name="press_here_to_login">Press here to login</string>
</resources>