Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
android:name=".PiPSampleActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="true"
android:supportsPictureInPicture="true"
android:supportsPictureInPicture="false"
android:launchMode="singleTask"
android:theme="@style/PiPAppTheme"
tools:targetApi="26" />

<activity
android:name=".PiPMovieActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:supportsPictureInPicture="true"
android:supportsPictureInPicture="false"
android:launchMode="singleTask"
android:theme="@style/PiPAppTheme"
tools:targetApi="o" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PiPMovieActivity : ComponentActivity() {

// Configure parameters for the picture-in-picture mode. We do this at the first layout of
// the MovieView because we use its layout position and size.
binding.movie.doOnLayout { updatePictureInPictureParams() }
// binding.movie.doOnLayout { updatePictureInPictureParams() }

// Set up the video; it automatically starts.
binding.movie.setMovieListener(movieListener)
Expand Down Expand Up @@ -175,7 +175,7 @@ class PiPMovieActivity : ComponentActivity() {
}
}

override fun onPictureInPictureModeChanged(
/*override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean, newConfig: Configuration,
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
Expand All @@ -188,18 +188,18 @@ class PiPMovieActivity : ComponentActivity() {
binding.movie.showControls()
}
}
}
}*/

@RequiresApi(35)
/*@RequiresApi(35)
override fun onPictureInPictureUiStateChanged(pipState: PictureInPictureUiState) {
super.onPictureInPictureUiStateChanged(pipState)
if (pipState.isTransitioningToPip) {
binding.movie.hideControls()
}
}
}*/


private fun updatePictureInPictureParams(): PictureInPictureParams {
/*private fun updatePictureInPictureParams(): PictureInPictureParams {
// Calculate the aspect ratio of the PiP screen.
val aspectRatio = Rational(binding.movie.width, binding.movie.height)
// The movie view turns into the picture-in-picture mode.
Expand All @@ -219,13 +219,13 @@ class PiPMovieActivity : ComponentActivity() {
return params.build().also {
setPictureInPictureParams(it)
}
}
}*/

/**
* Enters Picture-in-Picture mode.
*/
private fun minimize() {
enterPictureInPictureMode(updatePictureInPictureParams())
// enterPictureInPictureMode(updatePictureInPictureParams())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,62 +89,63 @@ class PiPSampleActivity : ComponentActivity() {
binding.clear.setOnClickListener { viewModel.clear() }
binding.startOrPause.setOnClickListener { viewModel.startOrPause() }
binding.pip.setOnClickListener {
enterPictureInPictureMode(updatePictureInPictureParams(viewModel.started.value == true))
// enterPictureInPictureMode(updatePictureInPictureParams(viewModel.started.value == true))
}
// Observe data from the viewModel.
viewModel.time.observe(this) { time -> binding.time.text = time }
viewModel.started.observe(this) { started ->
binding.startOrPause.setImageResource(
if (started) R.drawable.ic_pause_24dp else R.drawable.ic_play_arrow_24dp,
)
updatePictureInPictureParams(started)
// updatePictureInPictureParams(started)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out line should be removed. Keeping commented-out code can be confusing for other developers and reduces code quality.

}

// Use trackPipAnimationHint view to make a smooth enter/exit pip transition.
// See https://android.devsite.corp.google.com/develop/ui/views/picture-in-picture#smoother-transition
lifecycleScope.launch {
/* lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
trackPipAnimationHintView(binding.stopwatchBackground)
}
}
}*/
Comment on lines +105 to +109
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This lifecycleScope.launch block is commented out. It's better to remove dead code entirely rather than commenting it out, to improve readability and maintainability.


// Handle events from the action icons on the picture-in-picture mode.
ActivityCompat.registerReceiver(
/*ActivityCompat.registerReceiver(
this,
broadcastReceiver,
IntentFilter(ACTION_STOPWATCH_CONTROL),
ContextCompat.RECEIVER_NOT_EXPORTED
)
)*/
Comment on lines +112 to +117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This ActivityCompat.registerReceiver call is commented out. Please remove it to avoid code clutter.

}

// This is called when the activity gets into or out of the picture-in-picture mode.
override fun onPictureInPictureModeChanged(
/*override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean,
newConfig: Configuration,
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
// Toggle visibility of in-app buttons. They cannot be interacted in the picture-in-picture
// mode, and their features are provided as the action icons.
toggleControls(if (isInPictureInPictureMode) View.GONE else View.VISIBLE)
}
}*/
Comment on lines +121 to +129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onPictureInPictureModeChanged method is commented out. It should be removed completely to keep the code clean.


private fun toggleControls(view: Int) {
binding.clear.visibility = view
binding.startOrPause.visibility = view
}

@RequiresApi(35)
/* @RequiresApi(35)
override fun onPictureInPictureUiStateChanged(pipState: PictureInPictureUiState) {
super.onPictureInPictureUiStateChanged(pipState)
if (pipState.isTransitioningToPip) {
toggleControls(View.GONE)
}
}
}*/
Comment on lines +136 to +142
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onPictureInPictureUiStateChanged method is commented out. Please remove it instead of commenting it out.


/**
* Updates the parameters of the picture-in-picture mode for this activity based on the current
* [started] state of the stopwatch.
*/
/*
private fun updatePictureInPictureParams(started: Boolean): PictureInPictureParams {
val params = PictureInPictureParams.Builder()
// Set action items for the picture-in-picture mode. These are the only custom controls
Expand Down Expand Up @@ -191,6 +192,7 @@ class PiPSampleActivity : ComponentActivity() {
setPictureInPictureParams(it)
}
}
*/

/**
* Creates a [RemoteAction]. It is used as an action icon on the overlay of the
Expand Down
Loading