From 9b495f876a2b36220c674b38ec58fe17b35df67f Mon Sep 17 00:00:00 2001 From: Alexey Gulev Date: Sun, 2 Jan 2022 10:09:59 +0100 Subject: [PATCH 1/3] Fix top banner truncation on rounded-corner display --- .../src/java/com/agulev/defunityads/DefUnityAdsJNI.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java index be675b6..ef305b2 100644 --- a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java +++ b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java @@ -315,6 +315,11 @@ public void onBannerLoaded(BannerView bannerAdView) { layout = new LinearLayout(activity); layout.setOrientation(LinearLayout.VERTICAL); + layout.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | + View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); MarginLayoutParams params = new MarginLayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); params.setMargins(0, 0, 0, 0); From 33ec989c81569d7463b6fca156c391cfe5344578 Mon Sep 17 00:00:00 2001 From: Alexey Gulev Date: Sun, 2 Jan 2022 11:56:08 +0100 Subject: [PATCH 2/3] fix issue with navigation bar --- .../src/java/com/agulev/defunityads/DefUnityAdsJNI.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java index ef305b2..65b9211 100644 --- a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java +++ b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java @@ -315,12 +315,8 @@ public void onBannerLoaded(BannerView bannerAdView) { layout = new LinearLayout(activity); layout.setOrientation(LinearLayout.VERTICAL); - layout.setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - + layout.setSystemUiVisibility(activity.getWindow().getDecorView().getSystemUiVisibility()); + MarginLayoutParams params = new MarginLayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); params.setMargins(0, 0, 0, 0); From 27844c665d06dfa21e4499847cecba93e3730e1a Mon Sep 17 00:00:00 2001 From: Alexey Gulev Date: Sun, 2 Jan 2022 12:47:51 +0100 Subject: [PATCH 3/3] fix issue when system navigation cut banner --- .../com/agulev/defunityads/DefUnityAdsJNI.java | 13 +++++++------ defunityads/src/unityads.cpp | 16 +++++++++++++++- defunityads/src/unityads_android.cpp | 7 +++++++ defunityads/src/unityads_ios.mm | 4 ++++ defunityads/src/unityads_private.h | 1 + game.project | 1 + 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java index 65b9211..5b31323 100644 --- a/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java +++ b/defunityads/src/java/com/agulev/defunityads/DefUnityAdsJNI.java @@ -293,18 +293,18 @@ public void requestIDFA() { private boolean isShown = false; - private void ApplyBannerPosition() { - - } - - public void setBannerPosition(String position) { - m_bannerPosition = BannerPosition.fromString(position); + public void applyBannerPosition() { if (isShown) { _hideBanner(); showBanner(); } } + public void setBannerPosition(String position) { + m_bannerPosition = BannerPosition.fromString(position); + applyBannerPosition(); + } + public void loadBanner(String placementId, int width, int height) { if (bannerView == null) { BannerView banner = new BannerView(activity, placementId, new UnityBannerSize(width, height)); @@ -418,6 +418,7 @@ public void showBanner() { @Override public void run() { WindowManager wm = activity.getWindowManager(); + layout.setSystemUiVisibility(activity.getWindow().getDecorView().getSystemUiVisibility()); windowParams.gravity = m_bannerPosition.getGravity(); wm.addView(layout, windowParams); } diff --git a/defunityads/src/unityads.cpp b/defunityads/src/unityads.cpp index 44a76cc..a3fea6d 100755 --- a/defunityads/src/unityads.cpp +++ b/defunityads/src/unityads.cpp @@ -250,6 +250,16 @@ static dmExtension::Result UpdateUnityAds(dmExtension::Params* params) return dmExtension::RESULT_OK; } +static void OnEventUnityAds(dmExtension::Params* params, const dmExtension::Event* event) +{ + switch(event->m_Event) + { + case dmExtension::EVENT_ID_ACTIVATEAPP: + dmUnityAds::ActivateApp(); + break; + } +} + #else // unsupported platforms static dmExtension::Result AppInitializeUnityAds(dmExtension::AppParams* params) @@ -277,7 +287,11 @@ static dmExtension::Result UpdateUnityAds(dmExtension::Params* params) return dmExtension::RESULT_OK; } +static void OnEventUnityAds(dmExtension::Params* params, const dmExtension::Event* event) +{ +} + #endif // platforms -DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, AppInitializeUnityAds, AppFinalizeUnityAds, InitializeUnityAds, UpdateUnityAds, 0, FinalizeUnityAds) +DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, AppInitializeUnityAds, AppFinalizeUnityAds, InitializeUnityAds, UpdateUnityAds, OnEventUnityAds, FinalizeUnityAds) diff --git a/defunityads/src/unityads_android.cpp b/defunityads/src/unityads_android.cpp index 7cd02f9..71193af 100755 --- a/defunityads/src/unityads_android.cpp +++ b/defunityads/src/unityads_android.cpp @@ -72,6 +72,7 @@ struct DefUnityAdsClass jmethodID m_showBanner; jmethodID m_hideBanner; jmethodID m_requestIDFA; + jmethodID m_applyBannerPosition; }; DefUnityAdsClass g_duads; @@ -96,6 +97,7 @@ void Initialize_Ext() g_duads.m_showBanner = env->GetMethodID(cls, "showBanner", "()V"); g_duads.m_hideBanner = env->GetMethodID(cls, "hideBanner", "()V"); g_duads.m_requestIDFA = env->GetMethodID(cls, "requestIDFA", "()V"); + g_duads.m_applyBannerPosition = env->GetMethodID(cls, "applyBannerPosition", "()V"); jmethodID jni_constructor = env->GetMethodID(cls, "", "(Landroid/app/Activity;)V"); g_duads.m_DUADS_JNI = env->NewGlobalRef(env->NewObject(cls, jni_constructor, threadAttacher.GetActivity()->clazz)); @@ -205,6 +207,11 @@ void RequestIDFA() CallVoidMethod(g_duads.m_DUADS_JNI, g_duads.m_requestIDFA); } +void ActivateApp() +{ + CallVoidMethod(g_duads.m_DUADS_JNI, g_duads.m_applyBannerPosition); +} + } //namespaces #endif diff --git a/defunityads/src/unityads_ios.mm b/defunityads/src/unityads_ios.mm index 14d5f51..d05b5c8 100755 --- a/defunityads/src/unityads_ios.mm +++ b/defunityads/src/unityads_ios.mm @@ -265,6 +265,10 @@ void HideBanner() { } } +void ActivateApp() +{ +} + void SetBannerPosition(DefUnityBannerPosition bannerPosition) { currentPosition = bannerPosition; if (isBannerVisible) { diff --git a/defunityads/src/unityads_private.h b/defunityads/src/unityads_private.h index 3c289dd..9c946f6 100755 --- a/defunityads/src/unityads_private.h +++ b/defunityads/src/unityads_private.h @@ -27,6 +27,7 @@ void UnloadBanner(); void ShowBanner(); void HideBanner(); void RequestIDFA(); +void ActivateApp(); bool IsSupported(); bool IsInitialized(); diff --git a/game.project b/game.project index f69542e..ad693fb 100644 --- a/game.project +++ b/game.project @@ -12,6 +12,7 @@ game_binding = /input/game.input_bindingc [display] width = 1280 height = 720 +dynamic_orientation = 1 [physics] scale = 0.02