Skip to content
Snippets Groups Projects
Commit f864dba3 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Custom PiP: save and restore popup size

parent a0c846a4
No related branches found
No related tags found
1 merge request!1407Video player remote: multiple UI fixes and improvements
Pipeline #231067 passed with stage
in 21 minutes and 16 seconds
......@@ -165,6 +165,7 @@ const val PERMISSION_NEVER_ASK = "permission_never_ask"
const val WIDGETS_BACKGROUND_LAST_COLORS = "widgets_background_last_colors"
const val WIDGETS_FOREGROUND_LAST_COLORS = "widgets_foreground_last_colors"
const val CUSTOM_POPUP_HEIGHT = "custom_popup_height"
class DeviceInfo(context: Context) {
val pm = context.packageManager
......
......@@ -28,16 +28,21 @@ import android.content.Context
import android.graphics.PixelFormat
import android.graphics.Point
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.view.*
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.getSystemService
import androidx.core.view.GestureDetectorCompat
import org.videolan.libvlc.interfaces.IVLCVout
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.tools.CUSTOM_POPUP_HEIGHT
import org.videolan.tools.Settings
import org.videolan.tools.putSingle
import org.videolan.vlc.R
class PopupLayout : ConstraintLayout, ScaleGestureDetector.OnScaleGestureListener, View.OnTouchListener {
private lateinit var screenSize: DisplayMetrics
private var vlcVout: IVLCVout? = null
private var windowManager: WindowManager? = null
private var gestureDetector: GestureDetectorCompat? = null
......@@ -110,8 +115,16 @@ class PopupLayout : ConstraintLayout, ScaleGestureDetector.OnScaleGestureListene
private fun init(context: Context) {
windowManager = context.applicationContext.getSystemService()
screenSize = DisplayMetrics().also { windowManager!!.defaultDisplay.getMetrics(it) }
popupWidth = context.resources.getDimensionPixelSize(R.dimen.video_pip_width)
popupHeight = context.resources.getDimensionPixelSize(R.dimen.video_pip_height)
val ratio = popupWidth.toFloat() / popupHeight.toFloat()
val customPopupHeight = Settings.getInstance(context).getInt(CUSTOM_POPUP_HEIGHT, -1)
if (customPopupHeight != -1) {
popupHeight = customPopupHeight
popupWidth = (popupHeight.toFloat() * ratio).toInt()
}
val params = WindowManager.LayoutParams(
popupWidth,
popupHeight,
......@@ -182,6 +195,7 @@ class PopupLayout : ConstraintLayout, ScaleGestureDetector.OnScaleGestureListene
override fun onScaleEnd(detector: ScaleGestureDetector) {
setViewSize(popupWidth, popupHeight)
Settings.getInstance(context).putSingle(CUSTOM_POPUP_HEIGHT, popupHeight)
scaleFactor = 1.0
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment