Merge branch 'develop' into 'master'

Release

See merge request sschueller/peertube!23
This commit is contained in:
Stefan Schüller 2021-02-20 13:00:31 +01:00
commit 6a4088e985
6 changed files with 68 additions and 6 deletions

View File

@ -140,8 +140,8 @@ dependencies {
implementation "com.google.android.exoplayer:extension-mediasession:$exoplayer"
implementation "com.google.android.exoplayer:extension-okhttp:$exoplayer"
// date formatter
implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'
// date formatter, do not update past 4.0.4 https://github.com/sschueller/peertube-android/issues/262
implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final'
// Version comparison
implementation 'org.apache.maven:maven-artifact:3.6.3'

View File

@ -16,7 +16,9 @@
*/
package net.schueller.peertube.fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -72,8 +74,7 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
TextView speed15 = view.findViewById(R.id.video_speed15);
TextView speed20 = view.findViewById(R.id.video_speed20);
// Default
setVideoSpeed(1.0f, speed10Icon);
setDefaultVideoSpeed();
// Attach the listener
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
@ -103,4 +104,30 @@ public class VideoMenuSpeedFragment extends BottomSheetDialogFragment {
new Iconics.Builder().on(icon).build();
}
private void setDefaultVideoSpeed() {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
String speed = sharedPref.getString(getString(R.string.pref_video_speed_key), "1.0");
switch (speed) {
case "0.5":
setVideoSpeed(0.5f, speed05Icon);
break;
case "0.75":
setVideoSpeed(0.75f, speed075Icon);
break;
case "1.0":
setVideoSpeed(1.0f, speed10Icon);
break;
case "1.25":
setVideoSpeed(1.25f, speed125Icon);
break;
case "1.5":
setVideoSpeed(1.5f, speed15Icon);
break;
case "2.0":
setVideoSpeed(2.0f, speed20Icon);
break;
}
}
}

View File

@ -24,6 +24,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.media.AudioManager;
@ -32,6 +33,7 @@ import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.webkit.URLUtil;
import androidx.annotation.Nullable;
@ -255,8 +257,11 @@ public class VideoPlayerService extends Service {
// Auto play
player.setPlayWhenReady(true);
//reset playback speed
this.setPlayBackSpeed(1.0f);
//set playback speed to global default
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
float speed = Float.parseFloat(sharedPref.getString(getString(R.string.pref_video_speed_key), "1.0"));
this.setPlayBackSpeed(speed);
playerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
context, PLAYBACK_CHANNEL_ID, R.string.playback_channel_name,

View File

@ -11,6 +11,7 @@
<string name="pref_show_nsfw_key" translatable="false">pref_show_nsfw</string>
<string name="pref_video_language_key" translatable="false">pref_language</string>
<string name="pref_video_speed_key" translatable="false">pref_video_speed</string>
<string name="pref_back_pause_key" translatable="false">pref_back_pause</string>
<string name="pref_background_behavior_key" translatable="false">pref_background_behavior</string>
<string name="pref_torrent_player_key" translatable="false">pref_torrent_player</string>
@ -582,4 +583,22 @@
<item>High</item>
</string-array>
<string-array name="videoSpeed">
<item>0.5x</item>
<item>0.75x</item>
<item>Normal</item>
<item>1.25x</item>
<item>1.5x</item>
<item>2x</item>
</string-array>
<string-array name="videoSpeedValues">
<item>0.5</item>
<item>0.75</item>
<item>1.0</item>
<item>1.25</item>
<item>1.5</item>
<item>2.0</item>
</string-array>
</resources>

View File

@ -54,6 +54,8 @@
<string name="pref_title_peertube_server">PeerTube Server</string>
<string name="pref_title_background_play">Background Playback</string>
<string name="pref_description_background_play">If enabled, continues to play video in background.</string>
<string name="pref_title_video_speed">Default Playback Speed</string>
<string name="pref_description_video_speed">Select the global Video Playback Speed</string>
<string name="pref_title_back_pause">Pause on back button</string>
<string name="pref_description_back_pause">Pause background play when pressing back during video playback.</string>
<string name="pref_language_app">Application Language</string>

View File

@ -51,6 +51,15 @@
<PreferenceCategory app:title="@string/settings_activity_video_playback_category_title" app:iconSpaceReserved="false">
<ListPreference
app:defaultValue="1.0"
app:entries="@array/videoSpeed"
app:entryValues="@array/videoSpeedValues"
app:key="@string/pref_video_speed_key"
app:summary="@string/pref_description_video_speed"
app:title="@string/pref_title_video_speed"
app:iconSpaceReserved="false"/>
<SwitchPreference
app:defaultValue="true"
app:key="@string/pref_back_pause_key"