diff --git a/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp b/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp new file mode 100644 index 000000000..bdeede4b8 --- /dev/null +++ b/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp @@ -0,0 +1,22 @@ +#include "ThreadOperationsJNIHelper.h" +#include "SQLiteQueryExecutor.h" +#include "ThreadOperations.h" + +namespace comm { +void ThreadOperationsJNIHelper::updateSQLiteUnreadStatus( + facebook::jni::alias_ref jThis, + std::string sqliteFilePath, + std::string threadID, + bool unread) { + SQLiteQueryExecutor::initialize(sqliteFilePath); + ThreadOperations::updateSQLiteUnreadStatus(threadID, unread); +} + +void ThreadOperationsJNIHelper::registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "updateSQLiteUnreadStatus", + ThreadOperationsJNIHelper::updateSQLiteUnreadStatus), + }); +} +} // namespace comm diff --git a/native/android/app/src/cpp/jsiInstaller.cpp b/native/android/app/src/cpp/jsiInstaller.cpp index 45a173cdf..89d283248 100644 --- a/native/android/app/src/cpp/jsiInstaller.cpp +++ b/native/android/app/src/cpp/jsiInstaller.cpp @@ -1,56 +1,58 @@ #include "CommCoreModule.h" #include "GlobalNetworkSingletonJNIHelper.h" #include "SQLiteQueryExecutor.h" +#include "ThreadOperationsJNIHelper.h" #include "jniHelpers.h" #include #include #include namespace jni = facebook::jni; namespace jsi = facebook::jsi; namespace react = facebook::react; class CommHybrid : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = "Lapp/comm/android/fbjni/CommHybrid;"; static void initHybrid( jni::alias_ref jThis, jlong jsContext, jni::alias_ref jsCallInvokerHolder, comm::HashMap additionalParameters) { jsi::Runtime *rt = (jsi::Runtime *)jsContext; auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker(); std::shared_ptr nativeModule = std::make_shared(jsCallInvoker); if (rt != nullptr) { rt->global().setProperty( *rt, jsi::PropNameID::forAscii(*rt, "CommCoreModule"), jsi::Object::createFromHostObject(*rt, nativeModule)); } jni::local_ref sqliteFilePathObj = additionalParameters.get("sqliteFilePath"); std::string sqliteFilePath = sqliteFilePathObj->toString(); comm::SQLiteQueryExecutor::initialize(sqliteFilePath); } static void registerNatives() { javaClassStatic()->registerNatives({ makeNativeMethod("initHybrid", CommHybrid::initHybrid), }); } private: friend HybridBase; }; JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) { return jni::initialize(vm, [] { CommHybrid::registerNatives(); comm::GlobalNetworkSingletonJNIHelper::registerNatives(); + comm::ThreadOperationsJNIHelper::registerNatives(); }); } diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/ThreadOperations.java b/native/android/app/src/main/java/app/comm/android/fbjni/ThreadOperations.java new file mode 100644 index 000000000..53b3d4497 --- /dev/null +++ b/native/android/app/src/main/java/app/comm/android/fbjni/ThreadOperations.java @@ -0,0 +1,8 @@ +package app.comm.android.fbjni; + +public class ThreadOperations { + public static native void updateSQLiteUnreadStatus( + String sqliteFilePath, + String threadID, + boolean unread); +} diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperationsJNIHelper.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperationsJNIHelper.h new file mode 100644 index 000000000..250a132f1 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperationsJNIHelper.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace comm { +class ThreadOperationsJNIHelper + : public facebook::jni::JavaClass { +public: + static auto constexpr kJavaDescriptor = + "Lapp/comm/android/fbjni/ThreadOperations;"; + static void updateSQLiteUnreadStatus( + facebook::jni::alias_ref jThis, + std::string sqliteFilePath, + std::string threadID, + bool unread); + static void registerNatives(); +}; +} // namespace comm