Replaced fab speed dial with a different library - there is still some tweaking needed, but at least it works again

This commit is contained in:
Christian Basler 2017-07-24 18:01:40 +02:00
parent 593a390b40
commit faa6752b10
6 changed files with 30 additions and 28 deletions

View File

@ -71,7 +71,7 @@ dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.5.0@aar'
compile 'com.google.zxing:core:3.3.0'
compile 'io.github.yavski:fab-speed-dial:1.0.7'
compile 'com.github.kobakei:MaterialFabSpeedDial:1.1.4'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.4@aar') {
transitive = true

View File

@ -23,8 +23,8 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@ -40,9 +40,7 @@ import ch.dissem.apps.abit.listener.ActionBarListener;
import ch.dissem.apps.abit.repository.AndroidAddressRepository;
import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.entity.valueobject.Label;
import io.github.yavski.fabspeeddial.FabSpeedDial;
import io.github.yavski.fabspeeddial.SimpleMenuListenerAdapter;
import io.github.kobakei.materialfabspeeddial.FabSpeedDial;
/**
* Fragment that shows a list of all contacts, the ones we subscribed to first.
@ -133,21 +131,21 @@ public class AddressListFragment extends AbstractItemListFragment<Void, Bitmessa
View view = inflater.inflate(R.layout.fragment_address_list, container, false);
FabSpeedDial fabSpeedDial = (FabSpeedDial) view.findViewById(R.id.fab_add_contact);
fabSpeedDial.setMenuListener(new SimpleMenuListenerAdapter() {
fabSpeedDial.addOnMenuItemClickListener(new FabSpeedDial.OnMenuItemClickListener() {
@Override
public boolean onMenuItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
public void onMenuItemClick(FloatingActionButton floatingActionButton, @Nullable TextView textView, int itemId) {
switch (itemId) {
case R.id.action_read_qr_code:
IntentIntegrator.forSupportFragment(AddressListFragment.this)
.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES)
.initiateScan();
return true;
break;
case R.id.action_create_contact:
Intent intent = new Intent(getActivity(), CreateAddressActivity.class);
startActivity(intent);
return true;
break;
default:
return false;
break;
}
}
});

View File

@ -19,6 +19,8 @@ package ch.dissem.apps.abit;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
@ -29,6 +31,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
@ -49,8 +52,7 @@ import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.bitmessage.entity.BitmessageAddress;
import ch.dissem.bitmessage.entity.Plaintext;
import ch.dissem.bitmessage.entity.valueobject.Label;
import io.github.yavski.fabspeeddial.FabSpeedDial;
import io.github.yavski.fabspeeddial.SimpleMenuListenerAdapter;
import io.github.kobakei.materialfabspeeddial.FabSpeedDial;
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_BROADCAST;
import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY;
@ -168,31 +170,30 @@ public class MessageListFragment extends Fragment implements ListHolder<Label> {
// Show the dummy content as text in a TextView.
FabSpeedDial fab = (FabSpeedDial) rootView.findViewById(R.id
.fab_compose_message);
fab.setMenuListener(new SimpleMenuListenerAdapter() {
fab.addOnMenuItemClickListener(new FabSpeedDial.OnMenuItemClickListener() {
@Override
public boolean onMenuItemSelected(MenuItem menuItem) {
public void onMenuItemClick(FloatingActionButton floatingActionButton, @Nullable TextView textView, int itemId) {
BitmessageAddress identity = Singleton.getIdentity(getActivity());
if (identity == null) {
Toast.makeText(getActivity(), R.string.no_identity_warning,
Toast.LENGTH_LONG).show();
return false;
} else {
switch (menuItem.getItemId()) {
switch (itemId) {
case R.id.action_compose_message: {
Intent intent = new Intent(getActivity(), ComposeMessageActivity.class);
intent.putExtra(EXTRA_IDENTITY, identity);
startActivity(intent);
return true;
break;
}
case R.id.action_compose_broadcast: {
Intent intent = new Intent(getActivity(), ComposeMessageActivity.class);
intent.putExtra(EXTRA_IDENTITY, identity);
intent.putExtra(EXTRA_BROADCAST, true);
startActivity(intent);
return true;
break;
}
default:
return false;
break;
}
}
}

View File

@ -17,7 +17,7 @@
android:paddingBottom="88dp"
android:scrollbarStyle="outsideOverlay" />
<io.github.yavski.fabspeeddial.FabSpeedDial
<io.github.kobakei.materialfabspeeddial.FabSpeedDial
android:id="@+id/fab_add_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -26,7 +26,8 @@
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:elevation="8dp"
app:fabDrawable="@drawable/ic_action_add_contact"
app:fabGravity="bottom_end"
app:fabMenu="@menu/fab_address" />
app:fab_useTouchGuard="true"
app:fab_miniFabTextBackground="@color/colorPrimaryLight"
app:fab_fabDrawable="@drawable/ic_action_add_contact"
app:fab_menu="@menu/fab_address" />
</RelativeLayout>

View File

@ -19,7 +19,7 @@
android:scrollbars="vertical"
tools:listitem="@layout/message_row"/>
<io.github.yavski.fabspeeddial.FabSpeedDial
<io.github.kobakei.materialfabspeeddial.FabSpeedDial
android:id="@+id/fab_compose_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -28,7 +28,8 @@
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:elevation="8dp"
app:fabDrawable="@drawable/ic_action_compose_message"
app:fabGravity="bottom_end"
app:fabMenu="@menu/fab_message"/>
app:fab_useTouchGuard="true"
app:fab_miniFabTextBackground="@color/colorPrimaryLight"
app:fab_fabDrawable="@drawable/ic_action_compose_message"
app:fab_menu="@menu/fab_message"/>
</RelativeLayout>

View File

@ -24,5 +24,6 @@ allprojects {
jcenter()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "https://jitpack.io" }
}
}