-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae2eff8
commit 6b36f77
Showing
22 changed files
with
2,719 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Binaries/ | ||
Intermediate/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.0", | ||
"FriendlyName": "HuaweiAds", | ||
"Description": "Ads plugin for Unreal Game Engine to Huawei App Gallery", | ||
"Category": "Service", | ||
"CreatedBy": "Huawei Japan DTSE", | ||
"CreatedByURL": "", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"EnabledByDefault": true, | ||
"SupportURL": "", | ||
"Modules": [ | ||
{ | ||
"Name": "HuaweiAds", | ||
"Type": "Runtime", | ||
"LoadingPhase": "PreLoadingScreen" | ||
} | ||
] | ||
} |
102 changes: 102 additions & 0 deletions
102
Source/HuaweiAds/External/com/huawei/adplugin/Const.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.huawei.adplugin; | ||
|
||
public class Const { | ||
public static final class BannerAdSize { | ||
public static final String USER_DEFINED = "USER_DEFINED"; | ||
|
||
public static final String BANNER_SIZE_320_50 = "BANNER_SIZE_320_50"; | ||
|
||
public static final String BANNER_SIZE_320_100 = "BANNER_SIZE_320_100"; | ||
|
||
public static final String BANNER_SIZE_468_60 = "BANNER_SIZE_468_60"; | ||
|
||
public static final String BANNER_SIZE_DYNAMIC = "BANNER_SIZE_DYNAMIC"; | ||
|
||
public static final String BANNER_SIZE_728_90 = "BANNER_SIZE_728_90"; | ||
|
||
public static final String BANNER_SIZE_300_250 = "BANNER_SIZE_300_250"; | ||
|
||
public static final String BANNER_SIZE_SMART = "BANNER_SIZE_SMART"; | ||
|
||
public static final String BANNER_SIZE_160_600 = "BANNER_SIZE_160_600"; | ||
|
||
public static final String BANNER_SIZE_360_57 = "BANNER_SIZE_360_57"; | ||
|
||
public static final String BANNER_SIZE_360_144 = "BANNER_SIZE_360_144"; | ||
} | ||
|
||
public static final class BannerAdPositionCode { | ||
/** | ||
* Position constant for a position with a custom offset. | ||
*/ | ||
public static final int POSITION_CUSTOM = -1; | ||
|
||
/** | ||
* Position constant for top of the screen. | ||
*/ | ||
public static final int POSITION_TOP = 0; | ||
|
||
/** | ||
* Position constant for bottom of the screen. | ||
*/ | ||
public static final int POSITION_BOTTOM = 1; | ||
|
||
/** | ||
* Position constant for top-left of the screen. | ||
*/ | ||
public static final int POSITION_TOP_LEFT = 2; | ||
|
||
/** | ||
* Position constant for top-right of the screen. | ||
*/ | ||
public static final int POSITION_TOP_RIGHT = 3; | ||
|
||
/** | ||
* Position constant for bottom-left of the screen. | ||
*/ | ||
public static final int POSITION_BOTTOM_LEFT = 4; | ||
|
||
/** | ||
* Position constant bottom-right of the screen. | ||
*/ | ||
public static final int POSITION_BOTTOM_RIGHT = 5; | ||
|
||
/** | ||
* Position constant center of the screen. | ||
*/ | ||
public static final int POSITION_CENTER = 6; | ||
|
||
public static int getLayoutGravityForPositionCode(int positionCode) { | ||
int gravity; | ||
switch (positionCode) { | ||
case POSITION_TOP: | ||
gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; | ||
break; | ||
case POSITION_BOTTOM: | ||
gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; | ||
break; | ||
case POSITION_TOP_LEFT: | ||
gravity = Gravity.TOP | Gravity.LEFT; | ||
break; | ||
case POSITION_TOP_RIGHT: | ||
gravity = Gravity.TOP | Gravity.RIGHT; | ||
break; | ||
case POSITION_BOTTOM_LEFT: | ||
gravity = Gravity.BOTTOM | Gravity.LEFT; | ||
break; | ||
case POSITION_BOTTOM_RIGHT: | ||
gravity = Gravity.BOTTOM | Gravity.RIGHT; | ||
break; | ||
case POSITION_CENTER: | ||
gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL; | ||
break; | ||
case POSITION_CUSTOM: | ||
gravity = Gravity.TOP | Gravity.LEFT; | ||
break; | ||
default: | ||
throw new IllegalArgumentException("Attempted to position ad with invalid ad " + "position."); | ||
} | ||
return gravity; | ||
} | ||
} | ||
} |
204 changes: 204 additions & 0 deletions
204
Source/HuaweiAds/External/com/huawei/adplugin/HuaweiAdsPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
package com.huawei.adplugin; | ||
|
||
import com.huawei.adplugin.*; | ||
import com.huawei.hms.ads.*; | ||
|
||
import android.app.Activity; | ||
|
||
public class HuaweiAdsPlugin { | ||
private static boolean isInit = false; | ||
private static Activity mActivity = null; | ||
private static BannerAdProxy bannerAdProxy = null; | ||
private static InterstitialAdProxy interstitialAdProxy = null; | ||
private static RewardAdProxy rewardAdProxy = null; | ||
|
||
public static void initialize(Activity activity) { | ||
if (!isInit) { | ||
isInit = true; | ||
mActivity = activity; | ||
} | ||
} | ||
|
||
public static void loadBannerAd(String adId, int position, String size, IAdStatusListener adStatusListener) { | ||
if (mActivity == null) { | ||
return; | ||
} | ||
if (bannerAdProxy == null) { | ||
bannerAdProxy = new BannerAdProxy(mActivity, new IAdStatusListener() { | ||
@Override | ||
public void onAdClosed() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdClosed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdFailed(int errorCode) { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdFailed(errorCode); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdLeftApp() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdLeftApp(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdOpened() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdOpened(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdLoaded() { | ||
showBannerAd(); | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdLoaded(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdClicked() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdClicked(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdImpression() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdImpression(); | ||
} | ||
} | ||
}); | ||
} | ||
bannerAdProxy.setAdId(adId); | ||
bannerAdProxy.setBannerAdPosition(position); | ||
bannerAdProxy.setAdSizeType(size); | ||
AdParam adParam = new AdParam.Builder().build(); | ||
bannerAdProxy.loadAd(adParam); | ||
} | ||
|
||
public static void showBannerAd(){ | ||
if (bannerAdProxy != null) { | ||
bannerAdProxy.show(); | ||
} | ||
} | ||
|
||
public static void hideBannerAd() { | ||
if (bannerAdProxy != null) { | ||
bannerAdProxy.hide(); | ||
} | ||
} | ||
|
||
public static void destroyBannerAd() { | ||
if (bannerAdProxy != null) { | ||
bannerAdProxy.destroy(); | ||
} | ||
} | ||
|
||
public static void loadInterstitialAd(String adId, IAdStatusListener adStatusListener) { | ||
if (mActivity == null) { | ||
return; | ||
} | ||
if (interstitialAdProxy == null) { | ||
interstitialAdProxy = new InterstitialAdProxy(mActivity); | ||
} | ||
interstitialAdProxy.setAdId(adId); | ||
interstitialAdProxy.setAdListener(new IAdStatusListener() { | ||
@Override | ||
public void onAdClosed() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdClosed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdFailed(int errorCode) { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdFailed(errorCode); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdLeftApp() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdLeftApp(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdOpened() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdOpened(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdLoaded() { | ||
showInterstitialAd(); | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdLoaded(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdClicked() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdClicked(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAdImpression() { | ||
if (adStatusListener != null) { | ||
adStatusListener.onAdImpression(); | ||
} | ||
} | ||
}); | ||
AdParam adParam = new AdParam.Builder().build(); | ||
interstitialAdProxy.loadAd(adParam); | ||
} | ||
|
||
public static void showInterstitialAd() { | ||
if (interstitialAdProxy != null && interstitialAdProxy.isLoaded()) { | ||
interstitialAdProxy.show(); | ||
} | ||
} | ||
|
||
public static void loadRewardAd(String adId, IRewardAdLoadListener rewardLoadListener, IRewardAdStatusListener rewardStatusListener) { | ||
if (mActivity == null) { | ||
return; | ||
} | ||
if (rewardAdProxy == null) { | ||
rewardAdProxy = new RewardAdProxy(adId, mActivity); | ||
} | ||
AdParam adParam = new AdParam.Builder().build(); | ||
rewardAdProxy.loadAd(adParam, new IRewardAdLoadListener() { | ||
@Override | ||
public void onRewardAdFailedToLoad(final int errorCode) { | ||
if (rewardLoadListener != null) { | ||
rewardLoadListener.onRewardAdFailedToLoad(errorCode); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRewardedLoaded() { | ||
showRewardAd(rewardStatusListener); | ||
if (rewardLoadListener != null) { | ||
rewardLoadListener.onRewardedLoaded(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public static void showRewardAd(IRewardAdStatusListener adStatusListener) { | ||
if (rewardAdProxy != null && rewardAdProxy.isLoaded() && mActivity != null) { | ||
rewardAdProxy.show(mActivity, adStatusListener); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Source/HuaweiAds/External/com/huawei/adplugin/adlistener/IAdStatusListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.huawei.adplugin.adlistener; | ||
|
||
public interface IAdStatusListener { | ||
void onAdClosed(); | ||
|
||
void onAdFailed(int errorCode); | ||
|
||
void onAdLeftApp(); | ||
|
||
void onAdOpened(); | ||
|
||
void onAdLoaded(); | ||
|
||
void onAdClicked(); | ||
|
||
void onAdImpression(); | ||
} |
8 changes: 8 additions & 0 deletions
8
Source/HuaweiAds/External/com/huawei/adplugin/adlistener/IRewardAdLoadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
package com.huawei.adplugin.adlistener; | ||
|
||
public interface IRewardAdLoadListener { | ||
void onRewardAdFailedToLoad(int errorCode); | ||
|
||
void onRewardedLoaded(); | ||
} |
16 changes: 16 additions & 0 deletions
16
Source/HuaweiAds/External/com/huawei/adplugin/adlistener/IRewardAdStatusListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
package com.huawei.adplugin.adlistener; | ||
|
||
public interface IRewardAdStatusListener { | ||
void onRewardAdFailedToLoad(int errorCode); | ||
|
||
void onRewardedLoaded(); | ||
|
||
void onRewardAdClosed(); | ||
|
||
void onRewardAdFailedToShow(int errorCode); | ||
|
||
void onRewardAdOpened(); | ||
|
||
void onRewarded(String type, int amount); | ||
} |
Oops, something went wrong.