V1.0.1(2) 接入max

This commit is contained in:
lihongwei 2025-06-06 15:51:54 +08:00
parent 10ac90ff96
commit ce4fdc6df1
31 changed files with 1343 additions and 233 deletions

View File

@ -4,19 +4,27 @@ plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("io.objectbox")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("applovin-quality-service")
}
applovin{
apiKey = "Ln9ZBkOoNWDdTK3a4iHGH4XW1scCVDW14WRkncTTQHC1AIOkNRUT8OUAkEQOSHFrWp5Mn3eRrrnmT3dWmw41zD"
}
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
android {
namespace = "com.prank.sound.funnyapp"
compileSdk = 34
compileSdk = 35
defaultConfig {
//com.prank.sound.funnyapp
applicationId = "com.prank.sound.funnyapp"
minSdk = 23
targetSdk = 34
versionCode = 1
versionName = "1.0"
targetSdk = 35
versionCode = 2
versionName = "1.0.1"
setProperty("archivesBaseName", "Prank Sound App_V" + versionName + "(${versionCode})_$timestamp")
testInstrumentationRunner = "androidx.sounds.runner.AndroidJUnitRunner"
vectorDrawables {
@ -52,13 +60,47 @@ android {
}
dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.recyclerview:recyclerview:1.4.0")
implementation ("com.github.bumptech.glide:glide:4.16.0")
implementation ("com.airbnb.android:lottie:5.2.0")
implementation ("com.airbnb.android:lottie:6.6.6")
//获取gaid
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
implementation("com.google.android.gms:play-services-appset:16.0.1")
//开启协程
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
// Import the BoM for the Firebase platform
implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
// Add the dependencies for the Crashlytics and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-config")
//Max(BIGO Ads、Chartboost、DT Exchange、InMobi、ironSource、Liftoff Monetize、Mintegral、Pangle)
dependencies {
implementation("com.applovin:applovin-sdk:+")
implementation("com.applovin.mediation:bigoads-adapter:+")
implementation("com.applovin.mediation:chartboost-adapter:+")
implementation("com.google.android.gms:play-services-base:16.1.0")
implementation("com.applovin.mediation:fyber-adapter:+")
implementation("com.applovin.mediation:inmobi-adapter:+")
implementation("com.squareup.picasso:picasso:2.8")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("com.applovin.mediation:ironsource-adapter:+")
implementation("com.applovin.mediation:vungle-adapter:+")
implementation("com.applovin.mediation:mintegral-adapter:+")
implementation("com.applovin.mediation:bytedance-adapter:+")
}
}

29
app/google-services.json Normal file
View File

@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "460730096724",
"project_id": "prank-sound-app-f40d7",
"storage_bucket": "prank-sound-app-f40d7.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:460730096724:android:ee244a2c2da56ded34e1c1",
"android_client_info": {
"package_name": "com.prank.sound.funnyapp"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAycYvJZ90oYQWd6l8SBkZP4KQ-Y72EV7E"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@ -12,9 +12,12 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:name="com.prank.sound.funnyapp.MyApp"
android:name="com.prank.sound.funnyapp.MyApplication"
android:allowBackup="true"
android:networkSecurityConfig="@xml/net"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/icon"

View File

@ -1,48 +0,0 @@
package com.prank.sound.funnyapp;
import android.app.Application;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.bean.MyBean;
import com.prank.sound.funnyapp.bean.DbManager;
import com.prank.sound.funnyapp.mytool.Common;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class MyApp extends Application {
public static MyApp app;
public static Typeface defaultFont;
public static List<MyBean> bean;
@Override
public void onCreate() {
super.onCreate();
app = this;
AssetManager assets = getAssets();
defaultFont = Typeface.createFromAsset(assets, "prankfont.ttf");
DbManager.init(this);
if (bean != null)
return;
try {
InputStream open = getAssets().open("prank.json");
String string = Common.getString(open);
if (!string.isEmpty()) {
bean = Common.getBean(string);
for (MyBean category:bean){
for (MyInfo info1 : category.getInfoList()) {
info1.setLike(false);
DbManager.getBoxBean().put(info1);
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,83 @@
package com.prank.sound.funnyapp;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.applovin.sdk.AppLovinMediationProvider;
import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkConfiguration;
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.bean.MyBean;
import com.prank.sound.funnyapp.bean.DbManager;
import com.prank.sound.funnyapp.mytool.Common;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class MyApplication extends Application {
public static MyApplication application;
public static Typeface defaultFont;
public static List<MyBean> bean;
public static final String TAG = "--------------";
public static boolean initSDkOK = false;
public static String initAction = "ACTION_INIT";
private String SDK_KEY = "yhOU4TgSF10NVhdOBNZy6VbUxFc25c78nh_LA3905OB6rHVXJdsa0DVUhsIA6DWqJaHKDkimoBWXD5CktvrVXg";
@Override
public void onCreate() {
super.onCreate();
application = this;
AssetManager assets = getAssets();
defaultFont = Typeface.createFromAsset(assets, "prankfont.ttf");
DbManager.init(this);
if (bean != null)
return;
try {
InputStream open = getAssets().open("prank.json");
String string = Common.getString(open);
if (!string.isEmpty()) {
bean = Common.getBean(string);
for (MyBean category:bean){
for (MyInfo info1 : category.getInfoList()) {
info1.setLike(false);
DbManager.getBoxBean().put(info1);
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
initMAxSDk();
}
private void initMAxSDk() {
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(SDK_KEY, this)
.setMediationProvider(AppLovinMediationProvider.MAX)
.build();
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
@Override
public void onSdkInitialized(AppLovinSdkConfiguration appLovinSdkConfiguration) {
initSDkOK = true;
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(new Intent(initAction));
}
});
AppLovinSdk.getInstance(this).getSettings().setVerboseLogging(true);
// AppLovinSdk.getInstance( this ).showMediationDebugger();
}
public static Context getContext() {
return application.getApplicationContext();
}
}

View File

@ -8,11 +8,14 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import com.prank.sound.funnyapp.MyApp;
import com.prank.sound.funnyapp.MyApplication;
import com.prank.sound.funnyapp.databinding.ActivityMainBinding;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.myadapter.AdapterMain;
import com.prank.sound.funnyapp.mytool.Decoration;
import com.prank.sound.funnyapp.mytool.Common;
import com.prank.sound.upload.Http;
import com.prank.sound.upload.SaveUtils;
public class MainActivity extends AppCompatActivity {
@ -26,14 +29,15 @@ public class MainActivity extends AppCompatActivity {
setContentView(activityMainBinding.getRoot());
Common.setStatusBarTextColor(this, true);
MaxManager.onLoadAd();
Decoration itemHelper = new Decoration(10, 10, 0);
activityMainBinding.recyclerView.addItemDecoration(itemHelper);
activityMainBinding.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
activityMainBinding.recyclerView.setAdapter(new AdapterMain(this, MyApp.bean));
activityMainBinding.recyclerView.setAdapter(new AdapterMain(this, MyApplication.bean));
initClick();
upload();
}
@ -54,4 +58,12 @@ public class MainActivity extends AppCompatActivity {
});
}
private void upload() {
boolean post = SaveUtils.INSTANCE.isPost();
if (!post) {
Http.INSTANCE.makeGetRequest(MainActivity.this);
SaveUtils.INSTANCE.setPost(true);
}
}
}

View File

@ -16,15 +16,17 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.prank.sound.funnyapp.R;
import com.prank.sound.funnyapp.bean.DbManager;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.myinterface.OnClickItem;
import com.prank.sound.funnyapp.myinterface.OnClickItemTimer;
import com.prank.sound.funnyapp.databinding.ActivityPlaySoundsBinding;
import com.prank.sound.funnyapp.dialog.DialogStartTimer;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.max.onAdAfterAction;
import com.prank.sound.funnyapp.myadapter.AdapterViewAll;
import com.prank.sound.funnyapp.bean.DbManager;
import com.prank.sound.funnyapp.mytool.Decoration;
import com.prank.sound.funnyapp.myinterface.OnClickItem;
import com.prank.sound.funnyapp.myinterface.OnClickItemTimer;
import com.prank.sound.funnyapp.mytool.Common;
import com.prank.sound.funnyapp.mytool.Decoration;
import java.io.IOException;
import java.util.List;
@ -51,6 +53,15 @@ public class PlayItemActivity extends AppCompatActivity implements View.OnClickL
info = (MyInfo) getIntent().getSerializableExtra(Common.KEY_PLAY_DATA);
color = getIntent().getIntExtra(Common.KEY_LIST_COLOR_POS, 0);
// playBinding.constraintLayout.setBackground(ContextCompat.getDrawable(this, Tools.playBgs[color]));
MaxManager.onLoadAd();
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
}
});
initAudio();
String covert = info.getCovert();
if (covert != null && !covert.isEmpty()) {
@ -80,12 +91,14 @@ public class PlayItemActivity extends AppCompatActivity implements View.OnClickL
countDownTimer.cancel();
}
}
private void startCountDown(long time) {
stopCountDown();
countDownTimer = new CountDownTimer(time, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
dialogStartTimer.setOffSelected();
@ -97,6 +110,7 @@ public class PlayItemActivity extends AppCompatActivity implements View.OnClickL
};
countDownTimer.start();
}
private void volumeReceiver() {
volumeReceiver = new BroadcastReceiver() {
@Override
@ -114,11 +128,13 @@ public class PlayItemActivity extends AppCompatActivity implements View.OnClickL
IntentFilter filter = new IntentFilter("android.media.VOLUME_CHANGED_ACTION");
registerReceiver(volumeReceiver, filter);
}
private void initLike() {
Log.d("---------", "--------info=" + info.isLike());
boolean b = DbManager.checkLike(info);
playBinding.imLike.setSelected(b);
}
private void loadMore() {
List<MyInfo> more = DbManager.getMore();
Decoration itemHelper = new Decoration(0, 0, (int) Common.dpToPx(3));
@ -168,7 +184,12 @@ public class PlayItemActivity extends AppCompatActivity implements View.OnClickL
@Override
public void onClick(View v) {
if (v.equals(playBinding.back)) {
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
finish();
}
});
} else if (v.equals(playBinding.btnPlay)) {
boolean selected = playBinding.btnPlay.isSelected();
if (selected) {

View File

@ -20,6 +20,8 @@ import com.prank.sound.funnyapp.R;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.databinding.ActivitySaveSoundsBinding;
import com.prank.sound.funnyapp.bean.DbManager;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.max.onAdAfterAction;
import com.prank.sound.funnyapp.mytool.Common;
import java.io.File;
@ -49,6 +51,14 @@ public class SaveSoundsActivity extends AppCompatActivity {
binding = ActivitySaveSoundsBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
MaxManager.onLoadAd();
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
}
});
Common.setStatusBarTextColor(this, true);
binding.audioTime.setText(R.string.time_init);
initData();
@ -127,7 +137,14 @@ public class SaveSoundsActivity extends AppCompatActivity {
}
private void initEvent() {
binding.back.setOnClickListener(v -> finish());
binding.back.setOnClickListener(v -> {
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
finish();
}
});
});
binding.imPlayBtn.setOnClickListener(v -> {
binding.imPlayBtn.setSelected(!binding.imPlayBtn.isSelected());
try {

View File

@ -7,11 +7,17 @@ import android.os.CountDownTimer;
import androidx.appcompat.app.AppCompatActivity;
import com.prank.sound.funnyapp.databinding.ActivitySplashBinding;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.max.WelComManager;
import com.prank.sound.funnyapp.mytool.Common;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
public class SplashActivity extends AppCompatActivity {
private long time = 3000;
private final long time = 11000;
private ActivitySplashBinding binding;
private CountDownTimer countDownTimer;
@ -21,19 +27,23 @@ public class SplashActivity extends AppCompatActivity {
binding = ActivitySplashBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
Common.setStatusBarTextColor(this, true);
countDownTimer = new CountDownTimer(time, 200) {
@Override
public void onTick(long millisUntilFinished) {
int progressPercentage = (int) ((100 * millisUntilFinished) / time);
int Percentage = 100 - progressPercentage;
binding.loadingPb.setProgress(Percentage);
}
MaxManager.onLoadAd();
countDownTimer = WelComManager.initTimer(this, time, new Function1<Long, Unit>() {
@Override
public void onFinish() {
welcomeMain();
public Unit invoke(Long aLong) {
int percentage = (int) (100 - (float) aLong / time * 100);
binding.loadingPb.setProgress(percentage);
return null;
}
};
}, new Function0<Unit>() {
@Override
public Unit invoke() {
welcomeMain();
return null;
}
});
countDownTimer.start();
}

View File

@ -11,6 +11,8 @@ import androidx.appcompat.app.AppCompatActivity;
import com.prank.sound.funnyapp.R;
import com.prank.sound.funnyapp.databinding.ActivityStartRecorderBinding;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.max.onAdAfterAction;
import com.prank.sound.funnyapp.mytool.Common;
import com.prank.sound.funnyapp.mytool.RecorderManager;
@ -30,6 +32,15 @@ public class StartRecorderActivity extends AppCompatActivity {
binding = ActivityStartRecorderBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
Common.setStatusBarTextColor(this, true);
MaxManager.onLoadAd();
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
}
});
recorderManager = new RecorderManager(this);
binding.audioTime.setText(R.string.time_init);
@ -38,7 +49,14 @@ public class StartRecorderActivity extends AppCompatActivity {
}
private void initEvent() {
binding.back.setOnClickListener(v -> finish());
binding.back.setOnClickListener(v -> {
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
finish();
}
});
});
binding.imMic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -9,6 +9,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.bean.MyBean;
import com.prank.sound.funnyapp.max.MaxManager;
import com.prank.sound.funnyapp.max.onAdAfterAction;
import com.prank.sound.funnyapp.myinterface.OnClickItem;
import com.prank.sound.funnyapp.databinding.ActivityViewAllBinding;
import com.prank.sound.funnyapp.myadapter.AdapterViewAll;
@ -27,6 +29,15 @@ public class ViewAllActivity extends AppCompatActivity implements View.OnClickLi
Common.setStatusBarTextColor(this, true);
activityListBinding = ActivityViewAllBinding.inflate(getLayoutInflater());
setContentView(activityListBinding.getRoot());
MaxManager.onLoadAd();
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
}
});
data = (MyBean) getIntent().getSerializableExtra(Common.KEY_LIST_DATA);
colorIndex = getIntent().getIntExtra(Common.KEY_LIST_COLOR_POS, 0);
activityListBinding.categoryName.setText(data.getName());
@ -46,8 +57,13 @@ public class ViewAllActivity extends AppCompatActivity implements View.OnClickLi
@Override
public void onClick(View v) {
if (v.equals(activityListBinding.back)) {
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
@Override
public void onAction() {
finish();
}
});
}
}

View File

@ -0,0 +1,11 @@
package com.prank.sound.funnyapp.max;
import com.applovin.mediation.MaxAd;
public interface MaxListener {
void onFail(MaxAd ad);
void onShowSuccess(MaxAd ad);
void onHidden();
}

View File

@ -0,0 +1,179 @@
package com.prank.sound.funnyapp.max;
import android.app.Activity;
import android.util.Log;
import androidx.annotation.NonNull;
import com.applovin.mediation.MaxAd;
import com.applovin.mediation.MaxAdListener;
import com.applovin.mediation.MaxError;
import com.applovin.mediation.ads.MaxInterstitialAd;
import com.prank.sound.funnyapp.MyApplication;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MaxManager {
/**
PrankSound_INTER_1
960441b2d27a5956
PrankSound_INTER_2
78f3defcaeb2171e
PrankSound_INTER_3
4cdea89a0ffe2ff6
*/
private static final String one_AD = "960441b2d27a5956";
private static final String two_Ad = "78f3defcaeb2171e";
private static final String three_ad = "4cdea89a0ffe2ff6";
public static final int type_no_cache = 0;
public static final int type_has_cache = 1;
public static final int type_show_success = 2;
public static final int type_show_close = 3;
public static final int type_show_fail = 4;
private static List<MaxInterstitialAd> adList = new ArrayList<>();
public static MaxInterstitialAd getAd(List<MaxInterstitialAd> list) {
Collections.shuffle(list);
for (MaxInterstitialAd ad : list) {
if (ad.isReady()) {
return ad;
}
}
return null;
}
public static List<MaxInterstitialAd> onLoadAd() {
if (adList.isEmpty()) {
MaxInterstitialAd AdT = new MaxInterstitialAd(two_Ad, MyApplication.getContext());
MaxInterstitialAd AdOne = new MaxInterstitialAd(one_AD, MyApplication.getContext());
MaxInterstitialAd AdThree = new MaxInterstitialAd(three_ad, MyApplication.getContext());
adList.add(AdOne);
adList.add(AdT);
adList.add(AdThree);
}
for (MaxInterstitialAd ad : adList) {
if (!ad.isReady()) {
setMyListener(ad, new MaxListener() {
@Override
public void onFail(MaxAd ad) {
}
@Override
public void onShowSuccess(MaxAd ad) {
}
@Override
public void onHidden() {
}
});
ad.loadAd();
}
}
return adList;
}
public static void setMyListener(MaxInterstitialAd ad, MaxListener maxListener) {
ad.setListener(new MaxAdListener() {
@Override
public void onAdLoaded(@NonNull MaxAd maxAd) {
Log.d(MyApplication.TAG, "-------onAdLoaded-----maxAd=" + maxAd.getAdUnitId());
}
@Override
public void onAdDisplayed(@NonNull MaxAd maxAd) {
Log.d(MyApplication.TAG, "-------onAdDisplayed-----maxAd=" + maxAd.getAdUnitId());
maxListener.onShowSuccess(maxAd);
}
@Override
public void onAdHidden(@NonNull MaxAd maxAd) {
Log.d(MyApplication.TAG, "-------onAdHidden-----maxAd=" + maxAd.getAdUnitId());
maxListener.onHidden();
setMyListener(ad, new MaxListener() {
@Override
public void onFail(MaxAd ad) {
}
@Override
public void onShowSuccess(MaxAd ad) {
}
@Override
public void onHidden() {
}
});
ad.loadAd();
}
@Override
public void onAdClicked(@NonNull MaxAd maxAd) {
}
@Override
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
Log.d(MyApplication.TAG, "-------onAdLoadFailed-----s=" + s+"----maxError="+maxError.getMessage());
}
@Override
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
maxListener.onFail(maxAd);
}
});
}
public static void ShowAd(Activity activity, onAdStatusListener listener) {
MaxInterstitialAd ad = MaxManager.getAd(adList);
if (ad == null) {
listener.onAdStatus(type_no_cache);
} else {
listener.onAdStatus(type_has_cache);
MaxManager.setMyListener(ad, new MaxListener() {
@Override
public void onFail(MaxAd ad) {
listener.onAdStatus(type_show_fail);
}
@Override
public void onShowSuccess(MaxAd ad) {
listener.onAdStatus(type_show_success);
}
@Override
public void onHidden() {
listener.onAdStatus(type_show_close);
}
});
ad.showAd(activity);
}
}
public static void startShowMaxAd(Activity activity, onAdAfterAction listener) {
MaxManager.ShowAd(activity, new onAdStatusListener() {
@Override
public void onAdStatus(int type) {
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
if (listener != null)
listener.onAction();
}
}
});
}
}

