diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74b4791c2..7fd150c17 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,6 @@ jobs: - "java/admob/NativeAdvancedExample" - "java/admob/RewardedInterstitialExample" - "java/admob/RewardedVideoExample" - - "kotlin/admob/AdaptiveBannerExample" - "kotlin/admob/AppOpenExample" - "kotlin/admob/BannerExample" - "kotlin/admob/InterstitialExample" @@ -42,7 +41,6 @@ jobs: - "java/admanager/NativeAdsExample" - "java/admanager/RewardedInterstitialExample" - "java/admanager/RewardedVideoExample" - - "kotlin/admanager/AdaptiveBannerExample" - "kotlin/admanager/AppOpenExample" - "kotlin/admanager/BannerExample" - "kotlin/admanager/InterstitialExample" diff --git a/.github/workflows/build/folder-crawler.sh b/.github/workflows/build/folder-crawler.sh index 069ae39c2..a304d7c83 100755 --- a/.github/workflows/build/folder-crawler.sh +++ b/.github/workflows/build/folder-crawler.sh @@ -5,7 +5,7 @@ set -eo pipefail # If you are changing the expected_projects_count value, you likely want to be # changing .github/workflows.build.yml to modify which samples are built # through GitHub actions. -expected_projects_count=31 +expected_projects_count=29 projects=() # Reading all directories having a settings.gradle file into the projects diff --git a/kotlin/admanager/AdaptiveBannerExample/app/build.gradle b/kotlin/admanager/AdaptiveBannerExample/app/build.gradle deleted file mode 100644 index 0f6258c8f..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-android' - -android { - namespace 'com.google.android.gms.example.adaptivebannerexample' - compileSdkVersion 33 - defaultConfig { - applicationId "com.google.android.gms.example.adaptivebannerexample" - minSdkVersion 19 - targetSdkVersion 33 - versionCode 1 - versionName "1.0" - multiDexEnabled = true - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - buildFeatures { - viewBinding true - } -} - -repositories { - google() - mavenCentral() -} - -dependencies { - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.gms:play-services-ads:22.5.0' - implementation 'com.google.android.ump:user-messaging-platform:2.1.0' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/kotlin/admanager/AdaptiveBannerExample/app/proguard-rules.pro b/kotlin/admanager/AdaptiveBannerExample/app/proguard-rules.pro deleted file mode 100644 index e6210656d..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/proguard-rules.pro +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2019 Google, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Add project specific ProGuard rules here. -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/AndroidManifest.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/AndroidManifest.xml deleted file mode 100644 index 68a110540..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/GoogleMobileAdsConsentManager.kt b/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/GoogleMobileAdsConsentManager.kt deleted file mode 100644 index 1fb40846b..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/GoogleMobileAdsConsentManager.kt +++ /dev/null @@ -1,91 +0,0 @@ -package com.google.android.gms.example.adaptivebannerexample - -import android.app.Activity -import android.content.Context -import com.google.android.ump.ConsentDebugSettings -import com.google.android.ump.ConsentForm.OnConsentFormDismissedListener -import com.google.android.ump.ConsentInformation -import com.google.android.ump.ConsentRequestParameters -import com.google.android.ump.FormError -import com.google.android.ump.UserMessagingPlatform - -/** - * The Google Mobile Ads SDK provides the User Messaging Platform (Google's IAB Certified consent - * management platform) as one solution to capture consent for users in GDPR impacted countries. - * This is an example and you can choose another consent management platform to capture consent. - */ -class GoogleMobileAdsConsentManager private constructor(context: Context) { - private val consentInformation: ConsentInformation = - UserMessagingPlatform.getConsentInformation(context) - - /** Interface definition for a callback to be invoked when consent gathering is complete. */ - fun interface OnConsentGatheringCompleteListener { - fun consentGatheringComplete(error: FormError?) - } - - /** Helper variable to determine if the app can request ads. */ - val canRequestAds: Boolean - get() = consentInformation.canRequestAds() - - /** Helper variable to determine if the privacy options form is required. */ - val isPrivacyOptionsRequired: Boolean - get() = - consentInformation.privacyOptionsRequirementStatus == - ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED - - /** - * Helper method to call the UMP SDK methods to request consent information and load/show a - * consent form if necessary. - */ - fun gatherConsent( - activity: Activity, - onConsentGatheringCompleteListener: OnConsentGatheringCompleteListener - ) { - // For testing purposes, you can force a DebugGeography of EEA or NOT_EEA. - val debugSettings = - ConsentDebugSettings.Builder(activity) - // Uncomment the line below to set DebugGeography to EEA. - // .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA) - - // Check your logcat output for the hashed device ID e.g. - // "Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("ABCDEF012345")" to use - // the debug functionality. - .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID") - .build() - - val params = ConsentRequestParameters.Builder().setConsentDebugSettings(debugSettings).build() - - // Requesting an update to consent information should be called on every app launch. - consentInformation.requestConsentInfoUpdate( - activity, - params, - { - UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError -> - // Consent has been gathered. - onConsentGatheringCompleteListener.consentGatheringComplete(formError) - } - }, - { requestConsentError -> - onConsentGatheringCompleteListener.consentGatheringComplete(requestConsentError) - } - ) - } - - /** Helper method to call the UMP SDK method to show the privacy options form. */ - fun showPrivacyOptionsForm( - activity: Activity, - onConsentFormDismissedListener: OnConsentFormDismissedListener - ) { - UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener) - } - - companion object { - @Volatile private var instance: GoogleMobileAdsConsentManager? = null - - fun getInstance(context: Context) = - instance - ?: synchronized(this) { - instance ?: GoogleMobileAdsConsentManager(context).also { instance = it } - } - } -} diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt b/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt deleted file mode 100644 index 9cd7fb0ae..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2019 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.gms.example.adaptivebannerexample - -import android.os.Bundle -import android.util.DisplayMetrics -import android.util.Log -import android.view.Menu -import android.view.MenuItem -import android.view.View -import android.widget.PopupMenu -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.google.android.gms.ads.AdSize -import com.google.android.gms.ads.MobileAds -import com.google.android.gms.ads.RequestConfiguration -import com.google.android.gms.ads.admanager.AdManagerAdRequest -import com.google.android.gms.ads.admanager.AdManagerAdView -import com.google.android.gms.example.adaptivebannerexample.databinding.ActivityMyBinding -import java.util.concurrent.atomic.AtomicBoolean - -private const val TAG = "MyActivity" - -/** Main Activity. Inflates main activity xml and child fragments. */ -class MyActivity : AppCompatActivity() { - - private val isMobileAdsInitializeCalled = AtomicBoolean(false) - private val initialLayoutComplete = AtomicBoolean(false) - private lateinit var binding: ActivityMyBinding - private lateinit var adView: AdManagerAdView - private lateinit var googleMobileAdsConsentManager: GoogleMobileAdsConsentManager - - // Determine the screen width (less decorations) to use for the ad width. - // If the ad width isn't known, default to the full screen width. - val adSize: AdSize - get() { - val display = windowManager.defaultDisplay - val outMetrics = DisplayMetrics() - display.getMetrics(outMetrics) - - val density = outMetrics.density - - var adWidthPixels = binding.adViewContainer.width.toFloat() - if (adWidthPixels == 0f) { - adWidthPixels = outMetrics.widthPixels.toFloat() - } - - val adWidth = (adWidthPixels / density).toInt() - return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth) - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityMyBinding.inflate(layoutInflater) - setContentView(binding.root) - binding.loadButton.setOnClickListener { - if (googleMobileAdsConsentManager.canRequestAds) { - loadBanner(adSize) - } - } - - adView = AdManagerAdView(this) - binding.adViewContainer.addView(adView) - - // Log the Mobile Ads SDK version. - Log.d(TAG, "Google Mobile Ads SDK Version: " + MobileAds.getVersion()) - - googleMobileAdsConsentManager = GoogleMobileAdsConsentManager.getInstance(applicationContext) - googleMobileAdsConsentManager.gatherConsent(this) { error -> - if (error != null) { - // Consent not obtained in current session. - Log.d(TAG, "${error.errorCode}: ${error.message}") - } - - if (googleMobileAdsConsentManager.canRequestAds) { - initializeMobileAdsSdk() - } - - if (googleMobileAdsConsentManager.isPrivacyOptionsRequired) { - // Regenerate the options menu to include a privacy setting. - invalidateOptionsMenu() - } - } - - // This sample attempts to load ads using consent obtained in the previous session. - if (googleMobileAdsConsentManager.canRequestAds) { - initializeMobileAdsSdk() - } - - // Since we're loading the banner based on the adContainerView size, we need to wait until this - // view is laid out before we can get the width. - binding.adViewContainer.viewTreeObserver.addOnGlobalLayoutListener { - if (!initialLayoutComplete.getAndSet(true) && googleMobileAdsConsentManager.canRequestAds) { - loadBanner(adSize) - } - } - - // Set your test devices. Check your logcat output for the hashed device ID to - // get test ads on a physical device. e.g. - // "Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("ABCDEF012345")) - // to get test ads on this device." - MobileAds.setRequestConfiguration( - RequestConfiguration.Builder().setTestDeviceIds(listOf("ABCDEF012345")).build() - ) - } - - /** Called when leaving the activity. */ - public override fun onPause() { - adView.pause() - super.onPause() - } - - /** Called when returning to the activity */ - public override fun onResume() { - super.onResume() - adView.resume() - } - - /** Called before the activity is destroyed */ - public override fun onDestroy() { - adView.destroy() - super.onDestroy() - } - - override fun onCreateOptionsMenu(menu: Menu?): Boolean { - menuInflater.inflate(R.menu.action_menu, menu) - val moreMenu = menu?.findItem(R.id.action_more) - moreMenu?.isVisible = googleMobileAdsConsentManager.isPrivacyOptionsRequired - return super.onCreateOptionsMenu(menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - val menuItemView = findViewById(item.itemId) - PopupMenu(this, menuItemView).apply { - menuInflater.inflate(R.menu.popup_menu, menu) - show() - setOnMenuItemClickListener { popupMenuItem -> - when (popupMenuItem.itemId) { - R.id.privacy_settings -> { - // Handle changes to user consent. - googleMobileAdsConsentManager.showPrivacyOptionsForm(this@MyActivity) { formError -> - if (formError != null) { - Toast.makeText(this@MyActivity, formError.message, Toast.LENGTH_SHORT).show() - } - } - true - } - else -> false - } - } - return super.onOptionsItemSelected(item) - } - } - - private fun loadBanner(adSize: AdSize) { - adView.adUnitId = BACKFILL_AD_UNIT_ID - adView.setAdSizes(adSize) - - // Create an ad request. - val adRequest = AdManagerAdRequest.Builder().build() - - // Start loading the ad in the background. - adView.loadAd(adRequest) - } - - private fun initializeMobileAdsSdk() { - if (isMobileAdsInitializeCalled.getAndSet(true)) { - return - } - - // Initialize the Mobile Ads SDK. - MobileAds.initialize(this) {} - - // Load an ad. - if (initialLayoutComplete.get()) { - loadBanner(adSize) - } - } - - companion object { - internal val BACKFILL_AD_UNIT_ID = "/30497360/adaptive_banner_test_iu/backfill" - } -} diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml deleted file mode 100644 index 31bde2259..000000000 --- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml +++ /dev/null @@ -1,30 +0,0 @@ - - -