Skip to content
Snippets Groups Projects
Commit 44d189aa authored by Adrien Béraud's avatar Adrien Béraud
Browse files

HomeFragment: fix various glitches

Change-Id: Ia4bfc0ef3a9cbe4c8f9c0c49c43735b0b2b0b5c6
parent 155cbb83
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,8 @@ import android.view.animation.DecelerateInterpolator
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.widget.SearchView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
......@@ -265,11 +267,6 @@ class HomeFragment: BaseSupportFragment<HomePresenter, HomeView>(),
item.accountId,
item.uri
)
// Weird bug fixed by line below.
// Without it, the appBarLayoutBottom is not displayed correctly
// when collapsing the pendingList (no space between statusBar and
// appBarLayout).
//mBinding?.appBar?.fitsSystemWindows = true
}
override fun onItemLongClick(item: Conversation) {
......@@ -333,17 +330,19 @@ class HomeFragment: BaseSupportFragment<HomePresenter, HomeView>(),
ChangeBounds().setInterpolator(DecelerateInterpolator())
)
binding.appBarContainer.fitsSystemWindows = true
// Make the invitation card take all the height.
binding.appBar.updateLayoutParams {
height = ViewGroup.LayoutParams.MATCH_PARENT
}
binding.appBarContainer.updatePadding(bottom = 0)
val insetsCompat = ViewCompat.getRootWindowInsets(binding.invitationCard.invitationGroup) ?: return
val insets = insetsCompat.getInsets(WindowInsetsCompat.Type.systemBars())
binding.appBar.updatePadding(bottom = insets.bottom)
// Adapt the margins of the invitation card.
requireContext().resources.getDimensionPixelSize(R.dimen.bottom_sheet_radius).let {
(binding.invitationCard.invitationGroup.layoutParams as ViewGroup.MarginLayoutParams)
.setMargins(it, it, it, it)
.setMargins(it, it, it, 2*it)
}
// Enable to possibility to scroll the invitation pending list.
(binding.appBar.layoutParams as CoordinatorLayout.LayoutParams).behavior = null
......@@ -381,17 +380,7 @@ class HomeFragment: BaseSupportFragment<HomePresenter, HomeView>(),
Fade()
)
binding.appBarContainer.fitsSystemWindows = false
// Update AppBarLayoutBottom padding.
mDisposable.add(mAccountService.currentAccountSubject
.switchMap { account ->
account.getPendingSubject()
}
.firstOrError().subscribe { list ->
updateAppBarLayoutBottomPadding(hasInvites = list.isNotEmpty())
}
)
binding.appBar.updatePadding(bottom = 0)
// Make the invitation card wrap content (not take all space available anymore).
binding.appBar.updateLayoutParams {
......
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2004-2016 Savoir-faire Linux Inc.
This program is free software; you can redistribute it and/or modify
......@@ -21,7 +20,8 @@ along with this program; if not, write to the Free Software
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Smartlist to display swarms -->
<androidx.fragment.app.FragmentContainerView
......@@ -41,8 +41,8 @@ along with this program; if not, write to the Free Software
android:id="@+id/app_bar_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background_appbar_gradient"
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways|snap|exitUntilCollapsed">
<!-- Search bar to search for a swarm or for new contacts -->
......@@ -70,6 +70,7 @@ along with this program; if not, write to the Free Software
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:hint="@string/searchbar_hint"
app:layout_anchor="@id/search_bar"
tools:visibility="gone">
......@@ -160,22 +161,22 @@ along with this program; if not, write to the Free Software
<!-- Floating button to start a new conversation -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/new_swarm_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="8dp"
android:backgroundTint="@color/fab_background_color"
android:text="@string/start_conversation"
android:outlineProvider="none"
android:textColor="@color/fab_text_color"
app:icon="@drawable/baseline_chat_24"
app:iconTint="@color/fab_text_color"
app:layout_anchorGravity="bottom|center_horizontal"
app:pressedTranslationZ="12dp"
app:shapeAppearanceOverlay="@style/HomeFabButton" />
android:layout_height="match_parent">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/new_swarm_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="8dp"
android:backgroundTint="@color/fab_background_color"
android:outlineProvider="none"
android:text="@string/start_conversation"
android:textColor="@color/fab_text_color"
app:icon="@drawable/baseline_chat_24"
app:iconTint="@color/fab_text_color"
app:layout_anchorGravity="bottom|center_horizontal"
app:pressedTranslationZ="12dp"
app:shapeAppearanceOverlay="@style/HomeFabButton" />
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment