mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Make PIP react to camera orientation changes in the other participant's device (#6951)
* Make PIP react to camera orientation changes in the other participant's device Adds a `controls.onPipMediaOrientationUpdate` callback for the WebView that will trigger a new `pipParamsBuilder.setAspectRatioFromOrientation(orientation)` method * Fix warning about `PictureInPictureParams.Builder.setAspectRatio` only being available on API 26+
This commit is contained in:
committed by
GitHub
parent
2b3aeee1c6
commit
614619e306
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.androidutils.media
|
||||
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.util.Rational
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
/**
|
||||
* Set the aspect ratio of the Picture-in-Picture mode based on the current orientation of the other user's device.
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun PictureInPictureParams.Builder.setAspectRatioFromOrientation(orientation: Int): PictureInPictureParams.Builder {
|
||||
val aspectRatio = if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// If landscape orientation, invert the aspect ratio
|
||||
Rational(5, 3)
|
||||
} else {
|
||||
// In any other case, assume portrait orientation
|
||||
Rational(3, 5)
|
||||
}
|
||||
return setAspectRatio(aspectRatio)
|
||||
}
|
||||
Reference in New Issue
Block a user