From 9618057e872b8995cd32e9f284bfa493109588f8 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Nov 2019 22:05:42 +0200 Subject: [PATCH] Enable old aidl api for tracker --- OsmAnd-telegram/build.gradle | 1 - .../telegram/helpers/OsmandAidlHelper.kt | 94 +++++++++++-------- .../telegram/helpers/ShowLocationHelper.kt | 10 +- .../osmand/telegram/ui/UserGpxInfoFragment.kt | 2 +- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/OsmAnd-telegram/build.gradle b/OsmAnd-telegram/build.gradle index f2152adba9..4b215af1ad 100644 --- a/OsmAnd-telegram/build.gradle +++ b/OsmAnd-telegram/build.gradle @@ -138,7 +138,6 @@ afterEvaluate { dependencies { implementation project(path: ':OsmAnd-java', configuration: 'android') implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(':OsmAnd-api') implementation( "org.jetbrains.kotlin:kotlin-stdlib:1.2.71") { exclude group: 'org.jetbrains', module: 'annotations' diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt index 456cd1f8fe..6ff7d5fe80 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt @@ -7,44 +7,44 @@ import android.content.ServiceConnection import android.net.Uri import android.os.IBinder import android.os.RemoteException -import net.osmand.aidlapi.IOsmAndAidlCallback -import net.osmand.aidlapi.IOsmAndAidlInterface -import net.osmand.aidlapi.contextmenu.AContextMenuButton -import net.osmand.aidlapi.contextmenu.ContextMenuButtonsParams -import net.osmand.aidlapi.contextmenu.RemoveContextMenuButtonsParams -import net.osmand.aidlapi.favorite.AFavorite -import net.osmand.aidlapi.favorite.AddFavoriteParams -import net.osmand.aidlapi.favorite.RemoveFavoriteParams -import net.osmand.aidlapi.favorite.UpdateFavoriteParams -import net.osmand.aidlapi.favorite.group.AFavoriteGroup -import net.osmand.aidlapi.favorite.group.AddFavoriteGroupParams -import net.osmand.aidlapi.favorite.group.RemoveFavoriteGroupParams -import net.osmand.aidlapi.favorite.group.UpdateFavoriteGroupParams -import net.osmand.aidlapi.gpx.* -import net.osmand.aidlapi.map.ALatLon -import net.osmand.aidlapi.map.SetMapLocationParams -import net.osmand.aidlapi.maplayer.AMapLayer -import net.osmand.aidlapi.maplayer.AddMapLayerParams -import net.osmand.aidlapi.maplayer.RemoveMapLayerParams -import net.osmand.aidlapi.maplayer.UpdateMapLayerParams -import net.osmand.aidlapi.maplayer.point.* -import net.osmand.aidlapi.mapmarker.AMapMarker -import net.osmand.aidlapi.mapmarker.AddMapMarkerParams -import net.osmand.aidlapi.mapmarker.RemoveMapMarkerParams -import net.osmand.aidlapi.mapmarker.UpdateMapMarkerParams -import net.osmand.aidlapi.mapwidget.AMapWidget -import net.osmand.aidlapi.mapwidget.AddMapWidgetParams -import net.osmand.aidlapi.mapwidget.RemoveMapWidgetParams -import net.osmand.aidlapi.mapwidget.UpdateMapWidgetParams -import net.osmand.aidlapi.navdrawer.NavDrawerItem -import net.osmand.aidlapi.navdrawer.SetNavDrawerItemsParams -import net.osmand.aidlapi.navigation.* -import net.osmand.aidlapi.note.StartAudioRecordingParams -import net.osmand.aidlapi.note.StartVideoRecordingParams -import net.osmand.aidlapi.note.StopRecordingParams -import net.osmand.aidlapi.note.TakePhotoNoteParams -import net.osmand.aidlapi.search.SearchParams -import net.osmand.aidlapi.search.SearchResult +import net.osmand.aidl.IOsmAndAidlCallback +import net.osmand.aidl.IOsmAndAidlInterface +import net.osmand.aidl.contextmenu.AContextMenuButton +import net.osmand.aidl.contextmenu.ContextMenuButtonsParams +import net.osmand.aidl.contextmenu.RemoveContextMenuButtonsParams +import net.osmand.aidl.favorite.AFavorite +import net.osmand.aidl.favorite.AddFavoriteParams +import net.osmand.aidl.favorite.RemoveFavoriteParams +import net.osmand.aidl.favorite.UpdateFavoriteParams +import net.osmand.aidl.favorite.group.AFavoriteGroup +import net.osmand.aidl.favorite.group.AddFavoriteGroupParams +import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams +import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams +import net.osmand.aidl.gpx.* +import net.osmand.aidl.map.ALatLon +import net.osmand.aidl.map.SetMapLocationParams +import net.osmand.aidl.maplayer.AMapLayer +import net.osmand.aidl.maplayer.AddMapLayerParams +import net.osmand.aidl.maplayer.RemoveMapLayerParams +import net.osmand.aidl.maplayer.UpdateMapLayerParams +import net.osmand.aidl.maplayer.point.* +import net.osmand.aidl.mapmarker.AMapMarker +import net.osmand.aidl.mapmarker.AddMapMarkerParams +import net.osmand.aidl.mapmarker.RemoveMapMarkerParams +import net.osmand.aidl.mapmarker.UpdateMapMarkerParams +import net.osmand.aidl.mapwidget.AMapWidget +import net.osmand.aidl.mapwidget.AddMapWidgetParams +import net.osmand.aidl.mapwidget.RemoveMapWidgetParams +import net.osmand.aidl.mapwidget.UpdateMapWidgetParams +import net.osmand.aidl.navdrawer.NavDrawerItem +import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams +import net.osmand.aidl.navigation.* +import net.osmand.aidl.note.StartAudioRecordingParams +import net.osmand.aidl.note.StartVideoRecordingParams +import net.osmand.aidl.note.StopRecordingParams +import net.osmand.aidl.note.TakePhotoNoteParams +import net.osmand.aidl.search.SearchParams +import net.osmand.aidl.search.SearchResult import net.osmand.telegram.TelegramApplication import net.osmand.telegram.helpers.ShowLocationHelper.Companion.MAP_LAYER_ID import java.io.File @@ -263,7 +263,7 @@ class OsmandAidlHelper(private val app: TelegramApplication) { private fun bindService(packageName: String): Boolean { return if (mIOsmAndAidlInterface == null) { - val intent = Intent("net.osmand.aidl.OsmandAidlServiceV2") + val intent = Intent("net.osmand.aidl.OsmandAidlService") intent.`package` = packageName app.bindService(intent, mConnection, Context.BIND_AUTO_CREATE) } else { @@ -1231,4 +1231,18 @@ class OsmandAidlHelper(private val app: TelegramApplication) { } return false } -} \ No newline at end of file + + fun getGpxColor(filename: String): String? { + if (mIOsmAndAidlInterface != null) { + try { + val gpxColorParams = GpxColorParams(filename) + if (mIOsmAndAidlInterface!!.getGpxColor(gpxColorParams)) { + return gpxColorParams.gpxColor + } + } catch (e: RemoteException) { + e.printStackTrace() + } + } + return null + } +} diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index f93b7c7aa9..b5dac721f1 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -6,10 +6,10 @@ import android.os.AsyncTask import android.text.TextUtils import net.osmand.GPXUtilities import net.osmand.PlatformUtil -import net.osmand.aidlapi.gpx.AGpxFile -import net.osmand.aidlapi.map.ALatLon -import net.osmand.aidlapi.maplayer.point.AMapPoint -import net.osmand.aidlapi.mapmarker.AMapMarker +import net.osmand.aidl.gpx.AGpxFile +import net.osmand.aidl.map.ALatLon +import net.osmand.aidl.maplayer.point.AMapPoint +import net.osmand.aidl.mapmarker.AMapMarker import net.osmand.telegram.R import net.osmand.telegram.TelegramApplication import net.osmand.telegram.helpers.OsmandAidlHelper.ContextMenuButtonsListener @@ -301,7 +301,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { val aGpxFile = importedGpxFiles.firstOrNull { it.fileName == name } if (aGpxFile != null) { - val color = aGpxFile.color + val color = osmandAidlHelper.getGpxColor(aGpxFile.fileName) if (!color.isNullOrEmpty()) { gpxFile.extensionsToWrite["color"] = color } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt index 355c4916a1..2e8d6d381c 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/UserGpxInfoFragment.kt @@ -24,7 +24,7 @@ import android.widget.TextView import android.widget.Toast import net.osmand.GPXUtilities import net.osmand.PlatformUtil -import net.osmand.aidlapi.gpx.AGpxBitmap +import net.osmand.aidl.gpx.AGpxBitmap import net.osmand.telegram.R import net.osmand.telegram.TelegramApplication import net.osmand.telegram.TelegramSettings