...
  View open merge request
Commits (2)
......@@ -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);
}
}
package org.briarproject.briar.android.view;
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.util.AttributeSet;
import android.view.View;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.util.logging.Logger;
import io.github.kobakei.materialfabspeeddial.FabSpeedDial;
import static java.util.logging.Level.WARNING;
import static java.util.logging.Logger.getLogger;
@NotNullByDefault
public class FabSpeedDialBehavior
extends CoordinatorLayout.Behavior<FabSpeedDial> {
private static final Logger LOG =
getLogger(FabSpeedDialBehavior.class.getName());
public FabSpeedDialBehavior() {
super();
}
public FabSpeedDialBehavior(Context context, AttributeSet attrs) {
super();
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, FabSpeedDial child,
View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent,
FabSpeedDial child, View dependency) {
float diff = dependency.getTranslationY() - dependency.getHeight();
if (LOG.isLoggable(WARNING)) LOG.warning("translationY: " + diff);
child.setTranslationY(diff);
return false;
}
}
\ No newline at end of file
......@@ -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="org.briarproject.briar.android.view.FabSpeedDialBehavior"/>
</android.support.design.widget.CoordinatorLayout>