mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Merge pull request #1589 from nextcloud/feature/1557/show-lobby-timer-and-description-in-lobby-screen
Show lobby timer and description in lobby screen
This commit is contained in:
commit
f96392d05c
@ -1119,19 +1119,26 @@ class ChatController(args: Bundle) :
|
|||||||
binding.messageInputView.visibility = View.GONE
|
binding.messageInputView.visibility = View.GONE
|
||||||
binding.progressBar.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 !=
|
if (currentConversation?.lobbyTimer != null && currentConversation?.lobbyTimer !=
|
||||||
0L
|
0L
|
||||||
) {
|
) {
|
||||||
binding.lobby.lobbyTextView.text = String.format(
|
val timestamp = currentConversation?.lobbyTimer ?: 0
|
||||||
resources!!.getString(R.string.nc_lobby_waiting_with_date),
|
val stringWithStartDate = String.format(
|
||||||
DateUtils.getLocalDateStringFromTimestampForLobby(
|
resources!!.getString(R.string.nc_lobby_start_date),
|
||||||
currentConversation?.lobbyTimer
|
DateUtils.getLocalDateStringFromTimestampForLobby(timestamp)
|
||||||
?: 0
|
|
||||||
)
|
)
|
||||||
)
|
val relativeTime = DateUtils.relativeStartTimeForLobby(timestamp, resources!!)
|
||||||
} else {
|
|
||||||
binding.lobby.lobbyTextView.setText(R.string.nc_lobby_waiting)
|
sb.append("$stringWithStartDate - $relativeTime")
|
||||||
|
.append("\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.append(currentConversation!!.description)
|
||||||
|
binding.lobby.lobbyTextView.text = sb.toString()
|
||||||
} else {
|
} else {
|
||||||
binding.lobby.lobbyView.visibility = View.GONE
|
binding.lobby.lobbyView.visibility = View.GONE
|
||||||
binding.messagesListView.visibility = View.VISIBLE
|
binding.messagesListView.visibility = View.VISIBLE
|
||||||
|
@ -20,12 +20,26 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.utils
|
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.text.DateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
object DateUtils {
|
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 {
|
fun getLocalDateTimeStringFromTimestamp(timestamp: Long): String {
|
||||||
val cal = Calendar.getInstance()
|
val cal = Calendar.getInstance()
|
||||||
val tz = cal.timeZone
|
val tz = cal.timeZone
|
||||||
@ -41,6 +55,50 @@ object DateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getLocalDateStringFromTimestampForLobby(timestamp: Long): String {
|
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 {
|
||||||
|
""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
android:text="@string/nc_lobby_waiting"
|
android:text="@string/nc_lobby_waiting"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/grey_600"
|
android:textColor="@color/grey_600"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp"
|
||||||
|
android:autoLink="web" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -353,7 +353,8 @@
|
|||||||
<string name="nc_lobby">Lobby</string>
|
<string name="nc_lobby">Lobby</string>
|
||||||
<string name="nc_start_time">Start time</string>
|
<string name="nc_start_time">Start time</string>
|
||||||
<string name="nc_lobby_waiting">You are currently waiting in the lobby.</string>
|
<string name="nc_lobby_waiting">You are currently waiting in the lobby.</string>
|
||||||
<string name="nc_lobby_waiting_with_date">You are currently waiting in the lobby.\n This meeting is scheduled for %1$s.</string>
|
<string name="nc_lobby_start_date">This meeting is scheduled for %1$s</string>
|
||||||
|
<string name="nc_lobby_start_soon">The meeting will start soon</string>
|
||||||
<string name="nc_manual">Not set</string>
|
<string name="nc_manual">Not set</string>
|
||||||
|
|
||||||
<!-- Errors -->
|
<!-- Errors -->
|
||||||
|
Loading…
Reference in New Issue
Block a user