mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
Fix picture in picture mode.
This commit is contained in:
parent
85b5713b24
commit
7dfe5264cd
1 changed files with 13 additions and 2 deletions
|
@ -29,9 +29,12 @@ import android.graphics.drawable.Icon
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Rational
|
import android.util.Rational
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.core.app.PictureInPictureModeChangedInfo
|
||||||
|
import androidx.core.util.Consumer
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.airbnb.mvrx.Mavericks
|
import com.airbnb.mvrx.Mavericks
|
||||||
import com.airbnb.mvrx.viewModel
|
import com.airbnb.mvrx.viewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.addFragment
|
import im.vector.app.core.extensions.addFragment
|
||||||
|
@ -99,6 +102,7 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
||||||
// Trust element call widget by default
|
// Trust element call widget by default
|
||||||
if (widgetArgs.kind == WidgetKind.ELEMENT_CALL) {
|
if (widgetArgs.kind == WidgetKind.ELEMENT_CALL) {
|
||||||
if (supportFragmentManager.findFragmentByTag(WIDGET_FRAGMENT_TAG) == null) {
|
if (supportFragmentManager.findFragmentByTag(WIDGET_FRAGMENT_TAG) == null) {
|
||||||
|
addOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
|
||||||
addFragment(views.fragmentContainer, WidgetFragment::class.java, widgetArgs, WIDGET_FRAGMENT_TAG)
|
addFragment(views.fragmentContainer, WidgetFragment::class.java, widgetArgs, WIDGET_FRAGMENT_TAG)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -148,6 +152,11 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
removeOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun enterPictureInPicture() {
|
private fun enterPictureInPicture() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
createElementCallPipParams()?.let {
|
createElementCallPipParams()?.let {
|
||||||
|
@ -172,8 +181,10 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var hangupBroadcastReceiver: BroadcastReceiver? = null
|
private var hangupBroadcastReceiver: BroadcastReceiver? = null
|
||||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) {
|
|
||||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
private val pictureInPictureModeChangedInfoConsumer = Consumer<PictureInPictureModeChangedInfo> {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return@Consumer
|
||||||
|
|
||||||
if (isInPictureInPictureMode) {
|
if (isInPictureInPictureMode) {
|
||||||
hangupBroadcastReceiver = object : BroadcastReceiver() {
|
hangupBroadcastReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
|
Loading…
Reference in a new issue