package com.google.firebase.samples.apps.mlkit.smartreply.java.model;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;

import com.google.firebase.samples.apps.mlkit.smartreply.R;

public class Message {

    public final String text;
    public final boolean isLocalUser;
    public final long timestamp;

    public Message(String text, boolean isLocalUser, long timestamp) {
        this.text = text;
        this.isLocalUser = isLocalUser;
        this.timestamp = timestamp;
    }

    @NonNull
    public Drawable getIcon(Context context) {
        Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_tag_faces_black_24dp);
        if (drawable == null) {
            throw new IllegalStateException("Could not get drawable ic_tag_faces_black_24dp");
        }

        if (isLocalUser) {
            DrawableCompat.setTint(drawable, Color.BLUE);
        } else {
            DrawableCompat.setTint(drawable, Color.RED);
        }

        return drawable;
    }
}

@@ -151,33 +151,94 @@
 raphics.
-drawable.Drawable
+PorterDuff;%0Aimport android.graphics.drawable.Drawable;%0Aimport android.os.Build
 ;%0Aimport
@@ -1061,23 +1061,264 @@
     
-if (isLocalUser
+// See:%0A        // https://stackoverflow.com/questions/36731919/drawablecompat-settint-not-working-on-api-19%0A        drawable = DrawableCompat.wrap(drawable);%0A        int color = isLocalUser ? Color.BLUE : Color.RED;%0A        if (Build.VERSION.SDK_INT %3E= 22
 ) %7B%0A
@@ -1362,26 +1362,21 @@
 awable, 
-C
+c
 olor
-.BLUE
 );%0A     
@@ -1403,50 +1403,70 @@
     
-D
+d
 rawable
-Compat.setTint(drawable, Color.RED
+.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN
 );%0A 

Fix icon colors