aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-10-04 03:24:50 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-10-04 03:24:50 +0000
commit4f19bd83aa8d2500d825ce63ae8770325b4a44e9 (patch)
tree47d2c32a87b1c5c074ea84c5077c11db62ac3926 /app/src/main/java/ml/docilealligator/infinityforreddit
parent60fdb813c02f266c8c5ecaf20bfaee711372a982 (diff)
downloadinfinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar.gz
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar.bz2
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar.lz
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar.xz
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.tar.zst
infinity-for-reddit-4f19bd83aa8d2500d825ce63ae8770325b4a44e9.zip
Add two options: go to user and go to subreddit in FABMoreOptionsBottomSheetFragment.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/API/RedditAPI.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java63
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java59
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FABMoreOptionsBottomSheetFragment.java24
5 files changed, 152 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/API/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/API/RedditAPI.java
index db5798ec..ae2756e0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/API/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/API/RedditAPI.java
@@ -330,4 +330,10 @@ public interface RedditAPI {
@FormUrlEncoded
@POST("api/v2/gold/gild")
Call<String> awardThing(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
+
+ @GET("/r/random/comments.json?limit=1&raw_json=1")
+ Call<String> getRandomPost();
+
+ @GET("/r/randnsfw/new?sort=new&t=all&limit=1&raw_json=1")
+ Call<String> getRandomNSFWPost();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index c98a5e84..96851532 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -13,6 +14,8 @@ import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
@@ -1158,6 +1161,66 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Intent intent = new Intent(this, SearchActivity.class);
startActivity(intent);
break;
+ case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
+ EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
+ thingEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.go_to_user)
+ .setView(thingEditText)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
+ subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
+ startActivity(subredditIntent);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ break;
+ }
+ case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_USER: {
+ EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
+ thingEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.go_to_user)
+ .setView(thingEditText)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
+ userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
+ startActivity(userIntent);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ break;
+ }
+ case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
+
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index a5c7b9a7..3b043b9e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -12,6 +13,8 @@ import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -1065,6 +1068,62 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
startActivity(intent);
break;
+ case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
+ EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
+ thingEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.go_to_user)
+ .setView(thingEditText)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
+ subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
+ startActivity(subredditIntent);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ break;
+ }
+ case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_USER: {
+ EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
+ thingEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.go_to_user)
+ .setView(thingEditText)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
+ userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
+ startActivity(userIntent);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index db43a4c5..1cbdc75e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -587,7 +587,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (post.isNSFW() && mMuteNSFWVideo) ? 0f : 1f);
if (post.isGfycat() || post.isRedgifs() && !post.isLoadGfyOrRedgifsVideoSuccess()) {
- ((PostVideoAutoplayViewHolder) holder).typeTextView.setText("GFYCAT");
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
@@ -606,7 +605,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mGfycatRetrofit, mRedgifsRetrofit,
post.getGfycatId(), post.isGfycat(), mAutomaticallyTryRedgifs);
} else {
- ((PostVideoAutoplayViewHolder) holder).typeTextView.setText("VIDEO");
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
}
} else if (holder instanceof PostVideoAndGifPreviewViewHolder) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FABMoreOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FABMoreOptionsBottomSheetFragment.java
index dc4b212b..2924f34c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FABMoreOptionsBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/FABMoreOptionsBottomSheetFragment.java
@@ -22,6 +22,9 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
public static final int FAB_OPTION_CHANGE_SORT_TYPE = 2;
public static final int FAB_OPTION_CHANGE_POST_LAYOUT = 3;
public static final int FAB_OPTION_SEARCH = 4;
+ public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5;
+ public static final int FAB_OPTION_GO_TO_USER = 6;
+ public static final int FAB_RANDOM = 7;
@BindView(R.id.submit_post_text_view_fab_more_options_bottom_sheet_fragment)
TextView submitPostTextView;
@@ -33,6 +36,12 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
TextView changePostLayoutTextView;
@BindView(R.id.search_text_view_fab_more_options_bottom_sheet_fragment)
TextView searchTextView;
+ @BindView(R.id.go_to_subreddit_text_view_fab_more_options_bottom_sheet_fragment)
+ TextView goToSubredditTextView;
+ @BindView(R.id.go_to_user_text_view_fab_more_options_bottom_sheet_fragment)
+ TextView goToUserTextView;
+ @BindView(R.id.random_text_view_fab_more_options_bottom_sheet_fragment)
+ TextView randomTextView;
private FABOptionSelectionCallback activity;
public FABMoreOptionsBottomSheetFragment() {
@@ -72,6 +81,21 @@ public class FABMoreOptionsBottomSheetFragment extends RoundedBottomSheetDialogF
dismiss();
});
+ goToSubredditTextView.setOnClickListener(view -> {
+ activity.fabOptionSelected(FAB_OPTION_GO_TO_SUBREDDIT);
+ dismiss();
+ });
+
+ goToUserTextView.setOnClickListener(view -> {
+ activity.fabOptionSelected(FAB_OPTION_GO_TO_USER);
+ dismiss();
+ });
+
+ randomTextView.setOnClickListener(view -> {
+ activity.fabOptionSelected(FAB_RANDOM);
+ dismiss();
+ });
+
return rootView;
}