Commit b9d112bf authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RoomToolbar.java

parent 4b4c84f7
......@@ -17,6 +17,7 @@ import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import chat.rocket.android.widget.helper.DrawableHelper;
import com.amulyakhare.textdrawable.TextDrawable;
import java.lang.reflect.Field;
......@@ -103,23 +104,24 @@ public class RoomToolbar extends Toolbar {
}
public void showUserStatusIcon(int status) {
wrapDrawable(userStatusDrawable);
DrawableHelper.INSTANCE.wrapDrawable(userStatusDrawable);
Context context = getContext();
switch (status) {
case STATUS_ONLINE:
tintDrawable(userStatusDrawable, R.color.color_user_status_online);
DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_online);
break;
case STATUS_BUSY:
tintDrawable(userStatusDrawable, R.color.color_user_status_busy);
DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_busy);
break;
case STATUS_AWAY:
tintDrawable(userStatusDrawable, R.color.color_user_status_away);
DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_away);
break;
case STATUS_OFFLINE:
tintDrawable(userStatusDrawable, R.color.color_user_status_offline);
DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_offline);
break;
default:
tintDrawable(userStatusDrawable, R.color.color_user_status_offline);
DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_offline);
break;
}
......@@ -128,25 +130,6 @@ public class RoomToolbar extends Toolbar {
userStatusImage.setVisibility(VISIBLE);
}
/**
* Wraps a drawable to be used for example for tinting.
* @param drawable The drawable to wrap.
* @see #tintDrawable(Drawable, int)
*/
private void wrapDrawable(Drawable drawable) {
DrawableCompat.wrap(drawable);
}
/**
* REMARK: You MUST always wrap the drawable before tint it.
* @param drawable The drawable to tint.
* @param color The color to tint the drawable.
* @see #wrapDrawable(Drawable)
*/
private void tintDrawable(Drawable drawable, int color) {
DrawableCompat.setTint(drawable, ContextCompat.getColor(getContext(), color));
}
public void setUnreadBudge(int numUnreadChannels, int numMentionsSum) {
if (getNavigationIcon() == null) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment