change live to last response
This commit is contained in:
parent
d5842c2bc3
commit
e668e12143
3 changed files with 27 additions and 24 deletions
|
@ -1,4 +1,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="last_response">Last response</string>
|
||||||
<string name="shared_string_group">Group</string>
|
<string name="shared_string_group">Group</string>
|
||||||
<string name="logout_no_internet_msg">To properly log out from your Telegram account, the Internet is needed.</string>
|
<string name="logout_no_internet_msg">To properly log out from your Telegram account, the Internet is needed.</string>
|
||||||
<string name="shared_string_close">Close</string>
|
<string name="shared_string_close">Close</string>
|
||||||
|
|
|
@ -362,11 +362,11 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getListItemLiveTimeDescr(item: ListItem):String {
|
private fun getListItemLiveTimeDescr(item: ListItem):String {
|
||||||
return getString(R.string.shared_string_live) +
|
return getString(R.string.last_response) +
|
||||||
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(item))}"
|
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(item))}"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getListItemLiveTime(item: ListItem): Long = (System.currentTimeMillis() / 1000) - item.created
|
private fun getListItemLiveTime(item: ListItem): Long = (System.currentTimeMillis() / 1000) - item.lastUpdated
|
||||||
|
|
||||||
private fun showPopupMenu(holder: ChatViewHolder, chatId: Long) {
|
private fun showPopupMenu(holder: ChatViewHolder, chatId: Long) {
|
||||||
val ctx = holder.itemView.context
|
val ctx = holder.itemView.context
|
||||||
|
|
|
@ -283,26 +283,26 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
|
||||||
holder.description?.text = getString(R.string.shared_string_group)
|
holder.description?.text = getString(R.string.shared_string_group)
|
||||||
} else {
|
} else {
|
||||||
val message = telegramHelper.getChatMessages(chat.id).firstOrNull()
|
val message = telegramHelper.getChatMessages(chat.id).firstOrNull()
|
||||||
if (message != null) {
|
val content = message?.content
|
||||||
val content = message.content
|
if (message != null && content is TdApi.MessageLocation && (location != null && content.location != null)) {
|
||||||
if (content is TdApi.MessageLocation && (location != null && content.location != null)) {
|
val lastUpdated = if (message.editDate != 0) {
|
||||||
holder.description?.visibility = View.VISIBLE
|
message.editDate
|
||||||
holder.description?.text = getListItemLiveTimeDescr(message)
|
|
||||||
|
|
||||||
holder.locationViewContainer?.visibility = View.VISIBLE
|
|
||||||
locationViewCache.outdatedLocation = System.currentTimeMillis() / 1000 -
|
|
||||||
message.editDate > settings.staleLocTime
|
|
||||||
|
|
||||||
app.uiUtils.updateLocationView(
|
|
||||||
holder.directionIcon,
|
|
||||||
holder.distanceText,
|
|
||||||
LatLon(content.location.latitude, content.location.longitude),
|
|
||||||
locationViewCache
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
holder.locationViewContainer?.visibility = View.GONE
|
message.date
|
||||||
holder.description?.visibility = View.INVISIBLE
|
|
||||||
}
|
}
|
||||||
|
holder.description?.visibility = View.VISIBLE
|
||||||
|
holder.description?.text = getListItemLiveTimeDescr(lastUpdated)
|
||||||
|
|
||||||
|
holder.locationViewContainer?.visibility = View.VISIBLE
|
||||||
|
locationViewCache.outdatedLocation = System.currentTimeMillis() / 1000 -
|
||||||
|
lastUpdated > settings.staleLocTime
|
||||||
|
|
||||||
|
app.uiUtils.updateLocationView(
|
||||||
|
holder.directionIcon,
|
||||||
|
holder.distanceText,
|
||||||
|
LatLon(content.location.latitude, content.location.longitude),
|
||||||
|
locationViewCache
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
holder.locationViewContainer?.visibility = View.GONE
|
holder.locationViewContainer?.visibility = View.GONE
|
||||||
holder.description?.visibility = View.INVISIBLE
|
holder.description?.visibility = View.INVISIBLE
|
||||||
|
@ -321,12 +321,14 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
|
||||||
|
|
||||||
override fun getItemCount() = chats.size
|
override fun getItemCount() = chats.size
|
||||||
|
|
||||||
private fun getListItemLiveTimeDescr(message: TdApi.Message): String {
|
private fun getListItemLiveTimeDescr(lastUpdated: Int): String {
|
||||||
return getString(R.string.shared_string_live) +
|
return getString(R.string.last_response) +
|
||||||
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(message))}"
|
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(lastUpdated))}"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getListItemLiveTime(message: TdApi.Message): Long = (System.currentTimeMillis() / 1000) - message.date
|
private fun getListItemLiveTime(lastUpdated: Int): Long {
|
||||||
|
return (System.currentTimeMillis() / 1000) - lastUpdated
|
||||||
|
}
|
||||||
|
|
||||||
inner class ChatViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
|
inner class ChatViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
|
||||||
val icon: ImageView? = view.findViewById(R.id.icon)
|
val icon: ImageView? = view.findViewById(R.id.icon)
|
||||||
|
|
Loading…
Reference in a new issue