mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Merge branch '1582-pending-contacts-snackbar' into 'master'
Prevent pending contacts snackbar from covering contact list See merge request briar/briar!1152
This commit is contained in:
@@ -2,10 +2,14 @@ package org.briarproject.briar.android.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.CoordinatorLayout.LayoutParams;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@NotNullByDefault
|
||||
public class BriarRecyclerViewBehavior
|
||||
extends CoordinatorLayout.Behavior<BriarRecyclerView> {
|
||||
|
||||
@@ -15,30 +19,27 @@ public class BriarRecyclerViewBehavior
|
||||
|
||||
@Override
|
||||
public boolean onDependentViewChanged(CoordinatorLayout parent,
|
||||
BriarRecyclerView child, View dependency) {
|
||||
|
||||
// FIXME the below code works, but does not reset margin when snackbar is dismissed
|
||||
/*
|
||||
int margin = 0;
|
||||
if (dependency.isShown()) margin = dependency.getHeight();
|
||||
|
||||
// set snackbar height as bottom margin if it is shown
|
||||
CoordinatorLayout.LayoutParams params =
|
||||
(CoordinatorLayout.LayoutParams) child.getLayoutParams();
|
||||
params.setMargins(0, 0, 0, margin);
|
||||
child.setLayoutParams(params);
|
||||
|
||||
child.scrollToPosition(0);
|
||||
*/
|
||||
BriarRecyclerView child, View snackbar) {
|
||||
setMargin(child, snackbar.getHeight());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDependentViewRemoved(CoordinatorLayout parent,
|
||||
BriarRecyclerView child, View snackbar) {
|
||||
setMargin(child, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean layoutDependsOn(CoordinatorLayout parent,
|
||||
BriarRecyclerView child, View dependency) {
|
||||
// we only want to trigger the change
|
||||
// only when the changes is from a snackbar
|
||||
return dependency instanceof Snackbar.SnackbarLayout;
|
||||
}
|
||||
|
||||
private void setMargin(View child, int margin) {
|
||||
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
||||
params.setMargins(0, 0, 0, margin);
|
||||
child.setLayoutParams(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="org.briarproject.briar.android.view.BriarRecyclerViewBehavior"
|
||||
app:scrollToEnd="false"/>
|
||||
|
||||
<io.github.kobakei.materialfabspeeddial.FabSpeedDial
|
||||
@@ -19,6 +20,8 @@
|
||||
app:fab_fabRippleColor="@android:color/transparent"
|
||||
app:fab_menu="@menu/contact_list_actions"
|
||||
app:fab_miniFabTextBackground="@color/briar_accent"
|
||||
app:fab_miniFabTextColor="@android:color/white"/>
|
||||
app:fab_miniFabTextColor="@android:color/white"
|
||||
app:layout_anchorGravity="bottom|right|end"
|
||||
app:layout_behavior="io.github.kobakei.materialfabspeeddial.FabSpeedDial$Behavior"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
Reference in New Issue
Block a user