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.journeyapps:zxing-android-embedded:3.5.0@aar'
compile 'com.google.zxing:core:3.3.0' 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.github.amlcurran.showcaseview:library:5.4.3'
compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.4@aar') { compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.4@aar') {
transitive = true transitive = true

View File

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

View File

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

View File

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

View File

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

View File

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