Commit b0fb3485 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge branch 'develop' into iss424

parents 4401ed72 66cbbad6
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
buildscript { buildscript {
repositories { repositories {
......
...@@ -2,35 +2,28 @@ package chat.rocket.android.widget.internal ...@@ -2,35 +2,28 @@ package chat.rocket.android.widget.internal
import android.annotation.TargetApi import android.annotation.TargetApi
import android.content.Context import android.content.Context
import android.content.res.TypedArray
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.support.annotation.ColorRes import android.support.annotation.ColorRes
import android.support.annotation.StringRes
import android.support.graphics.drawable.VectorDrawableCompat import android.support.graphics.drawable.VectorDrawableCompat
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView
import chat.rocket.android.widget.R import chat.rocket.android.widget.R
import chat.rocket.android.widget.helper.DrawableHelper import chat.rocket.android.widget.helper.DrawableHelper
import kotlinx.android.synthetic.main.room_list_item.view.*
/** /**
* Room list-item view used in sidebar. * Room list-item view used in sidebar.
*/ */
class RoomListItemView : FrameLayout { class RoomListItemView : FrameLayout {
lateinit private var roomId: String lateinit private var roomId: String
lateinit private var roomTypeImage: ImageView private val privateChannelDrawable: Drawable? = VectorDrawableCompat.create(resources, R.drawable.ic_lock_white_24dp, null)
lateinit private var userStatusImage: ImageView private val publicChannelDrawable: Drawable? = VectorDrawableCompat.create(resources, R.drawable.ic_hashtag_white_24dp, null)
lateinit private var roomNameText: TextView private val liveChatChannelDrawable: Drawable? = VectorDrawableCompat.create(resources, R.drawable.ic_livechat_white_24dp, null)
lateinit private var alertCountText: TextView private val userStatusDrawable: Drawable? = VectorDrawableCompat.create(resources, R.drawable.ic_user_status_black_24dp, null)
lateinit private var privateChannelDrawable: Drawable
lateinit private var publicChannelDrawable: Drawable
lateinit private var livechatChannelDrawable: Drawable
lateinit private var userStatusDrawable: Drawable
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
initialize(context) initialize(context)
...@@ -60,16 +53,6 @@ class RoomListItemView : FrameLayout { ...@@ -60,16 +53,6 @@ class RoomListItemView : FrameLayout {
array.recycle() array.recycle()
View.inflate(context, R.layout.room_list_item, this) View.inflate(context, R.layout.room_list_item, this)
roomTypeImage = findViewById(R.id.image_room_type)
userStatusImage = findViewById(R.id.image_user_status)
roomNameText = findViewById(R.id.text_room_name)
alertCountText = findViewById(R.id.text_alert_count)
privateChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_lock_white_24dp, null)!!
publicChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_hashtag_white_24dp, null)!!
livechatChannelDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_livechat_white_24dp, null)!!
userStatusDrawable = VectorDrawableCompat.create(resources, R.drawable.ic_user_status_black_24dp, null)!!
} }
fun setRoomId(roomId: String) { fun setRoomId(roomId: String) {
...@@ -78,10 +61,10 @@ class RoomListItemView : FrameLayout { ...@@ -78,10 +61,10 @@ class RoomListItemView : FrameLayout {
fun setUnreadCount(count: Int) { fun setUnreadCount(count: Int) {
if (count > 0) { if (count > 0) {
alertCountText.text = count.toString() alertCount.text = count.toString()
alertCountText.visibility = View.VISIBLE alertCount.visibility = View.VISIBLE
} else { } else {
alertCountText.visibility = View.GONE alertCount.visibility = View.GONE
} }
} }
...@@ -90,25 +73,25 @@ class RoomListItemView : FrameLayout { ...@@ -90,25 +73,25 @@ class RoomListItemView : FrameLayout {
} }
fun setRoomName(roomName: String) { fun setRoomName(roomName: String) {
roomNameText.text = roomName name.text = roomName
} }
fun showPrivateChannelIcon() { fun showPrivateChannelIcon() {
roomTypeImage.setImageDrawable(privateChannelDrawable) type.setImageDrawable(privateChannelDrawable)
userStatusImage.visibility = View.GONE userStatus.visibility = View.GONE
roomTypeImage.visibility = View.VISIBLE type.visibility = View.VISIBLE
} }
fun showPublicChannelIcon() { fun showPublicChannelIcon() {
roomTypeImage.setImageDrawable(publicChannelDrawable) type.setImageDrawable(publicChannelDrawable)
userStatusImage.visibility = View.GONE userStatus.visibility = View.GONE
roomTypeImage.visibility = View.VISIBLE type.visibility = View.VISIBLE
} }
fun showLivechatChannelIcon() { fun showLivechatChannelIcon() {
roomTypeImage.setImageDrawable(livechatChannelDrawable) type.setImageDrawable(liveChatChannelDrawable)
userStatusImage.visibility = View.GONE userStatus.visibility = View.GONE
roomTypeImage.visibility = View.VISIBLE type.visibility = View.VISIBLE
} }
fun showOnlineUserStatusIcon() { fun showOnlineUserStatusIcon() {
...@@ -130,8 +113,8 @@ class RoomListItemView : FrameLayout { ...@@ -130,8 +113,8 @@ class RoomListItemView : FrameLayout {
private fun prepareDrawableAndShow(@ColorRes resId: Int) { private fun prepareDrawableAndShow(@ColorRes resId: Int) {
DrawableHelper.wrapDrawable(userStatusDrawable) DrawableHelper.wrapDrawable(userStatusDrawable)
DrawableHelper.tintDrawable(userStatusDrawable, context, resId) DrawableHelper.tintDrawable(userStatusDrawable, context, resId)
userStatusImage.setImageDrawable(userStatusDrawable) userStatus.setImageDrawable(userStatusDrawable)
roomTypeImage.visibility = View.GONE type.visibility = View.GONE
userStatusImage.visibility = View.VISIBLE userStatus.visibility = View.VISIBLE
} }
} }
\ No newline at end of file
...@@ -10,13 +10,13 @@ ...@@ -10,13 +10,13 @@
android:paddingBottom="10dp"> android:paddingBottom="10dp">
<ImageView <ImageView
android:id="@+id/image_room_type" android:id="@+id/type"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
android:id="@+id/image_user_status" android:id="@+id/userStatus"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
android:visibility="gone" /> android:visibility="gone" />
<TextView <TextView
android:id="@+id/text_room_name" android:id="@+id/name"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.9" android:layout_weight="0.9"
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body2" /> android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
<TextView <TextView
android:id="@+id/text_alert_count" android:id="@+id/alertCount"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.1" android:layout_weight="0.1"
......
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