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 @@
-
-
-
-
-
-
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml
deleted file mode 100644
index c4a677368..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml
deleted file mode 100644
index 91c059d6e..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100755
index 0d23b32e9..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100755
index 18181ddd3..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100755
index ce686f5c8..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100755
index 88fba1a6b..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100755
index c0d781241..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100755
index 64089b0b7..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100755
index 921d5f002..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100755
index 7cc8077cd..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100755
index 74ccd22d0..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100755
index 7391d555d..000000000
Binary files a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc81644..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/dimens.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c822467..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/strings.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/strings.xml
deleted file mode 100644
index 5bb9f3f1d..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- Ad Manager Adaptive Banner
- More
- Privacy Settings
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/styles.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/styles.xml
deleted file mode 100644
index 766ab9930..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml b/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml
deleted file mode 100644
index a34a5f190..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/kotlin/admanager/AdaptiveBannerExample/build.gradle b/kotlin/admanager/AdaptiveBannerExample/build.gradle
deleted file mode 100644
index cac693722..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/build.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- ext.kotlin_version = '1.7.0'
- repositories {
- google()
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:8.1.2'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- }
-}
diff --git a/kotlin/admanager/AdaptiveBannerExample/gradle.properties b/kotlin/admanager/AdaptiveBannerExample/gradle.properties
deleted file mode 100644
index cc8c88320..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/gradle.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-android.enableJetifier=true
-android.useAndroidX=true
diff --git a/kotlin/admanager/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties b/kotlin/admanager/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 7ce0aa38f..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Thu Nov 15 15:54:07 PST 2018
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https://services.gradle.org/distributions/gradle-8.4-all.zip
diff --git a/kotlin/admanager/AdaptiveBannerExample/gradlew b/kotlin/admanager/AdaptiveBannerExample/gradlew
deleted file mode 100755
index cccdd3d51..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/kotlin/admanager/AdaptiveBannerExample/gradlew.bat b/kotlin/admanager/AdaptiveBannerExample/gradlew.bat
deleted file mode 100644
index e95643d6a..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/kotlin/admanager/AdaptiveBannerExample/settings.gradle b/kotlin/admanager/AdaptiveBannerExample/settings.gradle
deleted file mode 100644
index e7b4def49..000000000
--- a/kotlin/admanager/AdaptiveBannerExample/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/kotlin/admanager/BannerExample/app/src/main/AndroidManifest.xml b/kotlin/admanager/BannerExample/app/src/main/AndroidManifest.xml
index 794b4d4f4..f359d0010 100644
--- a/kotlin/admanager/BannerExample/app/src/main/AndroidManifest.xml
+++ b/kotlin/admanager/BannerExample/app/src/main/AndroidManifest.xml
@@ -6,18 +6,17 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true"
android:theme="@style/AppTheme" >
+
+ android:value="ca-app-pub-9939518381636264~1092563270"/>
+ android:label="@string/app_name"
+ android:exported="true">
diff --git a/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt b/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
index 51b004178..f2d1d7a1e 100644
--- a/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
+++ b/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2023 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.bannerexample
import android.app.Activity
diff --git a/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/MyActivity.kt b/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/MyActivity.kt
index 5efa723cc..8acd457eb 100644
--- a/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/MyActivity.kt
+++ b/kotlin/admanager/BannerExample/app/src/main/kotlin/com/google/android/gms/example/bannerexample/MyActivity.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google, Inc.
+ * Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,19 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.google.android.gms.example.bannerexample
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 androidx.appcompat.widget.PopupMenu
+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.bannerexample.databinding.ActivityMyBinding
import java.util.concurrent.atomic.AtomicBoolean
@@ -35,25 +39,41 @@ private const val TAG = "MainActivity"
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 hasn't been laid out, default to the full screen width.
+ private 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)
+ adView = AdManagerAdView(this)
+ binding.adViewContainer.addView(adView)
+
// Log the Mobile Ads SDK version.
Log.d(TAG, "Google Mobile Ads SDK Version: " + MobileAds.getVersion())
- // 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()
- )
-
googleMobileAdsConsentManager = GoogleMobileAdsConsentManager.getInstance(applicationContext)
googleMobileAdsConsentManager.gatherConsent(this) { error ->
if (error != null) {
@@ -75,23 +95,39 @@ class MyActivity : AppCompatActivity() {
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()
+ }
+ }
+
+ // 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() {
- binding.adView.pause()
+ adView.pause()
super.onPause()
}
/** Called when returning to the activity. */
public override fun onResume() {
super.onResume()
- binding.adView.resume()
+ adView.resume()
}
/** Called before the activity is destroyed. */
public override fun onDestroy() {
- binding.adView.destroy()
+ adView.destroy()
super.onDestroy()
}
@@ -104,24 +140,37 @@ class MyActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val menuItemView = findViewById(item.itemId)
- val popup = PopupMenu(this, menuItemView)
- popup.menuInflater.inflate(R.menu.popup_menu, popup.menu)
- popup.show()
- popup.setOnMenuItemClickListener { popupMenuItem ->
- when (popupMenuItem.itemId) {
- R.id.privacy_settings -> {
- // Handle changes to user consent.
- googleMobileAdsConsentManager.showPrivacyOptionsForm(this) { formError ->
- if (formError != null) {
- Toast.makeText(this@MyActivity, formError.message, Toast.LENGTH_SHORT).show()
+ 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
}
- true
+ else -> false
}
- else -> false
}
+ return super.onOptionsItemSelected(item)
}
- return super.onOptionsItemSelected(item)
+ }
+
+ private fun loadBanner() {
+ // This is an ad unit ID for a test ad. Replace with your own banner ad unit ID.
+ adView.adUnitId = "/6499/example/banner"
+ adView.setAdSize(adSize)
+
+ // Create an ad request.
+ val adRequest = AdManagerAdRequest.Builder().build()
+
+ // Start loading the ad in the background.
+ adView.loadAd(adRequest)
}
private fun initializeMobileAdsSdk() {
@@ -129,12 +178,12 @@ class MyActivity : AppCompatActivity() {
return
}
- // Initialize the Mobile Ads SDK with an empty completion listener.
+ // Initialize the Mobile Ads SDK.
MobileAds.initialize(this) {}
- // Create an ad request.
- val adRequest = AdManagerAdRequest.Builder().build()
- // Start loading the ad in the background.
- binding.adView.loadAd(adRequest)
+ // Load an ad.
+ if (initialLayoutComplete.get()) {
+ loadBanner()
+ }
}
}
diff --git a/kotlin/admanager/BannerExample/app/src/main/res/layout/activity_my.xml b/kotlin/admanager/BannerExample/app/src/main/res/layout/activity_my.xml
index 08793d507..6efadd152 100644
--- a/kotlin/admanager/BannerExample/app/src/main/res/layout/activity_my.xml
+++ b/kotlin/admanager/BannerExample/app/src/main/res/layout/activity_my.xml
@@ -4,8 +4,10 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/activity_vertical_margin"
+ android:background="@android:color/transparent"
tools:context=".MyActivity"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
tools:ignore="MergeRootFrame">
-
-
+ android:layout_centerInParent="true"
+ android:layout_alignParentBottom="true" />
+
diff --git a/kotlin/admanager/BannerExample/app/src/main/res/values/strings.xml b/kotlin/admanager/BannerExample/app/src/main/res/values/strings.xml
index 4a659dd30..931829cd9 100644
--- a/kotlin/admanager/BannerExample/app/src/main/res/values/strings.xml
+++ b/kotlin/admanager/BannerExample/app/src/main/res/values/strings.xml
@@ -1,10 +1,8 @@
-
- Settings
- BannerExample
- Hello world!
+ Settings
+ Ad Manager Banner Example
+ Hello world!MorePrivacy Settings
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/build.gradle b/kotlin/admob/AdaptiveBannerExample/app/build.gradle
deleted file mode 100644
index dc6695f58..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/build.gradle
+++ /dev/null
@@ -1,35 +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
- }
-}
-
-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"
-}
-repositories {
- mavenCentral()
-}
diff --git a/kotlin/admob/AdaptiveBannerExample/app/proguard-rules.pro b/kotlin/admob/AdaptiveBannerExample/app/proguard-rules.pro
deleted file mode 100644
index e6210656d..000000000
--- a/kotlin/admob/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/admob/AdaptiveBannerExample/app/src/main/AndroidManifest.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 70475bac9..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/GoogleMobileAdsConsentManager.kt b/kotlin/admob/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/GoogleMobileAdsConsentManager.kt
deleted file mode 100644
index 1fb40846b..000000000
--- a/kotlin/admob/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/admob/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt b/kotlin/admob/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt
deleted file mode 100644
index 849d91554..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/adaptivebannerexample/MyActivity.kt
+++ /dev/null
@@ -1,193 +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 androidx.appcompat.app.AppCompatActivity
-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 com.google.android.gms.ads.AdRequest
-import com.google.android.gms.ads.AdSize
-import com.google.android.gms.ads.AdView
-import com.google.android.gms.ads.MobileAds
-import com.google.android.gms.ads.RequestConfiguration
-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: AdView
- private lateinit var googleMobileAdsConsentManager: GoogleMobileAdsConsentManager
-
- // Determine the screen width (less decorations) to use for the ad width.
- // If the ad hasn't been laid out, default to the full screen width.
- private 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)
-
- adView = AdView(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()
- }
- }
-
- // 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() {
- adView.adUnitId = AD_UNIT_ID
-
- adView.setAdSize(adSize)
-
- // Create an ad request.
- val adRequest = AdRequest.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()
- }
- }
-
- companion object {
- // This is an ad unit ID for a test ad. Replace with your own banner ad unit ID.
- private val AD_UNIT_ID = "ca-app-pub-3940256099942544/9214589741"
- }
-}
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml
deleted file mode 100644
index 6efadd152..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/layout/activity_my.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml
deleted file mode 100644
index c4a677368..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/action_menu.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/my.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/my.xml
deleted file mode 100644
index f1fa1552e..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/my.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml
deleted file mode 100644
index 91c059d6e..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/menu/popup_menu.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100755
index 0d23b32e9..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100755
index 18181ddd3..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100755
index ce686f5c8..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100755
index 88fba1a6b..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100755
index c0d781241..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100755
index 64089b0b7..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100755
index 921d5f002..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100755
index 7cc8077cd..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100755
index 74ccd22d0..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100755
index 7391d555d..000000000
Binary files a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc81644..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/dimens.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c822467..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/strings.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/strings.xml
deleted file mode 100644
index e6ee78b55..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- Settings
- AdMob Adaptive Banner
- Hello world!
- More
- Privacy Settings
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/styles.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/styles.xml
deleted file mode 100644
index 766ab9930..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml b/kotlin/admob/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml
deleted file mode 100644
index a34a5f190..000000000
--- a/kotlin/admob/AdaptiveBannerExample/app/src/main/res/xml/network_security_config.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/kotlin/admob/AdaptiveBannerExample/build.gradle b/kotlin/admob/AdaptiveBannerExample/build.gradle
deleted file mode 100644
index cac693722..000000000
--- a/kotlin/admob/AdaptiveBannerExample/build.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- ext.kotlin_version = '1.7.0'
- repositories {
- google()
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:8.1.2'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
-allprojects {
- repositories {
- google()
- mavenCentral()
- }
-}
diff --git a/kotlin/admob/AdaptiveBannerExample/gradle.properties b/kotlin/admob/AdaptiveBannerExample/gradle.properties
deleted file mode 100644
index cc8c88320..000000000
--- a/kotlin/admob/AdaptiveBannerExample/gradle.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-android.enableJetifier=true
-android.useAndroidX=true
diff --git a/kotlin/admob/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties b/kotlin/admob/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index d5181ae8a..000000000
--- a/kotlin/admob/AdaptiveBannerExample/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Mon Mar 30 10:38:12 PDT 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https://services.gradle.org/distributions/gradle-8.4-all.zip
diff --git a/kotlin/admob/AdaptiveBannerExample/gradlew b/kotlin/admob/AdaptiveBannerExample/gradlew
deleted file mode 100755
index cccdd3d51..000000000
--- a/kotlin/admob/AdaptiveBannerExample/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/kotlin/admob/AdaptiveBannerExample/gradlew.bat b/kotlin/admob/AdaptiveBannerExample/gradlew.bat
deleted file mode 100644
index e95643d6a..000000000
--- a/kotlin/admob/AdaptiveBannerExample/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/kotlin/admob/AdaptiveBannerExample/settings.gradle b/kotlin/admob/AdaptiveBannerExample/settings.gradle
deleted file mode 100644
index e7b4def49..000000000
--- a/kotlin/admob/AdaptiveBannerExample/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':app'
diff --git a/kotlin/admob/BannerExample/app/src/main/AndroidManifest.xml b/kotlin/admob/BannerExample/app/src/main/AndroidManifest.xml
index 3f0681ca6..4ade6bb60 100644
--- a/kotlin/admob/BannerExample/app/src/main/AndroidManifest.xml
+++ b/kotlin/admob/BannerExample/app/src/main/AndroidManifest.xml
@@ -1,14 +1,12 @@
+ package="com.google.android.gms.example.bannerexample" >
+ android:theme="@style/AppTheme" >
+ android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:exported="true">
diff --git a/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt b/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
index 51b004178..f2d1d7a1e 100644
--- a/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
+++ b/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/GoogleMobileAdsConsentManager.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2023 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.bannerexample
import android.app.Activity
diff --git a/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt b/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt
index 099203c54..d20449752 100644
--- a/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt
+++ b/kotlin/admob/BannerExample/app/src/main/java/com/google/android/gms/example/bannerexample/MainActivity.kt
@@ -1,14 +1,33 @@
+/*
+ * Copyright 2023 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.bannerexample
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 androidx.appcompat.widget.PopupMenu
import com.google.android.gms.ads.AdRequest
+import com.google.android.gms.ads.AdSize
+import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.RequestConfiguration
import com.google.android.gms.example.bannerexample.databinding.ActivityMainBinding
@@ -16,33 +35,50 @@ import java.util.concurrent.atomic.AtomicBoolean
private const val TAG = "MainActivity"
+/** Main Activity. Inflates main activity xml and child fragments. */
class MainActivity : AppCompatActivity() {
private val isMobileAdsInitializeCalled = AtomicBoolean(false)
+ private val initialLayoutComplete = AtomicBoolean(false)
private lateinit var binding: ActivityMainBinding
+ private lateinit var adView: AdView
private lateinit var googleMobileAdsConsentManager: GoogleMobileAdsConsentManager
+ // Determine the screen width (less decorations) to use for the ad width.
+ // If the ad hasn't been laid out, default to the full screen width.
+ private 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 = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
+ adView = AdView(this)
+ binding.adViewContainer.addView(adView)
+
// Log the Mobile Ads SDK version.
Log.d(TAG, "Google Mobile Ads SDK Version: " + MobileAds.getVersion())
- // 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()
- )
-
googleMobileAdsConsentManager = GoogleMobileAdsConsentManager.getInstance(applicationContext)
googleMobileAdsConsentManager.gatherConsent(this) { error ->
- error?.let {
+ if (error != null) {
// Consent not obtained in current session.
- Log.d(TAG, "${it.errorCode}: ${it.message}")
+ Log.d(TAG, "${error.errorCode}: ${error.message}")
}
if (googleMobileAdsConsentManager.canRequestAds) {
@@ -59,23 +95,39 @@ class MainActivity : AppCompatActivity() {
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()
+ }
+ }
+
+ // 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
+ /** Called when leaving the activity. */
public override fun onPause() {
- binding.adView.pause()
+ adView.pause()
super.onPause()
}
- // Called when returning to the activity
+ /** Called when returning to the activity. */
public override fun onResume() {
super.onResume()
- binding.adView.resume()
+ adView.resume()
}
- // Called before the activity is destroyed
+ /** Called before the activity is destroyed. */
public override fun onDestroy() {
- binding.adView.destroy()
+ adView.destroy()
super.onDestroy()
}
@@ -88,24 +140,37 @@ class MainActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val menuItemView = findViewById(item.itemId)
- val popup = PopupMenu(this, menuItemView)
- popup.menuInflater.inflate(R.menu.popup_menu, popup.menu)
- popup.show()
- popup.setOnMenuItemClickListener { popupMenuItem ->
- when (popupMenuItem.itemId) {
- R.id.privacy_settings -> {
- // Handle changes to user consent.
- googleMobileAdsConsentManager.showPrivacyOptionsForm(this) { formError ->
- formError?.let {
- Toast.makeText(this@MainActivity, it.message, Toast.LENGTH_SHORT).show()
+ 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@MainActivity) { formError ->
+ if (formError != null) {
+ Toast.makeText(this@MainActivity, formError.message, Toast.LENGTH_SHORT).show()
+ }
}
+ true
}
- true
+ else -> false
}
- else -> false
}
+ return super.onOptionsItemSelected(item)
}
- return super.onOptionsItemSelected(item)
+ }
+
+ private fun loadBanner() {
+ // This is an ad unit ID for a test ad. Replace with your own banner ad unit ID.
+ adView.adUnitId = "ca-app-pub-3940256099942544/9214589741"
+ adView.setAdSize(adSize)
+
+ // Create an ad request.
+ val adRequest = AdRequest.Builder().build()
+
+ // Start loading the ad in the background.
+ adView.loadAd(adRequest)
}
private fun initializeMobileAdsSdk() {
@@ -113,11 +178,12 @@ class MainActivity : AppCompatActivity() {
return
}
- // Initialize the Google Mobile Ads SDK.
- MobileAds.initialize(this)
+ // Initialize the Mobile Ads SDK.
+ MobileAds.initialize(this) {}
- // Request an ad.
- val adRequest = AdRequest.Builder().build()
- binding.adView.loadAd(adRequest)
+ // Load an ad.
+ if (initialLayoutComplete.get()) {
+ loadBanner()
+ }
}
}
diff --git a/kotlin/admob/BannerExample/app/src/main/res/layout/activity_main.xml b/kotlin/admob/BannerExample/app/src/main/res/layout/activity_main.xml
index 0f597d3d0..f4b7bbec7 100644
--- a/kotlin/admob/BannerExample/app/src/main/res/layout/activity_main.xml
+++ b/kotlin/admob/BannerExample/app/src/main/res/layout/activity_main.xml
@@ -1,34 +1,27 @@
-
-
+ android:background="@android:color/transparent"
+ tools:context=".MainActivity"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
+ tools:ignore="MergeRootFrame">
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginStart="@dimen/activity_horizontal_margin"
+ android:text="@string/hello_world" />
-
+ android:layout_centerInParent="true"
+ android:layout_alignParentBottom="true" />
-
+
diff --git a/kotlin/admob/BannerExample/app/src/main/res/values/dimensions.xml b/kotlin/admob/BannerExample/app/src/main/res/values/dimensions.xml
new file mode 100644
index 000000000..acf94cc67
--- /dev/null
+++ b/kotlin/admob/BannerExample/app/src/main/res/values/dimensions.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
diff --git a/kotlin/admob/BannerExample/app/src/main/res/values/strings.xml b/kotlin/admob/BannerExample/app/src/main/res/values/strings.xml
index 672f92edd..61067a038 100644
--- a/kotlin/admob/BannerExample/app/src/main/res/values/strings.xml
+++ b/kotlin/admob/BannerExample/app/src/main/res/values/strings.xml
@@ -1,5 +1,8 @@
+
- AdMob Banner Example
+ Settings
+ AdMob Banner Example
+ Hello world!MorePrivacy Settings