Skip to content

Commit

Permalink
Merge remote-tracking branch 'emma/adsNotifications' into adsNotifica…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
Bogdan Iusco committed Nov 24, 2011
2 parents 9f5a732 + 1b2e22e commit 30b315b
Show file tree
Hide file tree
Showing 2 changed files with 299 additions and 79 deletions.
148 changes: 134 additions & 14 deletions libs/Ads/Banner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace Ads
* @param bannerSize The size of the banner.
*/
Banner::Banner(
MAUtil::String publiserID,
MAUtil::String publisherID,
BannerSize bannerSize) :
mBannerManager(BannerManager::getInstance())
{
mHandle = maAdsBannerCreate(bannerSize, publiserID.c_str());
mHandle = maAdsBannerCreate(bannerSize, publisherID.c_str());
mBannerManager->registerBanner(this);
}

Expand Down Expand Up @@ -123,26 +123,22 @@ namespace Ads
}

/**
* Set a banner float property.
* Set a widget integer property, in hexadecimal base.
* @param property A string representing which property to set.
* @param value The string value which will be assigned to the property.
* @param value The integer value in hexadecimal which will be assigned to the property.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setPropertyFloat(
int Banner::setPropertyIntHexa(
const MAUtil::String& property,
float value)
{
char buffer[BUF_SIZE];
sprintf(buffer, "%f", value);
int resultCode = maAdsBannerSetProperty(
mHandle,
property.c_str(),
buffer);
const int value)

return resultCode;
{
char buffer[256];
sprintf(buffer, "0x%.6X", value);
return setProperty(property, buffer);
}

/**
Expand Down Expand Up @@ -303,6 +299,130 @@ namespace Ads
return false;
}

/**
* Sets the request state of the ads.
* If set to true ads are starting to be requested, if set to false the request for ads is stopped.
* Available only on Android. On iOS ads loading starts automatically at creation.
* @param requestState If true ads are starting to be requested, otherwise the request for ads is stopped.
*/
void Banner::requestContent(bool requestState)
{
setProperty(MA_ADS_REQUEST_CONTENT, (requestState ? "true" : "false") );
}

/**
* Sets the devices that are going to receive test ads only.
* You should utilize this property during development to avoid generating false impressions.
* Causes test ads to be returned to a device.
* Available only on Android.
* @param testDevice the device ID. Use TEST_EMULATOR to get test ads in the emulator.
*/
void Banner::addTestDevice(const MAUtil::String& testDevice)
{
setProperty(MA_ADS_TEST_DEVICE, testDevice);
}

/**
* Returns true if the ad is successfully loaded and is ready to be shown.
* Available only on Android.
* @return True if the ad is loaded, false otherwise.
*/
bool Banner::isReady()
{
MAUtil::String value = MAUtil::lowerString(
this->getPropertyString(MA_ADS_IS_READY));
if ( strcmp(value.c_str(),"true") == 0 )
{
return true;
}

return false;
}

/**
* Sets the coloration of test ads, specifically the background color.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setBackgroundColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_BG, color);
}

/**
* Sets the coloration of test ads,specifically the gradient background color at top.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setTopBackgroundColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_BG_TOP, color);
}

/**
* Sets the coloration of test ads, specfiically the border color.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setBorderColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_BORDER, color);
}

/**
* Sets the coloration of test ads, specfiically the link text color.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setLinkColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_LINK, color);
}

/**
* Sets the coloration of test ads, specfiically the text color.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setTextColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_TEXT, color);
}

/**
* Sets the coloration of test ads, specfiically the url color.
* Available only on Android.
* @param color A hexadecimal color value, e.g. 0xFF0000.
* @return Any of the following result codes:
* - #MA_ADS_RES_OK if the property could be set.
* - #MA_ADS_RES_INVALID_PROPERTY_NAME if the property name was invalid.
* - #MA_ADS_RES_INVALID_PROPERTY_VALUE if the property value was invalid.
*/
int Banner::setUrlColor(const int color)
{
return setPropertyIntHexa(MA_ADS_COLOR_URL, color);
}

/**
* Add an event listener for this banner.
* @param listener The listener that will receive
Expand Down
Loading

0 comments on commit 30b315b

Please sign in to comment.