diff --git a/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java b/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java index bae372f..e0312a1 100644 --- a/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java @@ -36,11 +36,12 @@ import com.google.zxing.integration.android.IntentIntegrator; import java.util.LinkedList; import java.util.List; -import ch.dissem.apps.abit.listener.ActionBarListener; import ch.dissem.apps.abit.repository.AndroidAddressRepository; import ch.dissem.apps.abit.service.Singleton; +import ch.dissem.apps.abit.util.FabUtils; import ch.dissem.bitmessage.entity.BitmessageAddress; import io.github.kobakei.materialfabspeeddial.FabSpeedDial; +import io.github.kobakei.materialfabspeeddial.FabSpeedDialMenu; /** * Fragment that shows a list of all contacts, the ones we subscribed to first. @@ -119,8 +120,31 @@ public class AddressListFragment extends AbstractItemListFragment */ public class MainActivity extends AppCompatActivity - implements ListSelectionListener, ActionBarListener { + implements ListSelectionListener { public static final String EXTRA_SHOW_MESSAGE = "ch.dissem.abit.ShowMessage"; public static final String EXTRA_SHOW_LABEL = "ch.dissem.abit.ShowLabel"; public static final String EXTRA_REPLY_TO_MESSAGE = "ch.dissem.abit.ReplyToMessage"; @@ -120,13 +120,17 @@ public class MainActivity extends AppCompatActivity private Drawer drawer; private SwitchDrawerItem nodeSwitch; + private FabSpeedDial fab; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = new WeakReference<>(this); bmc = Singleton.getBitmessageContext(this); - setContentView(R.layout.activity_message_list); + setContentView(R.layout.activity_main); + fab = (FabSpeedDial) findViewById(R.id.fab); + fab.hide(); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -487,7 +491,6 @@ public class MainActivity extends AppCompatActivity } } - @Override public void updateUnread() { for (IDrawerItem item : drawer.getDrawerItems()) { if (item.getTag() instanceof Label) { @@ -573,7 +576,6 @@ public class MainActivity extends AppCompatActivity } } - @Override public void updateTitle(CharSequence title) { if (getSupportActionBar() != null) { getSupportActionBar().setTitle(title); @@ -584,6 +586,10 @@ public class MainActivity extends AppCompatActivity return selectedLabel; } + public FabSpeedDial getFloatingActionButton() { + return fab; + } + public static MainActivity getInstance() { if (instance == null) return null; return instance.get(); diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java index 2ed4a13..e671741 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Set; import java.util.regex.Matcher; -import ch.dissem.apps.abit.listener.ActionBarListener; import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.util.Assets; import ch.dissem.apps.abit.util.Drawables; @@ -142,8 +141,8 @@ public class MessageDetailFragment extends Fragment { } MessageRepository messageRepo = Singleton.getMessageRepository(inflater.getContext()); if (removed) { - if (getActivity() instanceof ActionBarListener) { - ((ActionBarListener) getActivity()).updateUnread(); + if (getActivity() instanceof MainActivity) { + ((MainActivity) getActivity()).updateUnread(); } messageRepo.save(item); } @@ -200,13 +199,13 @@ public class MessageDetailFragment extends Fragment { case R.id.mark_unread: item.addLabels(messageRepo.getLabels(Label.Type.UNREAD)); messageRepo.save(item); - if (getActivity() instanceof ActionBarListener) { - ((ActionBarListener) getActivity()).updateUnread(); + if (getActivity() instanceof MainActivity) { + ((MainActivity) getActivity()).updateUnread(); } return true; case R.id.archive: - if (item.isUnread() && getActivity() instanceof ActionBarListener) { - ((ActionBarListener) getActivity()).updateUnread(); + if (item.isUnread() && getActivity() instanceof MainActivity) { + ((MainActivity) getActivity()).updateUnread(); } item.getLabels().clear(); messageRepo.save(item); diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.java b/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.java index a9acf41..5663a92 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/MessageListFragment.java @@ -16,6 +16,7 @@ package ch.dissem.apps.abit; +import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; @@ -45,14 +46,15 @@ import java.util.List; import java.util.Stack; import ch.dissem.apps.abit.adapter.SwipeableMessageAdapter; -import ch.dissem.apps.abit.listener.ActionBarListener; import ch.dissem.apps.abit.listener.ListSelectionListener; import ch.dissem.apps.abit.repository.AndroidMessageRepository; import ch.dissem.apps.abit.service.Singleton; +import ch.dissem.apps.abit.util.FabUtils; import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.valueobject.Label; import io.github.kobakei.materialfabspeeddial.FabSpeedDial; +import io.github.kobakei.materialfabspeeddial.FabSpeedDialMenu; import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_BROADCAST; import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_IDENTITY; @@ -119,8 +121,8 @@ public class MessageListFragment extends Fragment implements ListHolder