@@ -627,11 +627,10 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
627
627
628
628
private fun setupWindowInsets () {
629
629
ViewCompat .setOnApplyWindowInsetsListener(binding.root) { _, windowInsets ->
630
- val systemBarsInsets =
631
- windowInsets.getInsets(WindowInsetsCompat . Type .navigationBars() or WindowInsetsCompat .Type .ime())
630
+ val navInsets = windowInsets.getInsets( WindowInsetsCompat . Type .navigationBars())
631
+ val imeInsets = windowInsets.getInsets(WindowInsetsCompat .Type .ime())
632
632
633
- val imeHeight = windowInsets.getInsets(WindowInsetsCompat .Type .ime()).bottom
634
- val keyboardVisible = imeHeight > 0
633
+ val keyboardVisible = imeInsets.bottom > 0
635
634
636
635
if (keyboardVisible != isKeyboardVisible) {
637
636
isKeyboardVisible = keyboardVisible
@@ -645,10 +644,10 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
645
644
}
646
645
647
646
binding.bottomSpacer.updateLayoutParams<LayoutParams > {
648
- height = systemBarsInsets .bottom
647
+ height = if (keyboardVisible) imeInsets.bottom else navInsets .bottom
649
648
}
650
649
651
- windowInsets.inset(systemBarsInsets)
650
+ windowInsets
652
651
}
653
652
}
654
653
@@ -795,7 +794,8 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
795
794
} else {
796
795
// If there are new data updated, we'll try to stay scrolled at the bottom (if we were at the bottom).
797
796
// scrolled to bottom has a leniency of 50dp, so if we are within the 50dp but not fully at the bottom, scroll down
798
- if (binding.conversationRecyclerView.isNearBottom && ! binding.conversationRecyclerView.isFullyScrolled) {
797
+ if (binding.conversationRecyclerView.isNearBottom &&
798
+ ! binding.conversationRecyclerView.isFullyScrolled) {
799
799
binding.conversationRecyclerView.handleScrollToBottom()
800
800
}
801
801
}
@@ -817,7 +817,6 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
817
817
818
818
// called from onCreate
819
819
private fun setUpRecyclerView () {
820
- binding.conversationRecyclerView.applyImeBottomPadding()
821
820
binding.conversationRecyclerView.adapter = adapter
822
821
val layoutManager = LinearLayoutManager (this , LinearLayoutManager .VERTICAL , false )
823
822
binding.conversationRecyclerView.layoutManager = layoutManager
@@ -1998,6 +1997,9 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
1998
1997
if (sentMessageInfo != null ) {
1999
1998
messageToScrollAuthor.set(sentMessageInfo.first)
2000
1999
messageToScrollTimestamp.set(sentMessageInfo.second)
2000
+ binding.conversationRecyclerView.postDelayed({
2001
+ binding.conversationRecyclerView.handleScrollToBottom()
2002
+ }, 500L )
2001
2003
}
2002
2004
}
2003
2005
@@ -2115,7 +2117,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
2115
2117
if (isShowingAttachmentOptions) { toggleAttachmentOptions() }
2116
2118
2117
2119
// Keep it fixed on the bottom right away
2118
- binding.conversationRecyclerView.handleScrollToBottom()
2120
+ binding.conversationRecyclerView.handleScrollToBottom(true )
2119
2121
2120
2122
// do the heavy work in the bg
2121
2123
lifecycleScope.launch(Dispatchers .Default ) {
@@ -2680,7 +2682,6 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
2680
2682
searchViewModel.onSearchOpened()
2681
2683
binding.searchBottomBar.visibility = View .VISIBLE
2682
2684
binding.searchBottomBar.setData(0 , 0 , searchViewModel.searchQuery.value)
2683
- binding.inputBar.visibility = View .GONE
2684
2685
binding.root.requestApplyInsets()
2685
2686
2686
2687
}
@@ -2689,7 +2690,6 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
2689
2690
viewModel.onSearchClosed()
2690
2691
searchViewModel.onSearchClosed()
2691
2692
binding.searchBottomBar.visibility = View .GONE
2692
- binding.inputBar.visibility = View .VISIBLE
2693
2693
binding.root.requestApplyInsets()
2694
2694
adapter.onSearchQueryUpdated(null )
2695
2695
invalidateOptionsMenu()
@@ -2720,9 +2720,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
2720
2720
binding.conversationRecyclerView.scrollToPosition(position)
2721
2721
2722
2722
if (highlight) {
2723
- runOnUiThread {
2724
- highlightViewAtPosition(position)
2725
- }
2723
+ runOnUiThread { highlightViewAtPosition(position) }
2726
2724
}
2727
2725
} else {
2728
2726
onMessageNotFound?.run ()
0 commit comments