From 8d7063ee78e46264d8294a7ffcd8c020b5a3ea7d Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:30:00 +0200 Subject: [PATCH 1/6] Added VideoPlayerService#getPlayBackSpeed --- .../schueller/peertube/service/VideoPlayerService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java index d3aa9a8..b01ab4d 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -178,11 +178,18 @@ public class VideoPlayerService extends Service { //Playback speed control public void setPlayBackSpeed(float speed) { - Log.v(TAG, "setPlayBackSpeed..."); player.setPlaybackParameters(new PlaybackParameters(speed)); } + /** + * Returns the current playback speed of the player. + * @return the current playback speed of the player. + */ + public float getPlayBackSpeed() { + return player.getPlaybackParameters().speed; + } + public void playVideo() { Context context = this; From 70593c17ee201b6936f6aeb77d172d4b5b4eaeae Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:30:58 +0200 Subject: [PATCH 2/6] Added preview of the current playback speed and video quality in the VideoOptionsFragment --- .../peertube/fragment/VideoOptionsFragment.java | 17 +++++++++++++++-- app/src/main/res/values-ar/strings.xml | 6 +++--- app/src/main/res/values-bn/strings.xml | 4 ++-- app/src/main/res/values-de/strings.xml | 4 ++-- app/src/main/res/values-es/strings.xml | 4 ++-- app/src/main/res/values-fi/strings.xml | 4 ++-- app/src/main/res/values-fr/strings.xml | 4 ++-- app/src/main/res/values-gd/strings.xml | 4 ++-- app/src/main/res/values-it/strings.xml | 4 ++-- app/src/main/res/values-ja/strings.xml | 4 ++-- app/src/main/res/values-nb-rNO/strings.xml | 4 ++-- app/src/main/res/values-nl/strings.xml | 4 ++-- app/src/main/res/values-pl/strings.xml | 4 ++-- app/src/main/res/values-ru/strings.xml | 4 ++-- app/src/main/res/values-sv/strings.xml | 4 ++-- app/src/main/res/values-tr/strings.xml | 4 ++-- app/src/main/res/values-zh-rCN/strings.xml | 4 ++-- app/src/main/res/values-zh-rTW/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 19 files changed, 52 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 212c2d2..01da654 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -18,7 +18,9 @@ package net.schueller.peertube.fragment; import android.annotation.SuppressLint; +import android.content.SharedPreferences; import android.os.Bundle; +import android.preference.PreferenceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -65,7 +67,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView textView = menuRow.findViewById(R.id.video_quality_text); - textView.setText(getString(R.string.menu_video_options_playback_speed)); + textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), videoPlayerService.getPlayBackSpeed())); iconView.setText(R.string.video_option_speed_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); textView.setOnClickListener(view1 -> { @@ -80,7 +82,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow2 = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView2 = menuRow2.findViewById(R.id.video_quality_icon); TextView textView2 = menuRow2.findViewById(R.id.video_quality_text); - textView2.setText(getString(R.string.menu_video_options_quality)); + textView2.setText(String.format(getString(R.string.menu_video_options_quality), getCurrentVideoQuality(files))); iconView2.setText(R.string.video_option_quality_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView2).build(); textView2.setOnClickListener(view1 -> { @@ -95,4 +97,15 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { } + private String getCurrentVideoQuality(ArrayList files) { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); + Integer videoQuality = sharedPref.getInt("pref_quality", 0); + + for (File file : files) { + if (videoQuality.equals(file.getResolution().getId())) { + return file.getResolution().getLabel(); + } + } + return "Auto"; + } } \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 571c662..fbb0413 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -143,9 +143,9 @@ الرخصة اللغة العلامات - سرعة التشغيل - الجودة - الفيديو + سرعة التشغيل + (%s) الجودة + الفيديو (s%) القنوات حول الحساب: diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 0420e84..5fa6e20 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -285,8 +285,8 @@ গাঢ় বেগুনি অ্যাকাউন্ট সাম্প্রতিক - প্লেব্যাক এর গতি - কোয়ালিটি + প্লেব্যাক এর গতি (%s) + কোয়ালিটি (%s) ভিডিও চ্যানেলগুলি সম্পর্কিত diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index aae549c..8171a43 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -276,8 +276,8 @@ Lizenz Sprache Tags - Wiedergabegeschwindigkeit - Qualität + Wiedergabegeschwindigkeit (%s) + Qualität (%s) Videos Kanäle Über diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8c61319..c34ccb4 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -96,8 +96,8 @@ Licencia Idioma Etiquetas - Velocidad de reproducción - Calidad + Velocidad de reproducción (%s) + Calidad (%s) Vídeos Canales Acerca de diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 78b7b91..8071156 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -103,7 +103,7 @@ maori oriya (makrokieli) bislama - Laatu + Laatu (%s) Jotain meni pieleen, yritä myöhemmin! bulgaria uzbekki @@ -204,7 +204,7 @@ navajo kanuri sunda - Toistonopeus + Toistonopeus (%s) sichuanin-yi Punainen Videon esikatselukuva diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d1dab69..a39fbef 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -99,8 +99,8 @@ Licence Langue Étiquettes - Vitesse de lecture - Qualité + Vitesse de lecture (%s) + Qualité (%s) Vidéos Chaînes À propos diff --git a/app/src/main/res/values-gd/strings.xml b/app/src/main/res/values-gd/strings.xml index d338263..69b4a36 100644 --- a/app/src/main/res/values-gd/strings.xml +++ b/app/src/main/res/values-gd/strings.xml @@ -285,8 +285,8 @@ Ceadachas Cànan Tagaichean - Luaths na cluiche - Càileachd + Luaths na cluiche (%s) + Càileachd (%s) Videothan Seanailean Mu dhèidhinn diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9f0d2e8..7c482cf 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -286,8 +286,8 @@ Licenza Lingua Parole chiave - Velocità di riproduzione - Qualità + Velocità di riproduzione (%s) + Qualità (%s) Video Canali A proposito diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c9616a4..f993ef9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -88,8 +88,8 @@ ラインセンス 言語 タグ - 再生速度 - クオリティ + 再生速度 (%s) + クオリティ(%s) ビデオ チャンネル 情報 diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index abfcf6f..8288fd7 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -51,8 +51,8 @@ Lisens Språk Etiketter - Avspillingshastighet - Kvalitet + Avspillingshastighet (%s) + Kvalitet (%s) Videoer Kanaler Om diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 591194e..97f079d 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -275,8 +275,8 @@ Licentie Taal Labels - Afspeelsnelheid - Kwaliteit + Afspeelsnelheid (%s) + Kwaliteit (%s) Video\'s Kanalen Over diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9367e80..3cc2890 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -48,8 +48,8 @@ Konto: Kanały Filmy - Jakość - Prędkość odtwarzania + Jakość (%s) + Prędkość odtwarzania (%s) Znaczniki Język Licencja diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2807285..719be8e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -277,8 +277,8 @@ Лицензия Язык Теги - Скорость воспроизведения - Качество + Скорость воспроизведения (%s) + Качество (%s) Описание: Что-то пошло не так, пожалуйста, попробуйте позже! Выберите сервер diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 6a7f958..f3989a9 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -272,8 +272,8 @@ Licens Språk Taggar - Uppspelningshastighet - Kvalitet + Uppspelningshastighet (%s) + Kvalitet (%s) Videor Kanaler Om diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index dcb7795..77350d6 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -291,8 +291,8 @@ Lisans Dil Etiketler - Oynatma hızı - Kalite + Oynatma hızı (%s) + Kalite (%s) Hesap Yeniler diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 91e491e..e7835eb 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -112,8 +112,8 @@ 类别 许可 标签 - 播放速度 - 画质 + 播放速度 (%s) + 画质 (%s) 视频 频道 关于 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 039b46c..b8c74d4 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -279,8 +279,8 @@ 授權條款 語言 標籤 - 播放速度 - 畫質 + 播放速度 (%s) + 畫質 (%s) 影片 頻道 關於 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 543c2a3..4bee5e8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -324,8 +324,8 @@ License Language Tags - Playback speed - Quality + Playback speed (%s) + Quality (%s) Videos Channels About From fd3a7c87d1f9c2181876a88a5d35b540b4ef07b1 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 22:46:52 +0200 Subject: [PATCH 3/6] Fixed typo in ar strings.xml --- app/src/main/res/values-ar/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index fbb0413..cf2e631 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -143,9 +143,9 @@ الرخصة اللغة العلامات - سرعة التشغيل + سرعة التشغيل (s%) (%s) الجودة - الفيديو (s%) + الفيديو القنوات حول الحساب: From d631193311d1d56befaf26555a2f4fea1eb6628d Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 09:38:03 +0200 Subject: [PATCH 4/6] Made the "Automated" video quality translatable --- .../peertube/fragment/VideoMenuQualityFragment.java | 5 +++-- .../schueller/peertube/fragment/VideoOptionsFragment.java | 5 +++-- app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java index 45420d9..da55956 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java @@ -17,6 +17,7 @@ */ package net.schueller.peertube.fragment; +import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -44,7 +45,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { public static final String TAG = "VideoMenuQuality"; private static File autoQualityFile; - public static VideoMenuQualityFragment newInstance(ArrayList files) { + public static VideoMenuQualityFragment newInstance(Context context, ArrayList files) { mFiles = files; @@ -53,7 +54,7 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { autoQualityFile = new File(); Resolution autoQualityResolution = new Resolution(); autoQualityResolution.setId(0); - autoQualityResolution.setLabel("Auto"); + autoQualityResolution.setLabel(context.getString(R.string.menu_video_options_quality_automated)); autoQualityFile.setId(0); autoQualityFile.setResolution(autoQualityResolution); } diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 01da654..f27080c 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -87,7 +87,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { new Iconics.IconicsBuilder().ctx(getContext()).on(iconView2).build(); textView2.setOnClickListener(view1 -> { VideoMenuQualityFragment videoMenuQualityFragment = - VideoMenuQualityFragment.newInstance(files); + VideoMenuQualityFragment.newInstance(getContext(), files); videoMenuQualityFragment.show(getActivity().getSupportFragmentManager(), videoMenuQualityFragment.TAG); }); @@ -106,6 +106,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { return file.getResolution().getLabel(); } } - return "Auto"; + // Returning Automated as a placeholder + return getString(R.string.menu_video_options_quality_automated); } } \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index a39fbef..52397c7 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -343,4 +343,5 @@ Sélectionner un serveur Retirer un serveur Voulez-vous vraiment retirer ce serveur de votre carnet d\'adresses ? + Automatique \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4bee5e8..f000c8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -384,6 +384,7 @@ pref_token_type pref_auth_username pref_auth_password + Automated \ No newline at end of file From 9a91c2140adb7bf3c6f3263675ebd9ddadccc9a9 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 11:07:35 +0200 Subject: [PATCH 5/6] Made use of existing strings for the video speed display --- .../peertube/fragment/VideoOptionsFragment.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index f27080c..08c54c6 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -37,6 +37,7 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; public class VideoOptionsFragment extends BottomSheetDialogFragment { @@ -67,7 +68,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView textView = menuRow.findViewById(R.id.video_quality_text); - textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), videoPlayerService.getPlayBackSpeed())); + textView.setText(String.format(getString(R.string.menu_video_options_playback_speed), getCurrentVideoPlaybackSpeedString(videoPlayerService.getPlayBackSpeed()))); iconView.setText(R.string.video_option_speed_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); textView.setOnClickListener(view1 -> { @@ -109,4 +110,14 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment { // Returning Automated as a placeholder return getString(R.string.menu_video_options_quality_automated); } + + private String getCurrentVideoPlaybackSpeedString(float playbackSpeed) { + String speed = String.valueOf(playbackSpeed); + // Remove all non-digit characters from the string + speed = speed.replaceAll("[^0-9]", ""); + + // Dynamically get the localized string corresponding to the speed + @StringRes int stringId = getResources().getIdentifier("video_speed_" + speed, "string", videoPlayerService.getPackageName()); + return getString(stringId); + } } \ No newline at end of file From b2a8cf857da14f92df726c37468b921af65feca1 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 5 Jul 2020 11:07:57 +0200 Subject: [PATCH 6/6] Removed unusued imports in VideoOptionsFragment.java --- .../net/schueller/peertube/fragment/VideoOptionsFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java index 08c54c6..2e9c3b4 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoOptionsFragment.java @@ -17,11 +17,9 @@ */ package net.schueller.peertube.fragment; -import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;