Remove getGpxColor
This commit is contained in:
parent
46c443255c
commit
3a801cd5ae
9 changed files with 31 additions and 132 deletions
|
@ -1231,18 +1231,4 @@ class OsmandAidlHelper(private val app: TelegramApplication) {
|
||||||
}
|
}
|
||||||
return false
|
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
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -301,7 +301,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
||||||
val aGpxFile = importedGpxFiles.firstOrNull { it.fileName == name }
|
val aGpxFile = importedGpxFiles.firstOrNull { it.fileName == name }
|
||||||
|
|
||||||
if (aGpxFile != null) {
|
if (aGpxFile != null) {
|
||||||
val color = osmandAidlHelper.getGpxColor(aGpxFile.fileName)
|
val color = aGpxFile.color
|
||||||
if (!color.isNullOrEmpty()) {
|
if (!color.isNullOrEmpty()) {
|
||||||
gpxFile.extensionsToWrite["color"] = color
|
gpxFile.extensionsToWrite["color"] = color
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_UNSUPPORTED_FILE_TYPE_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
import static net.osmand.aidlapi.OsmandAidlConstants.COPY_FILE_WRITE_LOCK_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.OK_RESPONSE;
|
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 {
|
public class OsmandAidlApi {
|
||||||
|
|
||||||
AidlCallbackListener aidlCallbackListener = null;
|
AidlCallbackListener aidlCallbackListener = null;
|
||||||
AidlCallbackListenerV2 aidlCallbackListenerV2 = 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 Log LOG = PlatformUtil.getLog(OsmandAidlApi.class);
|
||||||
private static final String AIDL_REFRESH_MAP = "aidl_refresh_map";
|
private static final String AIDL_REFRESH_MAP = "aidl_refresh_map";
|
||||||
private static final String AIDL_SET_MAP_LOCATION = "aidl_set_map_location";
|
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;
|
boolean active = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath()) != null;
|
||||||
long modifiedTime = dataItem.getFileLastModifiedTime();
|
long modifiedTime = dataItem.getFileLastModifiedTime();
|
||||||
long fileSize = file.length();
|
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;
|
net.osmand.aidlapi.gpx.AGpxFileDetails details = null;
|
||||||
GPXTrackAnalysis analysis = dataItem.getAnalysis();
|
GPXTrackAnalysis analysis = dataItem.getAnalysis();
|
||||||
if (analysis != null) {
|
if (analysis != null) {
|
||||||
details = createGpxFileDetailsV2(analysis);
|
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;
|
return true;
|
||||||
|
|
|
@ -94,6 +94,10 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
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.CANNOT_ACCESS_API_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR;
|
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);
|
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<Long, AidlCallbackParams> callbacks = new ConcurrentHashMap<>();
|
private Map<Long, AidlCallbackParams> callbacks = new ConcurrentHashMap<>();
|
||||||
private Handler mHandler = null;
|
private Handler mHandler = null;
|
||||||
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceThread");
|
||||||
|
|
|
@ -37,7 +37,6 @@ import net.osmand.aidlapi.gpx.AGpxBitmap;
|
||||||
import net.osmand.aidlapi.gpx.AGpxFile;
|
import net.osmand.aidlapi.gpx.AGpxFile;
|
||||||
import net.osmand.aidlapi.gpx.ASelectedGpxFile;
|
import net.osmand.aidlapi.gpx.ASelectedGpxFile;
|
||||||
import net.osmand.aidlapi.gpx.CreateGpxBitmapParams;
|
import net.osmand.aidlapi.gpx.CreateGpxBitmapParams;
|
||||||
import net.osmand.aidlapi.gpx.GpxColorParams;
|
|
||||||
import net.osmand.aidlapi.gpx.HideGpxParams;
|
import net.osmand.aidlapi.gpx.HideGpxParams;
|
||||||
import net.osmand.aidlapi.gpx.ImportGpxParams;
|
import net.osmand.aidlapi.gpx.ImportGpxParams;
|
||||||
import net.osmand.aidlapi.gpx.RemoveGpxParams;
|
import net.osmand.aidlapi.gpx.RemoveGpxParams;
|
||||||
|
@ -96,6 +95,10 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
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.CANNOT_ACCESS_API_ERROR;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS;
|
||||||
import static net.osmand.aidlapi.OsmandAidlConstants.MIN_UPDATE_TIME_MS_ERROR;
|
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);
|
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<Long, AidlCallbackParams> callbacks = new ConcurrentHashMap<>();
|
private Map<Long, AidlCallbackParams> callbacks = new ConcurrentHashMap<>();
|
||||||
private Handler mHandler = null;
|
private Handler mHandler = null;
|
||||||
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceV2Thread");
|
HandlerThread mHandlerThread = new HandlerThread("OsmAndAidlServiceV2Thread");
|
||||||
|
@ -1210,21 +1208,6 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener
|
||||||
return false;
|
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) {
|
private void setCustomization(OsmandAidlApi api, CustomizationInfoParams params) {
|
||||||
|
|
|
@ -77,7 +77,6 @@ import net.osmand.aidlapi.customization.CustomizationInfoParams;
|
||||||
import net.osmand.aidlapi.gpx.AGpxFile;
|
import net.osmand.aidlapi.gpx.AGpxFile;
|
||||||
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
import net.osmand.aidlapi.gpx.AGpxFileDetails;
|
||||||
import net.osmand.aidlapi.gpx.CreateGpxBitmapParams;
|
import net.osmand.aidlapi.gpx.CreateGpxBitmapParams;
|
||||||
import net.osmand.aidlapi.gpx.GpxColorParams;
|
|
||||||
|
|
||||||
import net.osmand.aidlapi.tiles.ASqliteDbFile;
|
import net.osmand.aidlapi.tiles.ASqliteDbFile;
|
||||||
|
|
||||||
|
@ -832,18 +831,4 @@ interface IOsmAndAidlInterface {
|
||||||
* Empty class of params
|
* Empty class of params
|
||||||
*/
|
*/
|
||||||
boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams 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);
|
|
||||||
}
|
}
|
|
@ -13,13 +13,15 @@ public class AGpxFile extends AidlParams {
|
||||||
private long modifiedTime;
|
private long modifiedTime;
|
||||||
private long fileSize;
|
private long fileSize;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
private String color;
|
||||||
private AGpxFileDetails details;
|
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.fileName = fileName;
|
||||||
this.modifiedTime = modifiedTime;
|
this.modifiedTime = modifiedTime;
|
||||||
this.fileSize = fileSize;
|
this.fileSize = fileSize;
|
||||||
this.active = active;
|
this.active = active;
|
||||||
|
this.color = color;
|
||||||
this.details = details;
|
this.details = details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +57,10 @@ public class AGpxFile extends AidlParams {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
public AGpxFileDetails getDetails() {
|
public AGpxFileDetails getDetails() {
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +72,7 @@ public class AGpxFile extends AidlParams {
|
||||||
bundle.putLong("fileSize", fileSize);
|
bundle.putLong("fileSize", fileSize);
|
||||||
bundle.putBoolean("active", active);
|
bundle.putBoolean("active", active);
|
||||||
bundle.putParcelable("details", details);
|
bundle.putParcelable("details", details);
|
||||||
|
bundle.putString("color", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,5 +83,6 @@ public class AGpxFile extends AidlParams {
|
||||||
fileSize = bundle.getLong("fileSize");
|
fileSize = bundle.getLong("fileSize");
|
||||||
active = bundle.getBoolean("active");
|
active = bundle.getBoolean("active");
|
||||||
details = bundle.getParcelable("details");
|
details = bundle.getParcelable("details");
|
||||||
|
color = bundle.getString("color");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
package net.osmand.aidlapi.gpx;
|
|
||||||
|
|
||||||
parcelable GpxColorParams;
|
|
|
@ -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<GpxColorParams> CREATOR = new Creator<GpxColorParams>() {
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue