Fixed tabs fragment not hidden when going into settings or another non primary fragment

This commit is contained in:
Sylvain Berfini 2021-07-22 17:38:49 +02:00
parent 03e4415b5c
commit 52363c5466
2 changed files with 19 additions and 13 deletions

View file

@ -106,6 +106,9 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
sharedViewModel.layoutChangedEvent.value = Event(true) sharedViewModel.layoutChangedEvent.value = Event(true)
} }
private var tabsFragmentVisible1 = true
private var tabsFragmentVisible2 = true
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -179,11 +182,8 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
binding.rootCoordinatorLayout.viewTreeObserver.addOnGlobalLayoutListener { binding.rootCoordinatorLayout.viewTreeObserver.addOnGlobalLayoutListener {
val keyboardVisible = ViewCompat.getRootWindowInsets(binding.rootCoordinatorLayout)?.isVisible(WindowInsetsCompat.Type.ime()) == true val keyboardVisible = ViewCompat.getRootWindowInsets(binding.rootCoordinatorLayout)?.isVisible(WindowInsetsCompat.Type.ime()) == true
Log.d("[Tabs Fragment] Keyboard is ${if (keyboardVisible) "visible" else "invisible"}") Log.d("[Tabs Fragment] Keyboard is ${if (keyboardVisible) "visible" else "invisible"}")
if (keyboardVisible) { tabsFragmentVisible2 = !keyboardVisible
hideTabsFragment() updateTabsFragmentVisibility()
} else {
showTabsFragment()
}
} }
if (intent != null) handleIntentParams(intent) if (intent != null) handleIntentParams(intent)
@ -205,11 +205,16 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
statusFragment.visibility = View.VISIBLE statusFragment.visibility = View.VISIBLE
} }
when (destination.id) { tabsFragmentVisible1 = when (destination.id) {
R.id.masterCallLogsFragment, R.id.masterContactsFragment, R.id.dialerFragment, R.id.masterChatRoomsFragment -> R.id.masterCallLogsFragment, R.id.masterContactsFragment, R.id.dialerFragment, R.id.masterChatRoomsFragment ->
showTabsFragment() true
else -> hideTabsFragment() else -> false
} }
updateTabsFragmentVisibility()
}
private fun updateTabsFragmentVisibility() {
tabsFragment.visibility = if (tabsFragmentVisible1 && tabsFragmentVisible2) View.VISIBLE else View.GONE
} }
fun showTabsFragment() { fun showTabsFragment() {

View file

@ -117,7 +117,7 @@ class ShortcutsHelper(val context: Context) {
.setIntent(intent) .setIntent(intent)
.build().toShortcutInfo() .build().toShortcutInfo()
} catch (e: Exception) { } catch (e: Exception) {
Log.e("[Shortcuts Helper] ShortcutInfo.Builder exception: $e") Log.e("[Shortcuts Helper] createContactShortcut for contact [${contact.fullName}] exception: $e")
} }
return null return null
@ -151,11 +151,13 @@ class ShortcutsHelper(val context: Context) {
} }
private fun createChatRoomShortcut(context: Context, chatRoom: ChatRoom): ShortcutInfo? { private fun createChatRoomShortcut(context: Context, chatRoom: ChatRoom): ShortcutInfo? {
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val localAddress = chatRoom.localAddress.asStringUriOnly()
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
try { try {
val categories: ArraySet<String> = ArraySet() val categories: ArraySet<String> = ArraySet()
categories.add(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION) categories.add(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION)
val peerAddress = chatRoom.peerAddress.asStringUriOnly()
val localAddress = chatRoom.localAddress.asStringUriOnly()
val personsList = arrayListOf<Person>() val personsList = arrayListOf<Person>()
val subject: String val subject: String
@ -202,7 +204,6 @@ class ShortcutsHelper(val context: Context) {
intent.putExtra("RemoteSipUri", peerAddress) intent.putExtra("RemoteSipUri", peerAddress)
intent.putExtra("LocalSipUri", localAddress) intent.putExtra("LocalSipUri", localAddress)
val id = LinphoneUtils.getChatRoomId(localAddress, peerAddress)
return ShortcutInfoCompat.Builder(context, id) return ShortcutInfoCompat.Builder(context, id)
.setShortLabel(subject) .setShortLabel(subject)
.setIcon(icon) .setIcon(icon)
@ -213,7 +214,7 @@ class ShortcutsHelper(val context: Context) {
.setLocusId(LocusIdCompat(id)) .setLocusId(LocusIdCompat(id))
.build().toShortcutInfo() .build().toShortcutInfo()
} catch (e: Exception) { } catch (e: Exception) {
Log.e("[Shortcuts Helper] ShortcutInfo.Builder exception: $e") Log.e("[Shortcuts Helper] createChatRoomShortcut for id [$id] exception: $e")
} }
return null return null