V1.0.3(4)接入topon

This commit is contained in:
lihongwei 2024-11-29 18:09:37 +08:00
parent 38dd0c6fb6
commit f54a2e43b7
18 changed files with 538 additions and 43 deletions

View File

@ -67,5 +67,95 @@ dependencies {
implementation("com.google.firebase:firebase-analytics")
//-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo)
//Anythink (Necessary)
implementation("com.anythink.sdk:core-tpn:6.4.07")
implementation("com.anythink.sdk:nativead-tpn:6.4.07")
implementation("com.anythink.sdk:banner-tpn:6.4.07")
implementation("com.anythink.sdk:interstitial-tpn:6.4.07")
implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07")
implementation("com.anythink.sdk:splash-tpn:6.4.07")
//Androidx (Necessary)
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.browser:browser:1.4.0")
//StartApp
implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07")
implementation("com.startapp:inapp-sdk:5.0.2")
//Appnext
implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07")
implementation("com.appnext.sdk:ads:2.7.1.473")
implementation("com.appnext.sdk:banners:2.7.1.473")
implementation("com.appnext.sdk:native-ads2:2.7.1.473")
implementation("com.appnext.sdk:actions:2.4.6.472")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
//Vungle
implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07")
implementation("com.vungle:vungle-ads:7.4.0")
implementation("com.google.android.gms:play-services-basement:18.1.0")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
//UnityAds
implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07")
implementation("com.unity3d.ads:unity-ads:4.12.2")
//Ironsource
implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07")
implementation("com.ironsource.sdk:mediationsdk:8.2.1")
implementation("com.google.android.gms:play-services-appset:16.0.2")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
implementation("com.google.android.gms:play-services-basement:18.1.0")
//Bigo
implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07")
implementation("com.bigossp:bigo-ads:4.9.0")
//Pangle
implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07")
implementation("com.pangle.global:ads-sdk:6.1.0.9")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
//Inmobi
implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07")
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5")
//Mintegral
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07")
implementation("com.mbridge.msdk.oversea:reward:16.8.11")
implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11")
implementation("com.mbridge.msdk.oversea:mbnative:16.8.11")
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11")
implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11")
implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11")
implementation("com.mbridge.msdk.oversea:mbbid:16.8.11")
implementation("androidx.recyclerview:recyclerview:1.1.0")
//Chartboost
implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07")
implementation("com.chartboost:chartboost-sdk:9.7.0")
implementation("com.chartboost:chartboost-mediation-sdk:4.9.1")
implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0")
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
//Fyber
implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07")
implementation("com.fyber:marketplace-sdk:8.3.0")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
// Debugger UI Tools
//implementation ("com.anythink.sdk:debugger-ui:1.1.0")
//----------------------------------------------TopOn
}

6
app/keystore.properties Normal file
View File

@ -0,0 +1,6 @@
app_name=AppLocker pro
package_name=com.tool.app.protectorpro
keystoreFile=app/applockpro1
key_alias=key_lockpro
key_store_password=12345600
key_password=12345600

View File

