Merge pull request #7350 from osmandapp/TrackerImprovements

Tracker Improvements
This commit is contained in:
max-klaus 2019-07-30 15:26:11 +03:00 committed by GitHub
commit 5d97afcc3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View file

@ -42,9 +42,11 @@ class TelegramApplication : Application(), OsmandHelperListener {
telegramHelper.messageActiveTimeSec = settings.locHistoryTime
uiUtils = UiUtils(this)
osmandAidlHelper = OsmandAidlHelper(this)
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
osmandAidlHelper.listener = object : OsmandHelperListener {
override fun onOsmandConnectionStateChanged(connected: Boolean) {
if (connected) {
osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram")
osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram.debug")
osmandAidlHelper.setNavDrawerItems(
applicationContext.packageName,
listOf(getString(R.string.app_name_short)),

View file

@ -1043,6 +1043,16 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
return false
}
fun clearNavDrawerItems(appPackage: String): Boolean {
if (mIOsmAndAidlInterface != null) {
try {
return mIOsmAndAidlInterface!!.setNavDrawerItems(SetNavDrawerItemsParams(appPackage, emptyList()))
} catch (e: RemoteException) {
e.printStackTrace()
}
}
return false
}
/**
* Put navigation on pause.

View file

@ -156,12 +156,14 @@ class UserGpxInfoFragment : BaseDialogFragment() {
updateDateAndTimeButton()
liveBtn = mainView.findViewById<TextView>(R.id.live_btn).apply {
setOnClickListener {
val enabled = !liveTrackEnabled()
settings.updateLiveTrack(userId, chatId, deviceName, enabled)
updateLiveTrackBtn()
if (enabled) {
startHandler()
if (userId != telegramHelper.getCurrentUserId()) {
setOnClickListener {
val enabled = !liveTrackEnabled()
settings.updateLiveTrack(userId, chatId, deviceName, enabled)
updateLiveTrackBtn()
if (enabled) {
startHandler()
}
}
}
}