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 telegramHelper.messageActiveTimeSec = settings.locHistoryTime
uiUtils = UiUtils(this) uiUtils = UiUtils(this)
osmandAidlHelper = OsmandAidlHelper(this) osmandAidlHelper = OsmandAidlHelper(this)
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener { osmandAidlHelper.listener = object : OsmandHelperListener {
override fun onOsmandConnectionStateChanged(connected: Boolean) { override fun onOsmandConnectionStateChanged(connected: Boolean) {
if (connected) { if (connected) {
osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram")
osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram.debug")
osmandAidlHelper.setNavDrawerItems( osmandAidlHelper.setNavDrawerItems(
applicationContext.packageName, applicationContext.packageName,
listOf(getString(R.string.app_name_short)), listOf(getString(R.string.app_name_short)),

View file

@ -1043,6 +1043,16 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
return false 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. * Put navigation on pause.

View file

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