V1.2(3)
This commit is contained in:
parent
29d1a3eee9
commit
5b618daad0
@ -6,8 +6,8 @@ plugins {
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("io.objectbox")
|
||||
kotlin("kapt")
|
||||
// id("com.google.gms.google-services")
|
||||
// id("com.google.firebase.crashlytics")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
android {
|
||||
@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.wall.photography.wallpapers"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 2
|
||||
versionName = "1.1"
|
||||
versionCode = 3
|
||||
versionName = "1.2"
|
||||
|
||||
setProperty("archivesBaseName", "Photography Wallpapers_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.live.runner.AndroidJUnitRunner"
|
||||
@ -58,100 +58,100 @@ dependencies {
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
|
||||
//------------------firebase
|
||||
// implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
// implementation("com.google.firebase:firebase-crashlytics")
|
||||
// implementation("com.google.firebase:firebase-analytics")
|
||||
// implementation("com.google.firebase:firebase-config")
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
|
||||
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
|
||||
//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")
|
||||
|
||||
}
|
||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "9317891402",
|
||||
"project_id": "photography-wallpapers-6bb4f",
|
||||
"storage_bucket": "photography-wallpapers-6bb4f.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:9317891402:android:24b2c09eacb752ca3b95b3",
|
||||
"android_client_info": {
|
||||
"package_name": "com.wall.photography.wallpapers"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCZtGh4EY9p968e3hWHb9v0HGN5_isJFq8"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@ -17,6 +17,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/icon"
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/net"
|
||||
android:theme="@style/Theme.Wallpaper"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
|
||||
@ -5,10 +5,13 @@ import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.Log;
|
||||
|
||||
import com.anythink.core.api.ATSDK;
|
||||
import com.anythink.core.api.NetTrafficeCallback;
|
||||
import com.wall.photography.wallpapers.mybean.MyData;
|
||||
import com.wall.photography.wallpapers.tool.ComUtils;
|
||||
import com.wall.photography.wallpapers.tool.JsonData;
|
||||
import com.wall.photography.wallpapers.tool.ObectBoxManager;
|
||||
import com.wall.photography.wallpapers.topon.AdManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -42,7 +45,7 @@ public class MyApp extends Application {
|
||||
super.onCreate();
|
||||
mAppContext = this;
|
||||
defaultFont = Typeface.createFromAsset(getAssets(), "custfont.ttf");
|
||||
|
||||
initTop();
|
||||
ObectBoxManager.init(this);
|
||||
executor = Executors.newFixedThreadPool(8);
|
||||
String[] names = {wallpaperName, animasName, exName, filmName, natureName, pattName, streetName, travelName};
|
||||
@ -88,28 +91,29 @@ public class MyApp extends Application {
|
||||
}
|
||||
|
||||
|
||||
// private void initTop(){
|
||||
// ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
//
|
||||
// @Override
|
||||
// public void onResultCallback(boolean isEU) {
|
||||
// Log.e(TAG, "onResultCallback:" + isEU);
|
||||
// if (isEU && ATSDK.getGDPRDataLevel( MyApp.mAppContext) == ATSDK.UNKNOWN) {
|
||||
// ATSDK.showGdprAuth(MyApp.mAppContext);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onErrorCallback(String errorMsg) {
|
||||
// Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ATSDK.init( this, APPId, AppKey);
|
||||
// //测试工具
|
||||
//// ATDebuggerUITest.showDebuggerUI(this,debug_Key);
|
||||
// AdManager.loadAllAd();
|
||||
//
|
||||
// }
|
||||
private void initTop() {
|
||||
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
|
||||
@Override
|
||||
public void onResultCallback(boolean isEU) {
|
||||
|
||||
if (isEU && ATSDK.getGDPRDataLevel(MyApp.mAppContext) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(MyApp.mAppContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onErrorCallback(String errorMsg) {
|
||||
|
||||
}
|
||||
});
|
||||
String APPId = "h68352a758b9e9";
|
||||
String AppKey = "a6bd26922633cc061107765957e22a287";
|
||||
ATSDK.init(this, APPId, AppKey);
|
||||
//测试工具
|
||||
// ATDebuggerUITest.showDebuggerUI(this,"d0a434af69020f58cd1c246da4adb0630eb18a02");
|
||||
AdManager.loadAllAd();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ import com.wall.photography.wallpapers.tool.ItemHelper;
|
||||
import com.wall.photography.wallpapers.connector.OnItemClick;
|
||||
import com.wall.photography.wallpapers.mybean.MyData;
|
||||
import com.wall.photography.wallpapers.item.ItemList;
|
||||
import com.wall.photography.wallpapers.topon.AdManager;
|
||||
import com.wall.photography.wallpapers.topon.onActionListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -32,12 +34,20 @@ public class ListActivity extends AppCompatActivity implements OnItemClick {
|
||||
categoryName = getIntent().getStringExtra(key_index);
|
||||
vb.name.setText(categoryName);
|
||||
initList();
|
||||
AdManager.loadAllAd();
|
||||
vb.imageviewBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
AdManager.showTopOn(ListActivity.this, () -> {
|
||||
finish();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
AdManager.showTopOn(ListActivity.this, () -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void initList() {
|
||||
|
||||
@ -17,6 +17,8 @@ import com.wall.photography.wallpapers.databinding.ItemTabBinding;
|
||||
import com.wall.photography.wallpapers.fragment.FragmentLike;
|
||||
import com.wall.photography.wallpapers.fragment.FragmentMain;
|
||||
import com.wall.photography.wallpapers.tool.ComUtils;
|
||||
import com.wall.photography.wallpapers.up.Http;
|
||||
import com.wall.photography.wallpapers.up.SaveUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -38,6 +40,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
list.add(FragmentLike.newInstance());
|
||||
// list.add(FragmentDownload.newInstance());
|
||||
|
||||
boolean post = SaveUtils.INSTANCE.isPost();
|
||||
if(!post){
|
||||
Http.INSTANCE.makeGetRequest(MainActivity.this);
|
||||
SaveUtils.INSTANCE.setPost(true);
|
||||
}
|
||||
|
||||
int[] ints = {R.drawable.selector_home, R.drawable.selector_tab_like};
|
||||
vb.viewpager2.setAdapter(new FragmentStateAdapter(this) {
|
||||
@NonNull
|
||||
|
||||
@ -10,13 +10,14 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.wall.photography.wallpapers.R
|
||||
import com.wall.photography.wallpapers.databinding.ActivitySearchBinding
|
||||
import com.wall.photography.wallpapers.tool.ComUtils
|
||||
import com.wall.photography.wallpapers.tool.ObectBoxManager
|
||||
import com.wall.photography.wallpapers.tool.ItemHelper
|
||||
import com.wall.photography.wallpapers.connector.OnItemClick
|
||||
import com.wall.photography.wallpapers.mybean.MyData
|
||||
import com.wall.photography.wallpapers.databinding.ActivitySearchBinding
|
||||
import com.wall.photography.wallpapers.item.ItemList
|
||||
import com.wall.photography.wallpapers.mybean.MyData
|
||||
import com.wall.photography.wallpapers.tool.ComUtils
|
||||
import com.wall.photography.wallpapers.tool.ItemHelper
|
||||
import com.wall.photography.wallpapers.tool.ObectBoxManager
|
||||
import com.wall.photography.wallpapers.topon.AdManager
|
||||
|
||||
class SearchActivity : AppCompatActivity() ,
|
||||
OnItemClick {
|
||||
@ -26,6 +27,7 @@ class SearchActivity : AppCompatActivity() ,
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySearchBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
AdManager.loadAllAd()
|
||||
ComUtils.initFull(this, false)
|
||||
initList()
|
||||
binding.imageviewBack.setOnClickListener {
|
||||
@ -63,6 +65,7 @@ class SearchActivity : AppCompatActivity() ,
|
||||
}
|
||||
|
||||
private fun startSearch() {
|
||||
AdManager.showTopOn(this@SearchActivity){
|
||||
closeKeyboard()
|
||||
binding.searchPb.visibility = View.VISIBLE
|
||||
val string: String = binding.et.text.toString()
|
||||
@ -80,13 +83,15 @@ class SearchActivity : AppCompatActivity() ,
|
||||
} else {
|
||||
binding.searchPb.visibility = View.GONE
|
||||
Toast.makeText(
|
||||
this,
|
||||
this@SearchActivity,
|
||||
getString(R.string.please_input_keyword),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun showEmpty(showEmpty: Boolean) {
|
||||
if (showEmpty) {
|
||||
binding.emptyLayout.visibility = View.VISIBLE
|
||||
|
||||
@ -9,13 +9,16 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.wall.photography.wallpapers.databinding.ActivitySplashBinding;
|
||||
import com.wall.photography.wallpapers.tool.ComUtils;
|
||||
import com.wall.photography.wallpapers.topon.AdManager;
|
||||
import com.wall.photography.wallpapers.topon.CountAction;
|
||||
import com.wall.photography.wallpapers.topon.GoMainAction;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
private ActivitySplashBinding vb;
|
||||
|
||||
private long totalTime = 2000;
|
||||
private long totalTime = 12000;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
@ -26,43 +29,43 @@ public class SplashActivity extends AppCompatActivity {
|
||||
setContentView(vb.getRoot());
|
||||
|
||||
|
||||
countDownTimer = new CountDownTimer(totalTime,100) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime);
|
||||
|
||||
int countdownPercentage = 100 - progressPercentage;
|
||||
|
||||
vb.progressbar.setProgress(countdownPercentage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
vb.progressbar.setProgress(100);
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
// countDownTimer = AdManager.showWelcomeAd(this, totalTime, new CountAction() {
|
||||
// countDownTimer = new CountDownTimer(totalTime,100) {
|
||||
// @Override
|
||||
// public void onCount(long millisUntilFinished) {
|
||||
// public void onTick(long millisUntilFinished) {
|
||||
// int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime);
|
||||
//
|
||||
// int countdownPercentage = 100 - progressPercentage;
|
||||
//
|
||||
// vb.progressbar.setProgress(countdownPercentage);
|
||||
// }
|
||||
// }, new GoMainAction() {
|
||||
//
|
||||
// @Override
|
||||
// public void onGo() {
|
||||
// public void onFinish() {
|
||||
// vb.progressbar.setProgress(100);
|
||||
// Intent intent = new Intent(WElActivity.this, HomeActivity.class);
|
||||
// Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
// startActivity(intent);
|
||||
// finish();
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
|
||||
countDownTimer = AdManager.showWelcomeAd(this, totalTime, new CountAction() {
|
||||
@Override
|
||||
public void onCount(long millisUntilFinished) {
|
||||
int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime);
|
||||
|
||||
int countdownPercentage = 100 - progressPercentage;
|
||||
|
||||
vb.progressbar.setProgress(countdownPercentage);
|
||||
}
|
||||
}, new GoMainAction() {
|
||||
@Override
|
||||
public void onGo() {
|
||||
vb.progressbar.setProgress(100);
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
countDownTimer.start();
|
||||
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ import com.wall.photography.wallpapers.tool.ObectBoxManager;
|
||||
import com.wall.photography.wallpapers.tool.JsonData;
|
||||
import com.wall.photography.wallpapers.connector.OnSelectType;
|
||||
import com.wall.photography.wallpapers.mybean.MyData;
|
||||
import com.wall.photography.wallpapers.topon.AdManager;
|
||||
import com.wall.photography.wallpapers.topon.onActionListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -65,6 +67,7 @@ public class WallpaperActivity extends AppCompatActivity implements OnSelectType
|
||||
setContentView(vb.getRoot());
|
||||
weakReference = new WeakReference<>(this);
|
||||
data = (MyData) getIntent().getSerializableExtra(ComUtils.key_info);
|
||||
AdManager.loadAllAd();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
@ -74,6 +77,12 @@ public class WallpaperActivity extends AppCompatActivity implements OnSelectType
|
||||
initClick();
|
||||
loadDetail();
|
||||
vb.tvContent.setText(data.getDescription());
|
||||
AdManager.showTopOn(WallpaperActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadDetail() {
|
||||
@ -147,11 +156,21 @@ public class WallpaperActivity extends AppCompatActivity implements OnSelectType
|
||||
vb.imageviewBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
AdManager.showTopOn(WallpaperActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
vb.buttonSet.setOnClickListener(v -> {
|
||||
AdManager.showTopOn(WallpaperActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
if (dialogType == null) {
|
||||
dialogType = new MyDialog();
|
||||
dialogType.setListener(WallpaperActivity.this);
|
||||
@ -159,6 +178,9 @@ public class WallpaperActivity extends AppCompatActivity implements OnSelectType
|
||||
if (!dialogType.isAdded()) {
|
||||
dialogType.show(getSupportFragmentManager(), "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
@ -176,11 +198,17 @@ public class WallpaperActivity extends AppCompatActivity implements OnSelectType
|
||||
vb.layoutDownload.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdManager.showTopOn(WallpaperActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
boolean permission = JsonData.INSTANCE.requestPermission(WallpaperActivity.this, permissionCode);
|
||||
if (!permission) {
|
||||
return;
|
||||
}
|
||||
startSaveToAlbum();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -54,10 +54,10 @@ public class ObectBoxManager {
|
||||
.build()
|
||||
.findFirst();
|
||||
if (first == null) {
|
||||
Log.d(MyApp.TAG, "-----------addData " + imId);
|
||||
// Log.d(MyApp.TAG, "-----------addData " + imId);
|
||||
objectBoxLike.put(data);
|
||||
}else {
|
||||
Log.d(MyApp.TAG, "-----------忽略添加 ");
|
||||
// Log.d(MyApp.TAG, "-----------忽略添加 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.wall.photography.wallpapers.topon;
|
||||
|
||||
public interface AdListener {
|
||||
void loadFail(String placeId);
|
||||
void showSuccess();
|
||||
|
||||
void showFail();
|
||||
|
||||
void showClose();
|
||||
}
|
||||
@ -0,0 +1,262 @@
|
||||
package com.wall.photography.wallpapers.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.wall.photography.wallpapers.MyApp;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Photography_INTER_3
|
||||
* n68352bdba850c
|
||||
* Photography_INTER_2
|
||||
* n68352bcc39e3d
|
||||
* Photography_INTER_1
|
||||
* n68352bbc985f1
|
||||
*/
|
||||
private static final String place1Id = "n68352bdba850c";
|
||||
private static final String place2Id = "n68352bcc39e3d";
|
||||
private static final String place3Id = "n68352bbc985f1";
|
||||
|
||||
|
||||
private static boolean place1LoadFail = false;
|
||||
private static boolean place2LoadFail = false;
|
||||
private static boolean place3LoadFail = false;
|
||||
|
||||
private static boolean alreadyShow = false;
|
||||
|
||||
private static List<ATInterstitial> list = new ArrayList<>();
|
||||
|
||||
|
||||
private static String Ad_TAG = MyApp.TAG;
|
||||
public static void loadAllAd() {
|
||||
place1LoadFail = false;
|
||||
place2LoadFail = false;
|
||||
place3LoadFail = false;
|
||||
if (list.size() == 0) {
|
||||
ATInterstitial mInterstitialAd1 = new ATInterstitial(MyApp.mAppContext, place1Id);
|
||||
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApp.mAppContext, place2Id);
|
||||
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApp.mAppContext, 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(Ad_TAG, "-has Cache------------");
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
Log.d(Ad_TAG, "-No Cache------------");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||
ad.setAdListener(new ATInterstitialListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoaded() {
|
||||
Log.d(Ad_TAG, "LoadLoaded " + ad.mPlacementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoadFail(AdError adError) {
|
||||
listener.loadFail(ad.mPlacementId);
|
||||
Log.d(Ad_TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||
Log.d(Ad_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 CountDownTimer showWelcomeAd(
|
||||
Activity activity,
|
||||
Long totalTim,
|
||||
CountAction countAction,
|
||||
GoMainAction goMain
|
||||
) {
|
||||
Log.d(Ad_TAG,"----------alreadyShow="+alreadyShow);
|
||||
alreadyShow = false;
|
||||
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(place1LoadFail&&place2LoadFail&&place3LoadFail){
|
||||
Log.d(Ad_TAG,"------------all load fail");
|
||||
alreadyShow = true;
|
||||
goMain.onGo();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.wall.photography.wallpapers.topon;
|
||||
|
||||
public interface AdStatusAction {
|
||||
void onStatus(int adType);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.wall.photography.wallpapers.topon;
|
||||
|
||||
public interface CountAction {
|
||||
void onCount(long millisUntilFinished);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.wall.photography.wallpapers.topon;
|
||||
|
||||
public interface GoMainAction {
|
||||
void onGo();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.wall.photography.wallpapers.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
104
app/src/main/java/com/wall/photography/wallpapers/up/AESUtils.kt
Normal file
104
app/src/main/java/com/wall/photography/wallpapers/up/AESUtils.kt
Normal file
@ -0,0 +1,104 @@
|
||||
import android.app.Activity
|
||||
import android.util.Base64
|
||||
import com.wall.photography.wallpapers.up.Upload
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
73
app/src/main/java/com/wall/photography/wallpapers/up/Http.kt
Normal file
73
app/src/main/java/com/wall/photography/wallpapers/up/Http.kt
Normal file
@ -0,0 +1,73 @@
|
||||
package com.wall.photography.wallpapers.up
|
||||
|
||||
import AESUtils
|
||||
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", "")
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.wall.photography.wallpapers.up
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.wall.photography.wallpapers.MyApp
|
||||
|
||||
|
||||
|
||||
object SaveUtils {
|
||||
|
||||
|
||||
val IS_POST = MyApp.mAppContext.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 = MyApp.mAppContext.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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
353
app/src/main/java/com/wall/photography/wallpapers/up/Upload.kt
Normal file
353
app/src/main/java/com/wall/photography/wallpapers/up/Upload.kt
Normal file
@ -0,0 +1,353 @@
|
||||
package com.wall.photography.wallpapers.up
|
||||
|
||||
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 -> "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
|
||||
// }
|
||||
|
||||
}
|
||||
6
app/src/main/res/xml/net.xml
Normal file
6
app/src/main/res/xml/net.xml
Normal 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>
|
||||
@ -11,28 +11,28 @@ dependencyResolutionManagement {
|
||||
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")
|
||||
|
||||
//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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user