use string resources

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-04-09 17:15:24 +02:00 committed by Marcel Hibbe
parent 351b532e6a
commit b128c5a8ea
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 43 additions and 27 deletions

View File

@ -2989,11 +2989,11 @@ class ChatActivity :
popupWindow.showAsDropDown(anchorView, 0, -anchorView.height)
val meetingStatus = showEventSchedule()
titleTextView.text = "Scheduled"
subtitleTextView.text = meetingStatus
if (meetingStatus == "Meeting Ended" && currentConversation?.canDeleteConversation == true) {
if (meetingStatus == context.resources.getString(R.string.nc_meeting_ended) &&
currentConversation?.canDeleteConversation == true
) {
deleteConversation.visibility = View.VISIBLE
deleteConversation.setOnClickListener {
@ -3063,34 +3063,41 @@ class ChatActivity :
}
private fun showEventSchedule(): String {
val objectId = currentConversation?.objectId ?: ""
val status = getMeetingSchedule(objectId)
val meetingTimeStamp = currentConversation?.objectId ?: ""
val status = getMeetingSchedule(meetingTimeStamp)
return status
}
private fun getMeetingSchedule(objectId: String): String {
val timestamps = objectId.split("#")
if (timestamps.size != 2) return "Invalid Time"
private fun getMeetingSchedule(meetingTimeStamp: String): String {
val timestamps = meetingTimeStamp.split("#")
if (timestamps.size != 2) return context.resources.getString(R.string.nc_invalid_time)
val startEpoch = timestamps[0].toLong()
val endEpoch = timestamps[1].toLong()
val startEpoch = timestamps[ZERO_INDEX].toLong()
val endEpoch = timestamps[ONE_INDEX].toLong()
val startDateTime = Instant.ofEpochSecond(startEpoch).atZone(ZoneId.systemDefault())
val endDateTime = Instant.ofEpochSecond(endEpoch).atZone(ZoneId.systemDefault())
val now = ZonedDateTime.now(ZoneId.systemDefault())
val currentTime = ZonedDateTime.now(ZoneId.systemDefault())
return when {
now.isBefore(startDateTime) -> {
val isToday = startDateTime.toLocalDate().isEqual(now.toLocalDate())
val isTomorrow = startDateTime.toLocalDate().isEqual(now.toLocalDate().plusDays(1))
currentTime.isBefore(startDateTime) -> {
val isToday = startDateTime.toLocalDate().isEqual(currentTime.toLocalDate())
val isTomorrow = startDateTime.toLocalDate().isEqual(currentTime.toLocalDate().plusDays(1))
when {
isToday -> "Today at ${startDateTime.format(DateTimeFormatter.ofPattern("HH:mm"))}"
isTomorrow -> "Tomorrow at ${startDateTime.format(DateTimeFormatter.ofPattern("HH:mm"))}"
isToday -> String.format(
context.resources.getString(R.string.nc_today_meeting),
startDateTime.format(DateTimeFormatter.ofPattern("HH:mm"))
)
isTomorrow -> String.format(
context.resources.getString(R.string.nc_tomorrow_meeting),
startDateTime.format(DateTimeFormatter.ofPattern("HH:mm"))
)
else -> startDateTime.format(DateTimeFormatter.ofPattern("MMM d, yyyy, HH:mm"))
}
}
now.isAfter(endDateTime) -> "Meeting Ended"
else -> "Ongoing"
currentTime.isAfter(endDateTime) -> context.resources.getString(R.string.nc_meeting_ended)
else -> context.resources.getString(R.string.nc_ongoing_meeting)
}
}
@ -3951,5 +3958,7 @@ class ChatActivity :
const val VOICE_MESSAGE_PLAY_ADD_THRESHOLD = 0.1
const val VOICE_MESSAGE_MARK_PLAYED_FACTOR = 20
const val OUT_OF_OFFICE_ALPHA = 76
const val ZERO_INDEX = 0
const val ONE_INDEX = 1
}
}

View File

@ -275,11 +275,11 @@ class ConversationInfoEditActivity : BaseActivity() {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.save) {
if (conversation?.objectType != ConversationEnums.ObjectType.EVENT) {
saveConversationNameAndDescription()
}
if (item.itemId == R.id.save) {
if (conversation?.objectType != ConversationEnums.ObjectType.EVENT) {
saveConversationNameAndDescription()
}
}
return true
}

View File

@ -557,11 +557,11 @@ class ConversationsListActivity :
}
private fun futureEvent(conversation: ConversationModel): Boolean {
if(!conversation.objectId.contains("#")){
if (!conversation.objectId.contains("#")) {
return false
}
return conversation.objectType == ConversationEnums.ObjectType.EVENT &&
(conversation.objectId.split("#")[0].toLong() - (System.currentTimeMillis() / 1000)) >
(conversation.objectId.split("#")[0].toLong() - (System.currentTimeMillis() / LONG_1000)) >
AGE_THRESHOLD_FOR_EVENT_CONVERSATIONS
}
@ -2138,5 +2138,6 @@ class ConversationsListActivity :
const val OFFSET_HEIGHT_DIVIDER: Int = 3
const val ROOM_TYPE_ONE_ONE = "1"
private const val AGE_THRESHOLD_FOR_EVENT_CONVERSATIONS: Long = 86400
const val LONG_1000: Long = 1000
}
}

View File

@ -9,6 +9,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:padding="16dp"
android:background="@color/dialog_background">
@ -17,7 +18,7 @@
android:id="@+id/event_scheduled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scheduled"
android:text="@string/nc_event_schedule"
android:textStyle="bold"
android:textSize="16sp" />
@ -27,13 +28,13 @@
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
android:text="Meeting at 8:00 pm"/>
tools:text="Meeting at 8:00 pm"/>
<TextView
android:id="@+id/delete_conversation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete Conversation"
android:text="@string/nc_delete_call"
android:textColor="@android:color/holo_red_dark"
android:visibility = "gone"
android:paddingTop="16dp"/>

View File

@ -245,6 +245,11 @@ How to translate with transifex:
<string name="nc_event_schedule">Schedule</string>
<string name="nc_delete">Delete</string>
<string name="nc_delete_all">Delete all</string>
<string name="nc_ongoing_meeting">Ongoing meeting</string>
<string name="nc_meeting_ended">Meeting ended</string>
<string name="nc_invalid_time">Invalid time</string>
<string name="nc_today_meeting">Today at %1$s</string>
<string name="nc_tomorrow_meeting">Tomorrow at %1$s</string>
<string name="nc_delete_conversation_more">If you delete the conversation, it will also be deleted for all other participants.</string>
<string name="nc_new_conversation">New conversation</string>