@ -4,13 +4,17 @@ import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.anythink.core.api.ATSDK;
import com.anythink.core.api.NetTrafficeCallback;
import com.tool.app.protectorpro.mydb.DataApp;
import com.tool.app.protectorpro.mydb.MyDataBase;
import com.tool.app.protectorpro.tools.Common;
import com.tool.app.protectorpro.tools.MyThread;
import com.tool.app.protectorpro.topon.AdManager;
public class MyApplication extends Application {
public static String spName = "share_name";
@ -37,9 +41,11 @@ public class MyApplication extends Application {
public static int userOption = 0;
private static Context context;
public static final String AD_BROADCAST = "on_success_action";
private static final String MAX_SDK = "gOI7_5_DTTS8XFbtBncQSLPuqsKdh7UWwQ73rVxHD72rG3Me88_VMk9flB87BlGCS6TAUy1h8F9uQ8MwRMN0gc";
public static Boolean initSDK = false;
public static final String TAG = "--------------";
private static final String AppKey = "a51890ba57e8e80b7746f44bcfb6fc0cb";
private static final String APPId = "h674973964348d";
@Override
public void onCreate() {
@ -71,7 +77,34 @@ public class MyApplication extends Application {
private void initSDk() {
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
@Override
public void onResultCallback(boolean isEU) {
Log.e(TAG, "onResultCallback:" + isEU);
if (isEU && ATSDK.getGDPRDataLevel(MyApplication.this) == ATSDK.UNKNOWN) {
ATSDK.showGdprAuth(MyApplication.this);
}
}
@Override
public void onErrorCallback(String errorMsg) {
Log.e(TAG, "onErrorCallback:" + errorMsg);
}
});
ATSDK.init(this, APPId, AppKey);
AdManager.loadAllAd();
//测试工具
// ATDebuggerUITest.showDebuggerUI(this,debug_KEy);
//
// ATSDK.setNetworkLogDebug(true);
}
public static Context getContext() {
return context;
}
public static void updatePwd(String pwd) {

View File

@ -27,6 +27,8 @@ import com.tool.app.protectorpro.databinding.TabViewBinding;
import com.tool.app.protectorpro.listener.onPermssionListener;
import com.tool.app.protectorpro.service.LockService;
import com.tool.app.protectorpro.tools.Common;
import com.tool.app.protectorpro.topon.AdManager;
import com.tool.app.protectorpro.topon.onActionListener;
import java.util.ArrayList;
import java.util.List;
@ -55,6 +57,8 @@ public class ActivityMain extends AppCompatActivity implements SearchView.OnQuer
setContentView(binding.getRoot());
binding.searchItem.setOnQueryTextListener(this);
AdManager.loadAllAd();
initStatusBar();
openPermission();
startService(new Intent(this, LockService.class));
@ -144,7 +148,14 @@ public class ActivityMain extends AppCompatActivity implements SearchView.OnQuer
}
private void initClick() {
binding.imSetPwd.setOnClickListener(v -> setBottomSheetView());
binding.imSetPwd.setOnClickListener(v -> {
AdManager.showTopOn(ActivityMain.this, new onActionListener() {
@Override
public void onAction() {
setBottomSheetView();
}
});
});
}
private void setBottomSheetView() {
@ -164,7 +175,12 @@ public class ActivityMain extends AppCompatActivity implements SearchView.OnQuer
// 按钮1点击事件
btnOption1.setOnClickListener(v -> {
// TODO: 2024/7/19
goSet();
AdManager.showTopOn(this, new onActionListener() {
@Override
public void onAction() {
goSet();
}
});
});

View File

@ -19,6 +19,8 @@ import com.tool.app.protectorpro.customerview.MyLockView;
import com.tool.app.protectorpro.customerview.MyPasswordInputView;
import com.tool.app.protectorpro.databinding.ActivitySetPwdBinding;
import com.tool.app.protectorpro.listener.ListenerLock;
import com.tool.app.protectorpro.topon.AdManager;
import com.tool.app.protectorpro.topon.onActionListener;
public class ActivitySetPwd extends AppCompatActivity {
@ -278,6 +280,14 @@ public class ActivitySetPwd extends AppCompatActivity {
}
@Override
public void onBackPressed() {
super.onBackPressed();
AdManager.showTopOn(this,new onActionListener() {
@Override
public void onAction() {
finish();
}
});
}
}

View File

@ -1,19 +1,15 @@
package com.tool.app.protectorpro.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.tool.app.protectorpro.MyApplication;
import com.tool.app.protectorpro.databinding.ActivityWelBinding;
import com.tool.app.protectorpro.topon.AdManager;
public class ActivityWel extends AppCompatActivity {
@ -21,28 +17,27 @@ public class ActivityWel extends AppCompatActivity {
private CountDownTimer countDownTimer;
private long totalTime = 1000;
private long totalTime = 11000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityWelBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
initBar();
AdManager.loadAllAd();
countDownTimer = new CountDownTimer(totalTime, 200) {
@Override
public void onTick(long millisUntilFinished) {
goMain();
}
ProgressBar progressBar = binding.progressBar;
@Override
public void onFinish() {
AdManager.setAlreadyShow();
countDownTimer = AdManager.showWelcomeAd(this, totalTime, millisUntilFinished -> {
int percentage = (int) (100 - (float) millisUntilFinished / totalTime * 100);
progressBar.setProgress(percentage);
},
this::goMain
);
goMain();
}
};
countDownTimer.start();
}
@ -58,17 +53,11 @@ public class ActivityWel extends AppCompatActivity {
finish();
}
private void initBar() {
View decorView = getWindow().getDecorView();
int flag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(flag);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
@Override
protected void onDestroy() {
super.onDestroy();
countDownTimer.cancel();
if (countDownTimer != null) {
countDownTimer.cancel();
}
}
}

View File

@ -24,6 +24,8 @@ import com.tool.app.protectorpro.listener.OnShowDialogMsgListener;
import com.tool.app.protectorpro.mydb.DataApp;
import com.tool.app.protectorpro.mydb.MyDataBase;
import com.tool.app.protectorpro.tools.MyThread;
import com.tool.app.protectorpro.topon.AdManager;
import com.tool.app.protectorpro.topon.onActionListener;
import java.util.ArrayList;
import java.util.List;
@ -98,9 +100,15 @@ public class AdapterAllApp extends RecyclerView.Adapter<AdapterAllApp.AppViewHol
holder.switchCompat.setChecked(lock);
holder.switchCompat.setOnCheckedChangeListener((CompoundButton buttonView, boolean isChecked) -> {
MyApplication.userOption++;
if (MyApplication.userOption % 5 == 0) {
if (MyApplication.userOption % 3 == 0) {
// TODO: 2024/7/19
AdManager.showTopOn(mActivity, new onActionListener() {
@Override
public void onAction() {
}
});
MyThread.runIO(() -> {
dataApp.setLock(isChecked);

View File

@ -0,0 +1,10 @@
package com.tool.app.protectorpro.topon;
public interface AdListener {
void loadFail(String placeId);
void showSuccess();
void showFail();
void showClose();
}

View File

@ -0,0 +1,250 @@
package com.tool.app.protectorpro.topon;
import android.app.Activity;
import android.os.CountDownTimer;
import android.util.Log;
import androidx.annotation.NonNull;
import com.anythink.core.api.ATAdInfo;
import com.anythink.core.api.AdError;
import com.anythink.interstitial.api.ATInterstitial;
import com.anythink.interstitial.api.ATInterstitialListener;
import com.tool.app.protectorpro.MyApplication;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class AdManager {
private static final int type_no_cache = 0;
private static final int type_has_cache = 1;
private static final int type_show_success = 2;
private static final int type_show_close = 3;
private static final int type_show_fail = 4;
/**
Applock_Open
n674973cdd6c57
Applock_Reset
n674973cd8b3d5
Applock_Lock
n674973cd4e134
*/
private static final String place1Id = "n674973cd4e134";
private static final String place2Id = "n674973cd8b3d5";
private static final String place3Id = "n674973cdd6c57";
private static boolean place1LoadFail = false;
private static boolean place2LoadFail = false;
private static boolean place3LoadFail = false;
private static boolean alreadyShow = false;
private static List<ATInterstitial> list = new ArrayList<>();
public static void loadAllAd() {
if (list.isEmpty()) {
ATInterstitial mInterstitialAd1 = new ATInterstitial(MyApplication.getContext(), place1Id);
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApplication.getContext(), place2Id);
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApplication.getContext(), place3Id);
list.add(mInterstitialAd1);
list.add(mInterstitialAd2);
list.add(mInterstitialAd3);
}
for (ATInterstitial ad : list) {
if (!ad.isAdReady()) {
setCallBack(ad, new AdListener() {
@Override
public void loadFail(@NonNull String placeId) {
if (placeId.equals(place1Id)) {
place1LoadFail = true;
}
if (placeId.equals(place2Id)) {
place2LoadFail = true;
}
if (placeId.equals(place3Id)) {
place3LoadFail = true;
}
}
@Override
public void showSuccess() {
}
@Override
public void showFail() {
}
@Override
public void showClose() {
}
});
ad.load();
}
}
}
private static ATInterstitial getReadyAd() {
Collections.shuffle(list);
for (ATInterstitial ad : list) {
if (ad.isAdReady()) {
Log.d(MyApplication.TAG, "-has Cache------------");
return ad;
}
}
Log.d(MyApplication.TAG, "-No Cache------------");
return null;
}
private static void setCallBack(ATInterstitial ad, AdListener listener) {
ad.setAdListener(new ATInterstitialListener() {
@Override
public void onInterstitialAdLoaded() {
Log.d(MyApplication.TAG, "LoadLoaded " + ad.mPlacementId);
}
@Override
public void onInterstitialAdLoadFail(AdError adError) {
listener.loadFail(ad.mPlacementId);
Log.d(MyApplication.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
}
@Override
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
}
@Override
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
Log.d(MyApplication.TAG, "AdShow " + atAdInfo.getShowId());
listener.showSuccess();
ad.load();
}
@Override
public void onInterstitialAdClose(ATAdInfo atAdInfo) {
listener.showClose();
}
@Override
public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) {
}
@Override
public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) {
}
@Override
public void onInterstitialAdVideoError(AdError adError) {
}
});
}
public static void setAlreadyShow() {
alreadyShow = false;
}
public static CountDownTimer showWelcomeAd(
Activity activity,
Long totalTim,
CountAction countAction,
GoMainAction goMain
) {
CountDownTimer timer = new CountDownTimer(totalTim, 100) {
@Override
public void onTick(long millisUntilFinished) {
countAction.onCount(millisUntilFinished);
if (!alreadyShow) {
showAD(activity, new AdStatusAction() {
@Override
public void onStatus(int adType) {
if (adType == type_has_cache) {
alreadyShow = true;
}
if (adType == type_show_close || adType == type_show_fail) {
goMain.onGo();
}
}
});
}
}
@Override
public void onFinish() {
if (!alreadyShow) {
showTopOn(activity, new onActionListener() {
@Override
public void onAction() {
goMain.onGo();
}
});
}
}
};
return timer;
}
private static void showAD(Activity activity, AdStatusAction action) {
ATInterstitial readyAd = getReadyAd();
if (readyAd != null) {
action.onStatus(type_has_cache);
setCallBack(readyAd, new AdListener() {
@Override
public void loadFail(@NonNull String placeId) {
}
@Override
public void showSuccess() {
action.onStatus(type_show_success);
}
@Override
public void showFail() {
action.onStatus(type_show_fail);
}
@Override
public void showClose() {
action.onStatus(type_show_close);
}
});
readyAd.show(activity);
} else {
action.onStatus(type_no_cache);
}
}
public static void showTopOn(Activity activity, onActionListener listener) {
showAD(activity, new AdStatusAction() {
@Override
public void onStatus(int adType) {
if (adType == type_no_cache || adType == type_show_close || adType == type_show_fail) {
listener.onAction();
}
}
});
}
}

View File

@ -0,0 +1,5 @@
package com.tool.app.protectorpro.topon;
public interface AdStatusAction {
void onStatus(int adType);
}

View File

@ -0,0 +1,5 @@
package com.tool.app.protectorpro.topon;
public interface CountAction {
void onCount(long millisUntilFinished);
}

View File

@ -0,0 +1,5 @@
package com.tool.app.protectorpro.topon;
public interface GoMainAction {
void onGo();
}

View File

@ -0,0 +1,6 @@
package com.tool.app.protectorpro.topon;
public interface onActionListener {
void onAction();
}

View File

@ -0,0 +1,30 @@
<!-- res/drawable/seekbar_progress_drawable.xml -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dp" />
<solid android:color="#D3D3D3" /> <!-- 背景颜色 -->
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dp" />
<solid android:color="#FFD700" /> <!-- 次级进度颜色 -->
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dp" />
<gradient
android:startColor="#4891FF"
android:endColor="#6CE89E"
android:angle="0" />
</shape>
</clip>
</item>
</layer-list>

View File

@ -13,17 +13,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="45dp"
/>
android:layout_marginTop="45dp" />
<ImageView
android:id="@+id/im_set_pwd"
android:layout_width="50dp"
android:layout_height="24dp"
android:layout_alignTop="@id/search_item"
android:layout_alignBottom="@id/search_item"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_gravity="center"
android:layout_marginTop="93dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="-50dp"
android:paddingEnd="25dp"
android:src="@drawable/main_pwd" />

View File

@ -31,10 +31,18 @@
android:textStyle="bold" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/im_wel"
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="53dp"
android:layout_marginTop="100dp"
android:indeterminateTint="@color/color_5aa2f1" />
android:layout_marginEnd="53dp"
android:layout_marginBottom="53dp"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/seek_bar_color" />
</RelativeLayout>

View File

@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

View File

@ -13,6 +13,28 @@ dependencyResolutionManagement {
mavenCentral()
maven (url ="https://jitpack.io" )
//Anythink(Core)
maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk")
//Appnext
maven ("https://dl.appnext.com")
//Ironsource
maven ("https://android-sdk.is.com/")
//Pangle
maven ("https://artifact.bytedance.com/repository/pangle")
//Mintegral
maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
//Chartboost
maven ("https://cboost.jfrog.io/artifactory/chartboost-ads")
maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation")
//TopOn集成测试工具
// maven ( "https://jfrog.anythinktech.com/artifactory/debugger")
}
}