mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Removed the Fab and moved the icon into the toolbar
This commit is contained in:
@@ -1,27 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<org.briarproject.android.util.BriarRecyclerView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/coordinatorLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<org.briarproject.android.util.BriarRecyclerView
|
|
||||||
android:id="@+id/contactList"
|
android:id="@+id/contactList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/addContactFAB"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="@dimen/margin_activity_horizontal"
|
|
||||||
android:src="@drawable/ic_add_white"
|
|
||||||
app:fabSize="normal"
|
|
||||||
app:elevation="4dp"
|
|
||||||
app:layout_anchor="@id/contactList"
|
|
||||||
app:layout_anchorGravity="bottom|right|end"
|
|
||||||
app:layout_behavior="org.briarproject.android.util.HideFabOnScrollBehavior"/>
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
||||||
|
|||||||
12
briar-android/res/menu/contact_list_actions.xml
Normal file
12
briar-android/res/menu/contact_list_actions.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_add_contact"
|
||||||
|
android:icon="@drawable/ic_add_white"
|
||||||
|
android:title="@string/add_contact_title"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
|
</menu>
|
||||||
@@ -3,13 +3,15 @@ package org.briarproject.android.contact;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@@ -108,6 +110,9 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
View contentView =
|
View contentView =
|
||||||
inflater.inflate(R.layout.fragment_contact_list, container,
|
inflater.inflate(R.layout.fragment_contact_list, container,
|
||||||
false);
|
false);
|
||||||
@@ -148,23 +153,29 @@ public class ContactListFragment extends BaseFragment implements EventListener {
|
|||||||
list.setEmptyText(getString(R.string.no_contacts));
|
list.setEmptyText(getString(R.string.no_contacts));
|
||||||
list.periodicallyUpdateContent();
|
list.periodicallyUpdateContent();
|
||||||
|
|
||||||
// Show a floating action button
|
|
||||||
FloatingActionButton fab =
|
|
||||||
(FloatingActionButton) contentView.findViewById(
|
|
||||||
R.id.addContactFAB);
|
|
||||||
|
|
||||||
// handle FAB click
|
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(new Intent(getContext(),
|
|
||||||
KeyAgreementActivity.class));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return contentView;
|
return contentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.contact_list_actions, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
|
// Handle presses on the action bar items
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_add_contact:
|
||||||
|
Intent intent =
|
||||||
|
new Intent(getContext(), KeyAgreementActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
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