diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a6e98a7..f90dda5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,19 +4,21 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("io.objectbox") + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") } val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date()) android { namespace = "com.prank.sounds.fart" - compileSdk = 34 + compileSdk = 35 defaultConfig { //com.prank.sounds.fart applicationId = "com.prank.sounds.fart" minSdk = 23 - targetSdk = 34 - versionCode = 1 - versionName = "1.0" + targetSdk = 35 + versionCode = 2 + versionName = "1.0.1" setProperty("archivesBaseName", "Prank Sounds_V" + versionName + "(${versionCode})_$timestamp") testInstrumentationRunner = "androidx.sounds.runner.AndroidJUnitRunner" vectorDrawables { @@ -63,4 +65,111 @@ implementation("androidx.appcompat:appcompat:1.6.1") implementation ("com.airbnb.android:lottie:5.2.0") + //获取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") + + //-----------------------------------------------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.0.7") + + //----------------------------------------------TopOn } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..e02f447 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "463730324288", + "project_id": "prank-sounds-3499f", + "storage_bucket": "prank-sounds-3499f.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:463730324288:android:95142820ed97e5631080a5", + "android_client_info": { + "package_name": "com.prank.sounds.fart" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCW2SXJ1p4GQIaqbiU4e46Gz8cBuYWOaRs" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 4428e3a..3690c8f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -48,4 +48,134 @@ java.lang.Object readResolve(); -keepclassmembers class * extends io.objectbox.Box { (...); ; -} \ No newline at end of file +} + + +#---------------------------------------------Topon + -keep class com.startapp.** { + *; + } + + -keep class com.truenet.** { + *; + } + + -keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, + LineNumberTable, *Annotation*, EnclosingMethod + -dontwarn android.webkit.JavascriptInterface + -dontwarn com.startapp.** + + -dontwarn org.jetbrains.annotations.** + -keep class com.appnext.** { *; } + -dontwarn com.appnext.** + # Vungle + -dontwarn com.vungle.ads.** + -keepclassmembers class com.vungle.ads.** { + *; + } + -keep class com.vungle.ads.** + + + + # Google + -keep class com.google.android.gms.** { *; } + -dontwarn com.google.android.gms.** + + + + + # START OkHttp + Okio + # JSR 305 annotations are for embedding nullability information. + -dontwarn javax.annotation.** + + + # A resource is loaded with a relative path so the package of this class must be preserved. + -adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz + + + # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. + -dontwarn org.codehaus.mojo.animal_sniffer.* + + + # OkHttp platform used only on JVM and when Conscrypt and other security providers are available. + -dontwarn okhttp3.internal.platform.** + -dontwarn org.conscrypt.** + -dontwarn org.bouncycastle.** + -dontwarn org.openjsse.** + + + # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. + -dontwarn org.codehaus.mojo.animal_sniffer.* + + + # END OkHttp + Okio + + + # START Protobuf + -dontwarn com.google.protobuf.** + -keepclassmembers class com.google.protobuf.** { + *; + } + -keep class * extends com.google.protobuf.GeneratedMessageLite { *; } + + + # END Protobuf + -keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { + public *; + } + -keepclassmembers class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; + } + -keep public class com.google.android.gms.ads.** { + public *; + } + -keep class com.ironsource.adapters.** { *; + } + -dontwarn com.ironsource.mediationsdk.** + -dontwarn com.ironsource.adapters.** + -keepattributes JavascriptInterface + -keepclassmembers class * { + @android.webkit.JavascriptInterface ; + } + -keep class com.bytedance.sdk.** { *; } + -keep class com.inmobi.** { *; } + -keep public class com.google.android.gms.** + -dontwarn com.google.android.gms.** + -dontwarn com.squareup.picasso.** + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{ + public *; + } + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{ + public *; + } + # skip the Picasso library classes + -keep class com.squareup.picasso.** {*;} + -dontwarn com.squareup.okhttp.** + # skip Moat classes + -keep class com.moat.** {*;} + -dontwarn com.moat.** + # skip IAB classes + -keep class com.iab.** {*;} + -dontwarn com.iab.** + -keepattributes Signature + -keepattributes *Annotation* + -keep class com.mbridge.** {*; } + -keep interface com.mbridge.** {*; } + -keep class android.support.v4.** { *; } + -dontwarn com.mbridge.** + -keep class **.R$* { public static final int mbridge*; } + -keep public class com.mbridge.* extends androidx.** { *; } + -keep public class androidx.viewpager.widget.PagerAdapter{ *; } + -keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; } + -keep interface androidx.annotation.IntDef{ *; } + -keep interface androidx.annotation.Nullable{ *; } + -keep interface androidx.annotation.CheckResult{ *; } + -keep interface androidx.annotation.NonNull{ *; } + -keep public class androidx.fragment.app.Fragment{ *; } + -keep public class androidx.core.content.FileProvider{ *; } + -keep public class androidx.core.app.NotificationCompat{ *; } + -keep public class androidx.appcompat.widget.AppCompatImageView { *; } + -keep public class androidx.recyclerview.*{ *; } + -keep class com.chartboost.** { *; } + + #---------------------------------------------Topon \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8ee7c5b..b199876 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,9 +12,12 @@ + + bean; - - @Override - public void onCreate() { - super.onCreate(); - app = this; - AssetManager assets = getAssets(); - defaultFont = Typeface.createFromAsset(assets, "prankfont.ttf"); - Db.init(this); - if (bean != null) - return; - try { - InputStream open = getAssets().open("prank.json"); - String string = MyUtils.getString(open); - if (!string.isEmpty()) { - bean = MyUtils.getBean(string); - for (MyBean category:bean){ - for (Info info1 : category.getInfoList()) { - info1.setLike(false); - Db.getBoxBean().put(info1); - } - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/app/src/main/java/com/prank/sounds/fart/MyApplication.java b/app/src/main/java/com/prank/sounds/fart/MyApplication.java new file mode 100644 index 0000000..ff0d6ba --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/MyApplication.java @@ -0,0 +1,92 @@ +package com.prank.sounds.fart; + +import android.app.Application; +import android.content.Context; +import android.content.res.AssetManager; +import android.graphics.Typeface; +import android.util.Log; + +import com.anythink.core.api.ATSDK; +import com.anythink.core.api.NetTrafficeCallback; +import com.prank.sounds.fart.bean.Info; + +import com.prank.sounds.fart.bean.MyBean; +import com.prank.sounds.fart.tools.Db; +import com.prank.sounds.fart.tools.MyUtils; +import com.prank.sounds.fart.topon.AdManager; + +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 bean; + + public static final String TAG = "--------------"; + + private static final String AppKey = "a460517c4130df84822198f5e8c922a44"; + private static final String APPId = "h684261e85fc58"; + private static final String debug_KEy = "ed16491faf1c69a7f43813bec58f9fb7bfacbb2b"; + + @Override + public void onCreate() { + super.onCreate(); + application = this; + AssetManager assets = getAssets(); + defaultFont = Typeface.createFromAsset(assets, "prankfont.ttf"); + Db.init(this); + if (bean != null) + return; + try { + InputStream open = getAssets().open("prank.json"); + String string = MyUtils.getString(open); + if (!string.isEmpty()) { + bean = MyUtils.getBean(string); + for (MyBean category : bean) { + for (Info info1 : category.getInfoList()) { + info1.setLike(false); + Db.getBoxBean().put(info1); + } + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + + initSdk(); + } + + public static Context getContext() { + return application.getApplicationContext(); + } + + 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); + + } +} diff --git a/app/src/main/java/com/prank/sounds/fart/activity/InfoAct.java b/app/src/main/java/com/prank/sounds/fart/activity/InfoAct.java index 5c063d6..e6bddad 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/InfoAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/InfoAct.java @@ -14,6 +14,8 @@ import com.prank.sounds.fart.tools.MyUtils; import com.prank.sounds.fart.databinding.InfoActBinding; import com.prank.sounds.fart.myadapter.AdapterViewAll; import com.prank.sounds.fart.callback.OnClickSounds; +import com.prank.sounds.fart.topon.AdManager; +import com.prank.sounds.fart.topon.onActionListener; public class InfoAct extends AppCompatActivity implements View.OnClickListener, OnClickSounds { @@ -24,11 +26,20 @@ public class InfoAct extends AppCompatActivity implements View.OnClickListener, @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - MyUtils.setStatusBarTextColor(this,true); + MyUtils.setStatusBarTextColor(this, true); activityListBinding = InfoActBinding.inflate(getLayoutInflater()); setContentView(activityListBinding.getRoot()); + + AdManager.loadAllAd(); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + + } + }); + data = (MyBean) getIntent().getSerializableExtra(MyUtils.KEY_LIST_DATA); - colorIndex = getIntent().getIntExtra(MyUtils.KEY_LIST_COLOR_POS,0); + colorIndex = getIntent().getIntExtra(MyUtils.KEY_LIST_COLOR_POS, 0); activityListBinding.categoryName.setText(data.getName()); onList(); activityListBinding.back.setOnClickListener(this); @@ -38,15 +49,20 @@ public class InfoAct extends AppCompatActivity implements View.OnClickListener, MyItemDecoration itemHelper = new MyItemDecoration(10, 10, 0); activityListBinding.listRecycler.addItemDecoration(itemHelper); activityListBinding.listRecycler.setLayoutManager(new GridLayoutManager(this, 3)); - AdapterViewAll adapterViewAll = new AdapterViewAll(this, data.getInfoList(),0,this); + AdapterViewAll adapterViewAll = new AdapterViewAll(this, data.getInfoList(), 0, this); activityListBinding.listRecycler.setAdapter(adapterViewAll); adapterViewAll.setColorIndex(colorIndex); } @Override public void onClick(View v) { - if(v.equals(activityListBinding.back)){ - finish(); + if (v.equals(activityListBinding.back)) { + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + finish(); + } + }); } } @@ -56,6 +72,6 @@ public class InfoAct extends AppCompatActivity implements View.OnClickListener, Intent intent = new Intent(this, PlaySoundsAct.class); intent.putExtra(MyUtils.KEY_PLAY_DATA, data); intent.putExtra(MyUtils.KEY_LIST_COLOR_POS, colorIndex); - startActivity(intent); + startActivity(intent); } } \ No newline at end of file diff --git a/app/src/main/java/com/prank/sounds/fart/activity/MainAct.java b/app/src/main/java/com/prank/sounds/fart/activity/MainAct.java index 8ff66c0..bc7e14b 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/MainAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/MainAct.java @@ -23,6 +23,9 @@ import com.prank.sounds.fart.databinding.MainActBinding; import com.prank.sounds.fart.frag.FragLike; import com.prank.sounds.fart.frag.FragHome; import com.prank.sounds.fart.frag.FragRecorder; +import com.prank.sounds.fart.topon.AdManager; +import com.prank.sounds.fart.upload.Http; +import com.prank.sounds.fart.upload.SaveUtils; import java.util.ArrayList; import java.util.List; @@ -42,6 +45,9 @@ public class MainAct extends AppCompatActivity implements View.OnClickListener { activityMainBinding = MainActBinding.inflate(getLayoutInflater()); setContentView(activityMainBinding.getRoot()); MyUtils.setStatusBarTextColor(this, true); + + AdManager.loadAllAd(); + initVp2(); activityMainBinding.frameHome.setOnClickListener(this); activityMainBinding.frameAdd.setOnClickListener(this); @@ -61,6 +67,8 @@ public class MainAct extends AppCompatActivity implements View.OnClickListener { } }); + upload(); + // audioPickerLauncher = registerForActivityResult( // new ActivityResultContracts.StartActivityForResult(), // result -> { @@ -208,4 +216,12 @@ public class MainAct extends AppCompatActivity implements View.OnClickListener { audioPickerLauncher.launch("audio/*"); } + private void upload() { + boolean post = SaveUtils.INSTANCE.isPost(); + if (!post) { + Http.INSTANCE.makeGetRequest(MainAct.this); + SaveUtils.INSTANCE.setPost(true); + } + } + } \ No newline at end of file diff --git a/app/src/main/java/com/prank/sounds/fart/activity/PlaySoundsAct.java b/app/src/main/java/com/prank/sounds/fart/activity/PlaySoundsAct.java index 76ac7e5..d584569 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/PlaySoundsAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/PlaySoundsAct.java @@ -24,6 +24,8 @@ import com.prank.sounds.fart.frag.DialogTimer; import com.prank.sounds.fart.myadapter.AdapterViewAll; import com.prank.sounds.fart.callback.OnClickSounds; import com.prank.sounds.fart.callback.OnClickTimer; +import com.prank.sounds.fart.topon.AdManager; +import com.prank.sounds.fart.topon.onActionListener; import java.io.IOException; import java.util.List; @@ -47,8 +49,17 @@ public class PlaySoundsAct extends AppCompatActivity implements View.OnClickList playBinding = PlaySoundsActBinding.inflate(getLayoutInflater()); setContentView(playBinding.getRoot()); MyUtils.setStatusBarTextColor(this, true); + + AdManager.loadAllAd(); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + + } + }); + info = (Info) getIntent().getSerializableExtra(MyUtils.KEY_PLAY_DATA); - color = getIntent().getIntExtra(MyUtils.KEY_LIST_COLOR_POS,0); + color = getIntent().getIntExtra(MyUtils.KEY_LIST_COLOR_POS, 0); // playBinding.constraintLayout.setBackground(ContextCompat.getDrawable(this, Tools.playBgs[color])); initAudio(); String covert = info.getCovert(); @@ -79,12 +90,14 @@ public class PlaySoundsAct extends AppCompatActivity implements View.OnClickList countDownTimer.cancel(); } } + private void startCountDown(long time) { stopCountDown(); countDownTimer = new CountDownTimer(time, 1000) { @Override public void onTick(long millisUntilFinished) { } + @Override public void onFinish() { dialogTimer.setOffSelected(); @@ -96,6 +109,7 @@ public class PlaySoundsAct extends AppCompatActivity implements View.OnClickList }; countDownTimer.start(); } + private void volumeReceiver() { volumeReceiver = new BroadcastReceiver() { @Override @@ -113,10 +127,12 @@ public class PlaySoundsAct extends AppCompatActivity implements View.OnClickList IntentFilter filter = new IntentFilter("android.media.VOLUME_CHANGED_ACTION"); registerReceiver(volumeReceiver, filter); } + private void initLike() { boolean b = Db.checkLike(info); playBinding.imLike.setSelected(b); } + private void loadMore() { List more = Db.getMore(); MyItemDecoration itemHelper = new MyItemDecoration(0, 0, (int) MyUtils.dpToPx(3)); @@ -166,7 +182,12 @@ public class PlaySoundsAct extends AppCompatActivity implements View.OnClickList @Override public void onClick(View v) { if (v.equals(playBinding.back)) { - finish(); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + finish(); + } + }); } else if (v.equals(playBinding.btnPlay)) { boolean selected = playBinding.btnPlay.isSelected(); if (selected) { diff --git a/app/src/main/java/com/prank/sounds/fart/activity/RecorderSoundsAct.java b/app/src/main/java/com/prank/sounds/fart/activity/RecorderSoundsAct.java index 8ffc117..adc6cf1 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/RecorderSoundsAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/RecorderSoundsAct.java @@ -13,9 +13,11 @@ import com.prank.sounds.fart.R; import com.prank.sounds.fart.tools.RecorderManager; import com.prank.sounds.fart.tools.MyUtils; import com.prank.sounds.fart.databinding.RecordSoundsActBinding; +import com.prank.sounds.fart.topon.AdManager; +import com.prank.sounds.fart.topon.onActionListener; public class RecorderSoundsAct extends AppCompatActivity { - private RecordSoundsActBinding binding; + private RecordSoundsActBinding binding; private long startTime; private long elapsedTime; private Handler handler = new Handler(); @@ -29,6 +31,15 @@ public class RecorderSoundsAct extends AppCompatActivity { super.onCreate(savedInstanceState); binding = RecordSoundsActBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + + AdManager.loadAllAd(); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + + } + }); + MyUtils.setStatusBarTextColor(this, true); recorderManager = new RecorderManager(this); @@ -38,7 +49,14 @@ public class RecorderSoundsAct extends AppCompatActivity { } private void initEvent() { - binding.back.setOnClickListener(v -> finish()); + binding.back.setOnClickListener(v -> { + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + finish(); + } + }); + }); binding.imMic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/prank/sounds/fart/activity/SaveSoundsAct.java b/app/src/main/java/com/prank/sounds/fart/activity/SaveSoundsAct.java index 336d95e..2b0d832 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/SaveSoundsAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/SaveSoundsAct.java @@ -21,6 +21,8 @@ import com.prank.sounds.fart.bean.Info; import com.prank.sounds.fart.tools.Db; import com.prank.sounds.fart.tools.MyUtils; import com.prank.sounds.fart.databinding.SaveSoundsActBinding; +import com.prank.sounds.fart.topon.AdManager; +import com.prank.sounds.fart.topon.onActionListener; import java.io.File; import java.io.FileOutputStream; @@ -49,6 +51,14 @@ public class SaveSoundsAct extends AppCompatActivity { binding = SaveSoundsActBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + AdManager.loadAllAd(); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + + } + }); + MyUtils.setStatusBarTextColor(this, true); binding.audioTime.setText(R.string.time_init); initData(); @@ -127,7 +137,14 @@ public class SaveSoundsAct extends AppCompatActivity { } private void initEvent() { - binding.back.setOnClickListener(v -> finish()); + binding.back.setOnClickListener(v -> { + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + finish(); + } + }); + }); binding.imPlayBtn.setOnClickListener(v -> { binding.imPlayBtn.setSelected(!binding.imPlayBtn.isSelected()); try { @@ -140,7 +157,7 @@ public class SaveSoundsAct extends AppCompatActivity { String name = binding.saveEdit.getText().toString().trim(); boolean b = Db.checkName(name); if (!TextUtils.isEmpty(name)) { - if(!b){ + if (!b) { binding.saveEdit.setText(""); Toast.makeText(SaveSoundsAct.this, getString(R.string.name_hint), Toast.LENGTH_SHORT).show(); return; @@ -209,7 +226,6 @@ public class SaveSoundsAct extends AppCompatActivity { } - @Override protected void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/com/prank/sounds/fart/activity/SplAct.java b/app/src/main/java/com/prank/sounds/fart/activity/SplAct.java index ba9705a..ca84d52 100644 --- a/app/src/main/java/com/prank/sounds/fart/activity/SplAct.java +++ b/app/src/main/java/com/prank/sounds/fart/activity/SplAct.java @@ -8,10 +8,11 @@ import androidx.appcompat.app.AppCompatActivity; import com.prank.sounds.fart.tools.MyUtils; import com.prank.sounds.fart.databinding.SplActBinding; +import com.prank.sounds.fart.topon.AdManager; public class SplAct extends AppCompatActivity { - private long time = 1000; + private final long time = 11000; private SplActBinding binding; private CountDownTimer countDownTimer; @@ -21,19 +22,16 @@ public class SplAct extends AppCompatActivity { binding = SplActBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); MyUtils.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); - } - @Override - public void onFinish() { - welcomeMain(); - } - }; + AdManager.loadAllAd(); + AdManager.setAlreadyShow(); + + countDownTimer = AdManager.showWelcomeAd(this, time, millisUntilFinished -> { + int percentage = (int) (100 - (float) millisUntilFinished / time * 100); + binding.loadingPb.setProgress(percentage); + }, + this::welcomeMain + ); countDownTimer.start(); } diff --git a/app/src/main/java/com/prank/sounds/fart/frag/FragHome.java b/app/src/main/java/com/prank/sounds/fart/frag/FragHome.java index 78baf1a..4376e42 100644 --- a/app/src/main/java/com/prank/sounds/fart/frag/FragHome.java +++ b/app/src/main/java/com/prank/sounds/fart/frag/FragHome.java @@ -8,7 +8,7 @@ import android.view.ViewGroup; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.GridLayoutManager; -import com.prank.sounds.fart.MyApp; +import com.prank.sounds.fart.MyApplication; import com.prank.sounds.fart.bean.Info; import com.prank.sounds.fart.bean.MyBean; import com.prank.sounds.fart.databinding.FragHomeBinding; @@ -51,7 +51,7 @@ public class FragHome extends Fragment { MyItemDecoration itemHelper = new MyItemDecoration(10, 10, 10); binding.recyclerView.addItemDecoration(itemHelper); binding.recyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2)); - binding.recyclerView.setAdapter(new AdapterHome(requireContext(), MyApp.bean)); + binding.recyclerView.setAdapter(new AdapterHome(requireContext(), MyApplication.bean)); initAudioData(); @@ -60,7 +60,7 @@ public class FragHome extends Fragment { private void initAudioData() { list = new ArrayList<>(); - for (MyBean category : MyApp.bean) { + for (MyBean category : MyApplication.bean) { list.addAll(category.getInfoList()); } initAudio(); diff --git a/app/src/main/java/com/prank/sounds/fart/tools/MyItemDecoration.java b/app/src/main/java/com/prank/sounds/fart/tools/MyItemDecoration.java index 7e89740..811c59c 100644 --- a/app/src/main/java/com/prank/sounds/fart/tools/MyItemDecoration.java +++ b/app/src/main/java/com/prank/sounds/fart/tools/MyItemDecoration.java @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; -import com.prank.sounds.fart.MyApp; +import com.prank.sounds.fart.MyApplication; public class MyItemDecoration extends RecyclerView.ItemDecoration { @@ -70,7 +70,7 @@ public class MyItemDecoration 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; } } diff --git a/app/src/main/java/com/prank/sounds/fart/tools/MyUtils.java b/app/src/main/java/com/prank/sounds/fart/tools/MyUtils.java index 466ee1d..35e1ad7 100644 --- a/app/src/main/java/com/prank/sounds/fart/tools/MyUtils.java +++ b/app/src/main/java/com/prank/sounds/fart/tools/MyUtils.java @@ -15,7 +15,7 @@ import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; -import com.prank.sounds.fart.MyApp; +import com.prank.sounds.fart.MyApplication; import com.prank.sounds.fart.R; import com.prank.sounds.fart.bean.Info; import com.prank.sounds.fart.bean.MyBean; @@ -56,7 +56,7 @@ public class MyUtils { 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(); @@ -166,7 +166,7 @@ public class MyUtils { 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; } diff --git a/app/src/main/java/com/prank/sounds/fart/topon/AdListener.java b/app/src/main/java/com/prank/sounds/fart/topon/AdListener.java new file mode 100644 index 0000000..53843ee --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/AdListener.java @@ -0,0 +1,10 @@ +package com.prank.sounds.fart.topon; + +public interface AdListener { + void loadFail(String placeId); + void showSuccess(); + + void showFail(); + + void showClose(); +} diff --git a/app/src/main/java/com/prank/sounds/fart/topon/AdManager.java b/app/src/main/java/com/prank/sounds/fart/topon/AdManager.java new file mode 100644 index 0000000..79ebf76 --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/AdManager.java @@ -0,0 +1,250 @@ +package com.prank.sounds.fart.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.prank.sounds.fart.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; + + /** + Sounds_INTER_3 + n6842622ea6025 + Sounds_INTER_2 + n68426217dc54c + Sounds_INTER_1 + n684262033b4dd + */ + + private static final String place1Id = "n684262033b4dd"; + private static final String place2Id = "n68426217dc54c"; + private static final String place3Id = "n6842622ea6025"; + + + private static boolean place1LoadFail = false; + private static boolean place2LoadFail = false; + private static boolean place3LoadFail = false; + + private static boolean alreadyShow = false; + + private static List 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(); + } + } + }); + + } +} diff --git a/app/src/main/java/com/prank/sounds/fart/topon/AdStatusAction.java b/app/src/main/java/com/prank/sounds/fart/topon/AdStatusAction.java new file mode 100644 index 0000000..a32450c --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/AdStatusAction.java @@ -0,0 +1,5 @@ +package com.prank.sounds.fart.topon; + +public interface AdStatusAction { + void onStatus(int adType); +} diff --git a/app/src/main/java/com/prank/sounds/fart/topon/CountAction.java b/app/src/main/java/com/prank/sounds/fart/topon/CountAction.java new file mode 100644 index 0000000..dc0e642 --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/CountAction.java @@ -0,0 +1,5 @@ +package com.prank.sounds.fart.topon; + +public interface CountAction { + void onCount(long millisUntilFinished); +} diff --git a/app/src/main/java/com/prank/sounds/fart/topon/GoMainAction.java b/app/src/main/java/com/prank/sounds/fart/topon/GoMainAction.java new file mode 100644 index 0000000..e9b47c1 --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/GoMainAction.java @@ -0,0 +1,5 @@ +package com.prank.sounds.fart.topon; + +public interface GoMainAction { + void onGo(); +} diff --git a/app/src/main/java/com/prank/sounds/fart/topon/onActionListener.java b/app/src/main/java/com/prank/sounds/fart/topon/onActionListener.java new file mode 100644 index 0000000..5630c3f --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/topon/onActionListener.java @@ -0,0 +1,6 @@ +package com.prank.sounds.fart.topon; + +public interface onActionListener { + + void onAction(); +} diff --git a/app/src/main/java/com/prank/sounds/fart/upload/AESUtils.kt b/app/src/main/java/com/prank/sounds/fart/upload/AESUtils.kt new file mode 100644 index 0000000..383eae2 --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/upload/AESUtils.kt @@ -0,0 +1,105 @@ +package com.prank.sounds.fart.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() + } + } + +} diff --git a/app/src/main/java/com/prank/sounds/fart/upload/Http.kt b/app/src/main/java/com/prank/sounds/fart/upload/Http.kt new file mode 100644 index 0000000..fac063b --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/upload/Http.kt @@ -0,0 +1,72 @@ +package com.prank.sounds.fart.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", "") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/prank/sounds/fart/upload/SaveUtils.kt b/app/src/main/java/com/prank/sounds/fart/upload/SaveUtils.kt new file mode 100644 index 0000000..84dfbfd --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/upload/SaveUtils.kt @@ -0,0 +1,47 @@ +package com.prank.sounds.fart.upload + +import android.content.Context +import android.content.SharedPreferences +import com.prank.sounds.fart.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) + } + + + + +} \ No newline at end of file diff --git a/app/src/main/java/com/prank/sounds/fart/upload/Upload.kt b/app/src/main/java/com/prank/sounds/fart/upload/Upload.kt new file mode 100644 index 0000000..0729ca1 --- /dev/null +++ b/app/src/main/java/com/prank/sounds/fart/upload/Upload.kt @@ -0,0 +1,353 @@ +package com.prank.sounds.fart.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 { +// 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 -> "5G(Android 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 ID(Android 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 +// } + +} \ No newline at end of file diff --git a/app/src/main/res/xml/net.xml b/app/src/main/res/xml/net.xml new file mode 100644 index 0000000..0ac6102 --- /dev/null +++ b/app/src/main/res/xml/net.xml @@ -0,0 +1,6 @@ + + + + mobile-server.lux-ad.com + + diff --git a/build.gradle.kts b/build.gradle.kts index e5d3582..7929189 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { diff --git a/gradle.properties b/gradle.properties index 3c5031e..debf753 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a607998..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 4f906e0..f3b75f3 100644 --- a/gradlew +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @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 +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +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 diff --git a/settings.gradle.kts b/settings.gradle.kts index b5c5a93..6b4901c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,28 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + + //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") } }