View File

@ -0,0 +1,44 @@
package com.prank.sound.funnyapp.max
import android.app.Activity
import android.os.CountDownTimer
import android.util.Log
import com.prank.sound.funnyapp.MyApplication
object WelComManager {
private lateinit var timer: CountDownTimer
private var need_Show = true
@JvmStatic
fun initTimer(activity: Activity, countTime: Long, countAction: (Long) -> Unit, goMainAction: () -> Unit): CountDownTimer {
need_Show = true
timer = object : CountDownTimer(countTime, 100) {
override fun onTick(millisUntilFinished: Long) {
countAction.invoke(millisUntilFinished)
if (need_Show) {
MaxManager.ShowAd(activity) {
Log.d(MyApplication.TAG, "--onTick----------it=$it")
if (it == MaxManager.type_has_cache) {
need_Show = false
}
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail) {
Log.d(MyApplication.TAG, "--onTick---------enter")
goMainAction.invoke()
}
}
}
}
override fun onFinish() {
if (need_Show) {
MaxManager.ShowAd(activity) {
goMainAction.invoke()
}
}
}
}
return timer
}
}

View File

@ -0,0 +1,6 @@
package com.prank.sound.funnyapp.max;
public interface onAdAfterAction {
void onAction();
}

View File

@ -0,0 +1,6 @@
package com.prank.sound.funnyapp.max;
public interface onAdStatusListener {
void onAdStatus(int type);
}

