Browse Source

made play in background an option per https://redd.it/mmpeg9

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
84d82e92d3
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 1
      app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
  2. 16
      app/src/main/java/awais/instagrabber/fragments/settings/PostPreferencesFragment.java
  3. 1
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItem.java
  4. 1
      app/src/main/java/awais/instagrabber/utils/Constants.java
  5. 3
      app/src/main/java/awais/instagrabber/utils/SettingsHelper.java
  6. 2
      app/src/main/res/values/strings.xml

1
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()) {

16
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;
}

1
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;
}

1
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";

3
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})

2
app/src/main/res/values/strings.xml

@ -59,6 +59,8 @@
</plurals>
<string name="main_posts_following">%s\nFollowing</string>
<string name="post_viewer_autoplay_video">Autoplay videos</string>
<string name="post_viewer_background_play">Continue to play videos in background</string>
<string name="post_viewer_background_play_summary">When app is not in focus</string>
<string name="post_viewer_muted_autoplay">Always mute videos</string>
<string name="post_viewer_show_captions">Always show post captions</string>
<string name="post_viewer_download_dialog_title">Select what to download</string>

Loading…
Cancel
Save