Increase location accuracy threshold and remove 15 sec check for my location

This commit is contained in:
Chumva 2019-02-04 13:47:17 +02:00
parent cc676a39ac
commit 84ac49e09b
2 changed files with 2 additions and 53 deletions

View file

@ -13,9 +13,7 @@ import org.json.JSONObject
private const val USER_SET_LIVE_PERIOD_DELAY_MS = 5000 // 5 sec
private const val MY_LOCATION_UPDATE_MS = 15000 // 15 sec
private const val UPDATE_LOCATION_ACCURACY = 30 // 30 meters
private const val UPDATE_LOCATION_ACCURACY = 150 // 150 meters
class ShareLocationHelper(private val app: TelegramApplication) {
@ -32,8 +30,6 @@ class ShareLocationHelper(private val app: TelegramApplication) {
var lastLocationUpdateTime: Long = 0
var lastMyLocationUpdateTime: Long = 0
var lastLocation: Location? = null
set(value) {
if (lastTimeInMillis == 0L) {
@ -227,10 +223,7 @@ class ShareLocationHelper(private val app: TelegramApplication) {
prepareMapAndTextMessage(shareInfo, message, isBot, sharingMode)
}
}
if (System.currentTimeMillis() - lastMyLocationUpdateTime > MY_LOCATION_UPDATE_MS) {
app.locationMessages.addMyLocationMessage(location)
lastMyLocationUpdateTime = System.currentTimeMillis()
}
app.locationMessages.addMyLocationMessage(location)
if (bufferedMessagesFull) {
checkNetworkType()
}

View file

@ -226,32 +226,6 @@ object TelegramUiHelper {
}
}
private fun gpxToGpxChatItem(
helper: TelegramHelper,
gpx: GPXFile
): GpxChatItem? {
val user = helper.getUser(gpx.userId) ?: return null
val chat = helper.getChat(gpx.chatId) ?: return null
return GpxChatItem().apply {
chatId = chat.id
chatTitle = chat.title
gpxFile = gpx
name = TelegramUiHelper.getUserName(user)
if (helper.isGroup(chat)) {
photoPath = helper.getUserPhotoPath(user)
groupPhotoPath = chat.photo?.small?.local?.path
} else {
photoPath = user.profilePhoto?.small?.local?.path
}
grayscalePhotoPath = helper.getUserGreyPhotoPath(user)
placeholderId = R.drawable.img_user_picture
userId = user.id
privateChat = helper.isPrivateChat(chat) || helper.isSecretChat(chat)
chatWithBot = helper.isBot(userId)
lastUpdated = (gpx.modifiedTime / 1000).toInt()
}
}
fun userLocationsToChatItem(helper: TelegramHelper, userLocation: LocationMessages.UserLocations): LocationMessagesChatItem? {
val user = helper.getUser(userLocation.userId)
val chat = helper.getChat(userLocation.chatId)
@ -328,24 +302,6 @@ object TelegramUiHelper {
override fun getVisibleName() = chatTitle
}
class GpxChatItem : ListItem() {
var gpxFile: GPXFile? = null
internal set
var groupPhotoPath: String? = null
internal set
var privateChat: Boolean = false
internal set
var chatWithBot: Boolean = false
internal set
override fun canBeOpenedOnMap() = latLon != null
override fun getMapPointId() = "${chatId}_$userId"
override fun getVisibleName() = chatTitle
}
class LocationMessagesChatItem : ListItem() {
var userLocations: LocationMessages.UserLocations? = null