mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Restore custom layout behaviour for handling snackbar.
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
package org.briarproject.briar.android.view;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.design.widget.CoordinatorLayout.Behavior;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
|
||||||
public class DefaultBehavior<V extends View> extends Behavior<V> {
|
|
||||||
|
|
||||||
public DefaultBehavior(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.briarproject.briar.android.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
|
import android.support.design.widget.CoordinatorLayout.Behavior;
|
||||||
|
import android.support.design.widget.CoordinatorLayout.LayoutParams;
|
||||||
|
import android.support.design.widget.Snackbar.SnackbarLayout;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This behavior makes room for a snackbar at the bottom of the screen. The
|
||||||
|
* proper solution is to use layout_dodgeInsetEdges="bottom", but when used on
|
||||||
|
* a scrollable view that results in the view being pushed under the app bar
|
||||||
|
* (see https://issuetracker.google.com/issues/116541304).
|
||||||
|
*/
|
||||||
|
@NotNullByDefault
|
||||||
|
public class SnackbarAwareBehavior<V extends View> extends Behavior<V> {
|
||||||
|
|
||||||
|
public SnackbarAwareBehavior(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDependentViewChanged(CoordinatorLayout parent,
|
||||||
|
V child, View snackbar) {
|
||||||
|
setMargin(child, snackbar.getHeight());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDependentViewRemoved(CoordinatorLayout parent,
|
||||||
|
V child, View snackbar) {
|
||||||
|
setMargin(child, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean layoutDependsOn(CoordinatorLayout parent,
|
||||||
|
V child, View dependency) {
|
||||||
|
return dependency instanceof SnackbarLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMargin(V child, int margin) {
|
||||||
|
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
||||||
|
params.setMargins(0, 0, 0, margin);
|
||||||
|
child.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_dodgeInsetEdges="bottom"
|
app:layout_behavior="org.briarproject.briar.android.view.SnackbarAwareBehavior"
|
||||||
app:scrollToEnd="false"/>
|
app:scrollToEnd="false"/>
|
||||||
|
|
||||||
<io.github.kobakei.materialfabspeeddial.FabSpeedDial
|
<io.github.kobakei.materialfabspeeddial.FabSpeedDial
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
app:fab_miniFabTextBackground="@color/briar_accent"
|
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_anchorGravity="bottom|right|end"
|
||||||
app:layout_behavior="org.briarproject.briar.android.view.DefaultBehavior"
|
app:layout_behavior="org.briarproject.briar.android.view.SnackbarAwareBehavior"/>
|
||||||
app:layout_dodgeInsetEdges="bottom"/>
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user