New option: Default Playback Speed.

This commit is contained in:
Alex Ning 2021-10-10 20:36:25 +08:00
parent a30421e73b
commit d40b81d799
8 changed files with 37 additions and 3 deletions

View File

@ -470,6 +470,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();

View File

@ -361,7 +361,7 @@ public class ViewVideoActivity extends AppCompatActivity {
id = savedInstanceState.getString(ID_STATE);
playbackSpeed = savedInstanceState.getInt(PLAYBACK_SPEED_STATE);
}
setPlaybackSpeed(playbackSpeed);
setPlaybackSpeed(Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_PLAYBACK_SPEED, "100")));
if (videoType == VIDEO_TYPE_V_REDD_IT) {
loadVReddItVideo(savedInstanceState);
@ -701,6 +701,7 @@ public class ViewVideoActivity extends AppCompatActivity {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE && grantResults.length > 0) {
if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();

View File

@ -153,7 +153,7 @@ public class ViewImgurVideoFragment extends Fragment {
if (savedInstanceState != null) {
playbackSpeed = savedInstanceState.getInt(PLAYBACK_SPEED_STATE);
}
setPlaybackSpeed(playbackSpeed);
setPlaybackSpeed(Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_PLAYBACK_SPEED, "100")));
preparePlayer(savedInstanceState);
if (activity.isUseBottomAppBar()) {

View File

@ -156,7 +156,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
if (savedInstanceState != null) {
playbackSpeed = savedInstanceState.getInt(PLAYBACK_SPEED_STATE);
}
setPlaybackSpeed(playbackSpeed);
Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_PLAYBACK_SPEED, "100"));
preparePlayer(savedInstanceState);
if (activity.isUseBottomAppBar()) {

View File

@ -192,6 +192,7 @@ public class SharedPreferencesUtils {
public static final String LOCK_SCREEN_ANIMATION = "lock_screen_animation";
public static final String ENABLE_FOLD_SUPPORT = "enable_fold_support";
public static final String LOOP_VIDEO = "loop_video";
public static final String DEFAULT_PLAYBACK_SPEED = "default_playback_speed";
public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";

View File

@ -520,4 +520,26 @@
<item>2</item>
</string-array>
<string-array name="default_playback_speed">
<item>0.25x</item>
<item>0.5x</item>
<item>0.75x</item>
<item>@string/normal</item>
<item>1.25x</item>
<item>1.5x</item>
<item>1.75x</item>
<item>2x</item>
</string-array>
<string-array name="default_playback_speed_values">
<item>25</item>
<item>50</item>
<item>75</item>
<item>100</item>
<item>125</item>
<item>150</item>
<item>175</item>
<item>200</item>
</string-array>
</resources>

View File

@ -609,6 +609,7 @@
<string name="settings_app_lock_summary">Require authentication before using the app</string>
<string name="settings_app_lock_timeout_title">App Lock Timeout</string>
<string name="settings_enable_fold_support_title">Enable folding phone support</string>
<string name="settings_default_playback_speed_title">Default Playback Speed</string>
<string name="no_link_available">Cannot get the link</string>

View File

@ -36,6 +36,14 @@
app:title="@string/settings_loop_video_title"
app:summary="@string/settings_loop_video_summary" />
<ListPreference
app:defaultValue="100"
android:entries="@array/default_playback_speed"
app:entryValues="@array/default_playback_speed_values"
app:key="default_playback_speed"
app:title="@string/settings_default_playback_speed_title"
app:useSimpleSummaryProvider="true" />
<PreferenceCategory
app:title="@string/settings_video_autoplay_title" />