leopard8352
2023-12-04 8871a733498c8d717714b83bb096b7738224541a
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<?xml version="1.0" encoding="utf-8"?>
<!--GearVR plugin additions-->
<root xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- init section is always evaluated once per architecture -->
    <trace enable="true"/>
    <init>
        <log text="Taptap APL init"/>
    </init>
    <proguardAdditions>
        <insert>
            -keep public class com.tds.common.** {*;}
            -keep public class com.tapsdk.** {*;}
            -keep class com.tds.** {*;}
 
            # proguard.cfg
 
            -keepattributes Signature
            -dontwarn com.jcraft.jzlib.**
            -keep class com.jcraft.jzlib.** { *;}
 
            -dontwarn sun.misc.**
            -keep class sun.misc.** { *;}
 
            -dontwarn com.alibaba.fastjson.**
            -keep class com.alibaba.fastjson.** { *;}
 
            -dontwarn org.ligboy.retrofit2.**
            -keep class org.ligboy.retrofit2.** { *;}
 
            -dontwarn io.reactivex.rxjava2.**
            -keep class io.reactivex.rxjava2.** { *;}
 
            -dontwarn sun.security.**
            -keep class sun.security.** { *; }
 
            -dontwarn com.google.**
            -keep class com.google.** { *;}
 
            -dontwarn com.avos.**
            -keep class com.avos.** { *;}
 
            -dontwarn cn.leancloud.**
            -keep class cn.leancloud.** { *;}
 
            -keep public class android.net.http.SslError
            -keep public class android.webkit.WebViewClient
 
            -dontwarn android.webkit.WebView
            -dontwarn android.net.http.SslError
            -dontwarn android.webkit.WebViewClient
 
            -dontwarn android.support.**
 
            -dontwarn org.apache.**
            -keep class org.apache.** { *;}
 
            -dontwarn org.jivesoftware.smack.**
            -keep class org.jivesoftware.smack.** { *;}
 
            -dontwarn com.loopj.**
            -keep class com.loopj.** { *;}
 
            -dontwarn com.squareup.okhttp.**
            -keep class com.squareup.okhttp.** { *;}
            -keep interface com.squareup.okhttp.** { *; }
 
            -dontwarn okio.**
 
            -dontwarn org.xbill.**
            -keep class org.xbill.** { *;}
 
            -keepattributes *Annotation*
 
        </insert>
    </proguardAdditions>
    <androidManifestUpdates>
 
        <!--
            旧版 Android 额外配置
            如果 targetSdkVersion < 29,还需要添加如下配置:
        -->
<!--        <addAttribute -->
<!--                tag="manifest" -->
<!--                name="xmlns:tools" -->
<!--                value="http://schemas.android.com/tools" />-->
<!--        <addAttribute -->
<!--                tag="application " -->
<!--                name="tools:remove" -->
<!--                value="android:requestLegacyExternalStorage" />-->
        
        <!-- 广告 SDK 已添加的权限 -->
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <!-- 为了获取更精准的推送数据、建议游戏加上的权限 -->
        <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
        <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
        <uses-permission android:name="android.permission.BLUETOOTH"/>
        <!-- targetVersion 31 及以上 建议游戏加上这个权限 -->
        <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
        <!-- 为了获取更好的广告体验,建议游戏加上以下权限来获取用户信息 -->
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        <!-- 加上下列权限可以提高广告的转化率 -->
        <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    </androidManifestUpdates>
    <proguardAdditions>
        <insert>
        </insert>
    </proguardAdditions>
    
    <resourceCopies>
            <copyDir 
                src = "$S(PluginDir)/../../ThirdParty/"
                dst = "$S(BuildDir)/libs/" />
 
        <copyDir 
                src="$S(PluginDir)/../../ThirdParty/Android/Java/" 
                dst="$S(BuildDir)/src/com/leopard/taptap" />
    </resourceCopies>
    <gradleCopies>
    </gradleCopies>
    
    <buildGradleAdditions>
        <insert>
            <![CDATA[
repositories {
    flatDir {
        dirs 'src/main/libs'
    }
}
dependencies {
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "com.github.bumptech.glide:glide:4.9.0"
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'cn.leancloud:storage-android:8.2.19'   // 数据存储
    implementation 'cn.leancloud:realtime-android:8.2.19'  // 即时通讯
    implementation(name : 'TapAD_3.16.3.23', ext:'aar')
    implementation(name : 'TapBootstrap_3.24.0', ext:'aar')
    implementation(name : 'TapCommon_3.24.0', ext:'aar')
    implementation(name : 'TapLogin_3.24.0', ext:'aar')
    implementation(name : 'TapDB_3.24.0', ext:'aar')
}
            ]]>
        </insert>
    </buildGradleAdditions>
    
    <gameActivityImportAdditions>
        <insert>
            <![CDATA[
// taptap start
import com.tapsdk.tapad.AdRequest;
import com.tapsdk.tapad.CustomUser;
import com.tapsdk.tapad.TapAdConfig;
import com.tapsdk.tapad.TapAdCustomController;
import com.tapsdk.tapad.TapAdLocation;
import com.tapsdk.tapad.TapAdManager;
import com.tapsdk.tapad.TapAdNative;
import com.tapsdk.tapad.TapAdSdk;
import com.tapsdk.tapad.TapRewardVideoAd;
import android.util.Log;
// taptap end
            ]]>
        </insert>
    </gameActivityImportAdditions>
    <gameActivityClassAdditions>
        <insert>
            <![CDATA[
    public native void OnActivitySaveInstanceState();
    
    public void Logout(){
        com.leopard.taptap.TapNative.Logout();
    }
    public void TapDBTraceEvent(final String eventName,final String jsonObject) {
        // 委托主线程调用
        runOnUiThread(
            new Runnable() {
                public void run() {
                    com.leopard.taptap.TapNative.TapDBTraceEvent(eventName,jsonObject);
                }
            });
    }
    public void InitTapDB(
        final String clientId,
        final String clientToken,
        final String serverUrl,
        final String gameChannel,
        final String gameVersion
    ){
        android.util.Log.d("Leopard","InitTapDB ==>> clientId:" + clientId + ",clientToken" + clientToken + ",serverUrl" + serverUrl);
        // 委托主线程调用
        runOnUiThread(
            new Runnable() {
                public void run() {
                    com.leopard.taptap.TapNative.InitTapDB(clientId,clientToken,serverUrl,gameChannel,gameVersion);
                }
            });
    }
            
    public boolean CheckLogin() {
        return com.leopard.taptap.TapNative.CheckLogin();
    }
    
    public void InitLogin(final String clientId,final String clientToken,final String serverUrl){
        android.util.Log.d("Leopard","InitLoginStart ==>> clientId:" + clientId + ",clientToken" + clientToken + ",serverUrl" + serverUrl);
        runOnUiThread(
                new Runnable() {
                    public void run() {
                        com.leopard.taptap.TapNative.InitLogin(clientId, clientToken, serverUrl);
                    }
                });
    }
    
    public void Login(){
        android.util.Log.d("Leopard","LoginStart");
        com.leopard.taptap.TapNative.Login();
    }
    
    public String GetCurrentProfile(){
        android.util.Log.d("Leopard","GetCurrentProfile");
        return com.leopard.taptap.TapNative.GetCurrentProfile();
    }
    
    
    public void tapADNRequestPermissionIfNecessary() {
        TapAdManager.get().requestPermissionIfNecessary(this);
        android.util.Log.d("Leopard","RequestPermissionIfNecessary");
    }
 
    public void tapADNInit(
            int mediaID,
            String mediaName,
            String mediaKey,
            boolean enableDebug,
            int avatarLevel
    ) {
        android.util.Log.d("Leopard","tapADNInit:mediaName->" + mediaName + ",mediaKey:" + mediaKey);
        final TapAdConfig config = new TapAdConfig.Builder()
                .withMediaId(mediaID)               // 必选参数。为 TapADN 注册的媒体 ID
                .withMediaName(mediaName)           // 必选参数。为 TapADN 注册的媒体名称
                .withMediaKey(mediaKey)             // 必选参数。媒体密钥,可以在TapADN后台查看
                .withMediaVersion("1")              // 必选参数。默认值 "1"
                .withGameChannel("taptap2")          // 必选参数,渠道
//              .withTapClientId("0RiAlMny7jiz086FaU")
                .enableDebug(enableDebug)
                .withCustomController(new TapAdCustomController() {
                    @Override
                    public boolean isCanUseLocation() {
                        return true;
                    }
 
                    @Override
                    public TapAdLocation getTapAdLocation() {
                        double longitude = 0;
                        double latitude = 0;
                        double accuracy = 0;
                        return new TapAdLocation(longitude, latitude, accuracy);
                    }
 
                    @Override
                    public boolean isCanUsePhoneState() {
                        return super.isCanUsePhoneState();
                    }
 
                    @Override
                    public String getDevImei() {
                        return super.getDevImei();
                    }
 
                    @Override
                    public boolean isCanUseWifiState() {
                        return super.isCanUseWifiState();
                    }
 
                    @Override
                    public boolean isCanUseWriteExternal() {
                        return super.isCanUseWriteExternal();
                    }
 
                    @Override
                    public String getDevOaid() {
//                        if (inputOaidEditText != null && inputOaidEditText.getText() != null) {
//                            return inputOaidEditText.getText().toString();
//                        }
                        return "asdf12345";
                    }
 
                    @Override
                    public boolean alist() {
                        return super.alist();
                    }
 
                    @Override
                    public boolean isCanUseAndroidId() {
                        return true;
                    }
 
                    @Override
                    public CustomUser provideCustomUser() {
                        return new CustomUser.Builder()
                                .withRealAge(1)                   // 年龄
                                .withRealSex(1)                   // 性别 0:男 1:女
                                .withAvatarSex(1)           // 角色性别 0:男 1:女
                                .withAvatarLevel(1)            // 角色等级
                                .withNewUserStatus(1)          // 是否新玩家 0:否;1:是
                                .withPayedUserStatus(0)        // 是否付费用户 0:否;1:是
                                .withBeginMissionFinished(1) // 是否通过新手教程 0:否 1:是
                                .withAvatarPayedToolCnt(0)        // 角色当前付费道具数量
                                .build();
                    }
                })
                .build();
        TapAdSdk.init(this,config);
        android.util.Log.d("Leopard","TapAdSdkInitOver");
    }
 
    public TapAdNative tapAdNative;
    public TapRewardVideoAd lastTapRewardVideoAd;
    public native void nativeRewardRequestOver();
    public boolean isRewardCached(){
        return lastTapRewardVideoAd != null;
    }
    public void tapADNRequestRewardAD(
            int spaceID,     // 广告后台获取广告位id
            String rewardName,  // 奖品名称
            int rewardAmount    // 奖品数量
    ){
        android.util.Log.e("Leopard","tapADNInit:spaceID->" + spaceID);
        tapAdNative = TapAdManager.get().createAdNative(this);
        AdRequest adRequest = new AdRequest.Builder()
                .withSpaceId(spaceID)
                .withExtra1("{}")
                .withUserId("123")
                .withRewordName(rewardName)
                .withRewordAmount(rewardAmount)
                .build();
        tapAdNative.loadRewardVideoAd(adRequest, new TapAdNative.RewardVideoAdListener() {
             @Override
            public void onError(int code, String message) {
                 android.util.Log.e("Leopard","广告获取失败" + message);
            }
 
            @Override
            public void onRewardVideoAdLoad(TapRewardVideoAd rewardVideoAd) {
                tapADNPlayRewardAD();
            }
 
            @Override
            public void onRewardVideoCached(TapRewardVideoAd rewardVideoAd) {
                android.util.Log.d("Leopard","广告获取成功");
                lastTapRewardVideoAd = rewardVideoAd;
                GameActivity.this.nativeRewardRequestOver();
            }
        });
    }
    public native void nativeRewardAdPlayOver();
    public void tapADNPlayRewardAD(){
        if (lastTapRewardVideoAd != null){
            lastTapRewardVideoAd.setRewardAdInteractionListener(new TapRewardVideoAd.RewardAdInteractionListener() {
                @Override
                public void onAdShow() {
                    // 激励广告已显示
                }
 
                @Override
                public void onAdClose() {
                    // 激励广告已经关闭
                }
 
                @Override
                public void onVideoComplete() {
                    // 视频播放结束
                }
 
                @Override
                public void onVideoError() {
                    // 视频出错
                }
 
                @Override
                public void onRewardVerify(boolean rewardVerify, int rewardAmount, String rewardName, int code, String msg) {
                    // 激励任务已完成,游戏可以选择在此时进行玩家奖励,或者进一步通过 s2s 的流程来确认是否可以对当前玩家发放奖励
                    android.util.Log.d("Leopard","广告播放完毕!");
                    GameActivity.this.nativeRewardAdPlayOver();
                }
 
                @Override
                public void onSkippedVideo() {
                    // 激励广告中玩家点击了跳过视频的按钮
                }
            });
            lastTapRewardVideoAd.showRewardVideoAd(this);
        }
        else{
            android.util.Log.e("Leopard","没有缓存任何的广告");
        }
    }
            ]]>
        </insert>
    </gameActivityClassAdditions>
 
    <gameActivityOnCreateAdditions>
        <insert>
            <![CDATA[
com.leopard.taptap.TapNative.Init(this);
            ]]>
        </insert>
    </gameActivityOnCreateAdditions>
    <gameActivityOnSaveInstanceStateAdditions>
        <insert>
            <![CDATA[
        OnActivitySaveInstanceState();
        android.util.Log.d("Leopard","OnActivitySaveInstanceState");
            ]]>
        </insert>
    </gameActivityOnSaveInstanceStateAdditions>
</root>