mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Allow specification of whether we utilize windowTypes to lay out inset guidelines.
This commit is contained in:
committed by
Cody Henthorne
parent
b46d891183
commit
bd03f21cdf
@@ -66,7 +66,11 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
|
||||
private var previousKeyboardHeight: Int = 0
|
||||
private var applyRootInsets: Boolean = false
|
||||
|
||||
private var insets: WindowInsetsCompat? = null
|
||||
private var windowTypes: Int = InsetAwareConstraintLayout.windowTypes
|
||||
|
||||
private val windowInsetsListener = androidx.core.view.OnApplyWindowInsetsListener { _, insets ->
|
||||
this.insets = insets
|
||||
applyInsets(windowInsets = insets.getInsets(windowTypes), keyboardInsets = insets.getInsets(keyboardType))
|
||||
insets
|
||||
}
|
||||
@@ -100,6 +104,23 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
|
||||
|
||||
private fun insetTarget(): View = if (applyRootInsets) rootView else this
|
||||
|
||||
/**
|
||||
* Specifies whether or not window insets should be accounted for when applying
|
||||
* insets. This is useful when choosing whether to display the content in this
|
||||
* constraint layout as a full-window view or as a framed view.
|
||||
*/
|
||||
fun setUseWindowTypes(useWindowTypes: Boolean) {
|
||||
windowTypes = if (useWindowTypes) {
|
||||
InsetAwareConstraintLayout.windowTypes
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
if (insets != null) {
|
||||
applyInsets(insets!!.getInsets(windowTypes), insets!!.getInsets(keyboardType))
|
||||
}
|
||||
}
|
||||
|
||||
fun addKeyboardStateListener(listener: KeyboardStateListener) {
|
||||
keyboardStateListeners += listener
|
||||
}
|
||||
|
||||
@@ -590,6 +590,8 @@ class ConversationFragment :
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.toolbar.isBackInvokedCallbackEnabled = false
|
||||
|
||||
binding.root.setUseWindowTypes(resources.getWindowSizeClass().isCompact())
|
||||
|
||||
disposables.bindTo(viewLifecycleOwner)
|
||||
|
||||
if (requireActivity() is ConversationActivity) {
|
||||
|
||||
Reference in New Issue
Block a user