mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 04:08:44 +03:00
Support picture-in-picture mode for element call widget.
This commit is contained in:
parent
b3a8052a51
commit
85aba894d6
2 changed files with 23 additions and 1 deletions
|
@ -308,7 +308,8 @@
|
|||
<activity android:name=".features.terms.ReviewTermsActivity" />
|
||||
<activity
|
||||
android:name=".features.widgets.WidgetActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" />
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:supportsPictureInPicture="true" />
|
||||
|
||||
<activity android:name=".features.pin.PinActivity" />
|
||||
<activity android:name=".features.analytics.ui.consent.AnalyticsOptInActivity" />
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
package im.vector.app.features.widgets
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Rational
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.mvrx.Mavericks
|
||||
import com.airbnb.mvrx.viewModel
|
||||
|
@ -119,6 +122,24 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
super.onUserLeaveHint()
|
||||
val widgetArgs: WidgetArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG)
|
||||
if (widgetArgs?.kind == WidgetKind.ELEMENT_CALL) {
|
||||
enterPictureInPicture()
|
||||
}
|
||||
}
|
||||
|
||||
private fun enterPictureInPicture() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val aspectRatio = Rational(resources.getDimensionPixelSize(R.dimen.call_pip_width), resources.getDimensionPixelSize(R.dimen.call_pip_height))
|
||||
val params = PictureInPictureParams.Builder()
|
||||
.setAspectRatio(aspectRatio)
|
||||
.build()
|
||||
enterPictureInPictureMode(params)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleClose(event: WidgetViewEvents.Close) {
|
||||
if (event.content != null) {
|
||||
val intent = createResultIntent(event.content)
|
||||
|
|
Loading…
Add table
Reference in a new issue