diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
index 58caad5a..2232a927 100644
--- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
+++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
@@ -334,6 +334,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment im
if (bottomSheetBehavior != null) {
captionState = bottomSheetBehavior.getState();
}
+ if (settingsHelper.getBoolean(Constants.PLAY_IN_BACKGROUND)) return;
final Media media = viewModel.getMedia();
if (media == null) return;
switch (media.getMediaType()) {
diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/PostPreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/PostPreferencesFragment.java
index 14daec7f..492f574c 100644
--- a/app/src/main/java/awais/instagrabber/fragments/settings/PostPreferencesFragment.java
+++ b/app/src/main/java/awais/instagrabber/fragments/settings/PostPreferencesFragment.java
@@ -17,16 +17,26 @@ public class PostPreferencesFragment extends BasePreferencesFragment {
final Context context = getContext();
if (context == null) return;
// generalCategory.addPreference(getAutoPlayVideosPreference(context));
+ screen.addPreference(getBackgroundPlayPreference(context));
screen.addPreference(getAlwaysMuteVideosPreference(context));
screen.addPreference(getShowCaptionPreference(context));
screen.addPreference(getToggleKeywordFilterPreference(context));
screen.addPreference(getEditKeywordFilterPreference(context));
}
- private Preference getAutoPlayVideosPreference(@NonNull final Context context) {
+// private Preference getAutoPlayVideosPreference(@NonNull final Context context) {
+// final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
+// preference.setKey(Constants.AUTOPLAY_VIDEOS);
+// preference.setTitle(R.string.post_viewer_autoplay_video);
+// preference.setIconSpaceReserved(false);
+// return preference;
+// }
+
+ private Preference getBackgroundPlayPreference(@NonNull final Context context) {
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
- preference.setKey(Constants.AUTOPLAY_VIDEOS);
- preference.setTitle(R.string.post_viewer_autoplay_video);
+ preference.setKey(Constants.PLAY_IN_BACKGROUND);
+ preference.setTitle(R.string.post_viewer_background_play);
+ preference.setTitle(R.string.post_viewer_background_play_summary);
preference.setIconSpaceReserved(false);
return preference;
}
diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java
index 52ad8818..221afd79 100644
--- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java
+++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java
@@ -229,7 +229,6 @@ public class DirectItem implements Cloneable, Serializable {
public LocalDateTime getLocalDateTime() {
if (localDateTime == null) {
localDateTime = Instant.ofEpochMilli(timestamp / 1000).atZone(ZoneId.systemDefault()).toLocalDateTime();
- ;
}
return localDateTime;
}
diff --git a/app/src/main/java/awais/instagrabber/utils/Constants.java b/app/src/main/java/awais/instagrabber/utils/Constants.java
index a2a5fd13..9f79641e 100644
--- a/app/src/main/java/awais/instagrabber/utils/Constants.java
+++ b/app/src/main/java/awais/instagrabber/utils/Constants.java
@@ -21,6 +21,7 @@ public final class Constants {
public static final String DOWNLOAD_USER_FOLDER = "download_user_folder";
public static final String TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter";
public static final String DOWNLOAD_PREPEND_USER_NAME = "download_user_name";
+ public static final String PLAY_IN_BACKGROUND = "play_in_background";
// deprecated: public static final String BOTTOM_TOOLBAR = "bottom_toolbar";
public static final String FOLDER_SAVE_TO = "saved_to";
public static final String AUTOPLAY_VIDEOS = "autoplay_videos";
diff --git a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java
index fc568d9e..659070a9 100755
--- a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java
+++ b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java
@@ -43,6 +43,7 @@ import static awais.instagrabber.utils.Constants.HIDE_MUTED_REELS;
import static awais.instagrabber.utils.Constants.KEYWORD_FILTERS;
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
+import static awais.instagrabber.utils.Constants.PLAY_IN_BACKGROUND;
import static awais.instagrabber.utils.Constants.PREF_DARK_THEME;
import static awais.instagrabber.utils.Constants.PREF_EMOJI_VARIANTS;
import static awais.instagrabber.utils.Constants.PREF_HASHTAG_POSTS_LAYOUT;
@@ -164,7 +165,7 @@ public final class SettingsHelper {
@StringDef({DOWNLOAD_USER_FOLDER, DOWNLOAD_PREPEND_USER_NAME, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS,
SHOW_CAPTIONS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY,
CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED, PREF_ENABLE_DM_NOTIFICATIONS, PREF_ENABLE_DM_AUTO_REFRESH,
- FLAG_SECURE, TOGGLE_KEYWORD_FILTER, PREF_ENABLE_SENTRY, HIDE_MUTED_REELS})
+ FLAG_SECURE, TOGGLE_KEYWORD_FILTER, PREF_ENABLE_SENTRY, HIDE_MUTED_REELS, PLAY_IN_BACKGROUND})
public @interface BooleanSettings {}
@StringDef({PREV_INSTALL_VERSION, BROWSER_UA_CODE, APP_UA_CODE, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER})
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9cf27407..9e67c16d 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -59,6 +59,8 @@
%s\nFollowing
Autoplay videos
+ Continue to play videos in background
+ When app is not in focus
Always mute videos
Always show post captions
Select what to download