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; ...@@ -17,6 +17,7 @@ import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import chat.rocket.android.widget.helper.DrawableHelper;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -103,23 +104,24 @@ public class RoomToolbar extends Toolbar { ...@@ -103,23 +104,24 @@ public class RoomToolbar extends Toolbar {
} }
public void showUserStatusIcon(int status) { public void showUserStatusIcon(int status) {
wrapDrawable(userStatusDrawable); DrawableHelper.INSTANCE.wrapDrawable(userStatusDrawable);
Context context = getContext();
switch (status) { switch (status) {
case STATUS_ONLINE: case STATUS_ONLINE:
tintDrawable(userStatusDrawable, R.color.color_user_status_online); DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_online);
break; break;
case STATUS_BUSY: case STATUS_BUSY:
tintDrawable(userStatusDrawable, R.color.color_user_status_busy); DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_busy);
break; break;
case STATUS_AWAY: case STATUS_AWAY:
tintDrawable(userStatusDrawable, R.color.color_user_status_away); DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_away);
break; break;
case STATUS_OFFLINE: case STATUS_OFFLINE:
tintDrawable(userStatusDrawable, R.color.color_user_status_offline); DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_offline);
break; break;
default: default:
tintDrawable(userStatusDrawable, R.color.color_user_status_offline); DrawableHelper.INSTANCE.tintDrawable(userStatusDrawable, context, R.color.color_user_status_offline);
break; break;
} }
...@@ -128,25 +130,6 @@ public class RoomToolbar extends Toolbar { ...@@ -128,25 +130,6 @@ public class RoomToolbar extends Toolbar {
userStatusImage.setVisibility(VISIBLE); 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) { public void setUnreadBudge(int numUnreadChannels, int numMentionsSum) {
if (getNavigationIcon() == null) { if (getNavigationIcon() == null) {
return; 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