@@ -149,6 +149,19 @@ extern "C" void android_present_webview(bool shouldIntercept) {
149149 env->CallVoidMethod (java_object, method, jshouldIntercept);
150150}
151151
152+ extern " C" void android_webview_change_url (const char *url) {
153+ JNIEnv *env = GetJniEnv ();
154+ // Get the Kotlin class
155+ jclass jOpacityCore = env->GetObjectClass (java_object);
156+
157+ // Get the method ID for the method you want to call
158+ jmethodID method = env->GetMethodID (jOpacityCore, " changeUrlInBrowser" ,
159+ " (Ljava/lang/String;)V" );
160+
161+ jstring jurl = env->NewStringUTF (url);
162+ env->CallVoidMethod (java_object, method, jurl);
163+ }
164+
152165extern " C" const char *get_ip_address () {
153166 struct ifaddrs *ifAddrStruct = nullptr ;
154167 void *tmpAddrPtr = nullptr ;
@@ -197,11 +210,11 @@ extern "C" bool android_is_app_foregrounded() {
197210extern " C" const char *android_get_os_version () {
198211 JNIEnv *env = GetJniEnv ();
199212 jclass jOpacityCore = env->GetObjectClass (java_object);
200- jmethodID method = env->GetMethodID (jOpacityCore, " getOsVersion" , " ()Ljava/lang/String;" );
213+ jmethodID method =
214+ env->GetMethodID (jOpacityCore, " getOsVersion" , " ()Ljava/lang/String;" );
201215 auto res = (jstring)env->CallObjectMethod (java_object, method);
202216
203- if (res == nullptr )
204- {
217+ if (res == nullptr ) {
205218 return " " ;
206219 }
207220
@@ -212,11 +225,11 @@ extern "C" const char *android_get_os_version() {
212225extern " C" const char *android_get_device_manufacturer () {
213226 JNIEnv *env = GetJniEnv ();
214227 jclass jOpacityCore = env->GetObjectClass (java_object);
215- jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceManufacturer" , " ()Ljava/lang/String;" );
228+ jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceManufacturer" ,
229+ " ()Ljava/lang/String;" );
216230 auto res = (jstring)env->CallObjectMethod (java_object, method);
217231
218- if (res == nullptr )
219- {
232+ if (res == nullptr ) {
220233 return " " ;
221234 }
222235
@@ -227,11 +240,11 @@ extern "C" const char *android_get_device_manufacturer() {
227240extern " C" const char *android_get_device_model () {
228241 JNIEnv *env = GetJniEnv ();
229242 jclass jOpacityCore = env->GetObjectClass (java_object);
230- jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceModel" , " ()Ljava/lang/String;" );
243+ jmethodID method =
244+ env->GetMethodID (jOpacityCore, " getDeviceModel" , " ()Ljava/lang/String;" );
231245 auto res = (jstring)env->CallObjectMethod (java_object, method);
232246
233- if (res == nullptr )
234- {
247+ if (res == nullptr ) {
235248 return " " ;
236249 }
237250
@@ -242,11 +255,11 @@ extern "C" const char *android_get_device_model() {
242255extern " C" const char *android_get_device_locale () {
243256 JNIEnv *env = GetJniEnv ();
244257 jclass jOpacityCore = env->GetObjectClass (java_object);
245- jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceLocale" , " ()Ljava/lang/String;" );
258+ jmethodID method =
259+ env->GetMethodID (jOpacityCore, " getDeviceLocale" , " ()Ljava/lang/String;" );
246260 auto res = (jstring)env->CallObjectMethod (java_object, method);
247261
248- if (res == nullptr )
249- {
262+ if (res == nullptr ) {
250263 return " " ;
251264 }
252265
@@ -292,10 +305,10 @@ extern "C" int android_get_screen_dpi() {
292305extern " C" const char *android_get_device_cpu () {
293306 JNIEnv *env = GetJniEnv ();
294307 jclass jOpacityCore = env->GetObjectClass (java_object);
295- jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceCpu" , " ()Ljava/lang/String;" );
308+ jmethodID method =
309+ env->GetMethodID (jOpacityCore, " getDeviceCpu" , " ()Ljava/lang/String;" );
296310 jstring jCpu = (jstring)env->CallObjectMethod (java_object, method);
297- if (jCpu == nullptr )
298- {
311+ if (jCpu == nullptr ) {
299312 return strdup (" " );
300313 }
301314 const char *cpu = env->GetStringUTFChars (jCpu, nullptr );
@@ -308,10 +321,10 @@ extern "C" const char *android_get_device_cpu() {
308321extern " C" const char *android_get_device_codename () {
309322 JNIEnv *env = GetJniEnv ();
310323 jclass jOpacityCore = env->GetObjectClass (java_object);
311- jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceCodename" , " ()Ljava/lang/String;" );
324+ jmethodID method = env->GetMethodID (jOpacityCore, " getDeviceCodename" ,
325+ " ()Ljava/lang/String;" );
312326 jstring jCodename = (jstring)env->CallObjectMethod (java_object, method);
313- if (jCodename == nullptr )
314- {
327+ if (jCodename == nullptr ) {
315328 return strdup (" " );
316329 }
317330 const char *codename = env->GetStringUTFChars (jCodename, nullptr );
0 commit comments