Added back full screen mode for call activity

This commit is contained in:
Sylvain Berfini 2021-01-19 17:17:46 +01:00
parent b42b1f5910
commit a57d7d4578
7 changed files with 72 additions and 3 deletions

View file

@ -20,11 +20,14 @@
package org.linphone.activities.call package org.linphone.activities.call
import android.content.res.Configuration import android.content.res.Configuration
import android.content.res.Resources
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import kotlinx.coroutines.*
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R import org.linphone.R
@ -83,7 +86,8 @@ class CallActivity : ProximitySensorActivity() {
previewY = v.y - event.rawY previewY = v.y - event.rawY
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
v.animate().x(event.rawX + previewX).y(event.rawY + previewY).setDuration(0).start() v.animate().x(event.rawX + previewX).y(event.rawY + previewY).setDuration(0)
.start()
} }
else -> { else -> {
v.performClick() v.performClick()
@ -109,6 +113,20 @@ class CallActivity : ProximitySensorActivity() {
} else { } else {
coreContext.removeCallOverlay() coreContext.removeCallOverlay()
} }
if (corePreferences.fullScreenCallUI) {
hideSystemUI()
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
GlobalScope.launch {
delay(2000)
withContext(Dispatchers.Main) {
hideSystemUI()
}
}
}
}
}
} }
override fun onPause() { override fun onPause() {
@ -142,4 +160,21 @@ class CallActivity : ProximitySensorActivity() {
viewModel.isVideoPreviewResizedForPip.value = isInPictureInPictureMode viewModel.isVideoPreviewResizedForPip.value = isInPictureInPictureMode
} }
} }
override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
if (corePreferences.fullScreenCallUI) {
theme.applyStyle(R.style.FullScreenTheme, true)
}
return theme
}
private fun hideSystemUI() {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_IMMERSIVE or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
} }

View file

@ -27,6 +27,8 @@ import android.content.Intent
import android.content.pm.PackageManager.PERMISSION_GRANTED import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
import android.util.DisplayMetrics
import android.view.Display
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.google.android.flexbox.FlexboxLayout import com.google.android.flexbox.FlexboxLayout
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
@ -173,7 +175,11 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
val screenWidth = requireActivity().windowManager.defaultDisplay.width.toFloat()
val metrics = DisplayMetrics()
val display: Display = requireActivity().getWindowManager().getDefaultDisplay()
display.getRealMetrics(metrics)
val screenWidth = metrics.widthPixels.toFloat()
numpadAnimator = ValueAnimator.ofFloat(screenWidth, 0f).apply { numpadAnimator = ValueAnimator.ofFloat(screenWidth, 0f).apply {
addUpdateListener { addUpdateListener {
val value = it.animatedValue as Float val value = it.animatedValue as Float

View file

@ -59,6 +59,13 @@ class CallSettingsViewModel : GenericSettingsViewModel() {
} }
val encryptionMandatory = MutableLiveData<Boolean>() val encryptionMandatory = MutableLiveData<Boolean>()
val fullScreenListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) {
prefs.fullScreenCallUI = newValue
}
}
val fullScreen = MutableLiveData<Boolean>()
val overlayListener = object : SettingListenerStub() { val overlayListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) { override fun onBoolValueChanged(newValue: Boolean) {
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) { if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
@ -146,6 +153,7 @@ class CallSettingsViewModel : GenericSettingsViewModel() {
initEncryptionList() initEncryptionList()
encryptionMandatory.value = core.isMediaEncryptionMandatory encryptionMandatory.value = core.isMediaEncryptionMandatory
fullScreen.value = prefs.fullScreenCallUI
overlay.value = prefs.showCallOverlay overlay.value = prefs.showCallOverlay
sipInfoDtmf.value = core.useInfoForDtmf sipInfoDtmf.value = core.useInfoForDtmf
rfc2833Dtmf.value = core.useRfc2833ForDtmf rfc2833Dtmf.value = core.useRfc2833ForDtmf

View file

@ -206,6 +206,12 @@ class CorePreferences constructor(private val context: Context) {
config.setBool("app", "call_right_away", value) config.setBool("app", "call_right_away", value)
} }
var fullScreenCallUI: Boolean
get() = config.getBool("app", "full_screen_call", true)
set(value) {
config.setBool("app", "full_screen_call", value)
}
/* Assistant */ /* Assistant */
var firstStart: Boolean var firstStart: Boolean

View file

@ -95,6 +95,12 @@
linphone:checked="@={viewModel.encryptionMandatory}" linphone:checked="@={viewModel.encryptionMandatory}"
linphone:enabled="@{viewModel.encryptionIndex != 0}" linphone:enabled="@{viewModel.encryptionIndex != 0}"
android:visibility="@{viewModel.encryptionIndex != 0 ? View.VISIBLE : View.GONE}"/> android:visibility="@{viewModel.encryptionIndex != 0 ? View.VISIBLE : View.GONE}"/>
<include
layout="@layout/settings_widget_switch"
linphone:title="@{@string/call_settings_full_screen_title}"
linphone:subtitle="@{@string/call_settings_full_screen_summary}"
linphone:listener="@{viewModel.fullScreenListener}"
linphone:checked="@={viewModel.fullScreen}"/>
<include <include
layout="@layout/settings_widget_switch" layout="@layout/settings_widget_switch"

View file

@ -381,6 +381,8 @@
<string name="call_settings_media_encryption_dtls">DTLS</string> <string name="call_settings_media_encryption_dtls">DTLS</string>
<string name="call_settings_encryption_mandatory_title">Media encryption mandatory</string> <string name="call_settings_encryption_mandatory_title">Media encryption mandatory</string>
<string name="call_settings_encryption_mandatory_summary"></string> <string name="call_settings_encryption_mandatory_summary"></string>
<string name="call_settings_full_screen_title">Full screen app while in call</string>
<string name="call_settings_full_screen_summary">Hides status and navigation bars</string>
<string name="call_settings_overlay_title">Overlay call notification</string> <string name="call_settings_overlay_title">Overlay call notification</string>
<string name="call_settings_overlay_summary">You will be asked to grant overlay permission</string> <string name="call_settings_overlay_summary">You will be asked to grant overlay permission</string>
<string name="call_settings_sipinfo_dtmf_title">Send out-band DTMFs (SIP INFO)</string> <string name="call_settings_sipinfo_dtmf_title">Send out-band DTMFs (SIP INFO)</string>

View file

@ -46,10 +46,16 @@
<item name="button_background_drawable">@drawable/button_background_light</item> <item name="button_background_drawable">@drawable/button_background_light</item>
</style> </style>
<style name="LauncherTheme" parent="AppTheme"> <style name="LauncherTheme" parent="@style/AppTheme">
<item name="android:windowBackground">@drawable/launch_screen</item> <item name="android:windowBackground">@drawable/launch_screen</item>
</style> </style>
<style name="FullScreenTheme" parent="@style/AppTheme">
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<!-- Numpad --> <!-- Numpad -->
<style name="numpad_digit" parent="@android:style/TextAppearance.Medium"> <style name="numpad_digit" parent="@android:style/TextAppearance.Medium">