Commit 818ab3a7 authored by Paweł Wegner's avatar Paweł Wegner

cloudbrowser: refactored native methods.

parent 0940f327
......@@ -26,8 +26,6 @@ public class CloudBrowser extends QtActivity {
private RelativeLayout m_ad_view;
private boolean m_ad_view_visible = false;
private native void onRequestResult(int request, int result, Intent data);
private void updateAdView() {
if (m_ad_view != null && m_view_group != null)
m_view_group.removeView(m_ad_view);
......@@ -57,14 +55,14 @@ public class CloudBrowser extends QtActivity {
public void onAdLoaded() {
runOnUiThread(new Runnable() {
public void run() {
NotificationHelper.callback("SHOW_AD");
Utility.onActionRequested("SHOW_AD");
attach();
}
});
}
public void onAdFailedToLoad(int error) {
NotificationHelper.callback("HIDE_AD");
Utility.onActionRequested("HIDE_AD");
}
});
ad.loadAd(new AdRequest.Builder().build());
......@@ -93,7 +91,7 @@ public class CloudBrowser extends QtActivity {
@Override
public void onActivityResult(int request, int result, Intent data) {
super.onActivityResult(request, result, data);
onRequestResult(request, result, data);
Utility.onRequestResult(request, result, data);
}
@Override
......
......@@ -22,12 +22,10 @@ public class NotificationHelper {
private static class Receiver extends BroadcastReceiver {
public void onReceive(Context ctx, Intent intent) {
callback(intent.getAction());
Utility.onActionRequested(intent.getAction());
}
}
public static native void callback(String action);
public NotificationHelper(Context context) {
m_context = context;
m_notification_manager =
......
......@@ -4,6 +4,9 @@ import android.net.Uri;
import android.content.Intent;
public class Utility {
public static native void onActionRequested(String action);
public static native void onRequestResult(int request, int result, Intent data);
public static Uri stringToUri(String uri) {
String basename = uri.substring(0, uri.lastIndexOf('/') + 1);
String filename = uri.substring(uri.lastIndexOf('/') + 1);
......
......@@ -24,20 +24,15 @@ std::unordered_map<int, std::unordered_set<AndroidUtility::IResultListener *>>
} // namespace
extern "C" {
JNIEXPORT void JNICALL
Java_org_videolan_cloudbrowser_NotificationHelper_callback(JNIEnv *env,
jclass *,
jstring action) {
JNIEXPORT void JNICALL Java_org_videolan_cloudbrowser_Utility_onActionRequested(
JNIEnv *env, jclass *, jstring action) {
const char *str = env->GetStringUTFChars(action, nullptr);
emit android->notify(str);
env->ReleaseStringUTFChars(action, str);
}
JNIEXPORT void JNICALL
Java_org_videolan_cloudbrowser_CloudBrowser_onRequestResult(JNIEnv *, jobject *,
jint request,
jint result,
jobject data) {
JNIEXPORT void JNICALL Java_org_videolan_cloudbrowser_Utility_onRequestResult(
JNIEnv *, jclass *, jint request, jint result, jobject data) {
std::unique_lock<std::mutex> lock(mutex);
auto cb = result_listener.find(request);
if (cb != result_listener.end()) {
......
......@@ -57,7 +57,7 @@ class FileDialog : public IFileDialog {
public:
ActivityReceiver(FileDialog*);
void done(int request_code, int result_code,
const QAndroidJniObject& data) override;
const QAndroidJniObject& data) override;
private:
FileDialog* file_dialog_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment