diff --git a/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp b/native/android/app/src/cpp/ThreadOperationsJNIHelper.cpp new file mode 100644 --- /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 --- a/native/android/app/src/cpp/jsiInstaller.cpp +++ b/native/android/app/src/cpp/jsiInstaller.cpp @@ -1,6 +1,7 @@ #include "CommCoreModule.h" #include "GlobalNetworkSingletonJNIHelper.h" #include "SQLiteQueryExecutor.h" +#include "ThreadOperationsJNIHelper.h" #include "jniHelpers.h" #include #include @@ -52,5 +53,6 @@ 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 --- /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 --- /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