From 18c364f3b1c8d380218b6aa38a8da30e8e6e525c Mon Sep 17 00:00:00 2001 From: Olivier Humbert Date: Sat, 27 Jun 2020 22:24:12 +0000 Subject: [PATCH 01/46] Translated using Weblate (French) Currently translated at 99.7% (364 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/fr/ --- app/src/main/res/values-fr/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5567530..9482c9d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -333,4 +333,21 @@ Langue de l\'application Mettre la lecture d\'arrière-plan en pause en appuyant sur la touche de retour pendant la lecture de la vidéo. Pause sur le bouton retour + Apparence + À propos + Lecture vidéo + Liste des vidéos + SettingsActivity2 + Compte + Sélectionner un serveur + Êtes-vous sûr de vouloir supprimer ce serveur du carnet d\'adresses \? + Supprimer le serveur + Bengalais (Bangladesh) + Comment une vidéo en cours de lecture réagit lorsqu\'elle passe en arrière-plan + La permission \"Image dans l\'image\" est désactivée pour cette application dans les paramètres Android + La version Android ne prend pas en charge la vidéo flottante + Configuration de la lecture en arrière-plan + Continuer la lecture de la vidéo dans une fenêtre flottante + Arrêter toutes les lectures + Continuer comme un flux audio d\'arrière plan \ No newline at end of file From cbda00aabbc34a196ce538a3a3005500209d7d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Sun, 28 Jun 2020 05:37:23 +0000 Subject: [PATCH 02/46] Translated using Weblate (Turkish) Currently translated at 99.7% (364 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/tr/ --- app/src/main/res/values-tr/strings.xml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8312c87..81efe1a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -281,7 +281,7 @@ {faw-share} {faw-download} {faw-save} - Arkaplanda Oynatma + Arka Planda Oynatma Etkinleştirilirse, arka planda izleti oynatmaya devam eder. Yerel Hesap @@ -351,4 +351,21 @@ Arama Geçmişini Temizle Uygulama arayüzü için dil seçin. Değişikliklerin etkili olması için uygulamayı yeniden başlatın. Uygulama Dili + Görünüm + Hakkında + Video Oynatma + Video Listesi + SettingsActivity2 + Hesap + Sunucu Seç + Bu sunucuyu adres defterinden kaldırmak istediğinizden emin misiniz\? + Sunucuyu Kaldır + Bengalce (Bangladeş) + Arka plana giderken oynatılan bir videonun nasıl yanıt vereceği + Android Ayarlarında bu uygulama için resim içinde resim izni devre dışı + Android sürümü kayan videoyu desteklemiyor + Kayan pencerede video oynatmaya devam et + Arka planda oynatma yapılandırması + Tüm oynatmaları durdur + Arka planda ses akışı olarak devam et \ No newline at end of file From fa8a14865843595cf0b9a12d066f31118af3dc8c Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Sun, 28 Jun 2020 03:34:52 +0000 Subject: [PATCH 03/46] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (365 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/zh_Hant/ --- app/src/main/res/values-zh-rTW/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index ddce667..dca2312 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -323,4 +323,21 @@ 應用程式語言 當影片播放時按下後退鈕後暫停背景播放。 在後退鈕上暫停 + 外觀與感覺 + 關於 + 影片播放 + 影片清單 + SettingsActivity2 + 帳號 + 選取伺服器 + 您確定您想要從地址簿中移除此伺服器嗎? + 移除伺服器 + 孟加拉語(孟加拉) + 播放影片到背景時如何回應 + 在 Android 設定中已停用此應用程式的畫中畫權限 + Android 版本不支援懸浮影片 + 背景播放設定 + 繼續以懸浮視窗播放影片 + 停止所有播放 + 以背景音訊串流繼續 \ No newline at end of file From ab48efd8ff9cf5521493d5cc8dbc8f673de3c1f3 Mon Sep 17 00:00:00 2001 From: Heimen Stoffels Date: Sun, 28 Jun 2020 09:43:26 +0000 Subject: [PATCH 04/46] Translated using Weblate (Dutch) Currently translated at 100.0% (365 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/nl/ --- app/src/main/res/values-nl/strings.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 486a798..df609cc 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -323,4 +323,21 @@ App-taal Pauzeer het afspelen als er op de terugknop wordt gedrukt. Pauzeren na drukken op terugknop + Uiterlijk + Over + Video afspelen + Videolijst + SettingsActivity2 + Account + Server kiezen + Weet je zeker dat je deze server wilt verwijderen uit het adresboek\? + Server verwijderen + Bengaals (Bangladesh) + Hoe een video moet worden afgespeeld op de achtergrond + Picture-in-picturemachtiging is niet afgegeven voor deze app in de Android-instellingen + Deze Android-versie ondersteunt geen zwevende video\'s + Afspelen op achtergrond + Video afspelen in zwevend venster + Afspelen stoppen + Audio afspelen op achtergrond \ No newline at end of file From 03a196c4910d7658b8ee083e1f8e4a5f128ee57d Mon Sep 17 00:00:00 2001 From: dhk2 Date: Tue, 30 Jun 2020 14:56:01 -0700 Subject: [PATCH 05/46] fixing duplicate controlelrs --- .../schueller/peertube/activity/VideoPlayActivity.java | 10 +++++++++- .../schueller/peertube/service/VideoPlayerService.java | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 28e80ad..7015118 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -61,7 +61,7 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; - + private static boolean floatMode = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -112,6 +112,12 @@ public class VideoPlayActivity extends AppCompatActivity { VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; + Boolean killFloat=intent.getBooleanExtra("killFloat",false); + Log.e(TAG,killFloat.toString()+" "+floatMode); + if (killFloat && floatMode){ + finish(); + return; + } String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid()); assert videoPlayerFragment != null; @@ -355,8 +361,10 @@ public class VideoPlayActivity extends AppCompatActivity { public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { if (isInPictureInPictureMode) { Log.v(TAG,"switched to pip "); + floatMode=true; } else { Log.v(TAG,"switched to normal"); + floatMode=false; } } } 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 bb22505..6d9c9f9 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -239,6 +239,7 @@ public class VideoPlayerService extends Service { // don't show skip buttons in notification playerNotificationManager.setUseNavigationActions(false); + playerNotificationManager.setUseStopAction(true); playerNotificationManager.setNotificationListener( new PlayerNotificationManager.NotificationListener() { @@ -250,7 +251,10 @@ public class VideoPlayerService extends Service { @Override public void onNotificationCancelled(int notificationId) { Log.v(TAG, "onNotificationCancelled..."); - + Intent killFloatingWindow = new Intent(getApplicationContext(),VideoPlayActivity.class); + killFloatingWindow.putExtra("killFloat",true); + killFloatingWindow.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(killFloatingWindow); // TODO: only kill the notification if we no longer have a bound activity stopForeground(true); } From 9759e8372c6c324ee81984ad1f470bc7ad0b17e5 Mon Sep 17 00:00:00 2001 From: Digiwizkid Date: Tue, 30 Jun 2020 10:10:59 +0000 Subject: [PATCH 06/46] Translated using Weblate (Bengali) Currently translated at 99.4% (363 of 365 strings) Translation: PeerTube/Android Translate-URL: https://hosted.weblate.org/projects/peertube/android/bn/ --- app/src/main/res/values-bn/strings.xml | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 7277160..e02802e 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -43,8 +43,8 @@ একটি টরেন্ট স্ট্রিমের মাধ্যমে ভিডিও প্লেব্যাক করুন। এর জন্য স্টোরেজ অনুমতির প্রয়োজন । (আলফা, স্থিতিশীল নয়!) অনুমতিপত্র -\nগাহ্নু অফেরও সাধারণ গণ অনুমতিপত্র সং.৩.০ -\n +\nগাহ্নু অফেরও সাধারণ গণ অনুমতিপত্র সং.৩.০ +\n \nএই শক্তিশালী কপিলেফট লাইসেন্সের অনুমতি এই চুক্তির উপর নির্ভরশীল যে অনুমতিপত্রের দ্বারা আবদ্ধ সকল কাজ ও পরিবর্তনের সোর্স কোড উপলব্ধ করার মাধ্যমে, যার আওতায় পড়ে অনুমতিপত্রের দ্বারা আবদ্ধ কাজের বৃহত্তর অংশ একই অনুমতিপত্রের আওতায় আনার মাধ্যমে। কপিরাইট এবং লাইসেন্স নোটিশ সংরক্ষণ করা আবশ্যক। অবদানকারীগণ তাদের পেটেন্টর অধিকার অবশ্যই দেয়, যখন একটি পরিমার্জিত সংস্করণ ব্যবহার করে একটি পরিসেবা একটি নেটওয়ার্ক দিয়ে দেয়া হয়, সম্পূর্ণ সোর্স কোড এর পরিমার্জিত সংস্করণ উপলব্ধ তৈরি করা আবশ্যক। সংস্করণ সার্চ পিয়ারটিউব @@ -157,7 +157,7 @@ লিনগালা লিথুনীয় লোজবান - + লুবা-কাতাঙ্গা লাক্সেমবোর্গীয় ম্যাসিডোনিয় মালাগাসি @@ -331,4 +331,41 @@ নিচের তালিকা থেকে একটি সার্ভার নিন অথবা সরাসরি একটি সার্ভার দিন। 0.75x 1.25x + ব্যাকগ্রউন্ড প্লে এর কনফিগারেশন + লুক এবং ফিল + লগইন আছে + পেছনে অডিও স্ট্রিম হিসেবে চালু রাখুন + সম্পর্কিত + ভিডিও প্লেব্যাক + ভিডিও এর লিস্ট + আকাউন্ট + সার্ভার পাছন্দ করুন + আপনি কি এই সার্ভার রিমুভ করতে চান সার্ভার বই থেকে\? + সার্ভার রিমুভ করুন + এড্রেস বই + যোগ + পাসওয়ার্ড + ইউজারনেম + সার্চ + সার্ভার ইউআরএল + লেবেল + সাহায্য ও মতামত + লগ আউট + সঠিক ইউ আর এল দরকার + সার্ভার লেবেল দরকার + সার্ভার বই খালি আছে + লগইন সফল হয় নি! + লগইন সফল হয়েছে + বাংলা (বাংলাদেশ) + আপনি কি পুরোপুরি সার্চ ইতিহাস মুছে ফেলতে চান\? + সার্চ ইতিহাস মুছে ফেলুন + চালু ভিডিও কি করবে যখন পেছনে যাবে + অ্যান্ড্রয়েড সেটিং এ পিকচার ইন পিকচার পারমিশন বন্ধ আছে এই আয়াপ এ + অ্যান্ড্রয়েড ভার্সন ভাসমান ভিডিও সাপোর্ট করে + ভাসমান উইন্ডো তে ভিডিও চালু রাখুন + সব প্লেব্যাক বন্ধ করুন + ভাষা পছন্দ করুন অ্যাপ্লিকেশান এর জন্য। রিস্টার্ট করুন পরিবর্তন দেখার জন্য। + অ্যাপ্লিকেশান এর ভাষা + ভিডিও চলার সময় ব্যাকগ্রাউন্ড প্লে পজ হবে ব্যাক বাটন প্রেস করলে। + ব্যাক বাটন এ পজ \ No newline at end of file From ae058167b6b58976f85f6793d0246bc1f5c7108c Mon Sep 17 00:00:00 2001 From: dhk2 Date: Wed, 1 Jul 2020 09:04:20 -0700 Subject: [PATCH 07/46] fixing duplicate controlelrs --- .../peertube/activity/VideoPlayActivity.java | 90 ++++++++++++++++--- .../fragment/VideoPlayerFragment.java | 5 +- .../schueller/peertube/helper/Constants.java | 1 + .../peertube/service/VideoPlayerService.java | 9 +- 4 files changed, 93 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 7015118..ba64f12 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -21,11 +21,16 @@ package net.schueller.peertube.activity; import android.annotation.SuppressLint; import android.app.AppOpsManager; +import android.app.PendingIntent; import android.app.PictureInPictureParams; +import android.app.RemoteAction; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.drawable.Icon; import android.os.Build; import android.os.Bundle; @@ -49,12 +54,16 @@ import net.schueller.peertube.fragment.VideoMetaDataFragment; import net.schueller.peertube.fragment.VideoPlayerFragment; import net.schueller.peertube.service.VideoPlayerService; -import java.util.Objects; +import java.util.ArrayList; import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; +import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -62,7 +71,8 @@ public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; private static boolean floatMode = false; - + private static final int REQUEST_CODE = 101; + private BroadcastReceiver receiver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -112,12 +122,6 @@ public class VideoPlayActivity extends AppCompatActivity { VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; - Boolean killFloat=intent.getBooleanExtra("killFloat",false); - Log.e(TAG,killFloat.toString()+" "+floatMode); - if (killFloat && floatMode){ - finish(); - return; - } String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid()); assert videoPlayerFragment != null; @@ -167,7 +171,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (isLandscape) { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = FrameLayout.LayoutParams.MATCH_PARENT; videoPlayerFragment.getView().setLayoutParams(params); @@ -182,7 +186,7 @@ public class VideoPlayActivity extends AppCompatActivity { } else { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); videoPlayerFragment.getView().setLayoutParams(params); @@ -357,14 +361,80 @@ public class VideoPlayActivity extends AppCompatActivity { enterPictureInPictureMode(mParams); } + @RequiresApi(api = Build.VERSION_CODES.O) @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) + getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); + if (isInPictureInPictureMode) { + videoPlayerFragment.showControls(false); + //create custom actions + setActions(""); + + //setup receiver to handle customer actions + IntentFilter filter = new IntentFilter(); + filter.addAction(ACTION_STOP); + filter.addAction(ACTION_PAUSE); + filter.addAction(ACTION_PLAY); + filter.addAction((BACKGROUND_AUDIO)); + receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ACTION_PAUSE)){ + videoPlayerFragment.pauseVideo(); + } + if (action.equals(ACTION_PLAY)){ + videoPlayerFragment.pauseToggle(); + } + if (action.equals(BACKGROUND_AUDIO)) { + unregisterReceiver(receiver); + finish(); + } + if (action.equals(ACTION_STOP)){ + unregisterReceiver(receiver); + finishAndRemoveTask(); + } + } + }; + registerReceiver(receiver, filter); + Log.v(TAG,"switched to pip "); floatMode=true; } else { + videoPlayerFragment.showControls(true); + if (receiver != null) { + unregisterReceiver(receiver); + } Log.v(TAG,"switched to normal"); floatMode=false; } } + + @RequiresApi(api = Build.VERSION_CODES.O) + public void setActions(String actionCommand) { + + ArrayList actions = new ArrayList<>(); + + Intent actionIntent = new Intent(BACKGROUND_AUDIO); + PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); + RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); + actions.add(remoteAction); + + actionIntent = new Intent(ACTION_STOP); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_stop); + remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); + actions.add(remoteAction); + + //add custom actions to pip window + PictureInPictureParams params = + new PictureInPictureParams.Builder() + .setActions(actions) + .build(); + setPictureInPictureParams(params); + + } } diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index a37af1c..ab0e4d1 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -264,10 +264,13 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL mService.player.setPlayWhenReady(!mService.player.getPlayWhenReady()); } } + public void showControls(boolean value){ + simpleExoPlayerView.setUseController(value); + } public void stopVideo() { if (mBound) { - Objects.requireNonNull(getContext()).unbindService(mConnection); + requireContext().unbindService(mConnection); mBound = false; } } diff --git a/app/src/main/java/net/schueller/peertube/helper/Constants.java b/app/src/main/java/net/schueller/peertube/helper/Constants.java index 729377f..0e87a3f 100644 --- a/app/src/main/java/net/schueller/peertube/helper/Constants.java +++ b/app/src/main/java/net/schueller/peertube/helper/Constants.java @@ -21,4 +21,5 @@ public class Constants { public static final String THEME_PREF_KEY = "pref_theme"; public static final String DEFAULT_THEME = "AppTheme.BLUE"; public static final String BACKGROUND_PLAY_PREF_KEY = "pref_background_play"; + public static final String BACKGROUND_AUDIO = "BACKGROUND_AUDIO"; } 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 6d9c9f9..a601af4 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -64,6 +64,7 @@ import net.schueller.peertube.model.Video; import static android.media.session.PlaybackState.ACTION_PAUSE; import static android.media.session.PlaybackState.ACTION_PLAY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; import static net.schueller.peertube.activity.VideoListActivity.EXTRA_VIDEOID; public class VideoPlayerService extends Service { @@ -251,12 +252,18 @@ public class VideoPlayerService extends Service { @Override public void onNotificationCancelled(int notificationId) { Log.v(TAG, "onNotificationCancelled..."); + stopForeground(true); + Intent killFloat = new Intent(ACTION_STOP); + sendBroadcast(killFloat); + /* + Intent killFloat = new Intent(BROADCAST_ACTION); Intent killFloatingWindow = new Intent(getApplicationContext(),VideoPlayActivity.class); killFloatingWindow.putExtra("killFloat",true); - killFloatingWindow.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(killFloatingWindow); // TODO: only kill the notification if we no longer have a bound activity stopForeground(true); + */ } } ); From f04c64a60df3d0038f2acb13c8a8f83308057242 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 14:41:09 -0700 Subject: [PATCH 08/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 7 +++++-- .../schueller/peertube/fragment/VideoPlayerFragment.java | 2 +- app/src/main/res/layout/row_video.xml | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index ba64f12..ba8c71e 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -70,6 +70,8 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; + + private static boolean floatMode = false; private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; @@ -171,7 +173,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (isLandscape) { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = FrameLayout.LayoutParams.MATCH_PARENT; videoPlayerFragment.getView().setLayoutParams(params); @@ -186,7 +188,7 @@ public class VideoPlayActivity extends AppCompatActivity { } else { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics()); videoPlayerFragment.getView().setLayoutParams(params); @@ -388,6 +390,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (action.equals(ACTION_PLAY)){ videoPlayerFragment.pauseToggle(); } + */ if (action.equals(BACKGROUND_AUDIO)) { unregisterReceiver(receiver); finish(); diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index ab0e4d1..2c4140f 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -270,7 +270,7 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL public void stopVideo() { if (mBound) { - requireContext().unbindService(mConnection); + Objects.requireNonNull(getContext()).unbindService(mConnection); mBound = false; } } diff --git a/app/src/main/res/layout/row_video.xml b/app/src/main/res/layout/row_video.xml index afc2c1e..170c104 100644 --- a/app/src/main/res/layout/row_video.xml +++ b/app/src/main/res/layout/row_video.xml @@ -3,6 +3,7 @@ xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" + android:focusable="true" card_view:cardCornerRadius="0dp" card_view:cardElevation="0dp" card_view:contentPadding="0dp" From 61aa0e379ba60fef6cfb547e8da587504afb94e0 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 14:44:25 -0700 Subject: [PATCH 09/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index ba8c71e..cd424dc 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -56,6 +56,8 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; +import java.util.Objects; + import androidx.fragment.app.FragmentManager; @@ -173,7 +175,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (isLandscape) { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = FrameLayout.LayoutParams.MATCH_PARENT; videoPlayerFragment.getView().setLayoutParams(params); @@ -390,7 +392,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (action.equals(ACTION_PLAY)){ videoPlayerFragment.pauseToggle(); } - */ + if (action.equals(BACKGROUND_AUDIO)) { unregisterReceiver(receiver); finish(); From 05595b7b4e854ef18230fdf1884a9b6c46424b8b Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 14:49:02 -0700 Subject: [PATCH 10/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index cd424dc..6c16c75 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -175,7 +175,7 @@ public class VideoPlayActivity extends AppCompatActivity { if (isLandscape) { assert videoPlayerFragment != null; - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoPlayerFragment.requireView().getLayoutParams(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams(); params.width = FrameLayout.LayoutParams.MATCH_PARENT; params.height = FrameLayout.LayoutParams.MATCH_PARENT; videoPlayerFragment.getView().setLayoutParams(params); @@ -368,8 +368,8 @@ public class VideoPlayActivity extends AppCompatActivity { @RequiresApi(api = Build.VERSION_CODES.O) @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) - getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); if (isInPictureInPictureMode) { videoPlayerFragment.showControls(false); From a11a62ede47d4cee5eff3dfe2f2588507511b146 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:04:57 -0700 Subject: [PATCH 11/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 6c16c75..6d8ca33 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -406,14 +406,14 @@ public class VideoPlayActivity extends AppCompatActivity { registerReceiver(receiver, filter); Log.v(TAG,"switched to pip "); - floatMode=true; + // videoPlayerFragment.useController(false); } else { videoPlayerFragment.showControls(true); if (receiver != null) { unregisterReceiver(receiver); } Log.v(TAG,"switched to normal"); - floatMode=false; + // videoPlayerFragment.useController(true); } } From fb6462a67fd8ec53050869b14003783e693ca53a Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:17:31 -0700 Subject: [PATCH 12/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 99 ++++++++++--------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 6d8ca33..db1dc13 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -368,52 +368,11 @@ public class VideoPlayActivity extends AppCompatActivity { @RequiresApi(api = Build.VERSION_CODES.O) @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { - FragmentManager fragmentManager = getSupportFragmentManager(); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + if (isInPictureInPictureMode) { + changedToPipMode(); - if (isInPictureInPictureMode) { - videoPlayerFragment.showControls(false); - //create custom actions - setActions(""); - - //setup receiver to handle customer actions - IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_STOP); - filter.addAction(ACTION_PAUSE); - filter.addAction(ACTION_PLAY); - filter.addAction((BACKGROUND_AUDIO)); - receiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action.equals(ACTION_PAUSE)){ - videoPlayerFragment.pauseVideo(); - } - if (action.equals(ACTION_PLAY)){ - videoPlayerFragment.pauseToggle(); - } - - if (action.equals(BACKGROUND_AUDIO)) { - unregisterReceiver(receiver); - finish(); - } - if (action.equals(ACTION_STOP)){ - unregisterReceiver(receiver); - finishAndRemoveTask(); - } - } - }; - registerReceiver(receiver, filter); - - Log.v(TAG,"switched to pip "); - // videoPlayerFragment.useController(false); } else { - videoPlayerFragment.showControls(true); - if (receiver != null) { - unregisterReceiver(receiver); - } - Log.v(TAG,"switched to normal"); - // videoPlayerFragment.useController(true); + } } @@ -442,4 +401,56 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } + public void changedToPipMode() { + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + + videoPlayerFragment.showControls(false); + //create custom actions + setActions(""); + + //setup receiver to handle customer actions + IntentFilter filter = new IntentFilter(); + filter.addAction(ACTION_STOP); + filter.addAction(ACTION_PAUSE); + filter.addAction(ACTION_PLAY); + filter.addAction((BACKGROUND_AUDIO)); + receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ACTION_PAUSE)) { + videoPlayerFragment.pauseVideo(); + } + if (action.equals(ACTION_PLAY)) { + videoPlayerFragment.pauseToggle(); + } + + if (action.equals(BACKGROUND_AUDIO)) { + unregisterReceiver(receiver); + finish(); + } + if (action.equals(ACTION_STOP)) { + unregisterReceiver(receiver); + finishAndRemoveTask(); + } + } + }; + registerReceiver(receiver, filter); + + Log.v(TAG, "switched to pip "); + // videoPlayerFragment.useController(false); + } + public void changedToNormalMode(){ + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + + videoPlayerFragment.showControls(true); + if (receiver != null) { + unregisterReceiver(receiver); + } + Log.v(TAG,"switched to normal"); + // videoPlayerFragment.useController(true); + } } + From c4da2a53692eb44171364228ff8b9f9a9f58917f Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:22:12 -0700 Subject: [PATCH 13/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 100 +----------------- 1 file changed, 3 insertions(+), 97 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index db1dc13..28e80ad 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -21,16 +21,11 @@ package net.schueller.peertube.activity; import android.annotation.SuppressLint; import android.app.AppOpsManager; -import android.app.PendingIntent; import android.app.PictureInPictureParams; -import android.app.RemoteAction; -import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.drawable.Icon; import android.os.Build; import android.os.Bundle; @@ -54,18 +49,12 @@ import net.schueller.peertube.fragment.VideoMetaDataFragment; import net.schueller.peertube.fragment.VideoPlayerFragment; import net.schueller.peertube.service.VideoPlayerService; - -import java.util.ArrayList; import java.util.Objects; import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; -import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; -import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; -import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; -import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -74,9 +63,6 @@ public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; - private static boolean floatMode = false; - private static final int REQUEST_CODE = 101; - private BroadcastReceiver receiver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -365,92 +351,12 @@ public class VideoPlayActivity extends AppCompatActivity { enterPictureInPictureMode(mParams); } - @RequiresApi(api = Build.VERSION_CODES.O) @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { - if (isInPictureInPictureMode) { - changedToPipMode(); - + if (isInPictureInPictureMode) { + Log.v(TAG,"switched to pip "); } else { - + Log.v(TAG,"switched to normal"); } } - - @RequiresApi(api = Build.VERSION_CODES.O) - public void setActions(String actionCommand) { - - ArrayList actions = new ArrayList<>(); - - Intent actionIntent = new Intent(BACKGROUND_AUDIO); - PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); - RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); - actions.add(remoteAction); - - actionIntent = new Intent(ACTION_STOP); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_stop); - remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); - actions.add(remoteAction); - - //add custom actions to pip window - PictureInPictureParams params = - new PictureInPictureParams.Builder() - .setActions(actions) - .build(); - setPictureInPictureParams(params); - - } - public void changedToPipMode() { - FragmentManager fragmentManager = getSupportFragmentManager(); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - - videoPlayerFragment.showControls(false); - //create custom actions - setActions(""); - - //setup receiver to handle customer actions - IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_STOP); - filter.addAction(ACTION_PAUSE); - filter.addAction(ACTION_PLAY); - filter.addAction((BACKGROUND_AUDIO)); - receiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action.equals(ACTION_PAUSE)) { - videoPlayerFragment.pauseVideo(); - } - if (action.equals(ACTION_PLAY)) { - videoPlayerFragment.pauseToggle(); - } - - if (action.equals(BACKGROUND_AUDIO)) { - unregisterReceiver(receiver); - finish(); - } - if (action.equals(ACTION_STOP)) { - unregisterReceiver(receiver); - finishAndRemoveTask(); - } - } - }; - registerReceiver(receiver, filter); - - Log.v(TAG, "switched to pip "); - // videoPlayerFragment.useController(false); - } - public void changedToNormalMode(){ - FragmentManager fragmentManager = getSupportFragmentManager(); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - - videoPlayerFragment.showControls(true); - if (receiver != null) { - unregisterReceiver(receiver); - } - Log.v(TAG,"switched to normal"); - // videoPlayerFragment.useController(true); - } } - From 35742c656e3d40e516f9db6e10f7326d82acb7ae Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:23:42 -0700 Subject: [PATCH 14/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 28e80ad..a55de18 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -21,11 +21,16 @@ package net.schueller.peertube.activity; import android.annotation.SuppressLint; import android.app.AppOpsManager; +import android.app.PendingIntent; import android.app.PictureInPictureParams; +import android.app.RemoteAction; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.drawable.Icon; import android.os.Build; import android.os.Bundle; @@ -49,6 +54,8 @@ import net.schueller.peertube.fragment.VideoMetaDataFragment; import net.schueller.peertube.fragment.VideoPlayerFragment; import net.schueller.peertube.service.VideoPlayerService; + +import java.util.ArrayList; import java.util.Objects; import androidx.fragment.app.FragmentManager; From dd455de9557c4392adaf491c8de961675bb3039e Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:28:03 -0700 Subject: [PATCH 15/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index a55de18..70e98fd 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -69,6 +69,9 @@ public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; + private static boolean floatMode = false; + private static final int REQUEST_CODE = 101; + private BroadcastReceiver receiver; @Override protected void onCreate(Bundle savedInstanceState) { From 2bfc846ec0dadc1a280daed5f78264f9848e279d Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:32:19 -0700 Subject: [PATCH 16/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 70e98fd..14df78a 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -62,6 +62,8 @@ import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; +import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -369,4 +371,30 @@ public class VideoPlayActivity extends AppCompatActivity { Log.v(TAG,"switched to normal"); } } + + @RequiresApi(api = Build.VERSION_CODES.O) + public void setActions(String actionCommand) { + + ArrayList actions = new ArrayList<>(); + + Intent actionIntent = new Intent(BACKGROUND_AUDIO); + PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); + RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); + actions.add(remoteAction); + + actionIntent = new Intent(ACTION_STOP); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_stop); + remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); + actions.add(remoteAction); + + //add custom actions to pip window + PictureInPictureParams params = + new PictureInPictureParams.Builder() + .setActions(actions) + .build(); + setPictureInPictureParams(params); + + } } From 7c0f45c602357bb996e86eab536967a38911f42b Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:35:26 -0700 Subject: [PATCH 17/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 14df78a..34af981 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -62,6 +62,8 @@ import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; @@ -397,4 +399,45 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } + @RequiresApi(api = Build.VERSION_CODES.O) + public void changedToPipMode() { + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + + videoPlayerFragment.showControls(false); + //create custom actions + setActions(""); + + //setup receiver to handle customer actions + IntentFilter filter = new IntentFilter(); + filter.addAction(ACTION_STOP); + filter.addAction(ACTION_PAUSE); + filter.addAction(ACTION_PLAY); + filter.addAction((BACKGROUND_AUDIO)); + receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ACTION_PAUSE)) { + videoPlayerFragment.pauseVideo(); + } + if (action.equals(ACTION_PLAY)) { + videoPlayerFragment.pauseToggle(); + } + + if (action.equals(BACKGROUND_AUDIO)) { + unregisterReceiver(receiver); + finish(); + } + if (action.equals(ACTION_STOP)) { + unregisterReceiver(receiver); + finishAndRemoveTask(); + } + } + }; + registerReceiver(receiver, filter); + + Log.v(TAG, "switched to pip "); + // videoPlayerFragment.useController(false); + } } From f6cfe248f415b65f30bb89296b7d21fbabd5d474 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:38:41 -0700 Subject: [PATCH 18/46] adding controls to exit pip or switch to background audio --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 34af981..09482b0 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -399,7 +399,6 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } - @RequiresApi(api = Build.VERSION_CODES.O) public void changedToPipMode() { FragmentManager fragmentManager = getSupportFragmentManager(); VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); From b7fc1b02a3480d6a2033273a5a6dc2f230de92b2 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:40:12 -0700 Subject: [PATCH 19/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 09482b0..5c7e09f 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -62,8 +62,6 @@ import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; -import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; -import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; @@ -399,44 +397,5 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } - public void changedToPipMode() { - FragmentManager fragmentManager = getSupportFragmentManager(); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); - - videoPlayerFragment.showControls(false); - //create custom actions - setActions(""); - - //setup receiver to handle customer actions - IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_STOP); - filter.addAction(ACTION_PAUSE); - filter.addAction(ACTION_PLAY); - filter.addAction((BACKGROUND_AUDIO)); - receiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action.equals(ACTION_PAUSE)) { - videoPlayerFragment.pauseVideo(); - } - if (action.equals(ACTION_PLAY)) { - videoPlayerFragment.pauseToggle(); - } - - if (action.equals(BACKGROUND_AUDIO)) { - unregisterReceiver(receiver); - finish(); - } - if (action.equals(ACTION_STOP)) { - unregisterReceiver(receiver); - finishAndRemoveTask(); - } - } - }; - registerReceiver(receiver, filter); - - Log.v(TAG, "switched to pip "); - // videoPlayerFragment.useController(false); - } + } From bec85eab89e332add7578b162e714e7906dcb541 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:41:42 -0700 Subject: [PATCH 20/46] adding controls to exit pip or switch to background audio --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 5c7e09f..14df78a 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -397,5 +397,4 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } - } From 33779e10a1e7c34a41710a098e7d664d9dab78c6 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:43:13 -0700 Subject: [PATCH 21/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 14df78a..aec6dad 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -372,29 +372,4 @@ public class VideoPlayActivity extends AppCompatActivity { } } - @RequiresApi(api = Build.VERSION_CODES.O) - public void setActions(String actionCommand) { - - ArrayList actions = new ArrayList<>(); - - Intent actionIntent = new Intent(BACKGROUND_AUDIO); - PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); - RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); - actions.add(remoteAction); - - actionIntent = new Intent(ACTION_STOP); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_stop); - remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); - actions.add(remoteAction); - - //add custom actions to pip window - PictureInPictureParams params = - new PictureInPictureParams.Builder() - .setActions(actions) - .build(); - setPictureInPictureParams(params); - - } } From 71bc325d49f427386f126519fa4cfafa15682edb Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:44:22 -0700 Subject: [PATCH 22/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index aec6dad..779afea 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -74,7 +74,30 @@ public class VideoPlayActivity extends AppCompatActivity { private static boolean floatMode = false; private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; + public void setActions(String actionCommand) { + ArrayList actions = new ArrayList<>(); + + Intent actionIntent = new Intent(BACKGROUND_AUDIO); + PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); + RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); + actions.add(remoteAction); + + actionIntent = new Intent(ACTION_STOP); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_stop); + remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); + actions.add(remoteAction); + + //add custom actions to pip window + PictureInPictureParams params = + new PictureInPictureParams.Builder() + .setActions(actions) + .build(); + setPictureInPictureParams(params); + + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); From 76b3ddcf6947c6327fbd8d19a509f4bff33a0717 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:47:20 -0700 Subject: [PATCH 23/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 779afea..c890b91 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -74,14 +74,16 @@ public class VideoPlayActivity extends AppCompatActivity { private static boolean floatMode = false; private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; + //This can only be called when in entering pip mode which can only happen on a high enough level to support pip mode. + @SuppressLint("NewApi") public void setActions(String actionCommand) { ArrayList actions = new ArrayList<>(); Intent actionIntent = new Intent(BACKGROUND_AUDIO); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); - RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); + @SuppressLint("NewApi") Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); + @SuppressLint("NewApi") RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); actions.add(remoteAction); actionIntent = new Intent(ACTION_STOP); From 81e92a421a74c2d4edc14eb3fed9264e7da1b82b Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:50:54 -0700 Subject: [PATCH 24/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index c890b91..608b653 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -62,6 +62,8 @@ import androidx.fragment.app.FragmentManager; //import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PAUSE; +import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_PLAY; import static com.google.android.exoplayer2.ui.PlayerNotificationManager.ACTION_STOP; import static net.schueller.peertube.helper.Constants.BACKGROUND_AUDIO; import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; @@ -100,6 +102,46 @@ public class VideoPlayActivity extends AppCompatActivity { setPictureInPictureParams(params); } + public void changedToPipMode() { + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + + videoPlayerFragment.showControls(false); + //create custom actions + setActions(""); + + //setup receiver to handle customer actions + IntentFilter filter = new IntentFilter(); + filter.addAction(ACTION_STOP); + filter.addAction(ACTION_PAUSE); + filter.addAction(ACTION_PLAY); + filter.addAction((BACKGROUND_AUDIO)); + receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ACTION_PAUSE)) { + videoPlayerFragment.pauseVideo(); + } + if (action.equals(ACTION_PLAY)) { + videoPlayerFragment.pauseToggle(); + } + + if (action.equals(BACKGROUND_AUDIO)) { + unregisterReceiver(receiver); + finish(); + } + if (action.equals(ACTION_STOP)) { + unregisterReceiver(receiver); + finishAndRemoveTask(); + } + } + }; + registerReceiver(receiver, filter); + + Log.v(TAG, "switched to pip "); + // videoPlayerFragment.useController(false); + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -391,6 +433,7 @@ public class VideoPlayActivity extends AppCompatActivity { @Override public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { if (isInPictureInPictureMode) { + changedToPipMode(); Log.v(TAG,"switched to pip "); } else { Log.v(TAG,"switched to normal"); From c05c67e7f8fb78dd5810dd3dea59546e1a2b7b60 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 15:53:38 -0700 Subject: [PATCH 25/46] adding controls to exit pip or switch to background audio --- .../peertube/activity/VideoPlayActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 608b653..091a6f0 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -142,6 +142,17 @@ public class VideoPlayActivity extends AppCompatActivity { Log.v(TAG, "switched to pip "); // videoPlayerFragment.useController(false); } + public void changedToNormalMode(){ + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); + + videoPlayerFragment.showControls(true); + if (receiver != null) { + unregisterReceiver(receiver); + } + Log.v(TAG,"switched to normal"); + // videoPlayerFragment.useController(true); + } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -436,6 +447,7 @@ public class VideoPlayActivity extends AppCompatActivity { changedToPipMode(); Log.v(TAG,"switched to pip "); } else { + changedToNormalMode(); Log.v(TAG,"switched to normal"); } } From fabb8a6d792de630c19b5b24c1a64511c71b1b44 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 16:00:29 -0700 Subject: [PATCH 26/46] adding controls to exit pip or switch to background audio --- .../schueller/peertube/service/VideoPlayerService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 a601af4..fbfc033 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -131,8 +131,13 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); + //Null check is insufficient to determine if it's been registered + try { + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); + } + } catch (Exception e) { + Log.e(TAG,"attempted to unregister a nonregistered noisy audio service"); } if (player != null) { player.release(); From 6995d9fde61ac761c2192d33e4af64d764dc25a3 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 16:02:57 -0700 Subject: [PATCH 27/46] adding controls to exit pip or switch to background audio --- .../net/schueller/peertube/activity/VideoPlayActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 091a6f0..71b8924 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -76,7 +76,7 @@ public class VideoPlayActivity extends AppCompatActivity { private static boolean floatMode = false; private static final int REQUEST_CODE = 101; private BroadcastReceiver receiver; - //This can only be called when in entering pip mode which can only happen on a high enough level to support pip mode. + //This can only be called when in entering pip mode which can't happen if the device doesn't support pip mode. @SuppressLint("NewApi") public void setActions(String actionCommand) { @@ -84,8 +84,8 @@ public class VideoPlayActivity extends AppCompatActivity { Intent actionIntent = new Intent(BACKGROUND_AUDIO); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); - @SuppressLint("NewApi") Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); - @SuppressLint("NewApi") RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); + @SuppressLint({"NewApi", "LocalSuppress"}) Icon icon = Icon.createWithResource(getApplicationContext(), android.R.drawable.stat_sys_speakerphone); + @SuppressLint({"NewApi", "LocalSuppress"}) RemoteAction remoteAction = new RemoteAction(icon, "close pip", "from pip window custom command", pendingIntent); actions.add(remoteAction); actionIntent = new Intent(ACTION_STOP); From 42ce468b31b1711c65d88afdeacbf1fa637a3f9a Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 16:06:14 -0700 Subject: [PATCH 28/46] Trying to assuage gits conflict adverse attitude --- .../peertube/service/VideoPlayerService.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 fbfc033..cc7823c 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -131,13 +131,11 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - //Null check is insufficient to determine if it's been registered - try { - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); - } - } catch (Exception e) { - Log.e(TAG,"attempted to unregister a nonregistered noisy audio service"); + //TODO figure out how to stop this from crashing sometimes when the non null service is still not registered + // try catch fixes it but GIT considers that an unacceptable change to the code + + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); } if (player != null) { player.release(); From 46f6cf51698deae4c4352f054d1816d5a7e1b05b Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 16:08:05 -0700 Subject: [PATCH 29/46] Trying to assuage gits conflict adverse attitude --- .../net/schueller/peertube/service/VideoPlayerService.java | 3 --- 1 file changed, 3 deletions(-) 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 cc7823c..a601af4 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -131,9 +131,6 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - //TODO figure out how to stop this from crashing sometimes when the non null service is still not registered - // try catch fixes it but GIT considers that an unacceptable change to the code - if (null!=myNoisyAudioStreamReceiver) { this.unregisterReceiver(myNoisyAudioStreamReceiver); } From 63469d12beeb2ddec87e9bd20b96b0959aeda91e Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 16:15:15 -0700 Subject: [PATCH 30/46] Trying to assuage gits conflict adverse attitude --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 71b8924..479b5ea 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -140,6 +140,7 @@ public class VideoPlayActivity extends AppCompatActivity { registerReceiver(receiver, filter); Log.v(TAG, "switched to pip "); + floatMode=true; // videoPlayerFragment.useController(false); } public void changedToNormalMode(){ @@ -151,6 +152,7 @@ public class VideoPlayActivity extends AppCompatActivity { unregisterReceiver(receiver); } Log.v(TAG,"switched to normal"); + floatMode=false; // videoPlayerFragment.useController(true); } @Override From 9d1ffd77c36b4137736ab3a847c2356dfdaecdba Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 20:09:33 -0700 Subject: [PATCH 31/46] Trying to assuage gits conflict adverse attitude --- .../peertube/activity/VideoPlayActivity.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 479b5ea..d5c9a1a 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -78,7 +78,9 @@ public class VideoPlayActivity extends AppCompatActivity { private BroadcastReceiver receiver; //This can only be called when in entering pip mode which can't happen if the device doesn't support pip mode. @SuppressLint("NewApi") - public void setActions(String actionCommand) { + public void makePipControls() { + FragmentManager fragmentManager = getSupportFragmentManager(); + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment); ArrayList actions = new ArrayList<>(); @@ -94,6 +96,23 @@ public class VideoPlayActivity extends AppCompatActivity { remoteAction = new RemoteAction(icon, "play", "stop the media", pendingIntent); actions.add(remoteAction); + if (videoPlayerFragment.isPaused()){ + Log.e(TAG,"setting actions with play button"); + actionIntent = new Intent(ACTION_PLAY); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_play); + remoteAction = new RemoteAction(icon, "play", "play the media", pendingIntent); + actions.add(remoteAction); + } else { + Log.e(TAG,"setting actions with pause button"); + actionIntent = new Intent(ACTION_PAUSE); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, actionIntent, 0); + icon = Icon.createWithResource(getApplicationContext(), com.google.android.exoplayer2.ui.R.drawable.exo_notification_pause); + remoteAction = new RemoteAction(icon, "pause", "pause the media", pendingIntent); + actions.add(remoteAction); + } + + //add custom actions to pip window PictureInPictureParams params = new PictureInPictureParams.Builder() @@ -108,7 +127,7 @@ public class VideoPlayActivity extends AppCompatActivity { videoPlayerFragment.showControls(false); //create custom actions - setActions(""); + makePipControls(); //setup receiver to handle customer actions IntentFilter filter = new IntentFilter(); @@ -122,9 +141,11 @@ public class VideoPlayActivity extends AppCompatActivity { String action = intent.getAction(); if (action.equals(ACTION_PAUSE)) { videoPlayerFragment.pauseVideo(); + makePipControls(); } if (action.equals(ACTION_PLAY)) { - videoPlayerFragment.pauseToggle(); + videoPlayerFragment.unPauseVideo(); + makePipControls(); } if (action.equals(BACKGROUND_AUDIO)) { @@ -141,7 +162,7 @@ public class VideoPlayActivity extends AppCompatActivity { Log.v(TAG, "switched to pip "); floatMode=true; - // videoPlayerFragment.useController(false); + videoPlayerFragment.showControls(false); } public void changedToNormalMode(){ FragmentManager fragmentManager = getSupportFragmentManager(); @@ -153,7 +174,6 @@ public class VideoPlayActivity extends AppCompatActivity { } Log.v(TAG,"switched to normal"); floatMode=false; - // videoPlayerFragment.useController(true); } @Override protected void onCreate(Bundle savedInstanceState) { From a99e9978de2fcb93bb82e77fc0a60cdbf5c4f871 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 20:33:14 -0700 Subject: [PATCH 32/46] Fixing unregister error for noisy audio --- .../schueller/peertube/fragment/VideoPlayerFragment.java | 7 +++++-- .../schueller/peertube/service/VideoPlayerService.java | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index 2c4140f..08e4275 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -259,11 +259,14 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL mService.player.setPlayWhenReady(false); } } - public void pauseToggle() { + public void unPauseVideo() { if (mBound) { - mService.player.setPlayWhenReady(!mService.player.getPlayWhenReady()); + mService.player.setPlayWhenReady(true); } } + public boolean isPaused(){ + return !mService.player.getPlayWhenReady(); + } public void showControls(boolean value){ simpleExoPlayerView.setUseController(value); } 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 a601af4..4b76b0d 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -108,6 +108,7 @@ public class VideoPlayerService extends Service { if (playbackState == ACTION_PLAY) { // this means that play is available, hence the audio is paused or stopped Log.v(TAG, "ACTION_PAUSE: " + playbackState); unregisterReceiver(myNoisyAudioStreamReceiver); + myNoisyAudioStreamReceiver=null; } } } ); @@ -131,9 +132,10 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); - } + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); + myNoisyAudioStreamReceiver=null; + } if (player != null) { player.release(); player = null; From 39c38ca0fa274fd0d27a88a20972d69e0e1e6454 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 20:35:53 -0700 Subject: [PATCH 33/46] Fixing unregister error for noisy audio --- .../schueller/peertube/service/VideoPlayerService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 4b76b0d..d100402 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -132,10 +132,10 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); - myNoisyAudioStreamReceiver=null; - } + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); + myNoisyAudioStreamReceiver=null; + } if (player != null) { player.release(); player = null; From 2c5248aebb19d856f47ec8649ef83c2232013d34 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 21:41:35 -0700 Subject: [PATCH 34/46] Bug fix for DateUtils not working as documented --- .../java/net/schueller/peertube/helper/MetaDataHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java index 6c4b98e..164637d 100644 --- a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java @@ -28,8 +28,7 @@ import java.util.Date; public class MetaDataHelper { public static String getMetaString(Date getCreatedAt, Integer viewCount, Context context) { - return DateUtils. - getRelativeTimeSpanString(getCreatedAt.getTime()).toString() + + return (DateUtils.getRelativeTimeSpanString(context,getCreatedAt.getTime(),false).toString() + context.getResources().getString(R.string.meta_data_seperator) + viewCount + context.getResources().getString(R.string.meta_data_views); } From 1d3a464c62259a399964cab1cd053957c7c34f23 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 21:48:43 -0700 Subject: [PATCH 35/46] Bug fix for DateUtils not working as documented --- .../peertube/fragment/VideoPlayerFragment.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index 08e4275..9fad3b3 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -199,7 +199,11 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL } }); } - + public void useController(boolean value){ + if (mBound){ + simpleExoPlayerView.setUseController(value); + } + } private void playVideo(Video video) { Context context = getContext(); @@ -259,6 +263,11 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL mService.player.setPlayWhenReady(false); } } + public void pauseToggle() { + if (mBound) { + mService.player.setPlayWhenReady(!mService.player.getPlayWhenReady()); + } + } public void unPauseVideo() { if (mBound) { mService.player.setPlayWhenReady(true); From d11d19e164c1029d9b254e81ae8a773327443df3 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 21:53:58 -0700 Subject: [PATCH 36/46] Bug fix for DateUtils not working as documented --- .../schueller/peertube/fragment/VideoPlayerFragment.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index 9fad3b3..edfdb68 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -199,11 +199,7 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL } }); } - public void useController(boolean value){ - if (mBound){ - simpleExoPlayerView.setUseController(value); - } - } + private void playVideo(Video video) { Context context = getContext(); From 7790ca4592c062238b407446803b53a26e67e3eb Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 21:58:56 -0700 Subject: [PATCH 37/46] Bug fix for DateUtils not working as documented --- .../main/java/net/schueller/peertube/helper/MetaDataHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java index 164637d..84e9de9 100644 --- a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java @@ -30,7 +30,7 @@ public class MetaDataHelper { public static String getMetaString(Date getCreatedAt, Integer viewCount, Context context) { return (DateUtils.getRelativeTimeSpanString(context,getCreatedAt.getTime(),false).toString() + context.getResources().getString(R.string.meta_data_seperator) + - viewCount + context.getResources().getString(R.string.meta_data_views); + viewCount + context.getResources().getString(R.string.meta_data_views)); } public static String getOwnerString(String accountName, String serverHost, Context context) { From 83898c81cdffab04f65fcb68ff50c867636ba16c Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 22:06:38 -0700 Subject: [PATCH 38/46] Bug fix for DateUtils not working as documented --- .../schueller/peertube/service/VideoPlayerService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 d100402..d3aa9a8 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -132,9 +132,12 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); - myNoisyAudioStreamReceiver=null; + try { + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); + } + } catch (Exception e) { + Log.e("VideoPlayerService", "attempted to unregister a nonregistered service"); } if (player != null) { player.release(); From 6f51d8f6b372b8afed7d6c9f52a4b068778e809f Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 14:21:31 +0200 Subject: [PATCH 39/46] Removed translations for untranslatable strings --- app/src/main/res/values-ar/strings.xml | 7 ------ app/src/main/res/values-bn/strings.xml | 25 -------------------- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 7 ------ app/src/main/res/values-nb-rNO/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-sv/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 27 ---------------------- app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values-zh-rTW/strings.xml | 1 - 10 files changed, 72 deletions(-) diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index fb28e73..571c662 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -1,7 +1,5 @@ - Thorium - نشاط تشغيل الفيديو الإعدادات تسجيل الدخول @@ -24,13 +22,9 @@ الإشتراكات الحساب - 1.0.0-alpha.7 - https://troll.tv خادوم PeerTube - \u0020-\u0020 \u0020 مشاهدات - \@ الصورة المصغرة للفيديو الصورة الرمزية للحساب عرض NSFW @@ -51,7 +45,6 @@ لاتوجد نتائج المزيد مشاركة - PeerTube الرابط غير صالح. الوضع الداكن أعد تشغيل التطبيق لتنشيط الوضع الداكن. diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index 7277160..7e410c0 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -1,7 +1,5 @@ - Thorium - VideoPlayActivity সেটিংস সাইন ইন @@ -25,13 +23,9 @@ সাবস্ক্রিপশন অ্যাকাউন্ট - 1.0.0-alpha.7 - https://troll.tv পিয়ারটিউব সার্ভার - \u0020-\u0020 " দৃষ্ট" - \@ ভিডিও থাম্বনেইল অ্যাকাউন্ট অবতার নিষিদ্ধ কন্টেন্ট @@ -52,7 +46,6 @@ ফলাফল নেই আরও শেয়ার - PeerTube অবৈধ ইউআরএল। অন্ধকার মোড অন্ধকার মোড কার্যকর করার জন্য অ্যাপ্লিকেশন রিস্টার্ট করো। @@ -272,15 +265,6 @@ Normal ১.৫x 2x - {faw-check} - {faw-expand} - {faw-compress} - {faw-ellipsis-v} - {faw-thumbs-up} - {faw-thumbs-down} - {faw-share} - {faw-download} - {faw-save} ব্যাকগ্রাউন্ড প্লেব্যাক সক্রিয় থাকলে ব্যাকগ্রাউন্ডে ভিডিও প্লে করতে থাকবে। স্থানীয় @@ -298,15 +282,6 @@ ভাষা Tags - pref_token_access - pref_token_refresh - pref_token_expiration - pref_token_type - pref_auth_username - pref_auth_password - none - like - dislike গাঢ় বেগুনি অ্যাকাউন্ট সাম্প্রতিক diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 0f3fd83..aae549c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -16,7 +16,6 @@ Abos Konto PeerTube-Server - VideoPlayActivity Dieses Passwort ist zu kurz Dieses Passwort ist falsch Einstellungen diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5567530..273d7aa 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1,7 +1,5 @@ - Thorium - VideoPlayActivity Paramètres Se connecter @@ -24,13 +22,9 @@ Abonnements Compte - 1.0.0-alpha.7 - https://troll.tv Serveur Peertube - \u0020-\u0020 " vues" - \@ Miniature vidéo Avatar du compte Contenu pour adultes @@ -49,7 +43,6 @@ Pas de résultat Plus Partager - PeerTube URL invalide. Mode sombre Redémarrez l’application pour que le mode sombre soit activé. diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 6f96c67..abfcf6f 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -61,7 +61,6 @@ Beskrivelse: Tok del: Noe gikk galt, prøv igjen senere. - VideoPlayActivity Innvilg kontakttilgang for fullføring av e-postadresser. Populært " visninger" diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 486a798..b859884 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1,6 +1,5 @@ - VideoPlayActivity Instellingen Inloggen Server diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 689df8d..6a7f958 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -282,7 +282,6 @@ Beskrivning: Gick med: Någonting gick snett, försök gärna igen om en stund! - VideoPlayActivity Ge åtkomst till kontakter för komplettering av e-postadresser. UrlVideoPlayActivity diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8312c87..90b0ae9 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1,6 +1,5 @@ - İzleti Oynatma Etkinliği Ayarlar Oturum aç @@ -24,13 +23,9 @@ Abonelikler Hesap - 1.0.0-alpha.7 - https://troll.tv PeerTube Sunucusu - \u0020-\u0020 " Görüntüleme" - \@ İzleti Küçük Resmi Hesap Resmi Ahlaksız İçerik @@ -48,7 +43,6 @@ Sonuç yok Daha Paylaş - PeerTube Geçersiz bağlantı. Karanlık Kipi Karanlık kipin etkinleşmesi için uygulamayı yeniden başlatın. @@ -269,18 +263,6 @@ Normal 1,5× - {faw-play-circle} - {faw-cog} - {faw-check} - {faw-check} - {faw-expand} - {faw-compress} - {faw-ellipsis-v} - {faw-thumbs-up} - {faw-thumbs-down} - {faw-share} - {faw-download} - {faw-save} Arkaplanda Oynatma Etkinleştirilirse, arka planda izleti oynatmaya devam eder. Yerel @@ -300,15 +282,6 @@ Oynatma hızı Kalite - pref_token_access - pref_token_refresh - pref_token_expiration - pref_token_type - pref_auth_username - pref_auth_password - none - like - dislike Hesap Yeniler İzletiler diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index dbba02c..91e491e 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -63,7 +63,6 @@ 视频通过一个种子下载,此选项需要存储权限(实验阶段,不稳定!) 退出 中文 - 视频播放Activity 本字段必填 账户 最近 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index ddce667..037f1f0 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1,6 +1,5 @@ - 影片播放活動 設定 登入 伺服器 From 35059521878f10fe14d0de4eeaf6a0d711cb08fc Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 14:34:34 +0200 Subject: [PATCH 40/46] Improved and added some French translations --- app/src/main/res/values-fr/strings.xml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5567530..27fed15 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -312,7 +312,7 @@ Serveur actuel 0,75× 1,25× - Livre d\'adresse + Carnet d\'adresses Identification réussie Identification échouée ! a un identifiant @@ -333,4 +333,19 @@ Langue de l\'application Mettre la lecture d\'arrière-plan en pause en appuyant sur la touche de retour pendant la lecture de la vidéo. Pause sur le bouton retour + À propos + Apparence + Compte + Paramètres de lecture en fond + Votre version Android ne supporte pas la lecture de vidéos dans une fenêtre flottante + Le mode Picture-in-Picture est désactivé pour cette applications dans les paramètres Android + Lecture de vidéos + Continuer en fond sonore + Arrêter de lire la vidéo + Continuer dans une fenêtre flottante + Sélectionner le mode de fonctionnement de la lecture de vidéo lorsque l\'application est mise en arrière-plan + Liste de vidéos + Sélectionner un serveur + Retirer un serveur + Voulez-vous vraiment retirer ce serveur de votre carnet d\'adresses ? \ No newline at end of file From 15ce004b261c1f69b68baa44f596331b1e253069 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 17:01:49 +0200 Subject: [PATCH 41/46] Fixed https://github.com/sschueller/peertube-android/issues/194 with new Lib. --- app/build.gradle | 3 +++ .../peertube/helper/MetaDataHelper.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dd038df..0a32a8e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,6 +62,9 @@ android { implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$libVersions.exoplayer" implementation "com.google.android.exoplayer:extension-mediasession:$libVersions.exoplayer" + // date formatter + implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' + // testing testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' diff --git a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java index 84e9de9..fa7390f 100644 --- a/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/MetaDataHelper.java @@ -18,17 +18,28 @@ package net.schueller.peertube.helper; import android.content.Context; + import android.text.format.DateUtils; + import net.schueller.peertube.R; -import java.time.Duration; -import java.time.Period; +import org.ocpsoft.prettytime.PrettyTime; + import java.util.Date; +import java.util.Locale; + public class MetaDataHelper { + public static String getMetaString(Date getCreatedAt, Integer viewCount, Context context) { - return (DateUtils.getRelativeTimeSpanString(context,getCreatedAt.getTime(),false).toString() + + + // Compatible with SDK 21+ + String currentLanguage = Locale.getDefault().getDisplayLanguage(); + PrettyTime p = new PrettyTime(currentLanguage); + String relativeTime = p.format(new Date(getCreatedAt.getTime())); + + return (relativeTime + context.getResources().getString(R.string.meta_data_seperator) + viewCount + context.getResources().getString(R.string.meta_data_views)); } From 4f1a6fd97ccc0c3b96acfdadb2f43e24255b0e3f Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 4 Jul 2020 17:26:01 +0200 Subject: [PATCH 42/46] Added appbar at the top of the SettingsActivity --- .../peertube/activity/SettingsActivity.java | 13 +++++++++++++ app/src/main/res/layout/activity_settings.xml | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java index 52db457..38126d2 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SettingsActivity.java @@ -38,12 +38,25 @@ public class SettingsActivity extends CommonActivity { .beginTransaction() .replace(R.id.settings, new SettingsFragment()) .commit(); + + // Attaching the layout to the toolbar object + Toolbar toolbar = findViewById(R.id.tool_bar_settings); + // Setting toolbar as the ActionBar with setSupportActionBar() call + setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeAsUpIndicator(R.drawable.ic_baseline_close_24); } } + @Override + public boolean onSupportNavigateUp() { + finish(); // close this activity as oppose to navigating up + return false; + } + public static class SettingsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index de6591a..4fb6dcc 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,21 @@ + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + Date: Sat, 4 Jul 2020 20:46:32 +0200 Subject: [PATCH 43/46] Added more fields to server list --- app/build.gradle | 3 + .../peertube/adapter/ChannelAdapter.java | 2 +- .../peertube/adapter/ServerAdapter.java | 58 ++++++++++++------ .../peertube/adapter/VideoAdapter.java | 2 +- .../fragment/VideoMetaDataFragment.java | 2 +- .../net/schueller/peertube/model/Server.java | 59 ++++++++++++++++++- .../ic_baseline_remove_red_eye_24.xml | 10 ++++ .../main/res/layout/fragment_video_meta.xml | 6 +- app/src/main/res/layout/row_account_about.xml | 6 +- .../main/res/layout/row_account_channels.xml | 6 +- app/src/main/res/layout/row_account_video.xml | 6 +- app/src/main/res/layout/row_server.xml | 48 ++++++++++++--- app/src/main/res/layout/row_video.xml | 6 +- app/src/main/res/values/strings.xml | 4 ++ 14 files changed, 172 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml diff --git a/app/build.gradle b/app/build.gradle index 0a32a8e..e4b5736 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,6 +65,9 @@ android { // date formatter implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' + // Version comparison + implementation 'org.apache.maven:maven-artifact:3.0.3' + // testing testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' diff --git a/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java b/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java index ed4f2ea..4fbbe21 100644 --- a/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java +++ b/app/src/main/java/net/schueller/peertube/adapter/ChannelAdapter.java @@ -160,7 +160,7 @@ public class ChannelAdapter extends RecyclerView.Adapter= 0) { + // show NSFW Icon + if (serverList.get(position).getNSFW()) { + holder.isNSFW.setVisibility(View.VISIBLE); + } + } + + + // select server holder.itemView.setOnClickListener(v -> { -// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity); -// SharedPreferences.Editor editor = sharedPref.edit(); - String serverUrl = APIUrlHelper.cleanServerUrl(serverList.get(position).getHost()); -// editor.putString("pref_api_base", serverUrl); -// editor.apply(); -// -// - Toast.makeText(activity, activity.getString(R.string.server_selection_set_server, serverUrl), Toast.LENGTH_LONG).show(); Intent intent = new Intent(); @@ -138,17 +156,19 @@ public class ServerAdapter extends RecyclerView.Adapter languages; + private Boolean autoBlacklistUserVideosEnabled; + private String defaultNSFWPolicy; + private Boolean isNSFW; private Integer totalUsers; private Integer totalVideos; private Integer totalLocalVideos; private Integer totalInstanceFollowers; private Integer totalInstanceFollowing; - private Boolean supportsIPv6; private String country; - private Integer health; + private Date createdAt; public Integer getId() { return id; @@ -93,6 +100,46 @@ public class Server { this.userVideoQuota = userVideoQuota; } + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public ArrayList getLanguages() { + return languages; + } + + public void setLanguages(ArrayList languages) { + this.languages = languages; + } + + public Boolean getAutoBlacklistUserVideosEnabled() { + return autoBlacklistUserVideosEnabled; + } + + public void setAutoBlacklistUserVideosEnabled(Boolean autoBlacklistUserVideosEnabled) { + this.autoBlacklistUserVideosEnabled = autoBlacklistUserVideosEnabled; + } + + public String getDefaultNSFWPolicy() { + return defaultNSFWPolicy; + } + + public void setDefaultNSFWPolicy(String defaultNSFWPolicy) { + this.defaultNSFWPolicy = defaultNSFWPolicy; + } + + public Boolean getNSFW() { + return isNSFW; + } + + public void setNSFW(Boolean NSFW) { + isNSFW = NSFW; + } + public Integer getTotalUsers() { return totalUsers; } @@ -156,4 +203,12 @@ public class Server { public void setHealth(Integer health) { this.health = health; } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml b/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml new file mode 100644 index 0000000..a3e222a --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_remove_red_eye_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_video_meta.xml b/app/src/main/res/layout/fragment_video_meta.xml index 1db093d..f734fe4 100644 --- a/app/src/main/res/layout/fragment_video_meta.xml +++ b/app/src/main/res/layout/fragment_video_meta.xml @@ -16,7 +16,7 @@ android:paddingEnd="12dp" /> diff --git a/app/src/main/res/layout/row_account_about.xml b/app/src/main/res/layout/row_account_about.xml index a02de1c..cb86831 100644 --- a/app/src/main/res/layout/row_account_about.xml +++ b/app/src/main/res/layout/row_account_about.xml @@ -50,7 +50,7 @@ android:paddingEnd="12dp" /> + + - + android:orientation="vertical"> + + + + + + + + + + + + diff --git a/app/src/main/res/layout/row_video.xml b/app/src/main/res/layout/row_video.xml index 170c104..398db17 100644 --- a/app/src/main/res/layout/row_video.xml +++ b/app/src/main/res/layout/row_video.xml @@ -58,7 +58,7 @@ android:paddingEnd="12dp" /> About + PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular. + NSFW Instance + Videos: %s, Local Videos: %s + pref_token_access From 057c521a4af356a50eb9f4a30b6ad214a6302220 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:50:26 +0200 Subject: [PATCH 44/46] Fix merge --- app/src/main/res/values-fr/strings.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 09393f8..d1dab69 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -327,24 +327,9 @@ Mettre la lecture d\'arrière-plan en pause en appuyant sur la touche de retour pendant la lecture de la vidéo. Pause sur le bouton retour Apparence - À propos - Lecture vidéo - Liste des vidéos SettingsActivity2 - Compte - Sélectionner un serveur - Êtes-vous sûr de vouloir supprimer ce serveur du carnet d\'adresses \? - Supprimer le serveur Bengalais (Bangladesh) - Comment une vidéo en cours de lecture réagit lorsqu\'elle passe en arrière-plan - La permission \"Image dans l\'image\" est désactivée pour cette application dans les paramètres Android - La version Android ne prend pas en charge la vidéo flottante - Configuration de la lecture en arrière-plan - Continuer la lecture de la vidéo dans une fenêtre flottante - Arrêter toutes les lectures - Continuer comme un flux audio d\'arrière plan À propos - Apparence Compte Paramètres de lecture en fond Votre version Android ne supporte pas la lecture de vidéos dans une fenêtre flottante From 1d2035e4f805d434af3adebd173fb6207179a8ff Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:54:09 +0200 Subject: [PATCH 45/46] Version 1.0.42 --- CHANGELOG.md | 8 ++++++++ app/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f57e087..5e4f090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### Version 1.0.42 Tag: v1.0.42 (2020-07-04) + * Added appbar at the top of the SettingsActivity (@Poslovitch) + * Improved and added some French translations (@Poslovitch) + * Removed translations for untranslatable strings (@Poslovitch) + * Add stop button to expanded notification, and stop and switch to audio in video window (@dhk2) + * More data in Server search + * VideoList timestamp fix + ### Version 1.0.41 Tag: v1.0.41 (2020-06-28) * Floating window player controls fix (@dhk2) * Updated app icons diff --git a/app/build.gradle b/app/build.gradle index e4b5736..b3182c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "net.schueller.peertube" minSdkVersion 21 targetSdkVersion 29 - versionCode 1041 - versionName "1.0.41" + versionCode 1042 + versionName "1.0.42" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ext { libVersions = [ From 9f892a506589d7124ceded83e7719515743abb7f Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sat, 4 Jul 2020 20:57:35 +0200 Subject: [PATCH 46/46] Lib version bump --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b3182c2..701767c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,7 @@ android { implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final' // Version comparison - implementation 'org.apache.maven:maven-artifact:3.0.3' + implementation 'org.apache.maven:maven-artifact:3.5.0' // testing testImplementation 'junit:junit:4.12'