change live to last response

This commit is contained in:
Chumva 2018-08-16 12:43:47 +03:00
parent d5842c2bc3
commit e668e12143
3 changed files with 27 additions and 24 deletions

View file

@ -1,4 +1,5 @@
<resources>
<string name="last_response">Last response</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="shared_string_close">Close</string>

View file

@ -362,11 +362,11 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
}
private fun getListItemLiveTimeDescr(item: ListItem):String {
return getString(R.string.shared_string_live) +
return getString(R.string.last_response) +
": ${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) {
val ctx = holder.itemView.context

View file

@ -283,15 +283,19 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
holder.description?.text = getString(R.string.shared_string_group)
} else {
val message = telegramHelper.getChatMessages(chat.id).firstOrNull()
if (message != null) {
val content = message.content
if (content is TdApi.MessageLocation && (location != null && content.location != null)) {
val content = message?.content
if (message != null && content is TdApi.MessageLocation && (location != null && content.location != null)) {
val lastUpdated = if (message.editDate != 0) {
message.editDate
} else {
message.date
}
holder.description?.visibility = View.VISIBLE
holder.description?.text = getListItemLiveTimeDescr(message)
holder.description?.text = getListItemLiveTimeDescr(lastUpdated)
holder.locationViewContainer?.visibility = View.VISIBLE
locationViewCache.outdatedLocation = System.currentTimeMillis() / 1000 -
message.editDate > settings.staleLocTime
lastUpdated > settings.staleLocTime
app.uiUtils.updateLocationView(
holder.directionIcon,
@ -303,10 +307,6 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
holder.locationViewContainer?.visibility = View.GONE
holder.description?.visibility = View.INVISIBLE
}
} else {
holder.locationViewContainer?.visibility = View.GONE
holder.description?.visibility = View.INVISIBLE
}
}
holder.textInArea?.apply {
@ -321,12 +321,14 @@ class SetTimeDialogFragment : DialogFragment(), TelegramLocationListener, Telegr
override fun getItemCount() = chats.size
private fun getListItemLiveTimeDescr(message: TdApi.Message): String {
return getString(R.string.shared_string_live) +
": ${OsmandFormatter.getFormattedDuration(app, getListItemLiveTime(message))}"
private fun getListItemLiveTimeDescr(lastUpdated: Int): String {
return getString(R.string.last_response) +
": ${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) {
val icon: ImageView? = view.findViewById(R.id.icon)