diff --git a/app/build.gradle b/app/build.gradle index 5cee257..c87655e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,11 +38,12 @@ android { //ext.jabitVersion = '2.0.4' ext.jabitVersion = 'feature-extended-encoding-SNAPSHOT' +ext.supportVersion = '25.2.0' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.3.0' - compile 'com.android.support:support-v4:25.3.0' - compile 'com.android.support:design:25.3.0' + compile "com.android.support:appcompat-v7:$supportVersion" + compile "com.android.support:support-v4:$supportVersion" + compile "com.android.support:design:$supportVersion" compile "ch.dissem.jabit:jabit-core:$jabitVersion" compile "ch.dissem.jabit:jabit-networking:$jabitVersion" @@ -59,7 +60,8 @@ dependencies { compile('com.mikepenz:aboutlibraries:5.9.4@aar') { transitive = true } - compile 'com.mikepenz:iconics:1.6.2@aar' + compile "com.mikepenz:iconics-core:2.8.2@aar" + compile 'com.mikepenz:google-material-typeface:3.0.1.0.original@aar' compile 'com.mikepenz:community-material-typeface:1.8.36.1@aar' compile 'com.journeyapps:zxing-android-embedded:3.3.0@aar' @@ -71,6 +73,7 @@ dependencies { } compile 'com.github.angads25:filepicker:1.1.0' compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:2.7.19' diff --git a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java index fc45f75..9a2d9b0 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.java +++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.java @@ -48,14 +48,10 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import com.mikepenz.materialdrawer.model.interfaces.IProfile; import com.mikepenz.materialdrawer.model.interfaces.Nameable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.Serializable; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import ch.dissem.apps.abit.dialog.AddIdentityDialogFragment; import ch.dissem.apps.abit.dialog.FullNodeDialogActivity; @@ -65,6 +61,7 @@ import ch.dissem.apps.abit.repository.AndroidMessageRepository; import ch.dissem.apps.abit.service.BitmessageService; import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.synchronization.SyncAdapter; +import ch.dissem.apps.abit.util.Labels; import ch.dissem.apps.abit.util.Preferences; import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.entity.BitmessageAddress; @@ -100,7 +97,6 @@ public class MainActivity extends AppCompatActivity public static final String EXTRA_REPLY_TO_MESSAGE = "ch.dissem.abit.ReplyToMessage"; public static final String ACTION_SHOW_INBOX = "ch.dissem.abit.ShowInbox"; - private static final Logger LOG = LoggerFactory.getLogger(MainActivity.class); private static final int ADD_IDENTITY = 1; private static final int MANAGE_IDENTITY = 2; @@ -437,37 +433,9 @@ public class MainActivity extends AppCompatActivity public void addLabelEntry(Label label) { PrimaryDrawerItem item = new PrimaryDrawerItem() .withName(label.toString()) - .withTag(label); - if (label.getType() == null) { - item.withIcon(CommunityMaterial.Icon.cmd_label) - .withIconColor(label.getColor()); - } else { - switch (label.getType()) { - case INBOX: - item.withIcon(GoogleMaterial.Icon.gmd_inbox); - break; - case DRAFT: - item.withIcon(CommunityMaterial.Icon.cmd_file); - break; - case OUTBOX: - item.withIcon(CommunityMaterial.Icon.cmd_inbox_arrow_up); - break; - case SENT: - item.withIcon(CommunityMaterial.Icon.cmd_send); - break; - case BROADCAST: - item.withIcon(CommunityMaterial.Icon.cmd_rss); - break; - case UNREAD: - item.withIcon(GoogleMaterial.Icon.gmd_markunread_mailbox); - break; - case TRASH: - item.withIcon(GoogleMaterial.Icon.gmd_delete); - break; - default: - item.withIcon(CommunityMaterial.Icon.cmd_label); - } - } + .withTag(label) + .withIcon(Labels.getIcon(label)) + .withIconColor(Labels.getColor(label)); drawer.addItemAtPosition(item, drawer.getDrawerItems().size() - 3); } 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 5dced97..857a195 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java @@ -16,8 +16,11 @@ package ch.dissem.apps.abit; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; import android.text.util.Linkify; import android.view.LayoutInflater; import android.view.Menu; @@ -29,14 +32,19 @@ import android.widget.ImageView; import android.widget.TextView; import com.mikepenz.google_material_typeface_library.GoogleMaterial; +import com.mikepenz.iconics.view.IconicsImageView; +import java.util.ArrayList; import java.util.Iterator; +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; +import ch.dissem.apps.abit.util.Labels; import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.valueobject.Label; @@ -106,6 +114,11 @@ public class MessageDetailFragment extends Fragment { } else if (item.getType() == Plaintext.Type.BROADCAST) { ((TextView) rootView.findViewById(R.id.recipient)).setText(R.string.broadcast); } + RecyclerView labelView = (RecyclerView) rootView.findViewById(R.id.labels); + LabelAdapter labelAdapter = new LabelAdapter(getActivity(), item.getLabels()); + labelView.setAdapter(labelAdapter); + labelView.setLayoutManager(new GridLayoutManager(getActivity(), 2)); + TextView messageBody = (TextView) rootView.findViewById(R.id.text); messageBody.setText(item.getText()); @@ -197,4 +210,65 @@ public class MessageDetailFragment extends Fragment { } return false; } + + private static class LabelAdapter extends + RecyclerView.Adapter { + + private final List