aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java65
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java2
7 files changed, 99 insertions, 46 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index b2dfb26e..4c8c893b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -697,6 +697,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
break;
+ case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
+ break;
default:
if (mAccessToken == null) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
@@ -747,6 +750,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
sectionsPagerAdapter.filterPosts();
}
break;
+ case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -1368,6 +1376,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_GO_TO_TOP: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
index 453456d5..f20299fa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -298,7 +298,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
- fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
+ fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_hide_read_posts_24dp);
}
@@ -306,10 +306,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
fab.setImageResource(R.drawable.ic_filter_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ fab.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
+ break;
default:
if (mAccessToken == null) {
fab.setImageResource(R.drawable.ic_filter_24dp);
- fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
+ fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
fab.setImageResource(R.drawable.ic_add_day_night_24dp);
}
@@ -363,6 +366,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
sectionsPagerAdapter.filterPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -561,6 +569,12 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_GO_TO_TOP: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
index de0a22c7..97d72408 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -339,7 +339,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS:
if (mAccessToken == null) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
- fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
+ fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_hide_read_posts_24dp);
}
@@ -347,10 +347,13 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
+ break;
default:
if (mAccessToken == null) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
- fabOption = SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
+ fabOption = SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS;
} else {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_add_day_night_24dp);
}
@@ -396,6 +399,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
((PostFragment) mFragment).filterPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ if (mFragment instanceof PostFragment) {
+ ((PostFragment) mFragment).goBackToTop();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -964,6 +972,12 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_GO_TO_TOP: {
+ if (mFragment instanceof PostFragment) {
+ ((PostFragment) mFragment).goBackToTop();
+ }
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index de2bb5a6..0a9b837b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -867,6 +867,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
+ break;
default:
if (mAccessToken == null) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
@@ -918,6 +921,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
sectionsPagerAdapter.filterPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -1378,6 +1386,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_GO_TO_TOP: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 00f5ba09..5e4626ba 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -830,6 +830,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS:
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_keyboard_double_arrow_up_24);
+ break;
default:
if (mAccessToken == null) {
navigationWrapper.floatingActionButton.setImageResource(R.drawable.ic_filter_24dp);
@@ -880,6 +883,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
sectionsPagerAdapter.filterPosts();
}
break;
+ case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP:
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
default:
PostTypeBottomSheetFragment postTypeBottomSheetFragment = new PostTypeBottomSheetFragment();
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
@@ -1320,6 +1328,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
break;
}
+ case FABMoreOptionsBottomSheetFragment.FAB_GO_TO_TOP: {
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.goBackToTop();
+ }
+ break;
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
index 39d2b937..9925cbe3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FABMoreOptionsBottomSheetFragment.java
@@ -6,15 +6,12 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import androidx.annotation.NonNull;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
+import ml.docilealligator.infinityforreddit.databinding.FragmentFabMoreOptionsBottomSheetBinding;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
@@ -30,27 +27,8 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
public static final int FAB_RANDOM = 7;
public static final int FAB_HIDE_READ_POSTS = 8;
public static final int FAB_FILTER_POSTS = 9;
+ public static final int FAB_GO_TO_TOP = 10;
- @BindView(R.id.submit_post_text_view_fab_more_options_bottom_sheet_fragment)
- TextView submitPostTextView;
- @BindView(R.id.refresh_text_view_fab_more_options_bottom_sheet_fragment)
- TextView refreshTextView;
- @BindView(R.id.change_sort_type_text_view_fab_more_options_bottom_sheet_fragment)
- TextView changeSortTypeTextView;
- @BindView(R.id.change_post_layout_text_view_fab_more_options_bottom_sheet_fragment)
- 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;
- @BindView(R.id.hide_read_posts_text_view_fab_more_options_bottom_sheet_fragment)
- TextView hideReadPostsTextView;
- @BindView(R.id.filter_posts_text_view_fab_more_options_bottom_sheet_fragment)
- TextView filterPostsTextView;
private FABOptionSelectionCallback activity;
public FABMoreOptionsBottomSheetFragment() {
@@ -58,76 +36,79 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
- View rootView = inflater.inflate(R.layout.fragment_fab_more_options_bottom_sheet, container, false);
-
- ButterKnife.bind(this, rootView);
+ FragmentFabMoreOptionsBottomSheetBinding binding = FragmentFabMoreOptionsBottomSheetBinding.inflate(inflater, container, false);
if (getArguments() != null && getArguments().getBoolean(EXTRA_ANONYMOUS_MODE, false)) {
- submitPostTextView.setVisibility(View.GONE);
- hideReadPostsTextView.setVisibility(View.GONE);
+ binding.submitPostTextViewFabMoreOptionsBottomSheetFragment.setVisibility(View.GONE);
+ binding.hideReadPostsTextViewFabMoreOptionsBottomSheetFragment.setVisibility(View.GONE);
} else {
- submitPostTextView.setOnClickListener(view -> {
+ binding.submitPostTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_SUBMIT_POST);
dismiss();
});
- hideReadPostsTextView.setOnClickListener(view -> {
+ binding.hideReadPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_HIDE_READ_POSTS);
dismiss();
});
}
- refreshTextView.setOnClickListener(view -> {
+ binding.refreshTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_REFRESH);
dismiss();
});
- changeSortTypeTextView.setOnClickListener(view -> {
+ binding.changeSortTypeTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_CHANGE_SORT_TYPE);
dismiss();
});
- changePostLayoutTextView.setOnClickListener(view -> {
+ binding.changePostLayoutTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_CHANGE_POST_LAYOUT);
dismiss();
});
- searchTextView.setOnClickListener(view -> {
+ binding.searchTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_SEARCH);
dismiss();
});
- goToSubredditTextView.setOnClickListener(view -> {
+ binding.goToSubredditTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_GO_TO_SUBREDDIT);
dismiss();
});
- goToUserTextView.setOnClickListener(view -> {
+ binding.goToUserTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_GO_TO_USER);
dismiss();
});
- randomTextView.setOnClickListener(view -> {
+ binding.randomTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_RANDOM);
dismiss();
});
- filterPostsTextView.setOnClickListener(view -> {
+ binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_FILTER_POSTS);
dismiss();
});
+ binding.goToTopTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
+ activity.fabOptionSelected(FAB_GO_TO_TOP);
+ dismiss();
+ });
+
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) baseActivity).typeface != null) {
- Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface);
+ Utils.setFontToAllTextViews(binding.getRoot(), ((BaseActivity) baseActivity).typeface);
}
}
- return rootView;
+ return binding.getRoot();
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index e530b853..dc97ea85 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -291,6 +291,7 @@ public class SharedPreferencesUtils {
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_RANDOM = 7;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS = 8;
public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_FILTER_POSTS = 9;
+ public static final int MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_TOP = 10;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME = 0;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS = 1;
@@ -324,6 +325,7 @@ public class SharedPreferencesUtils {
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_RANDOM = 7;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_HIDE_READ_POSTS = 8;
public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_FILTER_POSTS = 9;
+ public static final int OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_TOP = 10;
public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler";
public static final String NSFW_BASE = "_nsfw";