diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt
index 5eee74f0c..4b386cb81 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt
+++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt
@@ -1119,19 +1119,26 @@ class ChatController(args: Bundle) :
binding.messageInputView.visibility = View.GONE
binding.progressBar.visibility = View.GONE
+ val sb = StringBuilder()
+ sb.append(resources!!.getText(R.string.nc_lobby_waiting))
+ .append("\n\n")
+
if (currentConversation?.lobbyTimer != null && currentConversation?.lobbyTimer !=
0L
) {
- binding.lobby.lobbyTextView.text = String.format(
- resources!!.getString(R.string.nc_lobby_waiting_with_date),
- DateUtils.getLocalDateStringFromTimestampForLobby(
- currentConversation?.lobbyTimer
- ?: 0
- )
+ val timestamp = currentConversation?.lobbyTimer ?: 0
+ val stringWithStartDate = String.format(
+ resources!!.getString(R.string.nc_lobby_start_date),
+ DateUtils.getLocalDateStringFromTimestampForLobby(timestamp)
)
- } else {
- binding.lobby.lobbyTextView.setText(R.string.nc_lobby_waiting)
+ val relativeTime = DateUtils.relativeStartTimeForLobby(timestamp, resources!!)
+
+ sb.append("$stringWithStartDate - $relativeTime")
+ .append("\n\n")
}
+
+ sb.append(currentConversation!!.description)
+ binding.lobby.lobbyTextView.text = sb.toString()
} else {
binding.lobby.lobbyView.visibility = View.GONE
binding.messagesListView.visibility = View.VISIBLE
diff --git a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt
index afa477884..201ceb5fc 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt
+++ b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt
@@ -20,12 +20,26 @@
package com.nextcloud.talk.utils
+import android.content.res.Resources
+import android.icu.text.RelativeDateTimeFormatter
+import android.icu.text.RelativeDateTimeFormatter.Direction
+import android.icu.text.RelativeDateTimeFormatter.RelativeUnit
+import android.os.Build
+import com.nextcloud.talk.R
import java.text.DateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
+import kotlin.math.roundToInt
object DateUtils {
+
+ private const val TIMESTAMP_CORRECTION_MULTIPLIER = 1000
+ private const val SECOND_DIVIDER = 1000
+ private const val MINUTES_DIVIDER = 60
+ private const val HOURS_DIVIDER = 60
+ private const val DAYS_DIVIDER = 24
+
fun getLocalDateTimeStringFromTimestamp(timestamp: Long): String {
val cal = Calendar.getInstance()
val tz = cal.timeZone
@@ -41,6 +55,50 @@ object DateUtils {
}
fun getLocalDateStringFromTimestampForLobby(timestamp: Long): String {
- return getLocalDateTimeStringFromTimestamp(timestamp * 1000)
+ return getLocalDateTimeStringFromTimestamp(timestamp * TIMESTAMP_CORRECTION_MULTIPLIER)
+ }
+
+ fun relativeStartTimeForLobby(timestamp: Long, resources: Resources): String {
+
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ val fmt = RelativeDateTimeFormatter.getInstance()
+ val timeLeftMillis = timestamp * TIMESTAMP_CORRECTION_MULTIPLIER - System.currentTimeMillis()
+ val minutes = timeLeftMillis.toDouble() / SECOND_DIVIDER / MINUTES_DIVIDER
+ val hours = minutes / HOURS_DIVIDER
+ val days = hours / DAYS_DIVIDER
+
+ val minutesInt = minutes.roundToInt()
+ val hoursInt = hours.roundToInt()
+ val daysInt = days.roundToInt()
+
+ when {
+ daysInt > 0 -> {
+ fmt.format(
+ daysInt.toDouble(),
+ Direction.NEXT,
+ RelativeUnit.DAYS
+ )
+ }
+ hoursInt > 0 -> {
+ fmt.format(
+ hoursInt.toDouble(),
+ Direction.NEXT,
+ RelativeUnit.HOURS
+ )
+ }
+ minutesInt > 1 -> {
+ fmt.format(
+ minutesInt.toDouble(),
+ Direction.NEXT,
+ RelativeUnit.MINUTES
+ )
+ }
+ else -> {
+ resources.getString(R.string.nc_lobby_start_soon)
+ }
+ }
+ } else {
+ ""
+ }
}
}
diff --git a/app/src/main/res/layout/lobby_view.xml b/app/src/main/res/layout/lobby_view.xml
index d267090c3..d16c81011 100644
--- a/app/src/main/res/layout/lobby_view.xml
+++ b/app/src/main/res/layout/lobby_view.xml
@@ -47,6 +47,7 @@
android:text="@string/nc_lobby_waiting"
android:textAlignment="center"
android:textColor="@color/grey_600"
- android:textSize="16sp" />
+ android:textSize="16sp"
+ android:autoLink="web" />
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index eef004e35..08a95685e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -353,7 +353,8 @@
Lobby
Start time
You are currently waiting in the lobby.
- You are currently waiting in the lobby.\n This meeting is scheduled for %1$s.
+ This meeting is scheduled for %1$s
+ The meeting will start soon
Not set