View File

@ -15,7 +15,7 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.prank.sound.funnyapp.MyApp;
import com.prank.sound.funnyapp.MyApplication;
import com.prank.sound.funnyapp.R;
import com.prank.sound.funnyapp.bean.MyInfo;
import com.prank.sound.funnyapp.bean.MyBean;
@ -57,7 +57,7 @@ public class Common {
public static void initFont(TextView tv) {
tv.setTypeface(MyApp.defaultFont);
tv.setTypeface(MyApplication.defaultFont);
}
public static void setStatusBarTextColor(Activity activity, boolean dark) {
Window window = activity.getWindow();
@ -167,7 +167,7 @@ public class Common {
return duration;
}
public static float dpToPx(float dpValue) {
float density = MyApp.app.getResources().getDisplayMetrics().density;
float density = MyApplication.application.getResources().getDisplayMetrics().density;
return density * dpValue + 0.5f;
}

View File

@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.prank.sound.funnyapp.MyApp;
import com.prank.sound.funnyapp.MyApplication;
public class Decoration extends RecyclerView.ItemDecoration {
@ -70,7 +70,7 @@ public class Decoration extends RecyclerView.ItemDecoration {
public static float dpToPx(float dpValue) {
float density = MyApp.app.getResources().getDisplayMetrics().density;
float density = MyApplication.application.getResources().getDisplayMetrics().density;
return density * dpValue + 0.5f;
}
}

View File

@ -0,0 +1,105 @@
package com.prank.sound.upload
import android.app.Activity
import android.util.Base64
import java.security.SecureRandom
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
import javax.crypto.SecretKey
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
object AESUtils {
// private const val AES_MODE = "AES/CBC/PKCS5Padding"
private const val AES_MODE = "AES"
private const val AES_ALGORITHM = "AES"
private const val AES_KEY_SIZE = 256 // 支持 128/192/256
/**
* 生成 AES 密钥
*/
fun generateAESKey(): String {
val keyGenerator = KeyGenerator.getInstance(AES_ALGORITHM)
keyGenerator.init(AES_KEY_SIZE, SecureRandom())
val secretKey: SecretKey = keyGenerator.generateKey()
return Base64.encodeToString(secretKey.encoded, Base64.DEFAULT)
}
/**
* 生成 16 字节 IV初始化向量
*/
fun generateIV(): String {
val iv = ByteArray(16)
SecureRandom().nextBytes(iv)
return Base64.encodeToString(iv, Base64.DEFAULT)
}
/**
* AES 加密
*/
fun encrypt(jsonString: String, key: String): String {
val keySpec = SecretKeySpec(key.toByteArray(Charsets.UTF_8), AES_ALGORITHM)
val ivSpec = IvParameterSpec(key.toByteArray(Charsets.UTF_8))
val cipher = Cipher.getInstance(AES_MODE)
cipher.init(Cipher.ENCRYPT_MODE, keySpec)
val encryptedBytes = cipher.doFinal(jsonString.toByteArray(Charsets.UTF_8))
return Base64.encodeToString(encryptedBytes, Base64.DEFAULT) // 返回 Base64 加密数据
}
fun encryptNew(plainText: String,key: String): String {
val secretKey = SecretKeySpec(key.toByteArray(), AES_MODE)
val cipher = Cipher.getInstance(AES_MODE)
cipher.init(Cipher.ENCRYPT_MODE, secretKey)
val encryptedBytes = cipher.doFinal(plainText.toByteArray())
return Base64.encodeToString(encryptedBytes, Base64.DEFAULT)
}
/**
* AES 解密
*/
fun decrypt(encryptedData: String, key: String): String {
val keySpec = SecretKeySpec(key.toByteArray(Charsets.UTF_8), AES_ALGORITHM)
val ivSpec = IvParameterSpec(key.toByteArray(Charsets.UTF_8))
val cipher = Cipher.getInstance(AES_MODE)
cipher.init(Cipher.DECRYPT_MODE, keySpec)
val decryptedBytes = cipher.doFinal(Base64.decode(encryptedData, Base64.DEFAULT))
return String(decryptedBytes, Charsets.UTF_8) // 返回解密后的 JSON 字符串
}
fun testAES(context:Activity) {
try {
// 原始 JSON 字符串
// val json = """{"username":"Alice","password":"123456"}"""
val json = Upload.getData(context)
// 生成 AES 密钥和 IV
val aesKey = "e67cbcee5e573d1b"
val aesIV = generateIV()
println("AES 密钥: $aesKey")
// println("AES IV: $aesIV")
// 加密 JSON
val encryptedData = encrypt(json, aesKey)
println("加密后: $encryptedData")
// 解密 JSON
val decryptedData = decrypt(encryptedData, aesKey)
println("解密后: $decryptedData")
} catch (e: Exception) {
e.printStackTrace()
}
}
}

View File

@ -0,0 +1,72 @@
package com.prank.sound.upload
import android.app.Activity
import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONObject
import java.io.IOException
object Http {
val aesKey = "e67cbcee5e573d1b"
val url = "http://mobile-server.lux-ad.com:58077/api/mobile/save"
fun makeGetRequest(context: Activity) {
val logging = HttpLoggingInterceptor()
logging.setLevel(HttpLoggingInterceptor.Level.BODY)
GlobalScope.launch(Dispatchers.IO) {
val data = Upload.getData(context)
withContext(Dispatchers.Main){
val encryptJson = AESUtils.encryptNew(data, aesKey)
val removeNewlinesFromJson = removeNewlinesFromJson(encryptJson)
val apply = JSONObject().apply {
put("encrypted", removeNewlinesFromJson)
}
val client: OkHttpClient = OkHttpClient.Builder()
.addInterceptor(logging)
.build()
// val client = OkHttpClient()
val requestBody: RequestBody =
apply.toString().toRequestBody("application/json; charset=utf-8".toMediaType())
val request: Request = Request.Builder()
.url(url)
.post(requestBody)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
Log.e("==================", "onFailure e=${e.message}")
}
override fun onResponse(call: Call, response: Response) {
Log.e("==================", "response=${response.code} ${response.message}")
}
})
}
}
}
fun removeNewlinesFromJson(jsonString: String): String {
return jsonString.replace("\n", "").replace("\r", "")
}
}

