Only modify UI when foldable device is half-opened if it is in tabletop mode, not in book posture
This commit is contained in:
parent
4ab54a50c1
commit
3c75ecdefa
4 changed files with 21 additions and 21 deletions
|
@ -51,8 +51,6 @@ class CallActivity : ProximitySensorActivity() {
|
|||
private lateinit var conferenceViewModel: ConferenceViewModel
|
||||
private lateinit var statsViewModel: StatisticsListViewModel
|
||||
|
||||
private var foldingFeature: FoldingFeature? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
@ -307,13 +305,9 @@ class CallActivity : ProximitySensorActivity() {
|
|||
}
|
||||
|
||||
override fun onLayoutChanges(foldingFeature: FoldingFeature?) {
|
||||
this.foldingFeature = foldingFeature
|
||||
updateConstraintSetDependingOnFoldingState()
|
||||
}
|
||||
foldingFeature ?: return
|
||||
Log.i("[Call Activity] Folding feature state changed: ${foldingFeature.state}, orientation is ${foldingFeature.orientation}")
|
||||
|
||||
private fun updateConstraintSetDependingOnFoldingState() {
|
||||
val feature = foldingFeature ?: return
|
||||
Log.i("[Call Activity] Folding feature state changed: $feature.state")
|
||||
controlsViewModel.foldingState.value = feature.state
|
||||
controlsViewModel.foldingState.value = foldingFeature
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,8 +200,8 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
|
|||
|
||||
controlsViewModel.foldingState.observe(
|
||||
viewLifecycleOwner
|
||||
) { state ->
|
||||
updateHingeRelatedConstraints(state)
|
||||
) { feature ->
|
||||
updateHingeRelatedConstraints(feature)
|
||||
}
|
||||
|
||||
callsViewModel.callUpdateEvent.observe(
|
||||
|
@ -327,14 +327,17 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
|
|||
timer.start()
|
||||
}
|
||||
|
||||
private fun updateHingeRelatedConstraints(state: FoldingFeature.State) {
|
||||
Log.i("[Conference Call] Updating constraint layout hinges: $state")
|
||||
private fun updateHingeRelatedConstraints(feature: FoldingFeature) {
|
||||
Log.i("[Conference Call] Updating constraint layout hinges: $feature")
|
||||
val constraintLayout = binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
|
||||
?: return
|
||||
val set = ConstraintSet()
|
||||
set.clone(constraintLayout)
|
||||
|
||||
if (state == FoldingFeature.State.HALF_OPENED) {
|
||||
// Only modify UI in table top mode
|
||||
if (feature.orientation == FoldingFeature.Orientation.HORIZONTAL &&
|
||||
feature.state == FoldingFeature.State.HALF_OPENED
|
||||
) {
|
||||
set.setGuidelinePercent(R.id.hinge_top, 0.5f)
|
||||
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
||||
controlsViewModel.folded.value = true
|
||||
|
|
|
@ -157,8 +157,8 @@ class SingleCallFragment : GenericFragment<VoipSingleCallFragmentBinding>() {
|
|||
|
||||
controlsViewModel.foldingState.observe(
|
||||
viewLifecycleOwner
|
||||
) { state ->
|
||||
updateHingeRelatedConstraints(state)
|
||||
) { feature ->
|
||||
updateHingeRelatedConstraints(feature)
|
||||
}
|
||||
|
||||
callsViewModel.callUpdateEvent.observe(
|
||||
|
@ -260,13 +260,17 @@ class SingleCallFragment : GenericFragment<VoipSingleCallFragmentBinding>() {
|
|||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun updateHingeRelatedConstraints(state: FoldingFeature.State) {
|
||||
Log.i("[Single Call] Updating constraint layout hinges: $state")
|
||||
private fun updateHingeRelatedConstraints(feature: FoldingFeature) {
|
||||
Log.i("[Single Call] Updating constraint layout hinges: $feature")
|
||||
|
||||
val constraintLayout = binding.constraintLayout
|
||||
val set = ConstraintSet()
|
||||
set.clone(constraintLayout)
|
||||
|
||||
if (state == FoldingFeature.State.HALF_OPENED) {
|
||||
// Only modify UI in table top mode
|
||||
if (feature.orientation == FoldingFeature.Orientation.HORIZONTAL &&
|
||||
feature.state == FoldingFeature.State.HALF_OPENED
|
||||
) {
|
||||
set.setGuidelinePercent(R.id.hinge_top, 0.5f)
|
||||
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
||||
controlsViewModel.folded.value = true
|
||||
|
|
|
@ -101,7 +101,7 @@ class ControlsViewModel : ViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val foldingState = MutableLiveData<FoldingFeature.State>()
|
||||
val foldingState = MutableLiveData<FoldingFeature>()
|
||||
|
||||
private val nonEarpieceOutputAudioDevice = MutableLiveData<Boolean>()
|
||||
|
||||
|
@ -199,7 +199,6 @@ class ControlsViewModel : ViewModel() {
|
|||
extraButtonsMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_call_extra_buttons_translate_y)
|
||||
audioRoutesMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_audio_routes_menu_translate_y)
|
||||
audioRoutesSelected.value = false
|
||||
foldingState.value = FoldingFeature.State.FLAT
|
||||
|
||||
nonEarpieceOutputAudioDevice.value = coreContext.core.outputAudioDevice?.type != AudioDevice.Type.Earpiece
|
||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||
|
|
Loading…
Reference in a new issue