Skip to content

Commit

Permalink
feat(unification): Prebid configuration unification #370
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinPostindustria committed Mar 16, 2022
1 parent eb3893c commit b37cd95
Show file tree
Hide file tree
Showing 49 changed files with 550 additions and 816 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.mopub.common.SdkConfiguration
import com.mopub.common.logging.MoPubLog
import org.prebid.mobile.Host
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings

class CustomApplication : Application() {

Expand Down Expand Up @@ -62,10 +61,10 @@ class CustomApplication : Application() {
PrebidMobile.setShareGeoLocation(true)
PrebidMobile.setApplicationContext(applicationContext)

val host = org.prebid.mobile.rendering.bidding.enums.Host.CUSTOM
val host = Host.CUSTOM
host.hostUrl = "https://prebid.openx.net/openrtb2/auction"
PrebidRenderingSettings.setBidServerHost(host)
PrebidRenderingSettings.setAccountId("0689a263-318d-448b-a3d4-b02e8a709d9d")
PrebidMobile.setPrebidServerHost(host)
PrebidMobile.setPrebidServerAccountId("0689a263-318d-448b-a3d4-b02e8a709d9d")
}

private fun initAdMob() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@
package org.prebid.mobile.renderingtestapp.uiAutomator.pages.mraidBannerAds;

import android.view.KeyEvent;

import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.Until;

import org.json.JSONException;
import org.json.JSONObject;
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings;
import org.prebid.mobile.rendering.utils.helpers.AdIdManager;
import org.prebid.mobile.rendering.utils.helpers.AppInfoManager;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;

public class Mraid3TestProperties extends MraidBasicPage {

Expand All @@ -52,13 +46,13 @@ public Mraid3TestProperties clickBanner() {

public Mraid3TestProperties checkMraidEnv() throws JSONException {
JSONObject envJson = new JSONObject();
envJson.put("version", PrebidRenderingSettings.MRAID_VERSION);
envJson.put("sdk", PrebidRenderingSettings.SDK_NAME);
envJson.put("sdkVersion", PrebidRenderingSettings.SDK_VERSION);
envJson.put("version", PrebidMobile.MRAID_VERSION);
envJson.put("sdk", PrebidMobile.SDK_NAME);
envJson.put("sdkVersion", PrebidMobile.SDK_VERSION);
envJson.put("appId", AppInfoManager.getPackageName());
envJson.put("ifa", AdIdManager.getAdId());
envJson.put("limitAdTracking", AdIdManager.isLimitAdTrackingEnabled());
envJson.put("coppa", PrebidRenderingSettings.isCoppaEnabled);
envJson.put("coppa", PrebidMobile.isCoppaEnabled);

String viewText = clearStringFromWhitespace(device.wait(Until.findObject(Locators.envContainer), TIMEOUT).getText());
assertEquals(envJson.toString(), viewText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.test.espresso.idling.CountingIdlingResource
import kotlinx.android.synthetic.main.events_bids.*
import org.prebid.mobile.*
import org.prebid.mobile.rendering.bidding.display.MediationNativeAdUnit
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings
import org.prebid.mobile.renderingtestapp.plugplay.config.*
import org.prebid.mobile.renderingtestapp.utils.BaseFragment
import org.prebid.mobile.renderingtestapp.utils.ConfigurationViewSettings
Expand All @@ -51,7 +50,7 @@ abstract class AdFragment : BaseFragment() {
protected var adUnitId: String = ""
protected var width = 0
protected var height = 0
protected var refreshDelay = PrebidRenderingSettings.AUTO_REFRESH_DELAY_DEFAULT / 1000
protected var refreshDelay = PrebidMobile.AUTO_REFRESH_DELAY_DEFAULT / 1000

private var adView: Any? = null

Expand Down Expand Up @@ -208,10 +207,10 @@ abstract class AdFragment : BaseFragment() {

private fun setNoBidsAccountId(enable: Boolean) {
if (enable) {
PrebidRenderingSettings.setAccountId(getString(R.string.prebid_account_id_prod_no_bids))
PrebidMobile.setPrebidServerAccountId(getString(R.string.prebid_account_id_prod_no_bids))
}
else {
PrebidRenderingSettings.setAccountId(getString(R.string.prebid_account_id_prod))
PrebidMobile.setPrebidServerAccountId(getString(R.string.prebid_account_id_prod))
}
}

Expand All @@ -226,12 +225,12 @@ abstract class AdFragment : BaseFragment() {
}

protected fun configureOriginalPrebid() {
val hostUrl = PrebidRenderingSettings.getBidServerHost().hostUrl
val hostUrl = PrebidMobile.getPrebidServerHost().hostUrl
val host = Host.CUSTOM
host.hostUrl = hostUrl
PrebidMobile.setApplicationContext(requireContext())
PrebidMobile.setPrebidServerHost(host)
PrebidMobile.setPrebidServerAccountId(PrebidRenderingSettings.getAccountId())
PrebidMobile.setPrebidServerAccountId(PrebidMobile.getPrebidServerAccountId())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import android.webkit.WebView
import androidx.multidex.MultiDex
import androidx.multidex.MultiDexApplication
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings
import org.prebid.mobile.renderingtestapp.utils.DemoItemProvider
import org.prebid.mobile.renderingtestapp.utils.MockServerUtils
import org.prebid.mobile.renderingtestapp.utils.SourcePicker
Expand All @@ -43,8 +42,8 @@ class InternalTestApplication : MultiDexApplication() {
instance = this

PrebidMobile.setApplicationContext(this)
PrebidRenderingSettings.setAccountId(getString(R.string.prebid_account_id_prod))
PrebidRenderingSettings.logLevel = PrebidRenderingSettings.LogLevel.DEBUG
PrebidMobile.setPrebidServerAccountId(getString(R.string.prebid_account_id_prod))
PrebidMobile.logLevel = PrebidMobile.LogLevel.DEBUG

// Setup mock responses only in mock build
val isMock = BuildConfig.FLAVOR == "mock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.EditText
import androidx.fragment.app.DialogFragment
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.renderingtestapp.R

private const val ARG_CONFIGURATOR_MODE = "ARG_CONFIGURATOR_MODE"
Expand Down Expand Up @@ -98,7 +98,7 @@ class AdConfiguratorDialogFragment : DialogFragment() {
heightField?.setText(argHeight.toString())
if (mode == AdConfiguratorMode.BANNER) {
refreshDelayField = dialogView.findViewById(R.id.etRefreshDelay)
refreshDelayField?.setText((PrebidRenderingSettings.AUTO_REFRESH_DELAY_DEFAULT / 1000).toString())
refreshDelayField?.setText((PrebidMobile.AUTO_REFRESH_DELAY_DEFAULT / 1000).toString())
}

dialogView.findViewById<Button>(R.id.btnLoad).setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.view.View
import com.google.android.gms.ads.MobileAds
import com.mopub.common.MoPub
import kotlinx.android.synthetic.main.fragments_version_info.*
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.renderingtestapp.R
import org.prebid.mobile.renderingtestapp.utils.BaseFragment

Expand All @@ -30,9 +30,9 @@ class VersionInfoFragment : BaseFragment() {

override fun initUi(view: View, savedInstanceState: Bundle?) {
MobileAds.initialize(requireContext())
tvPrebidRenderingVersion.text = PrebidRenderingSettings.SDK_VERSION
tvPrebidRenderingVersion.text = PrebidMobile.SDK_VERSION
tvMopubVersion.text = MoPub.SDK_VERSION
tvGamVersion.text = MobileAds.getVersionString()
tvOmsdkVersion.text = PrebidRenderingSettings.OMSDK_VERSION
tvOmsdkVersion.text = PrebidMobile.OMSDK_VERSION
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.prebid.mobile.renderingtestapp.utils

import org.prebid.mobile.rendering.bidding.enums.Host
import org.prebid.mobile.rendering.sdk.PrebidRenderingSettings
import org.prebid.mobile.Host
import org.prebid.mobile.PrebidMobile

object SourcePicker {

Expand Down Expand Up @@ -52,13 +52,13 @@ object SourcePicker {
accountId = PROD_ACCOUNT_ID
}
setBidServerHost(host)
PrebidRenderingSettings.setAccountId(accountId)
PrebidMobile.setPrebidServerAccountId(accountId)
}
}

private fun setBidServerHost(hostUrl: String) {
val host = Host.CUSTOM
host.hostUrl = hostUrl
PrebidRenderingSettings.setBidServerHost(host)
PrebidMobile.setPrebidServerHost(host)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ public String getHostUrl() {
return this.url;
}


public void setHostUrl(String url) {
if (this.equals(CUSTOM)) {
this.url = url;
}
}

public static Host createCustomHost(String url) {
Host custom = Host.CUSTOM;
custom.setHostUrl(url);
return custom;
}

}
Loading

0 comments on commit b37cd95

Please sign in to comment.