File indexing completed on 2024-12-15 04:00:58

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "android_intent_handler.hpp"
0008 
0009 #ifdef Q_OS_ANDROID
0010 
0011 extern "C" {
0012 #include <jni.h>
0013 
0014 JNIEXPORT void JNICALL Java_org_mattbas_glaxnimate_GlaxnimateActivity_openIntent(
0015     JNIEnv *env, jobject obj, jstring uri)
0016 {
0017     Q_UNUSED(obj);
0018     const char* utf = env->GetStringUTFChars(uri, nullptr);
0019     QUrl cppuri(utf);
0020     env->ReleaseStringUTFChars(uri, utf);
0021     glaxnimate::android::AndroidIntentHandler::instance()->set_view_uri(cppuri);
0022 }
0023 
0024 } // extern C
0025 #endif
0026 
0027 glaxnimate::android::AndroidIntentHandler *glaxnimate::android::AndroidIntentHandler::instance()
0028 {
0029     static AndroidIntentHandler instance;
0030     return &instance;
0031 }
0032 
0033 void glaxnimate::android::AndroidIntentHandler::set_view_uri(const QUrl &uri)
0034 {
0035     QMutexLocker lock(&mutex);
0036     this->uri = uri;
0037     Q_EMIT view_uri_changed(uri);
0038 }
0039 
0040 QUrl glaxnimate::android::AndroidIntentHandler::view_uri()
0041 {
0042     QMutexLocker lock(&mutex);
0043     return uri;
0044 }
0045 
0046 glaxnimate::android::AndroidIntentHandler::AndroidIntentHandler()
0047 {
0048 
0049 }
0050 
0051