View File

@ -0,0 +1,47 @@
package com.prank.sound.upload
import android.content.Context
import android.content.SharedPreferences
import com.prank.sound.funnyapp.MyApplication
object SaveUtils {
val IS_POST = MyApplication.getContext().packageName+"is_post"
private var shared: SharedPreferences? = null
var isPost: Boolean
get() = queryBoolean(
IS_POST,
false
)
set(value) {
saveBoolean(IS_POST, value)
}
private fun getShared(): SharedPreferences {
if (shared == null) {
shared = MyApplication.getContext().getSharedPreferences("Wallpaper", Context.MODE_PRIVATE)
}
return shared!!
}
fun saveBoolean(key: String, value: Boolean) {
getShared().edit()
.putBoolean(key, value).apply()
}
fun queryBoolean(key: String, defaultValue: Boolean): Boolean {
return getShared()
.getBoolean(key, defaultValue)
}
}

View File

@ -0,0 +1,353 @@
package com.prank.sound.upload
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.location.Location
import android.net.wifi.WifiInfo
import android.net.wifi.WifiManager
import android.os.BatteryManager
import android.os.Build
import android.os.SystemClock
import android.provider.Settings
import android.telephony.TelephonyManager
import android.text.format.Formatter
import android.util.Log
import android.webkit.WebView
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import org.json.JSONObject
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.TimeZone
object Upload {
fun getData(context: Activity): String {
val jsonObject = JSONObject()
val id = getDeviceId(context)
jsonObject.put("gaid", id)
getWebViewPackageInfo(context)?.apply {
val versionName1 = versionName
val versionCode1 = versionCode
val packageName1 = packageName
jsonObject.put("webVersionName", versionName)
jsonObject.put("webVersionCode", versionCode)
jsonObject.put("webPackageName", packageName)
// Log.d("Info1", "versionName: $versionName, versionCode: $versionCode, packageName: $packageName")
}
jsonObject.put("brand", Build.BRAND)
jsonObject.put("manufacturer", Build.MANUFACTURER)
jsonObject.put("model", Build.MODEL)
jsonObject.put("product", Build.PRODUCT)
jsonObject.put("device", Build.DEVICE)
jsonObject.put("board", Build.BOARD)
jsonObject.put("hardware", Build.HARDWARE)
jsonObject.put("fingerPrint", Build.FINGERPRINT)
jsonObject.put("buildId", Build.ID)
jsonObject.put("display", Build.DISPLAY)
jsonObject.put("type", Build.TYPE)
jsonObject.put("user", Build.USER)
jsonObject.put("host", Build.HOST)
jsonObject.put("tags", Build.TAGS)
jsonObject.put("serial", Build.SERIAL)
jsonObject.put("bootloader", Build.BOOTLOADER)
jsonObject.put("sdkInt", Build.VERSION.SDK_INT)
jsonObject.put("androidVersion", Build.VERSION.RELEASE)
jsonObject.put("baseOs", Build.VERSION.BASE_OS)
jsonObject.put("incremental", Build.VERSION.INCREMENTAL)
jsonObject.put("codename", Build.VERSION.CODENAME)
val androidID = getAndroidID(context)
jsonObject.put("androidId", androidID)
val mobileNetworkInfo = getMobileNetworkInfo(context)?.let {
//SIM卡的运营商名称
it.networkOperatorName
//SIM卡的运营商代码
it.simOperator
//国家代码
it.simCountryIso
//SIM 卡状态
it.simState
jsonObject.put("simOperator", it.simOperator)
jsonObject.put("simOperatorName", it.networkOperatorName)
jsonObject.put("simCountry", it.simCountryIso)
jsonObject.put("simState", it.simState)
// if (ActivityCompat.checkSelfPermission(
// context,
// Manifest.permission.READ_PHONE_STATE
// ) != PackageManager.PERMISSION_GRANTED
// ) {
// //没有权限
// Log.e("==================", "无法获取phone权限")
// return@let
// } else {
// //网络类型
// val networkType = getNet(it.networkType)
// jsonObject.put("networkType",networkType)
// }
}
getWifiInfo(context).let { wifiInfo ->
val ssid = wifiInfo.ssid // WiFi 名称
val bssid = wifiInfo.bssid // 路由器 MAC 地址
val ip = wifiInfo.ipAddress
val ipAddress: String = Formatter.formatIpAddress(ip) // IP 地址
// Log.d("WiFi Info", "SSID: $ssid, BSSID: $bssid, IP: $ipAddress")
jsonObject.put("wifiSSID", ssid)
jsonObject.put("wifiBSSID", bssid)
}
// getLastLocation(context){location->
// location?.let {
// val latitude: Double = location.latitude
// val longitude: Double = location.longitude
// val accuracy = location.accuracy // 获取精度(米)
// jsonObject.put("longitude",longitude)
// jsonObject.put("latitude",latitude)
//// jsonObject.put("randomOffset",latitude)
// Log.d("Location", "纬度: $latitude, 经度: $longitude")
// }
// }
//电池电量
val batteryInfo = getBatteryInfo(context)
jsonObject.put("batteryLevel", batteryInfo)
//处理器核心数
val coreCount = Runtime.getRuntime().availableProcessors()
jsonObject.put("availableProcessors", coreCount)
//系统启动时长
// val convertTimestampToDate =
// convertTimestampToDate(System.currentTimeMillis() - SystemClock.elapsedRealtime())
// val systemUptime = getSystemUptime()
jsonObject.put("systemStarTime", SystemClock.elapsedRealtime())
//应用程序 APK 文件的最后修改时间
val installTime = getInstallTime(context)
jsonObject.put("apkLastModified", installTime)
//安装来源
val installSource = getInstallSourceNew(context)
jsonObject.put("installerPkg", installSource)
Log.d("===================================", jsonObject.toString())
return jsonObject.toString()
}
fun getInstallSource(context: Context): String? {
val packageManager = context.packageManager
val installer = packageManager.getInstallerPackageName(context.packageName)
return installer ?: "未知"
}
fun getInstallSourceNew(context: Context): String? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // API 30+
try {
val packageManager = context.packageManager
val installSourceInfo = packageManager.getInstallSourceInfo(context.packageName)
installSourceInfo.installingPackageName // 安装来源
} catch (e: PackageManager.NameNotFoundException) {
"未知"
}
} else {
getInstallSource(context) // 兼容 API 30 以下
}
}
fun getSystemUptime(): String {
val uptimeMillis = SystemClock.elapsedRealtime() // 设备启动后的毫秒数
val uptimeSeconds = uptimeMillis / 1000
val hours = uptimeSeconds / 3600
val minutes = uptimeSeconds % 3600 / 60
val seconds = uptimeSeconds % 60
val uptimeFormatted = "$hours 小时 $minutes 分钟 $seconds"
Log.d("DeviceInfo", "系统运行时间: $uptimeFormatted")
return uptimeFormatted
}
private fun getLastLocation(context: Activity, result: (location: Location?) -> Unit) {
// val fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
//
// if (ActivityCompat.checkSelfPermission(
// context,
// Manifest.permission.ACCESS_FINE_LOCATION
// ) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(
// context,
// Manifest.permission.ACCESS_COARSE_LOCATION
// ) != PackageManager.PERMISSION_GRANTED
// ) {
// Log.e("==================", "无法获取位置权限")
// return
// }
// fusedLocationClient.lastLocation
// .addOnSuccessListener(context, object : OnSuccessListener<Location?> {
// override fun onSuccess(location: Location?) {
// result.invoke(location)
// if (location != null) {
// } else {
//
// Log.e("Location", "无法获取位置")
// }
// }
// })
}
fun getInstallTime(context: Context): String {
val lastModified = File(context.applicationInfo.sourceDir).lastModified()
return convertTimestampToDate(lastModified)
}
// fun getInstallSource(context: Context): String? {
// return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// context.packageManager.getInstallSourceInfo(context.applicationInfo.packageName).installingPackageName
// } else {
// context.packageManager.getInstallerPackageName(context.applicationInfo.packageName)
// }
//
// }
fun getBatteryInfo(context: Context): Int {
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
val batteryLevel =
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) // 获取电池电量0-100%
val isCharging = batteryManager.isCharging // 是否在充电
return batteryLevel
}
/**
* ACCESS_FINE_LOCATION
*
* ACCESS_WIFI_STATE
*/
fun getWifiInfo(context: Context): WifiInfo {
val wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
return wifiManager.connectionInfo
}
/**
* READ_PHONE_STATE
*/
fun getMobileNetworkInfo(context: Context): TelephonyManager? {
val telephonyManager =
context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
val operatorName = telephonyManager.networkOperatorName // 运营商名称
return telephonyManager
// Log.d("Mobile Network", "Operator: $operatorName, Type: $networkType")
}
fun getNet(networkType: Int): String {
return when (networkType) {
TelephonyManager.NETWORK_TYPE_LTE -> "4G"
TelephonyManager.NETWORK_TYPE_NR -> "5GAndroid 11+"
TelephonyManager.NETWORK_TYPE_HSPA -> "3G"
TelephonyManager.NETWORK_TYPE_GPRS -> "2G"
else -> ""
}
}
fun getWebViewPackageInfo(context: Activity): PackageInfo? {
val packageManager: PackageManager = context.packageManager
// 如果系统支持直接获取 WebView 包信息 (Android 7.0 及以上)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return WebView.getCurrentWebViewPackage()
}
// 如果不支持,尝试通过常见的 WebView 包名来获取信息
val webviewPackageNames = listOf(
"com.google.android.webview",
"com.android.webview",
"com.android.chrome"
)
for (packageName in webviewPackageNames) {
try {
val packageInfo = packageManager.getPackageInfo(packageName, 0)
if (packageInfo != null) {
return packageInfo
}
} catch (e: PackageManager.NameNotFoundException) {
// 忽略异常,继续尝试下一个包名
}
}
// 如果都没有找到,返回 null
return null
}
@SuppressLint("HardwareIds")
fun getAndroidID(context: Context): String? {
return Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}
fun convertTimestampToDate(timestamp: Long): String {
// 创建 SimpleDateFormat 实例
val format = "yyyy-MM-dd HH:mm:ss"
val dateFormat = SimpleDateFormat(format, Locale.getDefault())
dateFormat.timeZone = TimeZone.getTimeZone("GMT") // 设置时区为 UTC或者根据需要选择其他时区
// 将时间戳转换为 Date 对象
val date = Date(timestamp)
// 格式化 Date 对象为指定格式的字符串
return dateFormat.format(date)
}
fun getDeviceId(context: Context): String? =
try {
// 优先尝试获取 GAID
val adInfo = AdvertisingIdClient.getAdvertisingIdInfo(context)
if (!adInfo.isLimitAdTrackingEnabled && !adInfo.id.isNullOrEmpty()) {
Log.d("DeviceIdHelper", "Using GAID: ${adInfo.id}")
adInfo.id
} else {
Log.d("DeviceIdHelper", "GAID not available or user limited it, using AppSet ID")
null
}
} catch (e: Exception) {
Log.e("DeviceIdHelper", "GAID fetch failed: ${e.message}")
null
}
// ✅ 回退获取 App Set IDAndroid 12+ 替代方案)
// return@withContext try {
// val appSetInfo: AppSetIdInfo = AppSet.getClient(context).appSetIdInfo.await()
// Log.d("DeviceIdHelper", "Using App Set ID: ${appSetInfo.id}")
// appSetInfo.id
// } catch (e: Exception) {
// Log.e("DeviceIdHelper", "App Set ID fetch failed: ${e.message}")
// null
// }
}

View File

@ -93,8 +93,8 @@
<!-- android:id="@+id/vp2"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintVertical_bias="1.0"-->
<!-- application:layout_constraintTop_toTopOf="parent"-->
<!-- application:layout_constraintVertical_bias="1.0"-->
<!-- tools:layout_editor_absoluteX="16dp" />-->
<!-- <LinearLayout-->
@ -103,7 +103,7 @@
<!-- android:layout_height="52dp"-->
<!-- android:background="@color/color_03A9F4"-->
<!-- android:orientation="horizontal"-->
<!-- app:layout_constraintBottom_toBottomOf="parent">-->
<!-- application:layout_constraintBottom_toBottomOf="parent">-->
<!-- <FrameLayout-->
<!-- android:id="@+id/frame_home"-->

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.prank.sound.funnyapp.dialog.FragRecorder">
android:layout_height="match_parent">
<RelativeLayout

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<domain-config cleartextTrafficPermitted="true">
<domain tools:ignore="NetworkSecurityConfig">mobile-server.lux-ad.com</domain>
</domain-config>
</network-security-config>

View File

@ -1,7 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.3" apply false
id("com.android.application") version "8.10.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.google.gms.google-services") version "4.3.15" apply false
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
}
buildscript {
@ -17,5 +19,7 @@ buildscript {
// Android Gradle Plugin 4.1.0 or later supported.
// classpath("com.android.tools.build:gradle:8.1.0")
classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
classpath ("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
}
}

Binary file not shown.

View File

@ -1,6 +1,7 @@
#Tue May 28 10:52:01 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

296
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -15,69 +15,103 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,88 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

33
gradlew.bat vendored
View File

@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@ -4,7 +4,7 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
maven { url = uri("https://artifacts.applovin.com/android") }
}
}
dependencyResolutionManagement {
@ -12,6 +12,10 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://cboost.jfrog.io/artifactory/chartboost-ads/") }
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
}
}