Browse Source

restore stories autoplay; close #1409 (main)

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
dcd00ce60b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
  2. 3
      app/src/main/java/awais/instagrabber/fragments/settings/PreferenceKeys.kt
  3. 9
      app/src/main/java/awais/instagrabber/fragments/settings/StoriesPreferencesFragment.java
  4. 4
      app/src/main/java/awais/instagrabber/utils/SettingsHelper.kt
  5. 1
      app/src/main/res/values/strings.xml

4
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

@ -1029,7 +1029,7 @@ public class StoryViewerFragment extends Fragment {
if (context == null) return; if (context == null) return;
player = new SimpleExoPlayer.Builder(context).build(); player = new SimpleExoPlayer.Builder(context).build();
binding.playerView.setPlayer(player); binding.playerView.setPlayer(player);
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS));
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS_STORIES));
final Uri uri = Uri.parse(url); final Uri uri = Uri.parse(url);
final MediaItem mediaItem = MediaItem.fromUri(uri); final MediaItem mediaItem = MediaItem.fromUri(uri);
@ -1130,7 +1130,7 @@ public class StoryViewerFragment extends Fragment {
if (context == null) return; if (context == null) return;
player = new SimpleExoPlayer.Builder(context).build(); player = new SimpleExoPlayer.Builder(context).build();
binding.playerView.setPlayer(player); binding.playerView.setPlayer(player);
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS));
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS_STORIES));
final Uri uri = Uri.parse(url); final Uri uri = Uri.parse(url);
final MediaItem mediaItem = MediaItem.fromUri(uri); final MediaItem mediaItem = MediaItem.fromUri(uri);

3
app/src/main/java/awais/instagrabber/fragments/settings/PreferenceKeys.kt

@ -30,8 +30,7 @@ object PreferenceKeys {
const val TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter" const val TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter"
const val DOWNLOAD_PREPEND_USER_NAME = "download_user_name" const val DOWNLOAD_PREPEND_USER_NAME = "download_user_name"
const val PLAY_IN_BACKGROUND = "play_in_background" const val PLAY_IN_BACKGROUND = "play_in_background"
const val FOLDER_SAVE_TO = "saved_to"
const val AUTOPLAY_VIDEOS = "autoplay_videos"
const val AUTOPLAY_VIDEOS_STORIES = "autoplay_videos"
const val MUTED_VIDEOS = "muted_videos" const val MUTED_VIDEOS = "muted_videos"
const val SHOW_CAPTIONS = "show_captions" const val SHOW_CAPTIONS = "show_captions"
const val CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled" const val CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled"

9
app/src/main/java/awais/instagrabber/fragments/settings/StoriesPreferencesFragment.java

@ -18,6 +18,7 @@ public class StoriesPreferencesFragment extends BasePreferencesFragment {
screen.addPreference(getStorySortPreference(context)); screen.addPreference(getStorySortPreference(context));
screen.addPreference(getHideMutedReelsPreference(context)); screen.addPreference(getHideMutedReelsPreference(context));
screen.addPreference(getMarkStoriesSeenPreference(context)); screen.addPreference(getMarkStoriesSeenPreference(context));
screen.addPreference(getAutoPlayPreference(context));
} }
private Preference getStorySortPreference(@NonNull final Context context) { private Preference getStorySortPreference(@NonNull final Context context) {
@ -53,4 +54,12 @@ public class StoriesPreferencesFragment extends BasePreferencesFragment {
preference.setIconSpaceReserved(false); preference.setIconSpaceReserved(false);
return preference; return preference;
} }
private Preference getAutoPlayPreference(@NonNull final Context context) {
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
preference.setKey(PreferenceKeys.AUTOPLAY_VIDEOS_STORIES);
preference.setTitle(R.string.autoplay_stories_setting);
preference.setIconSpaceReserved(false);
return preference;
}
} }

4
app/src/main/java/awais/instagrabber/utils/SettingsHelper.kt

@ -7,7 +7,6 @@ import androidx.annotation.StringDef
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import java.util.* import java.util.*
import awais.instagrabber.utils.Constants
import awais.instagrabber.fragments.settings.PreferenceKeys import awais.instagrabber.fragments.settings.PreferenceKeys
class SettingsHelper(context: Context) { class SettingsHelper(context: Context) {
@ -117,8 +116,7 @@ class SettingsHelper(context: Context) {
@StringDef( @StringDef(
PreferenceKeys.DOWNLOAD_USER_FOLDER, PreferenceKeys.DOWNLOAD_USER_FOLDER,
PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME, PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME,
PreferenceKeys.FOLDER_SAVE_TO,
PreferenceKeys.AUTOPLAY_VIDEOS,
PreferenceKeys.AUTOPLAY_VIDEOS_STORIES,
PreferenceKeys.MUTED_VIDEOS, PreferenceKeys.MUTED_VIDEOS,
PreferenceKeys.SHOW_CAPTIONS, PreferenceKeys.SHOW_CAPTIONS,
PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED, PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED,

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

@ -32,6 +32,7 @@
<string name="hide_muted_reels_setting">Hide muted stories from feed</string> <string name="hide_muted_reels_setting">Hide muted stories from feed</string>
<string name="dm_mark_as_seen_setting">Mark DM as seen after viewing</string> <string name="dm_mark_as_seen_setting">Mark DM as seen after viewing</string>
<string name="dm_mark_as_seen_setting_summary">Other members will know you viewed it</string> <string name="dm_mark_as_seen_setting_summary">Other members will know you viewed it</string>
<string name="autoplay_stories_setting">Autoplay video stories</string>
<string name="activity_setting">Enable activity notifications</string> <string name="activity_setting">Enable activity notifications</string>
<string name="story_sort_setting">Feed stories sort</string> <string name="story_sort_setting">Feed stories sort</string>
<string name="error_loading_profile">Error loading profile! Is the username valid? If so, you may be ratelimited.</string> <string name="error_loading_profile">Error loading profile! Is the username valid? If so, you may be ratelimited.</string>

Loading…
Cancel
Save