aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-18 17:01:23 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-09-18 17:01:23 +0000
commit3552a9a490c64eec8e56f55fef2b359bcdabe5d1 (patch)
treef0d00bb16734ffda1fe550cf9977120e7652318f
parent4aa37adf43c5c6baeab12e4bc69bb907500eba44 (diff)
downloadinfinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar.gz
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar.bz2
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar.lz
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar.xz
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.tar.zst
infinity-for-reddit-3552a9a490c64eec8e56f55fef2b359bcdabe5d1.zip
Add an option to download all media in a gallery in ViewRedditGalleryActivity.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java31
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java2
-rw-r--r--app/src/main/res/layout/fragment_post_options_bottom_sheet.xml2
-rw-r--r--app/src/main/res/menu/view_reddit_gallery_activity.xml9
-rw-r--r--app/src/main/res/values/strings.xml2
8 files changed, 40 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
index 14005615..2dfe1ddc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java
@@ -5,6 +5,9 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Typeface;
@@ -49,14 +52,13 @@ import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGifFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.post.Post;
+import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
public class ViewRedditGalleryActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
- public static final String EXTRA_REDDIT_GALLERY = "ERG";
- public static final String EXTRA_SUBREDDIT_NAME = "ESN";
- public static final String EXTRA_IS_NSFW = "EIN";
+ public static final String EXTRA_POST = "EP";
public static final String EXTRA_GALLERY_ITEM_INDEX = "EGII";
@Inject
@@ -66,6 +68,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
Executor executor;
public Typeface typeface;
private SectionsPagerAdapter sectionsPagerAdapter;
+ private Post post;
private ArrayList<Post.Gallery> gallery;
private String subredditName;
private boolean isNsfw;
@@ -144,13 +147,18 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
getSupportActionBar().hide();
}
- gallery = getIntent().getParcelableArrayListExtra(EXTRA_REDDIT_GALLERY);
+ post = getIntent().getParcelableExtra(EXTRA_POST);
+ if (post == null) {
+ finish();
+ return;
+ }
+ gallery = post.getGallery();
if (gallery == null || gallery.isEmpty()) {
finish();
return;
}
- subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
- isNsfw = getIntent().getBooleanExtra(EXTRA_IS_NSFW, false);
+ subredditName = post.getSubredditName();
+ isNsfw = post.isNSFW();
if (sharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_VERTICALLY_TO_GO_BACK_FROM_MEDIA, true)) {
binding.getRoot().setOnDragDismissedListener(dragDirection -> {
@@ -201,6 +209,10 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
@Override
public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.view_reddit_gallery_activity, menu);
+ for (int i = 0; i < menu.size(); i++) {
+ Utils.setTitleWithCustomFontToMenuItem(typeface, menu.getItem(i), null);
+ }
return true;
}
@@ -209,6 +221,13 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
if (item.getItemId() == android.R.id.home) {
finish();
return true;
+ } else if (item.getItemId() == R.id.action_download_all_gallery_media_view_reddit_gallery_activity) {
+ //TODO: contentEstimatedBytes
+ JobInfo jobInfo = DownloadMediaService.constructGalleryDownloadAllImagesJobInfo(this, 5000000, post);
+ ((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
+
+ Toast.makeText(this, R.string.download_started, Toast.LENGTH_SHORT).show();
+ return true;
}
return false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
index a7e01054..8b6ca8d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java
@@ -2537,9 +2537,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mActivity.startActivity(intent);
} else if (post.getPostType() == Post.GALLERY_TYPE) {
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
- intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_IS_NSFW, post.isNSFW());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_POST, post);
intent.putExtra(ViewRedditGalleryActivity.EXTRA_GALLERY_ITEM_INDEX, galleryItemIndex);
mActivity.startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index bb704648..9b94485f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -1112,9 +1112,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mActivity.startActivity(intent);
} else if (post.getPostType() == Post.GALLERY_TYPE) {
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
- intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_IS_NSFW, post.isNSFW());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_POST, post);
intent.putExtra(ViewRedditGalleryActivity.EXTRA_GALLERY_ITEM_INDEX, galleryItemIndex);
mActivity.startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 6e88ad4b..dde14a7e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -2665,9 +2665,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mActivity.startActivity(intent);
} else if (post.getPostType() == Post.GALLERY_TYPE) {
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
- intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_SUBREDDIT_NAME, post.getSubredditName());
- intent.putExtra(ViewRedditGalleryActivity.EXTRA_IS_NSFW, post.isNSFW());
+ intent.putExtra(ViewRedditGalleryActivity.EXTRA_POST, post);
intent.putExtra(ViewRedditGalleryActivity.EXTRA_GALLERY_ITEM_INDEX, galleryItemIndex);
mActivity.startActivity(intent);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java
index e8b1c679..a272e1ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java
@@ -214,7 +214,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
requestPermissionAndDownload();
return true;
} else if (item.getItemId() == R.id.action_playback_speed_view_reddit_gallery_video_fragment) {
-
+ changePlaybackSpeed();
return true;
}
return false;
diff --git a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
index 3febcdd4..c5aa09b6 100644
--- a/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_post_options_bottom_sheet.xml
@@ -126,7 +126,7 @@
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
- android:text="@string/action_download_gallery"
+ android:text="@string/action_download_all_gallery_media"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:visibility="gone"
diff --git a/app/src/main/res/menu/view_reddit_gallery_activity.xml b/app/src/main/res/menu/view_reddit_gallery_activity.xml
new file mode 100644
index 00000000..f76cc079
--- /dev/null
+++ b/app/src/main/res/menu/view_reddit_gallery_activity.xml
@@ -0,0 +1,9 @@
+<?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_download_all_gallery_media_view_reddit_gallery_activity"
+ android:orderInCategory="10"
+ android:title="@string/action_download_all_gallery_media"
+ app:showAsAction="never" />
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fcb7d0b0..481aefe5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -99,7 +99,7 @@
<string name="action_more_options">More Options</string>
<string name="action_add_to_home_screen">Add to Home screen</string>
<string name="action_reset_fab_position">Reset FAB position</string>
- <string name="action_download_gallery">Download gallery</string>
+ <string name="action_download_all_gallery_media">Download All Gallery Media</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>