Remove duplicate nav drawer items and disable live track for current user

This commit is contained in:
Chumva 2019-07-30 15:03:18 +03:00
parent 680e9c37b7
commit 71281f85b4
3 changed files with 21 additions and 7 deletions

View file

@ -42,9 +42,10 @@ 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) {
val otherPackage = if (applicationContext.packageName != "net.osmand.telegram") "net.osmand.telegram" else "net.osmand.telegram.debug"
osmandAidlHelper.setNavDrawerItems(
applicationContext.packageName,
listOf(getString(R.string.app_name_short)),
@ -52,6 +53,7 @@ class TelegramApplication : Application(), OsmandHelperListener {
listOf("ic_action_location_sharing_app"),
listOf(-1)
)
osmandAidlHelper.clearNavDrawerItems(otherPackage)
showLocationHelper.addDirectionContextMenuButton()
showLocationHelper.startShowingLocation()
}

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()
}
}
}
}