Сщтмуке hardcoded value to the const

This commit is contained in:
Alex Sytnyk 2018-07-03 12:00:37 +03:00
parent b1d2b0de45
commit a8ee0e0fa6
2 changed files with 9 additions and 5 deletions

View file

@ -4,8 +4,6 @@ import net.osmand.Location
import net.osmand.telegram.TelegramApplication import net.osmand.telegram.TelegramApplication
import net.osmand.telegram.notifications.TelegramNotification.NotificationType import net.osmand.telegram.notifications.TelegramNotification.NotificationType
private const val MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC = 60 * 60 * 24 - 1 // day
class ShareLocationHelper(private val app: TelegramApplication) { class ShareLocationHelper(private val app: TelegramApplication) {
var sharingLocation: Boolean = false var sharingLocation: Boolean = false
@ -90,4 +88,10 @@ class ShareLocationHelper(private val app: TelegramApplication) {
app.notificationHelper.refreshNotification(NotificationType.LOCATION) app.notificationHelper.refreshNotification(NotificationType.LOCATION)
} }
} }
companion object {
const val MIN_LOCATION_MESSAGE_LIVE_PERIOD_SEC = 61
const val MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC = 60 * 60 * 24 - 1 // one day
}
} }

View file

@ -370,7 +370,7 @@ class TelegramHelper private constructor() {
* @latitude Latitude of the location * @latitude Latitude of the location
* @longitude Longitude of the location * @longitude Longitude of the location
*/ */
fun sendLiveLocationMessage(chatTitles: List<String>, livePeriod: Int = 61, latitude: Double, longitude: Double): Boolean { fun sendLiveLocationMessage(chatTitles: List<String>, livePeriod: Int, latitude: Double, longitude: Double): Boolean {
if (!requestingActiveLiveLocationMessages && haveAuthorization) { if (!requestingActiveLiveLocationMessages && haveAuthorization) {
if (needRefreshActiveLiveLocationMessages) { if (needRefreshActiveLiveLocationMessages) {
getActiveLiveLocationMessages { getActiveLiveLocationMessages {
@ -413,8 +413,8 @@ class TelegramHelper private constructor() {
} }
} }
private fun sendLiveLocationImpl(chatTitles: List<String>, livePeriod: Int = 61, latitude: Double, longitude: Double) { private fun sendLiveLocationImpl(chatTitles: List<String>, livePeriod: Int, latitude: Double, longitude: Double) {
val lp = livePeriod.coerceAtLeast(61) val lp = livePeriod.coerceAtLeast(ShareLocationHelper.MIN_LOCATION_MESSAGE_LIVE_PERIOD_SEC)
val location = TdApi.Location(latitude, longitude) val location = TdApi.Location(latitude, longitude)
val content = TdApi.InputMessageLocation(location, lp) val content = TdApi.InputMessageLocation(location, lp)