From 8004865e01684dab5795a12560882bc7a05263cd Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Mon, 12 Mar 2018 21:18:10 +0100 Subject: [PATCH] Nicer labels --- .../java/ch/dissem/apps/abit/MainActivity.kt | 8 +-- .../dissem/apps/abit/MessageDetailFragment.kt | 35 +---------- .../dissem/apps/abit/adapter/LabelAdapter.kt | 61 +++++++++++++++++++ .../java/ch/dissem/apps/abit/util/Labels.kt | 41 +++++++------ app/src/main/res/drawable/bg_label.xml | 6 ++ app/src/main/res/layout/item_label.xml | 21 ++++--- app/src/main/res/layout/subscription_row.xml | 4 +- 7 files changed, 107 insertions(+), 69 deletions(-) create mode 100644 app/src/main/java/ch/dissem/apps/abit/adapter/LabelAdapter.kt create mode 100644 app/src/main/res/drawable/bg_label.xml diff --git a/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt b/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt index 435d954..7277e88 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt +++ b/app/src/main/java/ch/dissem/apps/abit/MainActivity.kt @@ -32,9 +32,7 @@ import ch.dissem.apps.abit.repository.AndroidLabelRepository.Companion.LABEL_ARC import ch.dissem.apps.abit.service.Singleton import ch.dissem.apps.abit.service.Singleton.currentLabel import ch.dissem.apps.abit.synchronization.SyncAdapter -import ch.dissem.apps.abit.util.Labels -import ch.dissem.apps.abit.util.NetworkUtils -import ch.dissem.apps.abit.util.Preferences +import ch.dissem.apps.abit.util.* import ch.dissem.bitmessage.BitmessageContext import ch.dissem.bitmessage.entity.BitmessageAddress import ch.dissem.bitmessage.entity.Plaintext @@ -404,8 +402,8 @@ class MainActivity : AppCompatActivity(), ListSelectionListener { .withIdentifier(label.id as Long) .withName(label.toString()) .withTag(label) - .withIcon(Labels.getIcon(label)) - .withIconColor(Labels.getColor(label)) + .withIcon(label.getIcon()) + .withIconColor(label.getColor(0xFF000000.toInt())) drawer.addItemAtPosition(item, drawer.drawerItems.size - 3) } diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.kt b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.kt index 6e08ad2..e9d9780 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.kt +++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.kt @@ -29,6 +29,7 @@ import android.text.util.Linkify.WEB_URLS import android.view.* import android.widget.ImageView import android.widget.TextView +import ch.dissem.apps.abit.adapter.LabelAdapter import ch.dissem.apps.abit.service.Singleton import ch.dissem.apps.abit.util.Assets import ch.dissem.apps.abit.util.Constants.BITMESSAGE_ADDRESS_PATTERN @@ -259,40 +260,6 @@ class MessageDetailFragment : Fragment() { } } - private class LabelAdapter internal constructor(private val ctx: Context, labels: Set