Merge pull request #6123 from osmandapp/TelegramFixes

Telegram fixes
This commit is contained in:
Alexander Sytnyk 2018-10-02 17:51:59 +03:00 committed by GitHub
commit 492555ef6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View file

@ -147,7 +147,7 @@
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/hint_text_size"
app:typeface="@string/font_roboto_regular"
tools:text="@string/expire_in" />
tools:text="@string/expire_at" />
<net.osmand.telegram.ui.views.TextViewEx
android:id="@+id/ending_in_first_part"

View file

@ -35,7 +35,7 @@
<string name="send_my_location">Send my location</string>
<string name="gps_and_location">GPS &amp; location</string>
<string name="sharing_time">Sharing time</string>
<string name="expire_in">Expire at</string>
<string name="expire_at">Expire at</string>
<string name="stop_sharing_all">Sharing is enabled (disable)</string>
<string name="turn_off_location_sharing">Turn off location sharing</string>
<string name="open_osmand">Open OsmAnd</string>

View file

@ -31,6 +31,7 @@ class TelegramHelper private constructor() {
private const val DEVICE_PREFIX = "Device: "
private const val LOCATION_PREFIX = "Location: "
private const val LAST_LOCATION_PREFIX = "Last location: "
private const val UPDATED_PREFIX = "Updated: "
private const val FEW_SECONDS_AGO = "few seconds ago"
private const val SECONDS_AGO_SUFFIX = " seconds ago"
@ -796,7 +797,11 @@ class TelegramHelper private constructor() {
}
private fun TdApi.Message.isAppropriate(): Boolean {
if (isOutgoing || isChannelPost) {
if (isChannelPost) {
return false
}
val isOsmAndBot = isOsmAndBot(senderUserId) || isOsmAndBot(viaBotUserId)
if (isOutgoing && !isOsmAndBot) {
return false
}
val lastEdited = Math.max(date, editDate)
@ -806,8 +811,7 @@ class TelegramHelper private constructor() {
val content = content
return when (content) {
is TdApi.MessageLocation -> true
is TdApi.MessageText -> (isOsmAndBot(senderUserId) || isOsmAndBot(viaBotUserId))
&& content.text.text.startsWith(DEVICE_PREFIX)
is TdApi.MessageText -> (isOsmAndBot) && content.text.text.startsWith(DEVICE_PREFIX)
else -> false
}
}
@ -870,6 +874,13 @@ class TelegramHelper private constructor() {
}
}
}
s.startsWith(UPDATED_PREFIX) -> {
if (res.lastUpdated == 0) {
val updatedStr = s.removePrefix(UPDATED_PREFIX)
val updatedS = updatedStr.substring(0, updatedStr.indexOf("("))
res.lastUpdated = (parseTime(updatedS.trim()) / 1000).toInt()
}
}
}
}
return res

View file

@ -591,7 +591,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
holder.stopSharingDescr?.apply {
visibility = getStopSharingVisibility(expiresIn)
text = "${getText(R.string.expire_in)}:"
text = getText(R.string.expire_at)
}
holder.stopSharingFirstPart?.apply {