Commit 8c0916b1 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add localization strings and do not create a new conversation if already opend

parent a7409d78
......@@ -74,19 +74,20 @@ class MessageViewHolder(
}
val senderId = data.message.sender?.id
val subscriptionId = data.subscriptionId
text_sender.setOnClickListener {
toUserDetails(context, senderId)
toUserDetails(context, senderId, subscriptionId)
}
image_avatar.setOnClickListener {
toUserDetails(context, senderId)
toUserDetails(context, senderId, subscriptionId)
}
}
}
private fun toUserDetails(context: Context, userId: String?) {
userId?.let { context.startActivity(context.userDetailsIntent(it)) }
private fun toUserDetails(context: Context, userId: String?, subscriptionId: String) {
userId?.let { context.startActivity(context.userDetailsIntent(it, subscriptionId)) }
}
override fun unscheduleDrawable(who: Drawable?, what: Runnable?) {
......
......@@ -21,7 +21,8 @@ data class MessageUiModel(
var isFirstUnread: Boolean,
override var isTemporary: Boolean = false,
override var menuItemsToHide: MutableList<Int> = mutableListOf(),
override var permalink: String
override var permalink: String,
val subscriptionId: String
) : BaseMessageUiModel<Message> {
override val viewType: Int
get() = BaseUiModel.ViewType.MESSAGE.viewType
......
......@@ -456,7 +456,8 @@ class UiModelMapper @Inject constructor(
messageId = message.id, avatar = avatar!!, time = time, senderName = sender,
content = content, isPinned = message.pinned, currentDayMarkerText = dayMarkerText,
showDayMarker = false, reactions = getReactions(message), isFirstUnread = false,
preview = preview, isTemporary = !synced, unread = unread, permalink = permalink)
preview = preview, isTemporary = !synced, unread = unread, permalink = permalink,
subscriptionId = chatRoom.subscriptionId)
}
private fun mapMessagePreview(message: Message): Message {
......
package chat.rocket.android.userdetails.presentation
import androidx.core.text.toSpannable
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.helper.UserHelper
import chat.rocket.android.server.domain.GetConnectingServerInteractor
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.util.extension.launchUI
......@@ -22,11 +24,13 @@ class UserDetailsPresenter @Inject constructor(
private val dbManager: DatabaseManager,
private val strategy: CancelStrategy,
serverInteractor: GetConnectingServerInteractor,
factory: ConnectionManagerFactory
factory: ConnectionManagerFactory,
userHelper: UserHelper
) {
private var currentServer = serverInteractor.get()!!
private val manager = factory.create(currentServer)
private val client = manager.client
private val userId = userHelper.user()?.id
fun loadUserDetails(userId: String) {
launchUI(strategy) {
......@@ -50,7 +54,7 @@ class UserDetailsPresenter @Inject constructor(
if (matchFromSpotlight != null) {
with (matchFromSpotlight) {
ChatRoom(
id = id,
id = "$id$userId",
type = roomTypeOf(RoomType.DIRECT_MESSAGE),
name = u.username ?: u.name.orEmpty(),
fullName = u.name,
......@@ -76,7 +80,7 @@ class UserDetailsPresenter @Inject constructor(
subscriptionId = "",
timestamp = null,
updatedAt = null,
user = SimpleUser(id, username)
user = null
)
}
} else null
......
......@@ -17,6 +17,7 @@ import chat.rocket.android.util.extension.orFalse
import chat.rocket.android.util.extensions.showToast
import chat.rocket.common.model.roomTypeOf
import chat.rocket.core.model.ChatRoom
import chat.rocket.core.model.userId
import com.bumptech.glide.Glide
import com.bumptech.glide.Priority
import com.bumptech.glide.load.resource.bitmap.CenterCrop
......@@ -38,16 +39,19 @@ import org.threeten.bp.ZoneId
import org.threeten.bp.ZoneOffset
import org.threeten.bp.ZonedDateTime
import org.threeten.bp.format.DateTimeFormatter
import timber.log.Timber
import javax.inject.Inject
import kotlin.math.roundToLong
fun Context.userDetailsIntent(userId: String): Intent {
fun Context.userDetailsIntent(userId: String, subscriptionId: String): Intent {
return Intent(this, UserDetailsActivity::class.java).apply {
putExtra(EXTRA_USER_ID, userId)
putExtra(EXTRA_SUBSCRIPTION_ID, subscriptionId)
}
}
const val EXTRA_USER_ID = "EXTRA_USER_ID"
const val EXTRA_SUBSCRIPTION_ID = "EXTRA_USERNAME"
class UserDetailsActivity : AppCompatActivity(), UserDetailsView, HasSupportFragmentInjector {
......@@ -56,6 +60,8 @@ class UserDetailsActivity : AppCompatActivity(), UserDetailsView, HasSupportFrag
@Inject
lateinit var presenter: UserDetailsPresenter
private lateinit var subscriptionId: String
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
super.onCreate(savedInstanceState)
......@@ -63,6 +69,7 @@ class UserDetailsActivity : AppCompatActivity(), UserDetailsView, HasSupportFrag
setupToolbar()
val userId = intent.getStringExtra(EXTRA_USER_ID)
subscriptionId = intent.getStringExtra(EXTRA_SUBSCRIPTION_ID)
presenter.loadUserDetails(userId = userId)
}
......@@ -129,18 +136,20 @@ class UserDetailsActivity : AppCompatActivity(), UserDetailsView, HasSupportFrag
private fun toDirectMessage(chatRoom: ChatRoom?) {
chatRoom?.let { c ->
finish()
startActivity(
chatRoomIntent(
chatRoomId = c.id,
chatRoomName = c.name,
chatRoomType = c.type.toString(),
isReadOnly = c.readonly.orFalse(),
chatRoomLastSeen = c.lastSeen ?: 0,
isSubscribed = c.open,
isCreator = false,
isFavorite = c.favorite
if (c.subscriptionId.isEmpty() || c.subscriptionId != subscriptionId) {
startActivity(
chatRoomIntent(
chatRoomId = c.id,
chatRoomName = c.name,
chatRoomType = c.type.toString(),
isReadOnly = c.readonly.orFalse(),
chatRoomLastSeen = c.lastSeen ?: 0,
isSubscribed = c.open,
isCreator = false,
isFavorite = c.favorite
)
)
)
}
}
}
}
......@@ -32,7 +32,7 @@
android:id="@+id/text_view_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:text="@string/message"
android:textColor="#1d74f5"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/image_view_message"
......@@ -72,7 +72,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:text="Status"
android:text="@string/status"
android:textColor="@color/darkGray"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
......@@ -95,7 +95,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Timezone"
android:text="@string/timezone"
android:textColor="@color/darkGray"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
......@@ -152,7 +152,6 @@
android:layout_marginEnd="16dp"
android:background="@drawable/bg_round_bounds_white"
tools:srcCompat="@tools:sample/avatars[6]" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -329,6 +329,9 @@
<string name="notif_success_sending">Nachricht gesendet nach %1$s!</string>
<string name="read_by">Gelesen von</string>
<string name="message_information_title">Nachricht Information</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
</resources>
\ No newline at end of file
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string> <!--TODO - Add proper translation-->
<!-- User Details -->
<string name="message">Message</string> <!--TODO - Add proper translation-->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
</resources>
......@@ -330,6 +330,9 @@
<string name="msg_file_description">Descripción del archivo</string>
<string name="msg_send">Enviar</string>
<string name="msg_sent_attachment">Envió un archivo</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string> <!--TODO - Add proper translation-->
<!-- User Details -->
<string name="message">Message</string> <!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string> <!-- TODO - Add proper translation -->
</resources>
......@@ -334,4 +334,10 @@
<string name="msg_sent_attachment">Envoyé un fichier</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
\ No newline at end of file
......@@ -334,4 +334,10 @@
<string name="message_information_title">संदेश की जानकारी</string>
<string name="msg_log_out">लॉग आउट कर रहा हूं…</string>
<string name="message_room_changed_privacy">%2$s ने रूम का प्रकार बदलकर %1$s किया </string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
......@@ -329,4 +329,9 @@
<string name="message_information_title">Informazioni Messaggio</string>
<string name="message_room_changed_privacy">Il tipo di stanza è cambiato in: %1$s da %2$s</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
......@@ -336,4 +336,9 @@
<string name="message_room_changed_privacy">ルームタイプを %2$s から %1$s に変更しました</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
\ No newline at end of file
......@@ -332,4 +332,10 @@
<string name="msg_log_out">Deslogando…</string>
<string name="msg_sent_attachment">Enviou um arquivo</string>
<string name="message_room_changed_privacy">O tipo da sala mudou para: %1$s por %2$s</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Mensagem</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Fuso Horário</string>
</resources>
......@@ -330,4 +330,10 @@
<string name="message_information_title">Информация о прочтении</string>
<string name="msg_log_out">Выходим…</string>
<string name="message_room_changed_privacy">Тип канала изменен на: %1$s пользователем %2$s</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
......@@ -332,6 +332,9 @@
<string name="notif_success_sending">Mesaj %1$s\'a gönderildi!</string>
<string name="read_by">ile oku</string>
<string name="message_information_title">Mesaj bilgisi</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string> <!--TODO - Add proper translation-->
<!-- User Details -->
<string name="message">Message</string> <!--TODO - Add proper translation-->
<string name="timezone">Timezone</string> <!--TODO - Add proper translation-->
</resources>
......@@ -332,4 +332,10 @@
<string name="msg_sent_attachment">Долучення відправлено</string>
<!--TODO - Add proper translation-->
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<!-- User Details -->
<!-- TODO - Add proper translation -->
<string name="message">Message</string>
<!-- TODO - Add proper translation -->
<string name="timezone">Timezone</string>
</resources>
......@@ -203,7 +203,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="msg_view_more">view more</string>
<string name="msg_view_less">view less</string>
<string name="msg_muted_on_this_channel">You are muted on this channel</string>
<!-- Preferences messages -->
<string name="msg_analytics_tracking">Analytics tracking</string>
<string name="msg_send_analytics_tracking">Send anonymous statics to help improving this app</string>
......@@ -346,5 +346,10 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="message_information_title">Message information</string>
<string name="message_room_changed_privacy">Room type changed to: %1$s by %2$s</string>
<string name="foss" tools:ignore="MissingTranslation">(FOSS)</string>
<string name="foss" translatable="false">(FOSS)</string>
<!-- User Details -->
<string name="message">Message</string>
<string name="timezone">Timezone</string>
<string name="status" translatable="false">Status</string>
</resources>
\ No newline at end of file
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