fixing duplicate controlelrs

This commit is contained in:
dhk2 2020-06-30 14:56:01 -07:00
parent f942e27536
commit 03a196c491
2 changed files with 14 additions and 2 deletions

View File

@ -61,7 +61,7 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
public class VideoPlayActivity extends AppCompatActivity { public class VideoPlayActivity extends AppCompatActivity {
private static final String TAG = "VideoPlayActivity"; private static final String TAG = "VideoPlayActivity";
private static boolean floatMode = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -112,6 +112,12 @@ public class VideoPlayActivity extends AppCompatActivity {
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment)
getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
assert videoPlayerFragment != null; 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); String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID);
Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid()); Log.v(TAG, "new intent click: " + videoUuid +" is trying to replace: "+videoPlayerFragment.getVideoUuid());
assert videoPlayerFragment != null; assert videoPlayerFragment != null;
@ -355,8 +361,10 @@ public class VideoPlayActivity extends AppCompatActivity {
public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) {
if (isInPictureInPictureMode) { if (isInPictureInPictureMode) {
Log.v(TAG,"switched to pip "); Log.v(TAG,"switched to pip ");
floatMode=true;
} else { } else {
Log.v(TAG,"switched to normal"); Log.v(TAG,"switched to normal");
floatMode=false;
} }
} }
} }

View File

@ -239,6 +239,7 @@ public class VideoPlayerService extends Service {
// don't show skip buttons in notification // don't show skip buttons in notification
playerNotificationManager.setUseNavigationActions(false); playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setUseStopAction(true);
playerNotificationManager.setNotificationListener( playerNotificationManager.setNotificationListener(
new PlayerNotificationManager.NotificationListener() { new PlayerNotificationManager.NotificationListener() {
@ -250,7 +251,10 @@ public class VideoPlayerService extends Service {
@Override @Override
public void onNotificationCancelled(int notificationId) { public void onNotificationCancelled(int notificationId) {
Log.v(TAG, "onNotificationCancelled..."); 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 // TODO: only kill the notification if we no longer have a bound activity
stopForeground(true); stopForeground(true);
} }