diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt index 1ea767f072..456cd1f8fe 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt @@ -1231,18 +1231,4 @@ class OsmandAidlHelper(private val app: TelegramApplication) { } return false } - - 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 - } -} +} \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index 1b1d8f936b..f93b7c7aa9 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -301,7 +301,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { val aGpxFile = importedGpxFiles.firstOrNull { it.fileName == name } if (aGpxFile != null) { - val color = osmandAidlHelper.getGpxColor(aGpxFile.fileName) + val color = aGpxFile.color if (!color.isNullOrEmpty()) { gpxFile.extensionsToWrite["color"] = color } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 469c1ec6bf..240bf76580 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -109,15 +109,17 @@ import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_PART_SIZE_LIMIT_E import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR; import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR; import static net.osmand.aidlapi.OsmandAidlConstants.OK_RESPONSE; -import static net.osmand.aidl.OsmandAidlService.KEY_ON_CONTEXT_MENU_BUTTONS_CLICK; -import static net.osmand.aidl.OsmandAidlService.KEY_ON_NAV_DATA_UPDATE; -import static net.osmand.aidl.OsmandAidlService.KEY_ON_VOICE_MESSAGE; public class OsmandAidlApi { AidlCallbackListener aidlCallbackListener = null; AidlCallbackListenerV2 aidlCallbackListenerV2 = null; + public static final int KEY_ON_UPDATE = 1; + public static final int KEY_ON_NAV_DATA_UPDATE = 2; + public static final int KEY_ON_CONTEXT_MENU_BUTTONS_CLICK = 4; + public static final int KEY_ON_VOICE_MESSAGE = 5; + private static final Log LOG = PlatformUtil.getLog(OsmandAidlApi.class); private static final String AIDL_REFRESH_MAP = "aidl_refresh_map"; private static final String AIDL_SET_MAP_LOCATION = "aidl_set_map_location"; @@ -1441,12 +1443,17 @@ public class OsmandAidlApi { boolean active = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath()) != null; long modifiedTime = dataItem.getFileLastModifiedTime(); long fileSize = file.length(); + int color = dataItem.getColor(); + String colorName = ""; + if (color != 0) { + colorName = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColorName(app.getRendererRegistry().getCurrentSelectedRenderer(), color); + } net.osmand.aidlapi.gpx.AGpxFileDetails details = null; GPXTrackAnalysis analysis = dataItem.getAnalysis(); if (analysis != null) { details = createGpxFileDetailsV2(analysis); } - files.add(new net.osmand.aidlapi.gpx.AGpxFile(fileName, modifiedTime, fileSize, active, details)); + files.add(new net.osmand.aidlapi.gpx.AGpxFile(fileName, modifiedTime, fileSize, active, colorName, details)); } } return true; diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java index a0533c6e5d..d382439fff 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlService.java @@ -94,6 +94,10 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_CONTEXT_MENU_BUTTONS_CLICK; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_NAV_DATA_UPDATE; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_UPDATE; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_VOICE_MESSAGE; import static net.osmand.aidlapi.OsmandAidlConstants.CANNOT_ACCESS_API_ERROR; import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS; import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR; @@ -103,11 +107,6 @@ public class OsmandAidlService extends Service implements AidlCallbackListener { private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class); - public static final int KEY_ON_UPDATE = 1; - public static final int KEY_ON_NAV_DATA_UPDATE = 2; - public static final int KEY_ON_CONTEXT_MENU_BUTTONS_CLICK = 4; - public static final int KEY_ON_VOICE_MESSAGE = 5; - private Map callbacks = new ConcurrentHashMap<>(); private Handler mHandler = null; HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread"); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index ad153d58ff..728c1a0553 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -37,7 +37,6 @@ import net.osmand.aidlapi.gpx.AGpxBitmap; import net.osmand.aidlapi.gpx.AGpxFile; import net.osmand.aidlapi.gpx.ASelectedGpxFile; import net.osmand.aidlapi.gpx.CreateGpxBitmapParams; -import net.osmand.aidlapi.gpx.GpxColorParams; import net.osmand.aidlapi.gpx.HideGpxParams; import net.osmand.aidlapi.gpx.ImportGpxParams; import net.osmand.aidlapi.gpx.RemoveGpxParams; @@ -96,6 +95,10 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_CONTEXT_MENU_BUTTONS_CLICK; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_NAV_DATA_UPDATE; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_UPDATE; +import static net.osmand.aidl.OsmandAidlApi.KEY_ON_VOICE_MESSAGE; import static net.osmand.aidlapi.OsmandAidlConstants.CANNOT_ACCESS_API_ERROR; import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS; import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR; @@ -105,11 +108,6 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class); - public static final int KEY_ON_UPDATE = 1; - public static final int KEY_ON_NAV_DATA_UPDATE = 2; - public static final int KEY_ON_CONTEXT_MENU_BUTTONS_CLICK = 4; - public static final int KEY_ON_VOICE_MESSAGE = 5; - private Map callbacks = new ConcurrentHashMap<>(); private Handler mHandler = null; HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceV2Thread"); @@ -1210,21 +1208,6 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener return false; } } - - @Override - public boolean getGpxColor(GpxColorParams params) { - try { - OsmandAidlApi api = getApi("getGpxColor"); - if (api != null && params != null) { - String colorName = api.getGpxColor(params.getFileName()); - params.setGpxColor(colorName); - } - return false; - } catch (Exception e) { - handleException(e); - return false; - } - } }; private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) { diff --git a/osmand-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl b/osmand-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl index e8729e3a40..702904584d 100644 --- a/osmand-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl +++ b/osmand-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl @@ -77,7 +77,6 @@ import net.osmand.aidlapi.customization.CustomizationInfoParams; import net.osmand.aidlapi.gpx.AGpxFile; import net.osmand.aidlapi.gpx.AGpxFileDetails; import net.osmand.aidlapi.gpx.CreateGpxBitmapParams; -import net.osmand.aidlapi.gpx.GpxColorParams; import net.osmand.aidlapi.tiles.ASqliteDbFile; @@ -832,18 +831,4 @@ interface IOsmAndAidlInterface { * Empty class of params */ boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params); - - /** - * Method to get color name for gpx. - * - * @param fileName (String) - name of gpx file. - * - * @param gpxColor (String) - color name of gpx. Can be one of: "red", "orange", "lightblue", - * "blue", "purple", "translucent_red", "translucent_orange", - * "translucent_lightblue", "translucent_blue", "translucent_purple" - * Which used in {@link #importGpx(in ImportGpxParams params) importGpx} - * Or color hex if gpx has custom color. - * - */ - boolean getGpxColor(inout GpxColorParams params); -} +} \ No newline at end of file diff --git a/osmand-api/src/net/osmand/aidlapi/gpx/AGpxFile.java b/osmand-api/src/net/osmand/aidlapi/gpx/AGpxFile.java index acbc671456..e293875f10 100644 --- a/osmand-api/src/net/osmand/aidlapi/gpx/AGpxFile.java +++ b/osmand-api/src/net/osmand/aidlapi/gpx/AGpxFile.java @@ -13,13 +13,15 @@ public class AGpxFile extends AidlParams { private long modifiedTime; private long fileSize; private boolean active; + private String color; private AGpxFileDetails details; - public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, @Nullable AGpxFileDetails details) { + public AGpxFile(@NonNull String fileName, long modifiedTime, long fileSize, boolean active, String color, @Nullable AGpxFileDetails details) { this.fileName = fileName; this.modifiedTime = modifiedTime; this.fileSize = fileSize; this.active = active; + this.color = color; this.details = details; } @@ -55,6 +57,10 @@ public class AGpxFile extends AidlParams { return active; } + public String getColor() { + return color; + } + public AGpxFileDetails getDetails() { return details; } @@ -66,6 +72,7 @@ public class AGpxFile extends AidlParams { bundle.putLong("fileSize", fileSize); bundle.putBoolean("active", active); bundle.putParcelable("details", details); + bundle.putString("color", color); } @Override @@ -76,5 +83,6 @@ public class AGpxFile extends AidlParams { fileSize = bundle.getLong("fileSize"); active = bundle.getBoolean("active"); details = bundle.getParcelable("details"); + color = bundle.getString("color"); } } \ No newline at end of file diff --git a/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.aidl b/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.aidl deleted file mode 100644 index 6573d502a3..0000000000 --- a/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package net.osmand.aidlapi.gpx; - -parcelable GpxColorParams; \ No newline at end of file diff --git a/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.java b/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.java deleted file mode 100644 index 24ee56f85a..0000000000 --- a/osmand-api/src/net/osmand/aidlapi/gpx/GpxColorParams.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.osmand.aidlapi.gpx; - -import android.os.Bundle; -import android.os.Parcel; -import android.support.annotation.NonNull; - -import net.osmand.aidlapi.AidlParams; - -public class GpxColorParams extends AidlParams { - - private String fileName; - private String gpxColor; - - public GpxColorParams() { - - } - - public GpxColorParams(@NonNull String fileName) { - this.fileName = fileName; - } - - public GpxColorParams(@NonNull String fileName, String gpxColor) { - this.fileName = fileName; - this.gpxColor = gpxColor; - } - - public GpxColorParams(Parcel in) { - readFromParcel(in); - } - - public static final Creator CREATOR = new Creator() { - @Override - public GpxColorParams createFromParcel(Parcel in) { - return new GpxColorParams(in); - } - - @Override - public GpxColorParams[] newArray(int size) { - return new GpxColorParams[size]; - } - }; - - public String getFileName() { - return fileName; - } - - public String getGpxColor() { - return gpxColor; - } - - public void setGpxColor(String gpxColor) { - this.gpxColor = gpxColor; - } - - @Override - protected void readFromBundle(Bundle bundle) { - fileName = bundle.getString("fileName"); - gpxColor = bundle.getString("gpxColor"); - } - - @Override - public void writeToBundle(Bundle bundle) { - bundle.putString("fileName", fileName); - bundle.putString("gpxColor", gpxColor); - } -} \ No newline at end of file