-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapsell.b4a
278 lines (222 loc) · 13 KB
/
tapsell.b4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
Build1=Default,com.pp.ddcd
File1=item.bal
File2=Layout.bal
FileGroup1=Default Group
FileGroup2=Default Group
Group=Default Group
Library1=core
Library2=okhttp
Library3=xcustomlistview
Library4=xui
Library5=tapsellplusb4a
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="33"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>~\n~)~\n~~\n~~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~~\n~~\n~' Default adnetworks for TapsellPlus~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.AdMobTestAppId)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.AdMob)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.AdColony)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.UnityAds)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.AppLovin)~\n~CreateResourceFromFile(Macro, TapsellPlusB4A.Mintegral)~\n~~\n~~\n~~\n~''''' Important note for adding TapsellPlus adnetwork manifests '''''~\n~~\n~' If you want to add other adnetworks:~\n~~\n~' AdMob~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.AdMob)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~ ' Also you need to add this in your project:~\n~' #AdditionalJar: com.google.android.gms:play-services-ads-lite~\n~' For test to work you need to provide test appId~\n~'CreateResourceFromFile(Macro, TapsellPlusB4A.AdMobTestAppId)~\n~~\n~ ' AdColony~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.AdColony)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~ ' Also you need to add this in your project:~\n~' #AdditionalJar: adcolony-4.6.5.aar~\n~~\n~ ' Chartboost~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Chartboost)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~' Also you need to add this in your project:~\n~' #AdditionalJar: chartboost-sdk-8.2.1.aar~\n~~\n~ ' UnityAds~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.UnityAds)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~ ' Also you need to add this in your project:~\n~' #AdditionalJar: unity-ads-4.6.1.aar~\n~~\n~ ' AppLovin~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.AppLovin)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~ ' Also you need to add this in your project:~\n~' #AdditionalJar: applovin-sdk-11.8.2.aar~\n~~\n~' Mintegral~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Mintegral)~\n~' CreateResourceFromFile(Macro, TapsellPlusB4A.Essential)~\n~ ' Also you need to add this in your project:~\n~' #AdditionalJar: mintegral-interstitialvideo-16.3.91.aar~\n~' #AdditionalJar: mintegral-mbbanner-16.3.91.aar~\n~' #AdditionalJar: mintegral-mbjscommon-16.3.91.aar~\n~' #AdditionalJar: mintegral-playercommon-16.3.91.aar~\n~' #AdditionalJar: mintegral-reward-16.3.91.aar~\n~' #AdditionalJar: mintegral-same-16.3.91.aar~\n~' #AdditionalJar: mintegral-videocommon-16.3.91.aar~\n~' #AdditionalJar: mintegral-videojs-16.3.91.aar~\n~~\n~~\n~~\n~~\n~
Module1=Starter
NumberOfFiles=2
NumberOfLibraries=5
NumberOfModules=1
Version=12.5
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: TapsellPlusB4ASample
#VersionCode: 1
#VersionName: 1
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#MultiDex: true
#AdditionalJar: applovin-sdk-11.8.2.aar
#AdditionalJar: adcolony-4.6.5.aar
'#AdditionalJar: chartboost-sdk-8.2.1.aar ' Not supported for now, Don't use it
#AdditionalJar: unity-ads-4.6.1.aar
#AdditionalJar: com.google.android.gms:play-services-ads-lite
' Mintegral
#AdditionalJar: mintegral-interstitialvideo-16.3.91.aar
#AdditionalJar: mintegral-mbbanner-16.3.91.aar
#AdditionalJar: mintegral-mbjscommon-16.3.91.aar
#AdditionalJar: mintegral-playercommon-16.3.91.aar
#AdditionalJar: mintegral-reward-16.3.91.aar
#AdditionalJar: mintegral-same-16.3.91.aar
#AdditionalJar: mintegral-videocommon-16.3.91.aar
#AdditionalJar: mintegral-videojs-16.3.91.aar
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private xui As XUI
End Sub
Sub Globals
Dim tapsellPlus As TapsellPlus
Dim tapsellPlusAppId As String="alsoatsrtrotpqacegkehkaiieckldhrgsbspqtgqnbrrfccrtbdomgjtahflchkqtqosa"
Private xclv As CustomListView
Private Button1 As B4XView
Private pan As Panel
Private response As String = ""
' AdNetwork ZoneIds - These ARE for TESTING ONLY
' Make sure you have added TapsellPlus.Essential manifest (or TapsellPlus.Complete)
Private TapsellInterstitial As String = "5cfaa942e8d17f0001ffb292"
Private TapsellRewarded As String = "5cfaa802e8d17f0001ffb28e"
Private TapsellNativeBanner As String = "5cfaa9deaede570001d5553a"
Private TapsellNativeVideo As String = "60edcf8ad3459c17f019d36b"
Private TapsellStandard As String = "5cfaaa30e8d17f0001ffb294"
' For AdMob to work, you need to visit
' "https://docs.tapsell.ir/plus-sdk/b4a/adnetworks-test/ "
' and read the docs first
' Otherwise it will not work.
' Make sure you have added TapsellPlus.AdMob manifest as well (or TapsellPlus.Complete)
Private AdMobInterstitial As String = "5cfaa9b0e8d17f0001ffb293"
Private AdMobRewarded As String = "5cfaa8aee8d17f0001ffb28f"
Private AdMobNativeBanner As String = "5d123c9968287d00019e1a94"
Private AdMobStandard As String = "5cfaaa4ae8d17f0001ffb295"
' UnityAds
' Make sure you have added TapsellPlus.UnityAds manifest as well (or TapsellPlus.Complete)
Private UnityAdsInterstitial As String = "608d1c1c2d8e7e0001348111"
Private UnityAdsRewarded As String = "5cfaa8eae8d17f0001ffb291"
Private UnityAdsStandard As String = "608d20a7fb661b000190bfe4"
' Make sure you have added TapsellPlus.Chartboost manifest as well (or TapsellPlus.Complete)
Private ChartboostInterstitial As String = "60c5b303d756bf0001891f1c"
Private ChartboostRewarded As String = "5cfaa8cee8d17f0001ffb290"
' Make sure you have added TapsellPlus.AdColony manifest as well (or TapsellPlus.Complete)
Private AdColonyInterstitial As String = "5d336289e985d50001427acf"
Private AdColonyRewarded As String = "5d3362766de9f600013662d5"
Private AdColonyStandard As String = "60bf4ef0d40d970001693745"
' Make sure you have added TapsellPlus.AppLovin manifest as well (or TapsellPlus.Complete)
Private AppLovinInterstitial As String = "5d3eb4fa3aef7a0001406f85"
Private AppLovinRewarded As String = "5d3eb48c3aef7a0001406f84"
Private AppLovinStandard As String = "5d3eb5337a9b060001892441"
' End AdNetwork ZoneIds
' Mintegral
Private MintegralRewarded As String = "612232e33cf0307ab73e9a3f"
Private MintegralInterstitial As String = "612b6f24e2645f79d3f3549e"
Private MintegralStandard As String = "615800246cd7ee3cd28f15d6"
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
'tapsellPlus.InitializeWithEventPrefix(tapsellPlusAppId, "tapsell") ' When you want to change TapsellPlus_ to tapsell_
tapsellPlus.Initialize(tapsellPlusAppId)
tapsellPlus.SetDebugMode(2)
tapsellPlus.SetGDPRConsent(True)
pan.SetLayout(0, 50%y, 100%x, 50%y)
xclv.GetBase.SetLayoutAnimated(0, 0, 0, 100%x, 50%y)
generate_item("1. (TAPSELL) Interstitial Ad")
generate_item("2. (TAPSELL) Rewarded video Ad")
generate_item("3. (TAPSELL) Native Ad")
generate_item("4. (TAPSELL) NativeVideo Ad")
generate_item("5. (TAPSELL) Standard Ad")
generate_item("6. Remove Standard Banner")
generate_item("7. Remove Native (Video or Banner)")
generate_item("8. (AdMob) Insterstitial Ad")
generate_item("9. (AdMob) Standard Ad")
generate_item("10. (AdMob) Rewarded video Ad")
generate_item("11. (AdMob) Native Ad")
generate_item("12. (UnityAds) Interstitial Ad")
generate_item("13. (UnityAds) Rewarded video Ad")
generate_item("14. (UnityAds) Standard Banner")
generate_item("15. (Chartboost) Insterstitial Ad")
generate_item("16. (Chartboost) Rewarded video Ad")
generate_item("17. (AdColony) Interstitial Ad")
generate_item("18. (AdColony) Rewarded video Ad")
generate_item("19. (AdColony) Standard Banner")
generate_item("20. (AppLovin) Interstitial Ad")
generate_item("21. (AppLovin) Rewarded video Ad")
generate_item("22. (AppLovin) Standard Banner")
generate_item("23. (Mintegral) Rewarded video ad")
generate_item("24. (Mintegral) Interstitial ad")
generate_item("25. (Mintegral) Standard Banner")
generate_item("26. (Tapsell) Request interstiatial")
generate_item("27. Show Interstitial")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub generate_item (text As String)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(100, 0, 0, 100%x, 40dip)
p.LoadLayout("item")
Button1.Text= text
xclv.Add(p, "")
End Sub
Sub TapsellPlus_OnSuccess
ToastMessageShow("TapsellPlus is initialized", False)
End Sub
Sub TapsellPlus_OnResponse(zoneId As String, responseId As String)
response = responseId
Log("ZoneID: " & zoneId & "OnResponse: " & responseId)
End Sub
Sub TapsellPlus_OnClosed(zoneId As String, responseId As String)
Log("ZoneID: " & zoneId & "OnClosed: " & responseId)
End Sub
Sub TapsellPlus_OnOpened(zoneId As String, responseId As String)
Log("ZoneID: " & zoneId & "OnOpened: " & responseId)
End Sub
Sub TapsellPlus_OnRewarded(zoneId As String, responseId As String)
Log("ZoneID: " & zoneId & "OnRewarded: " & responseId)
End Sub
Sub TapsellPlus_OnError(error As String)
Log("OnError: " & error)
End Sub
Private Sub Button1_Click
Dim btn As Button = Sender
If btn.Text.StartsWith("1.") Then
tapsellPlus.RequestAndShowInterstitialAd(TapsellInterstitial) 'Tapsell
Else If btn.Text.StartsWith("2.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(TapsellRewarded) 'Tapsell
Else If btn.Text.StartsWith("3.") Then
tapsellPlus.RequestAndShowNativeAd(TapsellNativeBanner, pan) 'Tapsell
Else If btn.Text.StartsWith("4.") Then
tapsellPlus.RequestAndShowNativeVideoAd(TapsellNativeVideo, pan, True) 'Tapsell
Else If btn.Text.StartsWith("5.") Then
pan.RemoveAllViews
tapsellPlus.RequestAndShowStandardBanner(TapsellStandard, tapsellPlus.BANNER_320x50, pan) 'Tapsell
Else If btn.Text.StartsWith("6.") Then
If response.Length <> 0 Then
tapsellPlus.DestroyStandardBannerAd(response, pan) 'Tapsell
End If
Else If btn.Text.StartsWith("7.") Then
pan.RemoveAllViews
Else If btn.Text.StartsWith("8.") Then
tapsellPlus.RequestAndShowInterstitialAd(AdMobInterstitial) 'AdMob
Else If btn.Text.StartsWith("9.") Then
tapsellPlus.RequestAndShowStandardBanner(AdMobStandard, tapsellPlus.BANNER_320x50, pan) 'AdMob
Else If btn.Text.StartsWith("10.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(AdMobRewarded) 'AdMob
Else If btn.Text.StartsWith("11.") Then
tapsellPlus.RequestAndShowNativeAd(AdMobNativeBanner, pan) 'AdMob
Else If btn.Text.StartsWith("12.") Then
tapsellPlus.RequestAndShowInterstitialAd(UnityAdsInterstitial) 'UnityAds
Else If btn.Text.StartsWith("13.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(UnityAdsRewarded) 'UnityAds
Else If btn.Text.StartsWith("14.") Then
tapsellPlus.RequestAndShowStandardBanner(UnityAdsStandard, tapsellPlus.BANNER_320x50, pan) 'UnityAds
'tapsellPlus.RequestAndShowNativeVideoAd
Else If btn.Text.StartsWith("15.") Then
'tapsellPlus.RequestAndShowInterstitialAd(ChartboostInterstitial) 'Chartboost
ToastMessageShow("Chartboost native dependency is not supported by b4a", False)
Else If btn.Text.StartsWith("16.") Then
'tapsellPlus.RequestAndShowRewardedVideoAd(ChartboostRewarded) 'Chartboost
ToastMessageShow("Chartboost native dependency is not supported by b4a", False)
Else If btn.Text.StartsWith("17.") Then
tapsellPlus.RequestAndShowInterstitialAd(AdColonyInterstitial) 'AdColony
Else If btn.Text.StartsWith("18.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(AdColonyRewarded) 'AdColony
Else If btn.Text.StartsWith("19.") Then
tapsellPlus.RequestAndShowStandardBanner(AdColonyStandard, tapsellPlus.BANNER_320x50, pan) 'AdColony
Else If btn.Text.StartsWith("20.") Then
tapsellPlus.RequestAndShowInterstitialAd(AppLovinInterstitial) 'AppLovin
Else If btn.Text.StartsWith("21.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(AppLovinRewarded) 'AppLovin
Else If btn.Text.StartsWith("22.") Then
tapsellPlus.RequestAndShowStandardBanner(AppLovinStandard, tapsellPlus.BANNER_320x50, pan) 'AppLovin
Else If btn.Text.StartsWith("23.") Then
tapsellPlus.RequestAndShowRewardedVideoAd(MintegralRewarded) ' Mintegral
Else If btn.Text.StartsWith("24.") Then
tapsellPlus.RequestAndShowInterstitialAd(MintegralInterstitial) ' Mintegral
Else If btn.Text.StartsWith("25.") Then
tapsellPlus.RequestAndShowStandardBanner(MintegralStandard, tapsellPlus.BANNER_320x50, pan)
Else If btn.Text.StartsWith("26.") Then
tapsellPlus.RequestInterstitialAd(TapsellInterstitial)
Else if btn.Text.StartsWith("27.") Then
tapsellPlus.ShowInterstitialAd(response)
End If
End Sub