mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 19:41:57 +02:00
webxdc (#2174)
* add new w30 APIs * create the webview, disable internet access, inject deltachat.js * connect deltachat to the webview * promisify api * use msgActionButton to start the w30 apps * cleanup - create observers in onCreate() to avoid memory leak, - derive from WebViewActivity to easier deal with particularities and to saves >100 loc - reorder some methods to reflect lifetimes * make it more clear, which uri-part is 'domain' and which one is 'path' * unify logging * it is 'statusUpdate' not 'stateUpdate'; not sure if promise is needed at the end, we can readd that as needed, simple code for now * use core implementation for status updates * disable debugging enabled by default, streamline code * use same name for InternalJSApi for both, js and java * getStatusUpdates() always return an array * call JSON.stringify() on payload * fix typo, fix equal operator * use shorter function names in js land * adapt to new zipped w30 format * load any file from w30 archives * add fallback if getMimeTypeFromExtension() fails * rename w30 to webxdc * add selfName() * return selfAddr() if selfName() is empty * rename deltachat.js to webxdc.js * observer correct event * rename getBlobFromArchive() to getWebxdcBlob() * show webxdc app name in title bar * swap payload and descr in sendUpdate() (adapt to new core api) * allow user-defined-texts for webxdc apps, make room for icon+name * show webxdc icon and name in chats * render webxdc drafts accordingly * allow configuring drafts * do not destroy webxdc-message to be sent out by removing it via setDraft(null) * fix crash when replying to webxdc messages * add webxdc messages to profile's document tab * hide 'search menu' for webxdc apps * show app summary beside app icon * remove outdated comment * add precautious WebView restrictions * Update src/org/thoughtcrime/securesms/ConversationItem.java Co-authored-by: Asiel Díaz Benítez <adbenitez@nauta.cu> * Update src/org/thoughtcrime/securesms/ConversationItem.java Co-authored-by: Asiel Díaz Benítez <adbenitez@nauta.cu> * Update src/org/thoughtcrime/securesms/ConversationActivity.java Co-authored-by: Hocuri <hocuri@gmx.de> * Webxdc requires at least Android 5 Lollipop see https://github.com/deltachat/deltachat-android/pull/2174#discussion_r785436874 * recognize .xdc files on android10 based on @Hocuri's findings in #2188 Co-authored-by: Simon Laux <mobile.info@simonlaux.de> Co-authored-by: adbenitez <asieldbenitez@gmail.com> Co-authored-by: Asiel Díaz Benítez <adbenitez@nauta.cu> Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
parent
aaf53e71a0
commit
9e70aa7cad
21 changed files with 665 additions and 39 deletions
|
@ -86,6 +86,19 @@ static jstring jstring_new__(JNIEnv* env, const char* a)
|
|||
#define CTIMESTAMP(a) (((jlong)a)/((jlong)1000))
|
||||
|
||||
|
||||
static jbyteArray ptr2jbyteArray(JNIEnv *env, const void* ptr, size_t len) {
|
||||
if (ptr == NULL || len <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
jbyteArray ret = (*env)->NewByteArray(env, len);
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetByteArrayRegion(env, ret, 0, len, (const jbyte*)ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
|
@ -704,6 +717,26 @@ JNIEXPORT jint Java_com_b44t_messenger_DcContext_sendVideochatInvitation(JNIEnv
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_sendWebxdcStatusUpdate(JNIEnv *env, jobject obj, jint msg_id, jstring payload, jstring descr)
|
||||
{
|
||||
CHAR_REF(payload);
|
||||
CHAR_REF(descr);
|
||||
jboolean ret = dc_send_webxdc_status_update(get_dc_context(env, obj), msg_id, payloadPtr, descrPtr) != 0;
|
||||
CHAR_UNREF(descr);
|
||||
CHAR_UNREF(payload);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcContext_getWebxdcStatusUpdates(JNIEnv *env, jobject obj, jint msg_id, jint status_update_id)
|
||||
{
|
||||
char* temp = dc_get_webxdc_status_updates(get_dc_context(env, obj), msg_id, status_update_id);
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
dc_str_unref(temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_addDeviceMsg(JNIEnv *env, jobject obj, jstring label, jobject msg)
|
||||
{
|
||||
CHAR_REF(label);
|
||||
|
@ -1528,6 +1561,28 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcMsg_getFilename(JNIEnv *env, jobject
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT jbyteArray Java_com_b44t_messenger_DcMsg_getWebxdcBlob(JNIEnv *env, jobject obj, jstring filename)
|
||||
{
|
||||
jbyteArray ret = NULL;
|
||||
CHAR_REF(filename)
|
||||
size_t ptrSize = 0;
|
||||
char* ptr = dc_msg_get_webxdc_blob(get_dc_msg(env, obj), filenamePtr, &ptrSize);
|
||||
ret = ptr2jbyteArray(env, ptr, ptrSize);
|
||||
dc_str_unref(ptr);
|
||||
CHAR_UNREF(filename)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcMsg_getWebxdcInfoJson(JNIEnv *env, jobject obj)
|
||||
{
|
||||
char* temp = dc_msg_get_webxdc_info(get_dc_msg(env, obj));
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
dc_str_unref(temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcMsg_isForwarded(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_msg_is_forwarded(get_dc_msg(env, obj))!=0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue