From 7939c3d73fc35597e78738e7d43d61d53281ec03 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Tue, 18 Jun 2013 15:53:56 +0800 Subject: [PATCH 1/2] Add advertisement type for more Ads plugins. --- plugin/.gitignore | 1 + .../src/org/cocos2dx/plugin/AdsAdmob.java | 10 +++++++++- plugin/plugins/admob/proj.ios/AdsAdmob.h | 1 + plugin/plugins/admob/proj.ios/AdsAdmob.m | 19 ++++++++++++++++--- plugin/protocols/include/ProtocolAds.h | 6 ++++++ .../platform/android/ProtocolAds.cpp | 5 +++++ plugin/protocols/platform/ios/AdsWrapper.h | 1 + plugin/protocols/platform/ios/InterfaceAds.h | 1 + .../src/org/cocos2dx/plugin/AdsWrapper.java | 1 + .../src/org/cocos2dx/plugin/InterfaceAds.java | 1 + .../HelloAds/Classes/HelloWorldScene.cpp | 1 + 11 files changed, 43 insertions(+), 4 deletions(-) diff --git a/plugin/.gitignore b/plugin/.gitignore index 26284a528f..89803f5e7e 100644 --- a/plugin/.gitignore +++ b/plugin/.gitignore @@ -94,4 +94,5 @@ tools/toolsForPublish/environment.sh .settings plugins/china* plugins/punchbox* +plugins/touchpay* samplesPrivate* diff --git a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java index 98f524e999..1f5689c465 100644 --- a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java +++ b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java @@ -99,6 +99,9 @@ public class AdsAdmob implements InterfaceAds { case AdsWrapper.ADS_TYPE_FULL_SCREEN: LogD("Now not support full screen view in Admob"); break; + case AdsWrapper.ADS_TYPE_MORE_APP: + LogD("Now not support more app ads in Admob"); + break; default: break; } @@ -106,7 +109,7 @@ public class AdsAdmob implements InterfaceAds { @Override public void spendPoints(int points) { - // do nothing, Admob don't have this function + LogD("Admob not support spend points!"); } @Override @@ -261,4 +264,9 @@ public class AdsAdmob implements InterfaceAds { public String getPluginVersion() { return "0.2.0"; } + + @Override + public void queryPoints() { + LogD("Admob not support query points!"); + } } diff --git a/plugin/plugins/admob/proj.ios/AdsAdmob.h b/plugin/plugins/admob/proj.ios/AdsAdmob.h index 50f7de8176..ffebe758d4 100644 --- a/plugin/plugins/admob/proj.ios/AdsAdmob.h +++ b/plugin/plugins/admob/proj.ios/AdsAdmob.h @@ -50,6 +50,7 @@ typedef enum { - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; - (void) hideAds: (int) type; +- (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) isDebugMode; - (NSString*) getSDKVersion; diff --git a/plugin/plugins/admob/proj.ios/AdsAdmob.m b/plugin/plugins/admob/proj.ios/AdsAdmob.m index 351651c635..f1128e37fc 100644 --- a/plugin/plugins/admob/proj.ios/AdsAdmob.m +++ b/plugin/plugins/admob/proj.ios/AdsAdmob.m @@ -62,10 +62,18 @@ return; } - if (type == kTypeBanner) { + switch (type) { + case kTypeBanner: [self showBanner:sizeEnum atPos:pos]; - } else { + break; + case kTypeFullScreen: OUTPUT_LOG(@"Now not support full screen view in Admob"); + break; + case kTypeMoreApp: + OUTPUT_LOG(@"Now not support more app ads in Admob"); + break; + default: + break; } } @@ -82,9 +90,14 @@ } } +- (void) queryPoints +{ + OUTPUT_LOG(@"Admob not support query points!"); +} + - (void) spendPoints: (int) points { - + OUTPUT_LOG(@"Admob not support spend points!"); } - (void) setDebugMode: (BOOL) isDebugMode diff --git a/plugin/protocols/include/ProtocolAds.h b/plugin/protocols/include/ProtocolAds.h index 4ca675cf1d..f485eb2adb 100644 --- a/plugin/protocols/include/ProtocolAds.h +++ b/plugin/protocols/include/ProtocolAds.h @@ -72,6 +72,7 @@ public: typedef enum { kBannerAd = 0, kFullScreenAd, + kMoreApp, } AdsType; typedef enum { @@ -111,6 +112,11 @@ public: */ void hideAds(AdsType type); + /** + @brief Query the points of player + */ + void queryPoints(); + /** @brief Spend the points. Use this method to notify server spend points. diff --git a/plugin/protocols/platform/android/ProtocolAds.cpp b/plugin/protocols/platform/android/ProtocolAds.cpp index 8bdc34029c..fead515b40 100644 --- a/plugin/protocols/platform/android/ProtocolAds.cpp +++ b/plugin/protocols/platform/android/ProtocolAds.cpp @@ -119,6 +119,11 @@ void ProtocolAds::hideAds(AdsType type) PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type); } +void ProtocolAds::queryPoints() +{ + PluginUtils::callJavaFunctionWithName(this, "queryPoints"); +} + void ProtocolAds::spendPoints(int points) { PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points); diff --git a/plugin/protocols/platform/ios/AdsWrapper.h b/plugin/protocols/platform/ios/AdsWrapper.h index b8686f2e4f..550c284028 100644 --- a/plugin/protocols/platform/ios/AdsWrapper.h +++ b/plugin/protocols/platform/ios/AdsWrapper.h @@ -41,6 +41,7 @@ typedef enum { typedef enum { kTypeBanner = 0, kTypeFullScreen, + kTypeMoreApp, } AdsTypeEnum; typedef enum { diff --git a/plugin/protocols/platform/ios/InterfaceAds.h b/plugin/protocols/platform/ios/InterfaceAds.h index 7fb01971ed..f15b7ab03d 100644 --- a/plugin/protocols/platform/ios/InterfaceAds.h +++ b/plugin/protocols/platform/ios/InterfaceAds.h @@ -29,6 +29,7 @@ THE SOFTWARE. - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; - (void) hideAds: (int) type; +- (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) debug; - (NSString*) getSDKVersion; diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java index 42978cad90..cd14e6224f 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java @@ -39,6 +39,7 @@ public class AdsWrapper { public static final int ADS_TYPE_BANNER = 0; public static final int ADS_TYPE_FULL_SCREEN = 1; + public static final int ADS_TYPE_MORE_APP = 2; public static final int POS_CENTER = 0; public static final int POS_TOP = 1; diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java index 6d7f85f1f9..cd740b9d73 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java @@ -32,6 +32,7 @@ public interface InterfaceAds { public void configDeveloperInfo(Hashtable devInfo); public void showAds(int type, int sizeEnum, int pos); public void hideAds(int type); + public void queryPoints(); public void spendPoints(int points); public void setDebugMode(boolean debug); public String getSDKVersion(); diff --git a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp b/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp index 27393f1d83..a4949daa1f 100644 --- a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp @@ -34,6 +34,7 @@ const std::string s_aTestCases[] = { const std::string s_aTestTypes[] = { "Banner", "Full Screen", + "More App", }; const std::string s_aTestPoses[] = { From 776efaf458b03382ce34cd29081c2e131e258437 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 19 Jun 2013 16:41:15 +0800 Subject: [PATCH 2/2] Adjust ProtocolAds for more Ads plugins. --- .../admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java | 4 ++-- plugin/protocols/include/ProtocolAds.h | 4 ++-- plugin/protocols/platform/ios/AdsWrapper.h | 4 ++-- .../proj.android/src/org/cocos2dx/plugin/AdsWrapper.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java index 1f5689c465..d69ccf83c4 100644 --- a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java +++ b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java @@ -216,7 +216,7 @@ public class AdsAdmob implements InterfaceAds { @Override public void onDismissScreen(Ad arg0) { LogD("onDismissScreen invoked"); - AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!"); + AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads view dismissed!"); } @Override @@ -250,7 +250,7 @@ public class AdsAdmob implements InterfaceAds { @Override public void onPresentScreen(Ad arg0) { LogD("onPresentScreen invoked"); - AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!"); + AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsShown, "Ads view shown!"); } @Override diff --git a/plugin/protocols/include/ProtocolAds.h b/plugin/protocols/include/ProtocolAds.h index f485eb2adb..2d2393c74f 100644 --- a/plugin/protocols/include/ProtocolAds.h +++ b/plugin/protocols/include/ProtocolAds.h @@ -36,8 +36,8 @@ typedef enum { kAdsReceived = 0, // The ad is received - kFullScreenViewShown, // The full screen advertisement shown - kFullScreenViewDismissed, // The full screen advertisement dismissed + kAdsShown, // The advertisement shown + kAdsDismissed, // The advertisement dismissed kPointsSpendSucceed, // The points spend succeed kPointsSpendFailed, // The points spend failed diff --git a/plugin/protocols/platform/ios/AdsWrapper.h b/plugin/protocols/platform/ios/AdsWrapper.h index 550c284028..ff7d176835 100644 --- a/plugin/protocols/platform/ios/AdsWrapper.h +++ b/plugin/protocols/platform/ios/AdsWrapper.h @@ -28,8 +28,8 @@ THE SOFTWARE. typedef enum { kAdsReceived = 0, - kFullScreenViewShown, - kFullScreenViewDismissed, + kAdsShown, + kAdsDismissed, kPointsSpendSucceed, kPointsSpendFailed, diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java index cd14e6224f..6803baa0d2 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java @@ -30,8 +30,8 @@ import android.view.WindowManager; public class AdsWrapper { public static final int RESULT_CODE_AdsReceived = 0; // The ad is received - public static final int RESULT_CODE_FullScreenViewShown = 1; // The full screen advertisement shown - public static final int RESULT_CODE_FullScreenViewDismissed = 2; // The full screen advertisement dismissed + public static final int RESULT_CODE_AdsShown = 1; // The advertisement shown + public static final int RESULT_CODE_AdsDismissed = 2; // The advertisement dismissed public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed public static final int RESULT_CODE_NetworkError = 5; // Network error