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 conferenceViewModel: ConferenceViewModel
|
||||||
private lateinit var statsViewModel: StatisticsListViewModel
|
private lateinit var statsViewModel: StatisticsListViewModel
|
||||||
|
|
||||||
private var foldingFeature: FoldingFeature? = null
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -307,13 +305,9 @@ class CallActivity : ProximitySensorActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLayoutChanges(foldingFeature: FoldingFeature?) {
|
override fun onLayoutChanges(foldingFeature: FoldingFeature?) {
|
||||||
this.foldingFeature = foldingFeature
|
foldingFeature ?: return
|
||||||
updateConstraintSetDependingOnFoldingState()
|
Log.i("[Call Activity] Folding feature state changed: ${foldingFeature.state}, orientation is ${foldingFeature.orientation}")
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateConstraintSetDependingOnFoldingState() {
|
controlsViewModel.foldingState.value = foldingFeature
|
||||||
val feature = foldingFeature ?: return
|
|
||||||
Log.i("[Call Activity] Folding feature state changed: $feature.state")
|
|
||||||
controlsViewModel.foldingState.value = feature.state
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,8 +200,8 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
|
||||||
|
|
||||||
controlsViewModel.foldingState.observe(
|
controlsViewModel.foldingState.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) { state ->
|
) { feature ->
|
||||||
updateHingeRelatedConstraints(state)
|
updateHingeRelatedConstraints(feature)
|
||||||
}
|
}
|
||||||
|
|
||||||
callsViewModel.callUpdateEvent.observe(
|
callsViewModel.callUpdateEvent.observe(
|
||||||
|
@ -327,14 +327,17 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
|
||||||
timer.start()
|
timer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateHingeRelatedConstraints(state: FoldingFeature.State) {
|
private fun updateHingeRelatedConstraints(feature: FoldingFeature) {
|
||||||
Log.i("[Conference Call] Updating constraint layout hinges: $state")
|
Log.i("[Conference Call] Updating constraint layout hinges: $feature")
|
||||||
val constraintLayout = binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
|
val constraintLayout = binding.root.findViewById<ConstraintLayout>(R.id.conference_constraint_layout)
|
||||||
?: return
|
?: return
|
||||||
val set = ConstraintSet()
|
val set = ConstraintSet()
|
||||||
set.clone(constraintLayout)
|
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_top, 0.5f)
|
||||||
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
||||||
controlsViewModel.folded.value = true
|
controlsViewModel.folded.value = true
|
||||||
|
|
|
@ -157,8 +157,8 @@ class SingleCallFragment : GenericFragment<VoipSingleCallFragmentBinding>() {
|
||||||
|
|
||||||
controlsViewModel.foldingState.observe(
|
controlsViewModel.foldingState.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) { state ->
|
) { feature ->
|
||||||
updateHingeRelatedConstraints(state)
|
updateHingeRelatedConstraints(feature)
|
||||||
}
|
}
|
||||||
|
|
||||||
callsViewModel.callUpdateEvent.observe(
|
callsViewModel.callUpdateEvent.observe(
|
||||||
|
@ -260,13 +260,17 @@ class SingleCallFragment : GenericFragment<VoipSingleCallFragmentBinding>() {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateHingeRelatedConstraints(state: FoldingFeature.State) {
|
private fun updateHingeRelatedConstraints(feature: FoldingFeature) {
|
||||||
Log.i("[Single Call] Updating constraint layout hinges: $state")
|
Log.i("[Single Call] Updating constraint layout hinges: $feature")
|
||||||
|
|
||||||
val constraintLayout = binding.constraintLayout
|
val constraintLayout = binding.constraintLayout
|
||||||
val set = ConstraintSet()
|
val set = ConstraintSet()
|
||||||
set.clone(constraintLayout)
|
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_top, 0.5f)
|
||||||
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
set.setGuidelinePercent(R.id.hinge_bottom, 0.5f)
|
||||||
controlsViewModel.folded.value = true
|
controlsViewModel.folded.value = true
|
||||||
|
|
|
@ -101,7 +101,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
MutableLiveData<Event<Boolean>>()
|
MutableLiveData<Event<Boolean>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
val foldingState = MutableLiveData<FoldingFeature.State>()
|
val foldingState = MutableLiveData<FoldingFeature>()
|
||||||
|
|
||||||
private val nonEarpieceOutputAudioDevice = MutableLiveData<Boolean>()
|
private val nonEarpieceOutputAudioDevice = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
@ -199,7 +199,6 @@ class ControlsViewModel : ViewModel() {
|
||||||
extraButtonsMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_call_extra_buttons_translate_y)
|
extraButtonsMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_call_extra_buttons_translate_y)
|
||||||
audioRoutesMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_audio_routes_menu_translate_y)
|
audioRoutesMenuTranslateY.value = AppUtils.getDimension(R.dimen.voip_audio_routes_menu_translate_y)
|
||||||
audioRoutesSelected.value = false
|
audioRoutesSelected.value = false
|
||||||
foldingState.value = FoldingFeature.State.FLAT
|
|
||||||
|
|
||||||
nonEarpieceOutputAudioDevice.value = coreContext.core.outputAudioDevice?.type != AudioDevice.Type.Earpiece
|
nonEarpieceOutputAudioDevice.value = coreContext.core.outputAudioDevice?.type != AudioDevice.Type.Earpiece
|
||||||
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
proximitySensorEnabled.value = shouldProximitySensorBeEnabled()
|
||||||
|
|
Loading…
Reference in a new issue