Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f33a43a authored by David Hoppenbrouwers's avatar David Hoppenbrouwers Committed by cketti
Browse files

Added colored chip in Unified Inbox widget items (#3759)

Add colored chip in Unified Inbox widget items
parent c577c908
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteVi
            MessageProvider.MessageColumns.PREVIEW,
            MessageProvider.MessageColumns.UNREAD,
            MessageProvider.MessageColumns.HAS_ATTACHMENTS,
            MessageProvider.MessageColumns.URI
            MessageProvider.MessageColumns.URI,
            MessageProvider.MessageColumns.ACCOUNT_COLOR,
    };


@@ -84,8 +85,9 @@ public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteVi
                boolean unread = toBoolean(cursor.getString(4));
                boolean hasAttachment = toBoolean(cursor.getString(5));
                Uri viewUri = Uri.parse(cursor.getString(6));
                int color = cursor.getInt(7);

                mailItems.add(new MailItem(sender, date, subject, preview, unread, hasAttachment, viewUri));
                mailItems.add(new MailItem(sender, date, subject, preview, unread, hasAttachment, viewUri, color));
            }
        } finally {
            cursor.close();
@@ -135,6 +137,9 @@ public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteVi
        Intent intent = new Intent();
        intent.setData(item.uri);
        remoteView.setOnClickFillInIntent(R.id.mail_list_item, intent);

        remoteView.setInt(R.id.chip, "setBackgroundColor", item.color);

        return remoteView;
    }

@@ -180,10 +185,11 @@ public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteVi
        final boolean unread;
        final boolean hasAttachment;
        final Uri uri;
        final int color;


        MailItem(String sender, long date, String subject, String preview, boolean unread, boolean hasAttachment,
                Uri viewUri) {
                Uri viewUri, int color) {
            this.sender = sender;
            this.date = date;
            this.preview = preview;
@@ -191,6 +197,7 @@ public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteVi
            this.unread = unread;
            this.uri = viewUri;
            this.hasAttachment = hasAttachment;
            this.color = color;
        }

        int getTextColor() {
+73 −59
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mail_list_item"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:background="@color/md_white_1000">

    <!-- A regular View breaks things for some reason, but a TextView does the job -->
    <TextView
        android:id="@+id/chip"
        android:layout_width="8dip"
        android:layout_height="match_parent"
        tools:background="@color/orange"
        android:visibility="visible" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/widget_padding">
@@ -12,8 +25,8 @@
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
        android:layout_marginLeft="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginLeft="4dp"
            tools:text="25 May" />

        <ImageView
@@ -22,10 +35,10 @@
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/mail_date"
            android:layout_centerInParent="true"
        android:layout_marginLeft="4dp"
            android:layout_marginStart="4dp"
        android:layout_toLeftOf="@+id/mail_date"
            android:layout_marginLeft="4dp"
            android:layout_toStartOf="@+id/mail_date"
            android:layout_toLeftOf="@+id/mail_date"
            android:src="@drawable/ic_email_attachment_small"
            android:visibility="gone"
            tools:visibility="visible" />
@@ -34,14 +47,14 @@
            android:id="@+id/sender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_gravity="start"
        android:layout_toLeftOf="@id/attachment"
            android:layout_toStartOf="@id/attachment"
        android:maxLines="1"
            android:layout_toLeftOf="@id/attachment"
            android:ellipsize="end"
            android:maxLines="1"
            android:textSize="16sp"
            tools:text="Kinda long subject that should be long enough to exceed the available display space" />

@@ -49,11 +62,11 @@
            android:id="@+id/mail_subject"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
            android:layout_below="@+id/sender"
        android:maxLines="1"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:ellipsize="end"
            android:maxLines="1"
            android:paddingBottom="2dp"
            android:textSize="15sp"
            tools:text="Wikipedia" />
@@ -62,11 +75,12 @@
            android:id="@+id/mail_preview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
            android:layout_below="@+id/mail_subject"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:maxLines="1"
            android:textSize="13sp"
            tools:text="Towel Day is celebrated every year on 25 May as a tribute to the author Douglas Adams by his fans." />

    </RelativeLayout>
</LinearLayout>