From 03a196c4910d7658b8ee083e1f8e4a5f128ee57d Mon Sep 17 00:00:00 2001 From: dhk2 Date: Tue, 30 Jun 2020 14:56:01 -0700 Subject: [PATCH] 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); }