Fix gps on after sharing finished
This commit is contained in:
parent
874bb9f08d
commit
ca876dbd84
2 changed files with 18 additions and 15 deletions
|
@ -64,11 +64,13 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
if (usedBy and usageIntent > 0) {
|
||||
usedBy -= usageIntent
|
||||
}
|
||||
if (usedBy == 0) {
|
||||
when {
|
||||
usedBy == 0 -> {
|
||||
shouldCleanupResources = false
|
||||
val serviceIntent = Intent(ctx, TelegramService::class.java)
|
||||
ctx.stopService(serviceIntent)
|
||||
} else if (isUsedByMyLocation(usedBy)) {
|
||||
}
|
||||
isUsedByMyLocation(usedBy) -> {
|
||||
val app = app()
|
||||
if (app.settings.sendMyLocInterval >= OFF_INTERVAL_THRESHOLD && serviceOffInterval == 0L) {
|
||||
serviceOffInterval = app.settings.sendMyLocInterval
|
||||
|
@ -77,12 +79,15 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
}
|
||||
app.notificationHelper.refreshNotification(NotificationType.LOCATION)
|
||||
}
|
||||
isUsedByUsersLocations(usedBy) -> removeLocationUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
val app = app()
|
||||
handler = Handler()
|
||||
usedBy = intent.getIntExtra(USAGE_INTENT, 0)
|
||||
val usageIntent = intent.getIntExtra(USAGE_INTENT, 0)
|
||||
usedBy = usageIntent or usedBy
|
||||
|
||||
serviceOffInterval = intent.getLongExtra(USAGE_OFF_INTERVAL, 0)
|
||||
sendLocationInterval = intent.getLongExtra(SEND_LOCATION_INTERVAL, 0)
|
||||
|
@ -259,10 +264,8 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
|
|||
Toast.makeText(this, getString(R.string.location_service_no_gps_available), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
|
||||
override fun onProviderEnabled(provider: String) {}
|
||||
|
||||
|
||||
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent) {
|
||||
|
|
|
@ -45,7 +45,7 @@ private const val TIMELINE_TAB_POS = 2
|
|||
|
||||
class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListener, TelegramIncomingMessagesListener {
|
||||
|
||||
private val log = PlatformUtil.getLog(TelegramHelper::class.java)
|
||||
private val log = PlatformUtil.getLog(MainActivity::class.java)
|
||||
|
||||
private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null
|
||||
private var paused: Boolean = false
|
||||
|
|
Loading…
Reference in a new issue