Skip to content

Commit

Permalink
update pmi JoinRoomRecord title
Browse files Browse the repository at this point in the history
  • Loading branch information
AderanFeng committed Nov 22, 2023
1 parent f3d1e42 commit 73ed7fd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
30 changes: 30 additions & 0 deletions app/src/main/java/io/agora/flat/common/android/I18NFetcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.agora.flat.common.android

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import io.agora.flat.R
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class I18NFetcher @Inject constructor(@ApplicationContext context: Context) {
companion object {
const val JOIN_ROOM_RECORD_PMI_TITLE = "join_room_record_pmi_title"

val map = mapOf(
JOIN_ROOM_RECORD_PMI_TITLE to R.string.join_room_record_pmi_title
)
}

private val resources = context.resources

fun getString(key: String): String {
val resId = map[key] ?: return ""
return resources.getString(resId)
}

fun getString(key: String, vararg formatArgs: Any?): String {
val resId = map[key] ?: return ""
return resources.getString(resId, *formatArgs)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.agora.flat.data.repository

import io.agora.flat.common.android.I18NFetcher
import io.agora.flat.data.Result
import io.agora.flat.data.RoomServiceFetcher
import io.agora.flat.data.manager.JoinRoomRecordManager
Expand Down Expand Up @@ -31,6 +32,7 @@ class RoomRepository @Inject constructor(
private val roomService: RoomService,
private val roomServiceFetcher: RoomServiceFetcher,
private val joinRoomRecordManager: JoinRoomRecordManager,
private val i18NFetcher: I18NFetcher,
) {
private fun fetchService(uuid: String): RoomService {
return roomServiceFetcher.fetch(uuid)
Expand All @@ -52,9 +54,12 @@ class RoomRepository @Inject constructor(
return withContext(Dispatchers.IO) {
fetchService(roomUUID).getOrdinaryRoomInfo(RoomDetailOrdinaryReq(roomUUID = roomUUID)).toResult().also {
it.get()?.roomInfo?.run {
if (isPmi == true) {
joinRoomRecordManager.addRecord(JoinRoomRecord(this.title, this.inviteCode))
val title = if (isPmi == true) {
i18NFetcher.getString(I18NFetcher.JOIN_ROOM_RECORD_PMI_TITLE, ownerUserName)
} else {
this.title
}
joinRoomRecordManager.addRecord(JoinRoomRecord(title, inviteCode))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<string name="turn_on_mic">开启麦克风</string>
<string name="join_room_default_time_format">%1$s创建的房间</string>
<string name="join_room_toast_empty">房间号不能为空</string>
<string name="join_room_record_pmi_title">%1$s的个人房间</string>

<string name="home_room_list">房间列表</string>
<string name="home_room_history">历史记录</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
<string name="turn_on_camera">Turn on camera</string>
<string name="turn_on_mic">Turn on microphone</string>
<string name="join_room_default_time_format">Room created by %1$s</string>
<string name="join_room_record_pmi_title">%1$s\'s personal room</string>

<string name="home_room_list">Room</string>
<string name="home_room_history">History</string>

Expand Down

0 comments on commit 73ed7fd

Please sign in to comment.