From d6e404dc0c663ea5705986b4e71c77b5a00841a8 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Thu, 30 May 2024 16:02:17 -0300 Subject: [PATCH 1/6] chore: change repository name in files --- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- README.md | 40 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 04d6a9fa..bfec97ce 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ blank_issues_enabled: false contact_links: - name: Issue with AdMob on iOS only - url: https://github.com/Poing-Studios/godot-admob-ios + url: https://github.com/poingstudios/godot-admob-ios about: Check the iOS plugin repository. - name: Issue with AdMob on Godot Editor - url: https://github.com/Poing-Studios/godot-admob-plugin + url: https://github.com/poingstudios/godot-admob-plugin about: Check the Godot plugin repository. diff --git a/README.md b/README.md index 1d73e804..77acbad0 100644 --- a/README.md +++ b/README.md @@ -10,24 +10,24 @@

A Godot's plugin for Android of AdMob.

- - + + - - + + - - + + - - + +

AboutHow to useDocs • - Downloads + Downloads

@@ -38,7 +38,7 @@ This repository is for a _Godot Engine Plugin_ that allows showing the ads offered by **AdMob** in an **easy** way, without worrying about the building or version, **just download and use**. -The **purpose** of this plugin is to always keep **up to date with Godot**, supporting **ALMOST ALL** versions from v4.1+, and also make the code **compatible** on **Android and [iOS](https://github.com/Poing-Studios/godot-admob-ios)**, so each advertisement will work **identically on both systems**. +The **purpose** of this plugin is to always keep **up to date with Godot**, supporting **ALMOST ALL** versions from v4.1+, and also make the code **compatible** on **Android and [iOS](https://github.com/poingstudios/godot-admob-ios)**, so each advertisement will work **identically on both systems**. ### 🔑 Key features @@ -49,18 +49,18 @@ The **purpose** of this plugin is to always keep **up to date with Godot**, supp - Targeting Capabilities. 🎯 - Seamless integration with Mediation partners: **AdColony**, **Meta**, **Vungle**. 💰 - CI/CD for streamlined development and deployment. 🔄🚀 -- Features a dedicated [Godot Plugin](https://github.com/Poing-Studios/godot-admob-plugin), reducing the need for extensive coding. 🔌 -- There is also an [iOS plugin](https://github.com/Poing-Studios/godot-admob-ios) available, which has the same behavior. 🍎 +- Features a dedicated [Godot Plugin](https://github.com/poingstudios/godot-admob-plugin), reducing the need for extensive coding. 🔌 +- There is also an [iOS plugin](https://github.com/poingstudios/godot-admob-ios) available, which has the same behavior. 🍎 ## 🙋‍♂️How to use -- We recommend you to use the [AdMob Plugin](https://github.com/Poing-Studios/godot-admob-plugin), you can download direcly from [Godot Assets](https://godotengine.org/asset-library/asset/2063). -- After download, we recommend you to read the [README.md](https://github.com/Poing-Studios/godot-admob-plugin/blob/master/README.md) of the Plugin to know how to use. +- We recommend you to use the [AdMob Plugin](https://github.com/poingstudios/godot-admob-plugin), you can download direcly from [Godot Assets](https://godotengine.org/asset-library/asset/2063). +- After download, we recommend you to read the [README.md](https://github.com/poingstudios/godot-admob-plugin/blob/master/README.md) of the Plugin to know how to use. ## 📦Installing: ### 📥Download -- To get started, download the `poing-godot-admob-android-v{{ your_godot_version }}.zip` file from the [releases tab](https://github.com/Poing-Studios/godot-admob-android/releases). We recommend checking the [supported Godot version](https://github.com/Poing-Studios/godot-admob-versions/blob/master/versions.json) before proceeding. You can also use the [AdMob Plugin](https://github.com/Poing-Studios/godot-admob-plugin) for this step by navigating to `Tools -> AdMob Download Manager -> Android -> LatestVersion`. +- To get started, download the `poing-godot-admob-android-v{{ your_godot_version }}.zip` file from the [releases tab](https://github.com/poingstudios/godot-admob-android/releases). We recommend checking the [supported Godot version](https://github.com/poingstudios/godot-admob-versions/blob/master/versions.json) before proceeding. You can also use the [AdMob Plugin](https://github.com/poingstudios/godot-admob-plugin) for this step by navigating to `Tools -> AdMob Download Manager -> Android -> LatestVersion`. ### 🧑‍💻Usage - Video tutorial: https://youtu.be/WpVGn7ZasKM. @@ -79,12 +79,12 @@ The **purpose** of this plugin is to always keep **up to date with Godot**, supp ## 📎Useful links: -- 🦾 Godot Plugin: https://github.com/Poing-Studios/godot-admob-plugin -- 🍏 iOS: https://github.com/Poing-Studios/godot-admob-ios -- ⏳ Plugin for Godot below v4.1: https://github.com/Poing-Studios/godot-admob-android/tree/v2 +- 🦾 Godot Plugin: https://github.com/poingstudios/godot-admob-plugin +- 🍏 iOS: https://github.com/poingstudios/godot-admob-ios +- ⏳ Plugin for Godot below v4.1: https://github.com/poingstudios/godot-admob-android/tree/v2 ## 📄Documentation -For a complete documentation of this Plugin: [check here](https://poing-studios.github.io/godot-admob-plugin/). +For a complete documentation of this Plugin: [check here](https://poingstudios.github.io/godot-admob-plugin/). Alternatively, you can check the docs of AdMob itself of [Android](https://developers.google.com/admob/android/quick-start). @@ -101,7 +101,7 @@ Your support helps us continue to improve and maintain this plugin. Thank you fo ## 🆘Getting help -[![DISCUSSIONS](https://img.shields.io/badge/Discussions-green?style=for-the-badge)](https://github.com/Poing-Studios/godot-admob-android/discussions) +[![DISCUSSIONS](https://img.shields.io/badge/Discussions-green?style=for-the-badge)](https://github.com/poingstudios/godot-admob-android/discussions) [![DISCORD](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge)](https://discord.com/invite/YEPvYjSSMk) From 70c7d00ce6bceeb2f95beecb776fc5302c6d0948 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Thu, 30 May 2024 16:41:40 -0300 Subject: [PATCH 2/6] fix: wrong margin on banner --- .../godot/admob/ads/adformats/Banner.kt | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt b/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt index 5e360740..ee61bd9f 100644 --- a/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt +++ b/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt @@ -25,10 +25,12 @@ package com.poingstudios.godot.admob.ads.adformats import android.app.Activity import android.graphics.Rect import android.os.Build +import android.view.DisplayCutout import android.view.Gravity import android.view.View import android.view.View.OnLayoutChangeListener import android.view.ViewGroup +import android.view.Window import android.view.WindowInsets import android.widget.FrameLayout import com.google.android.gms.ads.* @@ -141,16 +143,15 @@ class Banner( if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { return safeInsetRect } - val windowInsets: WindowInsets = activity.window.decorView.rootWindowInsets ?: return safeInsetRect - val displayCutout = windowInsets.displayCutout - if (displayCutout != null) { - safeInsetRect.set( - displayCutout.safeInsetLeft, - displayCutout.safeInsetTop, - displayCutout.safeInsetRight, - displayCutout.safeInsetBottom - ) - } + val window: Window = activity.window?: return safeInsetRect + val windowInsets : WindowInsets= window.decorView.rootWindowInsets ?: return safeInsetRect + val displayCutout : DisplayCutout = windowInsets.displayCutout ?: return safeInsetRect + + safeInsetRect.left = displayCutout.safeInsetLeft + safeInsetRect.top = displayCutout.safeInsetTop + safeInsetRect.right = displayCutout.safeInsetRight + safeInsetRect.bottom = displayCutout.safeInsetBottom + return safeInsetRect } private fun getGravity(adPosition: Int?) : Int{ @@ -170,32 +171,31 @@ class Banner( return gravity } private fun getLayoutParams() : FrameLayout.LayoutParams { - val adParams = FrameLayout.LayoutParams( + val adParams : FrameLayout.LayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT ) LogUtils.debug("Safe Area of screen: $safeArea.") - fun calculateTopMargin() : Int{ - var returnValue = adParams.topMargin - when (adPosition) { - AdPosition.TOP.ordinal, AdPosition.TOP_LEFT.ordinal, AdPosition.TOP_RIGHT.ordinal -> { - returnValue = safeArea.top.takeIf { it > 0 } ?: adParams.topMargin - } - } - return returnValue - } - adParams.gravity = getGravity(adPosition) - adParams.bottomMargin = safeArea.bottom adParams.rightMargin = safeArea.right adParams.leftMargin = safeArea.left - adParams.topMargin = calculateTopMargin() - + adParams.topMargin = calculateTopMargin(adParams.topMargin) return adParams } + fun calculateTopMargin(topMargin : Int) : Int{ + var returnValue = topMargin + when (adPosition) { + AdPosition.TOP.ordinal, AdPosition.TOP_LEFT.ordinal, AdPosition.TOP_RIGHT.ordinal -> { + returnValue = safeArea.top + } + } + return returnValue + } + + private fun updatePosition(){ activity.runOnUiThread{ val layoutParams = getLayoutParams() From 420232236f97d3a2f11038cc454404181d65f8c0 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Thu, 30 May 2024 17:06:41 -0300 Subject: [PATCH 3/6] chore: update version ads to 1.0.1 --- src/ads/config/poing-godot-admob-ads.gdap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ads/config/poing-godot-admob-ads.gdap b/src/ads/config/poing-godot-admob-ads.gdap index 1b75de9b..242b72c1 100644 --- a/src/ads/config/poing-godot-admob-ads.gdap +++ b/src/ads/config/poing-godot-admob-ads.gdap @@ -2,7 +2,7 @@ name="AdMob" binary_type="local" -binary="poing-godot-admob-libs/poing-godot-admob-ads-v1.0.0-release.aar" +binary="poing-godot-admob-libs/poing-godot-admob-ads-v1.0.1-release.aar" [dependencies] From d2b2a51ff5f6b1b44d50636bb00b3c9b45f2fb82 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Sun, 1 Sep 2024 23:20:28 -0300 Subject: [PATCH 4/6] chore: upgrade sdk 22.4.0 -> 23.3.0 --- src/ads/config/poing-godot-admob-ads.gdap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ads/config/poing-godot-admob-ads.gdap b/src/ads/config/poing-godot-admob-ads.gdap index 242b72c1..4b4de08f 100644 --- a/src/ads/config/poing-godot-admob-ads.gdap +++ b/src/ads/config/poing-godot-admob-ads.gdap @@ -7,4 +7,4 @@ binary="poing-godot-admob-libs/poing-godot-admob-ads-v1.0.1-release.aar" [dependencies] local=["poing-godot-admob-libs/poing-godot-admob-core-v1.0.1-release.aar"] -remote=["com.google.android.gms:play-services-ads:22.4.0"] +remote=["com.google.android.gms:play-services-ads:23.3.0"] From 5a691e5710847bbd162e3c1948519f4d9d5abf52 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Sun, 1 Sep 2024 23:21:07 -0300 Subject: [PATCH 5/6] docs: add more information for development - How to download - How to build - How to deploy - How to catch logs --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/README.md b/README.md index 77acbad0..b8285419 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,74 @@ Your support helps us continue to improve and maintain this plugin. Thank you fo [![DISCORD](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge)](https://discord.com/invite/YEPvYjSSMk) +## Development +All scripts must be executed within the project root folder + +### Downloading +#### Clear Download & Build Script: +Unix (Linux & MacOS): +```shell +./scripts/unix/clean_build.sh 4.3 +``` + +Windows: +```shell +./scripts/windows/clean_build.ps1 4.3 +``` + +#### Just Download: +Unix (Linux & MacOS): +```shell +./scripts/unix/download_godot.sh 4.3 +``` + +Windows: +```shell +./scripts/windows/download_godot.ps1 4.3 +``` + +### Building, Exporting, Zipping + +#### Just Build: +```shell +./gradlew build +``` + +#### Export files: +```shell +./gradlew exportFiles -PpluginExportPath=D:\godot-admob-editor\android\plugins +``` + +#### Build and exporting plugin files into the desired directory: +```shell +./gradlew build ; ./gradlew exportFiles -PpluginExportPath=D:\godot-admob-editor\android\plugins +``` + + +#### Zip: +(-PgodotVersion is optional) +```shell +./gradlew zipPlugins -PgodotVersion=4.1.1 +``` + +### Logging +If you are having some issues with crashing or any expected behavior, you can easily get the log of the plugin with [ADB](https://developer.android.com/tools/adb): + +#### Logcat AdMob Plugin & Godot (recommended) +```shell +adb logcat -s poing-godot-admob godot +``` + +#### Logcat AdMob Plugin +```shell +adb logcat -s poing-godot-admob +``` + +#### Logcat Godot +```shell +adb logcat -s godot +``` + ## ⭐ Star History If you appreciate our work, don't forget to give us a star on GitHub! ⭐ From ff46759822711e48a4438c962a5274ca6d9973b3 Mon Sep 17 00:00:00 2001 From: Gustavo Maciel Date: Sun, 1 Sep 2024 23:22:08 -0300 Subject: [PATCH 6/6] fix: banner layout safe area when `immersive_mode` --- .../godot/admob/ads/adformats/Banner.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt b/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt index ee61bd9f..f61671bc 100644 --- a/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt +++ b/src/ads/src/main/java/com/poingstudios/godot/admob/ads/adformats/Banner.kt @@ -144,6 +144,11 @@ class Banner( return safeInsetRect } val window: Window = activity.window?: return safeInsetRect + + if (!isImmersiveModeEnabledLegacy(window)) { + return safeInsetRect + } + val windowInsets : WindowInsets= window.decorView.rootWindowInsets ?: return safeInsetRect val displayCutout : DisplayCutout = windowInsets.displayCutout ?: return safeInsetRect @@ -154,6 +159,15 @@ class Banner( return safeInsetRect } + + @Suppress("DEPRECATION") + private fun isImmersiveModeEnabledLegacy(window: Window): Boolean { + val uiOptions = window.decorView.systemUiVisibility + return (uiOptions and View.SYSTEM_UI_FLAG_FULLSCREEN != 0) && + (uiOptions and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION != 0) && + (uiOptions and View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY != 0) + } + private fun getGravity(adPosition: Int?) : Int{ val gravity = when (adPosition) { AdPosition.TOP.ordinal -> Gravity.TOP or Gravity.CENTER_HORIZONTAL @@ -171,10 +185,11 @@ class Banner( return gravity } private fun getLayoutParams() : FrameLayout.LayoutParams { + LogUtils.debug("Safe Area of screen: $safeArea.") + val adParams : FrameLayout.LayoutParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT ) - LogUtils.debug("Safe Area of screen: $safeArea.") adParams.gravity = getGravity(adPosition) adParams.bottomMargin = safeArea.bottom @@ -185,7 +200,7 @@ class Banner( return adParams } - fun calculateTopMargin(topMargin : Int) : Int{ + private fun calculateTopMargin(topMargin : Int) : Int{ var returnValue = topMargin when (adPosition) { AdPosition.TOP.ordinal, AdPosition.TOP_LEFT.ordinal, AdPosition.TOP_RIGHT.ordinal -> {