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,24 @@ +#include "ThreadOperationsJNIHelper.h" +#include "SQLiteQueryExecutor.h" +#include "ThreadOperations.h" + +namespace comm { +void ThreadOperationsJNIHelper::updateSQLiteUnreadStatus( + facebook::jni::alias_ref jThis, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString threadID, + bool unread) { + std::string sqliteFilePathCpp = sqliteFilePath.toStdString(); + std::string threadIDCpp = threadID.toStdString(); + SQLiteQueryExecutor::initialize(sqliteFilePathCpp); + ThreadOperations::updateSQLiteUnreadStatus(threadIDCpp, unread); +} + +void ThreadOperationsJNIHelper::registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "updateSQLiteUnreadStatus", + ThreadOperationsJNIHelper::updateSQLiteUnreadStatus), + }); +} +} // namespace comm \ No newline at end of file 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); +} \ No newline at end of file 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, + facebook::jni::JString sqliteFilePath, + facebook::jni::JString threadID, + bool unread); + static void registerNatives(); +}; +} // namespace comm \ No newline at end of file