aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java32
-rw-r--r--app/src/main/res/menu/history_post_fragment.xml8
2 files changed, 40 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
index 369da42b..3ea7ae13 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java
@@ -9,6 +9,9 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -54,6 +57,7 @@ import ml.docilealligator.infinityforreddit.post.HistoryPostViewModel;
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.utils.Utils;
import ml.docilealligator.infinityforreddit.videoautoplay.ExoCreator;
import ml.docilealligator.infinityforreddit.videoautoplay.media.PlaybackInfo;
import ml.docilealligator.infinityforreddit.videoautoplay.media.VolumeInfo;
@@ -356,6 +360,34 @@ public class HistoryPostFragment extends PostFragmentBase implements FragmentCom
view -> mAdapter.retry())));
}
+ @Override
+ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
+ inflater.inflate(R.menu.history_post_fragment, menu);
+ for (int i = 0; i < menu.size(); i++) {
+ Utils.setTitleWithCustomFontToMenuItem(activity.typeface, menu.getItem(i), null);
+ }
+ lazyModeItem = menu.findItem(R.id.action_lazy_mode_history_post_fragment);
+
+ if (isInLazyMode) {
+ Utils.setTitleWithCustomFontToMenuItem(activity.typeface, lazyModeItem, getString(R.string.action_stop_lazy_mode));
+ } else {
+ Utils.setTitleWithCustomFontToMenuItem(activity.typeface, lazyModeItem, getString(R.string.action_start_lazy_mode));
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ if (item.getItemId() == R.id.action_lazy_mode_history_post_fragment) {
+ if (isInLazyMode) {
+ stopLazyMode();
+ } else {
+ startLazyMode();
+ }
+ return true;
+ }
+ return false;
+ }
+
private void noPostFound() {
hasPost = false;
if (isInLazyMode) {
diff --git a/app/src/main/res/menu/history_post_fragment.xml b/app/src/main/res/menu/history_post_fragment.xml
new file mode 100644
index 00000000..31fa8e8c
--- /dev/null
+++ b/app/src/main/res/menu/history_post_fragment.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/action_lazy_mode_history_post_fragment"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+</menu> \ No newline at end of file