mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
This introduces a floating action button (FAB) in the contact list.
The button hides itself when you scroll down the list of contacts and shows again when you scroll up. To properly color the button, the accent color has been defined. It uses the same color as the action bar (primary color). I leave it to a UX designer to adapt the color scheme. Please note that the design support library was used. It includes the app-compat library, so this has been removed from the `build.gradle` file. Closes #199
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package org.briarproject.android.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class HideFabOnScrollBehavior extends FloatingActionButton.Behavior {
|
||||
|
||||
public HideFabOnScrollBehavior(Context context, AttributeSet attrs) {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout,
|
||||
FloatingActionButton child, View directTargetChild, View target,
|
||||
int nestedScrollAxes) {
|
||||
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL ||
|
||||
super.onStartNestedScroll(coordinatorLayout, child,
|
||||
directTargetChild, target,
|
||||
nestedScrollAxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedScroll(CoordinatorLayout coordinatorLayout,
|
||||
FloatingActionButton child,
|
||||
View target, int dxConsumed, int dyConsumed, int dxUnconsumed,
|
||||
int dyUnconsumed) {
|
||||
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed,
|
||||
dyConsumed, dxUnconsumed,
|
||||
dyUnconsumed);
|
||||
|
||||
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
|
||||
child.hide();
|
||||
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
|
||||
child.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user