diff --git a/app/src/main/java/io/agora/flat/common/android/I18NFetcher.kt b/app/src/main/java/io/agora/flat/common/android/I18NFetcher.kt
new file mode 100644
index 00000000..17dbe6f2
--- /dev/null
+++ b/app/src/main/java/io/agora/flat/common/android/I18NFetcher.kt
@@ -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)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/agora/flat/data/repository/RoomRepository.kt b/app/src/main/java/io/agora/flat/data/repository/RoomRepository.kt
index 602c2cb1..a70a51ee 100644
--- a/app/src/main/java/io/agora/flat/data/repository/RoomRepository.kt
+++ b/app/src/main/java/io/agora/flat/data/repository/RoomRepository.kt
@@ -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
@@ -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)
@@ -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))
}
}
}
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index fb81116f..b6001cb4 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -92,6 +92,7 @@
开启麦克风
%1$s创建的房间
房间号不能为空
+ %1$s的个人房间
房间列表
历史记录
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2da5e9a6..7de355ba 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -87,6 +87,8 @@
Turn on camera
Turn on microphone
Room created by %1$s
+ %1$s\'s personal room
+
Room
History