Merge branch 'master' into global_map_view

This commit is contained in:
cyBerta
2019-03-23 01:55:13 +01:00
5 changed files with 27 additions and 13 deletions
+15 -2
View File
@@ -64,8 +64,15 @@ static jstring jstring_new__(JNIEnv* env, const char* a)
return ret;
}
// convert c-timestamp to java-timestamp
#define JTIMESTAMP(a) (((jlong)a)*((jlong)1000))
// convert java-timestamp to c-timestamp
#define CTIMESTAMP(a) (((jlong)a)/((jlong)1000))
static jintArray dc_array2jintArray_n_unref(JNIEnv *env, dc_array_t* ca)
{
/* takes a C-array of type dc_array_t and converts it it a Java-Array.
@@ -752,9 +759,9 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_setLocation(JNIEnv *env, jo
}
JNIEXPORT jlong Java_com_b44t_messenger_DcContext_getLocationsCPtr(JNIEnv *env, jobject obj, jint chat_id, jint contact_id)
JNIEXPORT jlong Java_com_b44t_messenger_DcContext_getLocationsCPtr(JNIEnv *env, jobject obj, jint chat_id, jint contact_id, jlong timestamp_start, jlong timestamp_end)
{
return (jlong)dc_get_locations(get_dc_context(env, obj), chat_id, contact_id);
return (jlong)dc_get_locations(get_dc_context(env, obj), chat_id, contact_id, CTIMESTAMP(timestamp_start), CTIMESTAMP(timestamp_end));
}
@@ -825,6 +832,12 @@ JNIEXPORT jint Java_com_b44t_messenger_DcArray_getMsgId(JNIEnv *env, jobject obj
}
JNIEXPORT jint Java_com_b44t_messenger_DcArray_getLocationId(JNIEnv *env, jobject obj, jint index)
{
return dc_array_get_id(get_dc_array(env, obj), index);
}
/*******************************************************************************
* DcChatlist
******************************************************************************/
+7 -6
View File
@@ -12,12 +12,13 @@ public class DcArray {
arrayCPtr = 0;
}
public native int getCnt ();
public native float getLatitude (int index);
public native float getLongitude(int index);
public native float getAccuracy (int index);
public native long getTimestamp(int index);
public native int getMsgId (int index);
public native int getCnt ();
public native float getLatitude (int index);
public native float getLongitude (int index);
public native float getAccuracy (int index);
public native long getTimestamp (int index);
public native int getMsgId (int index);
public native int getLocationId(int index);
// working with raw c-data
private long arrayCPtr; // CAVE: the name is referenced in the JNI
+2 -2
View File
@@ -155,7 +155,7 @@ public class DcContext {
public native int joinSecurejoin (String qr);
public native void sendLocationsToChat (int chat_id, int seconds);
public native boolean isSendingLocationsToChat(int chat_id);
public @NonNull DcArray getLocations (int chat_id, int contact_id) { return new DcArray(getLocationsCPtr(chat_id, contact_id)); }
public @NonNull DcArray getLocations (int chat_id, int contact_id, long timestamp_start, long timestamp_end) { return new DcArray(getLocationsCPtr(chat_id, contact_id, timestamp_start, timestamp_end)); }
public native void deleteAllLocations ();
/**
@@ -183,5 +183,5 @@ public class DcContext {
private native long getMsgCPtr (int id);
private native long getDraftCPtr (int id);
private native long getContactCPtr (int id);
private native long getLocationsCPtr (int chat_id, int contact_id);
private native long getLocationsCPtr (int chat_id, int contact_id, long timestamp_start, long timestamp_end);
}
@@ -32,6 +32,7 @@ import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcHelper;
@@ -206,13 +207,12 @@ public class MapDataManager implements DcEventCenter.DcEventDelegate, GenerateIn
Log.d(TAG, "refreshSource finished");
}
private void updateSource(int chatId, int contactId) {
updateSource(chatId, contactId, null);
}
private void updateSource(int chatId, int contactId, LatLngBounds.Builder boundingBuilder) {
DcArray locations = dcContext.getLocations(chatId, contactId);
DcArray locations = ApplicationContext.getInstance(context).dcContext.getLocations(chatId, contactId, System.currentTimeMillis()-3*60*60*1000, 0);
MapSource contactMapMetadata = contactMapSources.get(contactId);
FeatureTreeSet sortedPointFeatures = featureCollections.get(contactMapMetadata.getMarkerFeatureCollection());