Commit 95ad502f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Updates getUserStatusDrawable function.

parent d40ad994
...@@ -108,46 +108,12 @@ object DrawableHelper { ...@@ -108,46 +108,12 @@ object DrawableHelper {
* @see [UserStatus] * @see [UserStatus]
* @return The user status drawable. * @return The user status drawable.
*/ */
fun getUserStatusDrawable(userStatus: UserStatus?, context: Context, getSmallDrawable: Boolean = false): Drawable { fun getUserStatusDrawable(userStatus: UserStatus?, context: Context): Drawable {
return when (userStatus) { return when (userStatus) {
is UserStatus.Online -> { is UserStatus.Online -> getDrawableFromId(R.drawable.ic_status_online_12dp, context)
getDrawableFromId( is UserStatus.Away -> getDrawableFromId(R.drawable.ic_status_away_12dp, context)
if (getSmallDrawable) { is UserStatus.Busy -> getDrawableFromId(R.drawable.ic_status_busy_12dp, context)
R.drawable.ic_status_online_12dp else -> getDrawableFromId(R.drawable.ic_status_invisible_12dp, context)
} else {
R.drawable.ic_status_online_24dp
},
context
)
}
is UserStatus.Away -> {
getDrawableFromId(
if (getSmallDrawable) {
R.drawable.ic_status_away_12dp
} else {
R.drawable.ic_status_away_24dp
},
context
)
}
is UserStatus.Busy -> {
getDrawableFromId(
if (getSmallDrawable) {
R.drawable.ic_status_busy_12dp
} else {
R.drawable.ic_status_busy_24dp
},
context
)
}
else -> getDrawableFromId(
if (getSmallDrawable){
R.drawable.ic_status_invisible_12dp
} else {
R.drawable.ic_status_invisible_24dp
},
context
)
} }
} }
} }
\ No newline at end of file
...@@ -94,8 +94,7 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -94,8 +94,7 @@ class ChatRoomsAdapter(private val context: Context,
) )
is RoomType.DirectMessage -> DrawableHelper.getUserStatusDrawable( is RoomType.DirectMessage -> DrawableHelper.getUserStatusDrawable(
chatRoom.status, chatRoom.status,
context, context
true
) )
else -> null else -> null
} }
......
...@@ -84,11 +84,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -84,11 +84,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
override fun showUserStatus(userStatus: UserStatus) { override fun showUserStatus(userStatus: UserStatus) {
headerLayout.apply { headerLayout.apply {
image_user_status.setImageDrawable( image_user_status.setImageDrawable(
DrawableHelper.getUserStatusDrawable( DrawableHelper.getUserStatusDrawable(userStatus, this.context)
userStatus,
this.context,
true
)
) )
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_status_online_24dp" android:drawableStart="@drawable/ic_status_online_12dp"
android:text="@string/action_online" android:text="@string/action_online"
android:background="?selectableItemBackground"/> android:background="?selectableItemBackground"/>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_status_away_24dp" android:drawableStart="@drawable/ic_status_away_12dp"
android:text="@string/action_away" android:text="@string/action_away"
android:background="?selectableItemBackground"/> android:background="?selectableItemBackground"/>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_status_busy_24dp" android:drawableStart="@drawable/ic_status_busy_12dp"
android:text="@string/action_busy" android:text="@string/action_busy"
android:background="?selectableItemBackground"/> android:background="?selectableItemBackground"/>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_status_invisible_24dp" android:drawableStart="@drawable/ic_status_invisible_12dp"
android:text="@string/action_invisible" android:text="@string/action_invisible"
android:background="?selectableItemBackground"/> android:background="?selectableItemBackground"/>
......
...@@ -49,8 +49,9 @@ ...@@ -49,8 +49,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
app:layout_constraintBaseline_toBaselineOf="@+id/text_chat_name" app:layout_constraintBottom_toBottomOf="@+id/image_chat_icon"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/image_chat_icon"
tools:text="11:45 AM" /> tools:text="11:45 AM" />
<TextView <TextView
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
app:layout_constraintEnd_toStartOf="@id/layout_unread_messages_badge" app:layout_constraintEnd_toStartOf="@id/layout_unread_messages_badge"
app:layout_constraintStart_toStartOf="@id/image_chat_icon" app:layout_constraintStart_toStartOf="@id/image_chat_icon"
app:layout_constraintTop_toBottomOf="@id/text_chat_name" app:layout_constraintTop_toBottomOf="@id/text_chat_name"
tools:text="You: Type something that is very big and need at least to lines, or maybe even more" /> tools:text="Filipe de Lima Brito: Type something that is very big and need at least to lines, or maybe even more" />
<include <include
android:id="@+id/layout_unread_messages_badge" android:id="@+id/layout_unread_messages_badge"
......
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