Merge pull request #6358 from osmandapp/TelegramSharingImprovements
Add sharing link
This commit is contained in:
commit
35270d2b59
1 changed files with 12 additions and 3 deletions
|
@ -42,6 +42,8 @@ class TelegramHelper private constructor() {
|
||||||
private const val UPDATED_PREFIX = "Updated: "
|
private const val UPDATED_PREFIX = "Updated: "
|
||||||
private const val USER_TEXT_LOCATION_TITLE = "\uD83D\uDDFA OsmAnd sharing:"
|
private const val USER_TEXT_LOCATION_TITLE = "\uD83D\uDDFA OsmAnd sharing:"
|
||||||
|
|
||||||
|
private const val SHARING_LINK = "https://play.google.com/store/apps/details?id=net.osmand.telegram"
|
||||||
|
|
||||||
private const val ALTITUDE_PREFIX = "Altitude: "
|
private const val ALTITUDE_PREFIX = "Altitude: "
|
||||||
private const val SPEED_PREFIX = "Speed: "
|
private const val SPEED_PREFIX = "Speed: "
|
||||||
private const val HDOP_PREFIX = "Horizontal precision: "
|
private const val HDOP_PREFIX = "Horizontal precision: "
|
||||||
|
@ -933,8 +935,9 @@ class TelegramHelper private constructor() {
|
||||||
val builder = StringBuilder()
|
val builder = StringBuilder()
|
||||||
val locationMessage = formatLocation(location)
|
val locationMessage = formatLocation(location)
|
||||||
|
|
||||||
entities.add(TdApi.TextEntity(builder.length, USER_TEXT_LOCATION_TITLE.length,
|
val firstSpace = USER_TEXT_LOCATION_TITLE.indexOf(' ')
|
||||||
TdApi.TextEntityTypeTextUrl("https://play.google.com/store/apps/details?id=net.osmand.telegram")))
|
val secondSpace = USER_TEXT_LOCATION_TITLE.indexOf(' ', firstSpace + 1)
|
||||||
|
entities.add(TdApi.TextEntity(builder.length + firstSpace + 1, secondSpace - firstSpace, TdApi.TextEntityTypeTextUrl(SHARING_LINK)))
|
||||||
builder.append("$USER_TEXT_LOCATION_TITLE\n")
|
builder.append("$USER_TEXT_LOCATION_TITLE\n")
|
||||||
|
|
||||||
entities.add(TdApi.TextEntity(builder.lastIndex, LOCATION_PREFIX.length, TdApi.TextEntityTypeBold()))
|
entities.add(TdApi.TextEntity(builder.lastIndex, LOCATION_PREFIX.length, TdApi.TextEntityTypeBold()))
|
||||||
|
@ -963,7 +966,7 @@ class TelegramHelper private constructor() {
|
||||||
}
|
}
|
||||||
val textMessage = builder.toString().trim()
|
val textMessage = builder.toString().trim()
|
||||||
|
|
||||||
return TdApi.InputMessageText(TdApi.FormattedText(textMessage, entities.toTypedArray()), false, true)
|
return TdApi.InputMessageText(TdApi.FormattedText(textMessage, entities.toTypedArray()), true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1170,6 +1173,12 @@ class TelegramHelper private constructor() {
|
||||||
val (latS, lonS) = locStr.split(" ")
|
val (latS, lonS) = locStr.split(" ")
|
||||||
res.lat = latS.dropLast(1).toDouble()
|
res.lat = latS.dropLast(1).toDouble()
|
||||||
res.lon = lonS.toDouble()
|
res.lon = lonS.toDouble()
|
||||||
|
|
||||||
|
val timeIndex = locStr.indexOf("(")
|
||||||
|
if (timeIndex != -1) {
|
||||||
|
val updatedS = locStr.substring(timeIndex, locStr.length)
|
||||||
|
res.lastUpdated = (parseTime(updatedS.removePrefix("(").removeSuffix(")")) / 1000).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
Loading…
Reference in a new issue