V2.1(3) 接入IronSource-mtg
3
.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
1
.idea/.name
generated
@ -1 +0,0 @@
|
||||
My Application
|
||||
6
.idea/AndroidProjectSystem.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/compiler.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="21" />
|
||||
</component>
|
||||
</project>
|
||||
21
.idea/deploymentTargetSelector.xml
generated
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="test2">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-12-05T06:23:58.625535100Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\Administrator\.android\avd\Pixel_4_API_29.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/deviceManager.xml
generated
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DeviceTable">
|
||||
<option name="columnSorters">
|
||||
<list>
|
||||
<ColumnSorterState>
|
||||
<option name="column" value="Name" />
|
||||
<option name="order" value="ASCENDING" />
|
||||
</ColumnSorterState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
21
.idea/gradle.xml
generated
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="D:\gradle\gradle-8.11.1-bin\gradle-8.11.1" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/test2" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/migrations.xml
generated
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/misc.xml
generated
@ -1,9 +0,0 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/runConfigurations.xml
generated
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
0
test2/.gitignore → app/.gitignore
vendored
138
app/build.gradle.kts
Normal file
@ -0,0 +1,138 @@
|
||||
import java.io.FileInputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties().apply {
|
||||
load(FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
android {
|
||||
namespace = "com.wall.exquisite.wallpaper"
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.wall.exquisite.wallpaper"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 3
|
||||
versionName = "2.1"
|
||||
setProperty("archivesBaseName","Wallpaper Exquisite_v"+versionName+"(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
storeFile = file(keystoreProperties["keystoreFile"] as String)
|
||||
storePassword = keystoreProperties["key_store_password"] as String
|
||||
keyAlias = keystoreProperties["key_alias"] as String
|
||||
keyPassword = keystoreProperties["key_password"] as String
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation("androidx.activity:activity:1.10.0")
|
||||
implementation(libs.constraintlayout)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.ext.junit)
|
||||
androidTestImplementation(libs.espresso.core)
|
||||
|
||||
// 图片加载库
|
||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||
annotationProcessor("com.github.bumptech.glide:compiler:4.16.0")
|
||||
|
||||
// JSON解析
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
// 其他UI组件
|
||||
implementation("androidx.viewpager2:viewpager2:1.0.0")
|
||||
implementation("androidx.recyclerview:recyclerview:1.3.2")
|
||||
// 图片缩放库(必加,否则无法缩放大图)
|
||||
// implementation("com.github.chrisbanes:PhotoView:2.3.0")
|
||||
|
||||
|
||||
implementation("androidx.core:core-ktx:1.12.0")
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
|
||||
// 新增:Glide Transform扩展(用于圆角变换)
|
||||
implementation ("jp.wasabeef:glide-transformations:4.3.0")
|
||||
|
||||
implementation ("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
|
||||
implementation(files("libs/UpLoadLibrary_12_03_15_13-release.aar"))
|
||||
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||||
|
||||
implementation ("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
|
||||
//firebase
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
implementation("com.google.firebase:firebase-config")
|
||||
|
||||
|
||||
implementation(files("libs/IronSourceLibrary_01_07_18_13-release.aar"))
|
||||
|
||||
//---------------------------ironSource
|
||||
implementation("com.unity3d.ads-mediation:mediation-sdk:9.2.0")
|
||||
// Add BIGO Ads Network
|
||||
implementation("com.unity3d.ads-mediation:bigo-adapter:5.2.0")
|
||||
implementation("com.bigossp:bigo-ads:5.6.2")
|
||||
// Add Chartboost Network
|
||||
implementation("com.unity3d.ads-mediation:chartboost-adapter:5.2.0")
|
||||
// implementation("com.chartboost:chartboost-sdk:9.10.2")
|
||||
|
||||
implementation("com.chartboost:chartboost-sdk:9.8.3")
|
||||
// Add DT Exchange Network
|
||||
implementation("com.unity3d.ads-mediation:fyber-adapter:5.2.0")
|
||||
implementation("com.fyber:marketplace-sdk:8.4.1")
|
||||
// Add InMobi Network
|
||||
implementation("com.unity3d.ads-mediation:inmobi-adapter:5.3.0")
|
||||
implementation("com.inmobi.monetization:inmobi-ads-kotlin:11.1.0")
|
||||
// Add Liftoff Monetize Network
|
||||
implementation("com.unity3d.ads-mediation:vungle-adapter:5.2.0")
|
||||
implementation("com.vungle:vungle-ads:7.6.1")
|
||||
// Add Mintegral Network
|
||||
implementation("com.unity3d.ads-mediation:mintegral-adapter:5.3.0")
|
||||
implementation("com.mbridge.msdk.oversea:mbridge_android_sdk:17.0.31")
|
||||
// Add Moloco Network
|
||||
implementation("com.unity3d.ads-mediation:moloco-adapter:5.5.0")
|
||||
implementation("com.moloco.sdk:moloco-sdk:4.3.1")
|
||||
// Add Pangle Network
|
||||
implementation("com.unity3d.ads-mediation:pangle-adapter:5.4.0")
|
||||
implementation("com.pangle.global:pag-sdk:7.8.0.7")
|
||||
// Add Unity Ads Network
|
||||
implementation("com.unity3d.ads-mediation:unityads-adapter:5.3.0")
|
||||
implementation("com.unity3d.ads:unity-ads:4.16.4")
|
||||
}
|
||||
BIN
app/libs/IronSourceLibrary_01_07_18_13-release.aar
Normal file
@ -3,10 +3,7 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<application
|
||||
android:name=".WallpaperApplication"
|
||||
android:allowBackup="true"
|
||||
@ -1840,29 +1840,6 @@
|
||||
"portfolio_url": "null"
|
||||
}
|
||||
},
|
||||
{
|
||||
"alt_description": "null",
|
||||
"links": {
|
||||
"download": "https://unsplash.com/photos/064Cnj9BjEQ/download?ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA",
|
||||
"download_location": "https://api.unsplash.com/photos/064Cnj9BjEQ/download?ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA",
|
||||
"html": "https://unsplash.com/photos/064Cnj9BjEQ"
|
||||
},
|
||||
"urls": {
|
||||
"full": "https://images.unsplash.com/photo-1647206194634-faad30a1f16e?crop=entropy&cs=srgb&fm=jpg&ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA&ixlib=rb-4.0.3&q=85",
|
||||
"raw": "https://images.unsplash.com/photo-1647206194634-faad30a1f16e?ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA&ixlib=rb-4.0.3",
|
||||
"regular": "https://images.unsplash.com/photo-1647206194634-faad30a1f16e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA&ixlib=rb-4.0.3&q=80&w=1080",
|
||||
"small": "https://images.unsplash.com/photo-1647206194634-faad30a1f16e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA&ixlib=rb-4.0.3&q=80&w=400",
|
||||
"thumb": "https://images.unsplash.com/photo-1647206194634-faad30a1f16e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTYzMHwwfDF8dG9waWN8fHFQWXNEenZKT1ljfHx8fHwyfHwxNzIwNDMwNjQwfA&ixlib=rb-4.0.3&q=80&w=200"
|
||||
},
|
||||
"user": {
|
||||
"authorHtml": "https://unsplash.com/@arnosenoner",
|
||||
"header_large": "https://images.unsplash.com/profile-1574617745209-42d2e8da884dimage?ixlib=rb-4.0.3&crop=faces&fit=crop&w=128&h=128",
|
||||
"header_medium": "https://images.unsplash.com/profile-1574617745209-42d2e8da884dimage?ixlib=rb-4.0.3&crop=faces&fit=crop&w=64&h=64",
|
||||
"header_small": "https://images.unsplash.com/profile-1574617745209-42d2e8da884dimage?ixlib=rb-4.0.3&crop=faces&fit=crop&w=32&h=32",
|
||||
"name": "Arno Senoner",
|
||||
"portfolio_url": "https://www.decidea.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"alt_description": "a woman standing under a tree with her hands in the air",
|
||||
"links": {
|
||||
@ -8,13 +8,15 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ad.tradpluslibrary.TPAdManager;
|
||||
import com.ad.ironsourcelibrary.ISAdManager;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -31,9 +33,11 @@ public class CollectionActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_collection);
|
||||
|
||||
ISAdManager.loadAllAd();
|
||||
setupStatusBar();
|
||||
TPAdManager.INSTANCE.showTPAD(this,()-> null);
|
||||
ISAdManager.showIsAd(this, () -> {
|
||||
|
||||
});
|
||||
initViews();
|
||||
setupRecyclerView();
|
||||
loadFavoriteData();
|
||||
@ -65,10 +69,7 @@ public class CollectionActivity extends AppCompatActivity {
|
||||
rvFavoriteImages = findViewById(R.id.rv_favorite_images);
|
||||
tvEmpty = findViewById(R.id.tv_empty);
|
||||
|
||||
findViewById(R.id.btn_back).setOnClickListener(v -> TPAdManager.INSTANCE.showTPAD(this,()-> {
|
||||
finish();
|
||||
return null;
|
||||
}));
|
||||
findViewById(R.id.btn_back).setOnClickListener(v -> ISAdManager.showIsAd(this, this::finish));
|
||||
|
||||
favoriteManager = new CollectionManager(this);
|
||||
favoriteList = new ArrayList<>();
|
||||
@ -1,22 +1,20 @@
|
||||
package com.wall.exquisite.wallpaper;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
@ -27,7 +25,8 @@ import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import com.ad.tradpluslibrary.TPAdManager;
|
||||
import com.ad.ironsourcelibrary.ActionListener;
|
||||
import com.ad.ironsourcelibrary.ISAdManager;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
@ -37,8 +36,9 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.wall.exquisite.wallpaper.databinding.ActivityFullImageBinding;
|
||||
|
||||
|
||||
import com.wall.exquisite.wallpaper.databinding.ActivityFullImageBinding;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -47,11 +47,7 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
// 壁纸设置类型常量
|
||||
interface WallpaperType {
|
||||
int TYPE_HOME = 1; // 桌面
|
||||
int TYPE_LOCK = 2; // 锁屏
|
||||
int TYPE_BOTH = 3; // 桌面+锁屏
|
||||
}
|
||||
|
||||
|
||||
public class FullImageActivity extends AppCompatActivity implements WallpaperType {
|
||||
// 传递参数Key
|
||||
@ -64,7 +60,7 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
private String imageId;
|
||||
private String imageDesc;
|
||||
private File tempFile;
|
||||
private WallpaperManager wallpaperManager;
|
||||
|
||||
private CollectionManager favoriteManager;
|
||||
private int screenWidth; // 屏幕宽度
|
||||
private int screenHeight; // 屏幕高度(包含状态栏/导航栏,适配全面屏)
|
||||
@ -72,6 +68,7 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
private boolean isActivityDestroyed = false; // 标记Activity是否已销毁
|
||||
private Thread downloadThread; // 下载线程引用(用于销毁时中断)
|
||||
private Thread setWallpaperThread; // 设置壁纸线程引用(用于销毁时中断)
|
||||
private ImageView imageviewBack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -79,6 +76,9 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
binding = ActivityFullImageBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
imageviewBack = findViewById(R.id.imageview_back);
|
||||
ISAdManager.loadAllAd();
|
||||
|
||||
// 1. 初始化Glide RequestManager,绑定Activity生命周期(避免内存泄漏)
|
||||
glideRequestManager = Glide.with(this);
|
||||
|
||||
@ -87,7 +87,7 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
// 获取屏幕尺寸(用于壁纸精准缩放)
|
||||
getScreenSize();
|
||||
// 初始化管理器
|
||||
wallpaperManager = WallpaperManager.getInstance(this);
|
||||
|
||||
favoriteManager = new CollectionManager(this);
|
||||
|
||||
// 获取传递的参数
|
||||
@ -98,6 +98,12 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
initClick();
|
||||
// 初始化点赞状态
|
||||
initFavoriteState();
|
||||
ISAdManager.showIsAd(this, new ActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,25 +224,13 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
*/
|
||||
private void initClick() {
|
||||
// 返回按钮(关闭当前页面)
|
||||
binding.imageviewBack.setOnClickListener(v -> TPAdManager.INSTANCE.showTPAD(this,()-> {
|
||||
finish();
|
||||
return null;
|
||||
}));
|
||||
|
||||
// 下载按钮(保存图片到相册,无需权限)
|
||||
binding.layoutDownload.setOnClickListener(v -> TPAdManager.INSTANCE.showTPAD(this,()-> {
|
||||
startDownload();
|
||||
return null;
|
||||
}));
|
||||
imageviewBack.setOnClickListener(v -> ISAdManager.showIsAd(this, this::finish));
|
||||
|
||||
// 设置壁纸按钮(弹出选择弹窗)
|
||||
binding.buttonSet1.setOnClickListener(v -> showWallpaperTypeDialog());
|
||||
binding.buttonSet1.setOnClickListener(v -> ISAdManager.showIsAd(this, this::showWallpaperTypeDialog));
|
||||
|
||||
// 点赞按钮(收藏/取消收藏)
|
||||
binding.imageFavorite.setOnClickListener(v -> TPAdManager.INSTANCE.showTPAD(this,()-> {
|
||||
toggleFavorite();
|
||||
return null;
|
||||
}));
|
||||
binding.imageFavorite.setOnClickListener(v -> toggleFavorite());
|
||||
|
||||
}
|
||||
|
||||
@ -279,107 +273,6 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载图片到相册(通过MediaStore,无需存储权限)
|
||||
*/
|
||||
private void startDownload() {
|
||||
// 显示加载进度条,隐藏下载按钮
|
||||
showLoading(binding.pbDownload, binding.imageDownload, true);
|
||||
|
||||
// 保存线程引用,便于销毁时中断
|
||||
downloadThread = new Thread(() -> {
|
||||
// 检查Activity是否已销毁,避免无效执行
|
||||
if (isActivityDestroyed) {
|
||||
runOnUiThread(() -> showLoading(binding.pbDownload, binding.imageDownload, false));
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
// 检查线程是否被中断(Activity销毁时触发)
|
||||
if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
|
||||
|
||||
// 1. 从网络下载图片
|
||||
URL url = new URL(imageUrl);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
// 检查图片是否解码成功
|
||||
if (bitmap == null) {
|
||||
throw new IOException("Failed to decode image");
|
||||
}
|
||||
|
||||
// 再次检查Activity状态和线程中断状态
|
||||
if (isActivityDestroyed || Thread.currentThread().isInterrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
||||
// 2. 通过MediaStore写入相册(Android 10+ 适配)
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Images.Media.DISPLAY_NAME, imageId + ".jpg"); // 文件名
|
||||
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); // 文件类型
|
||||
values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/Wallpaper"); // 相册路径(DCIM/Wallpaper)
|
||||
values.put(MediaStore.Images.Media.WIDTH, bitmap.getWidth());
|
||||
values.put(MediaStore.Images.Media.HEIGHT, bitmap.getHeight());
|
||||
|
||||
// Android 10+ 标记为待处理(避免相册立即扫描)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 1);
|
||||
}
|
||||
|
||||
// 插入到媒体库,获取图片Uri
|
||||
Uri imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||
if (imageUri == null) {
|
||||
throw new IOException("Failed to import to media library");
|
||||
}
|
||||
|
||||
// 写入图片数据到Uri
|
||||
try (OutputStream os = getContentResolver().openOutputStream(imageUri)) {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os);
|
||||
}
|
||||
|
||||
// Android 10+ 标记为完成(允许相册扫描)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.clear();
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
getContentResolver().update(imageUri, values, null, null);
|
||||
}
|
||||
|
||||
// 保存临时文件(用于后续设置壁纸,无需重复下载)
|
||||
saveTempFile(bitmap);
|
||||
|
||||
// 主线程更新UI(下载成功)
|
||||
if (!isActivityDestroyed && !Thread.currentThread().isInterrupted()) {
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbDownload, binding.imageDownload, false);
|
||||
Toast.makeText(this, "Download successful. Saved to your photo library", Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
// 线程被中断(Activity销毁),直接退出,不提示错误
|
||||
Log.d("FullImage", "Download thread interrupted");
|
||||
runOnUiThread(() -> showLoading(binding.pbDownload, binding.imageDownload, false));
|
||||
} catch (Exception e) {
|
||||
// 其他异常(下载失败)
|
||||
e.printStackTrace();
|
||||
if (!isActivityDestroyed) {
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbDownload, binding.imageDownload, false);
|
||||
Toast.makeText(FullImageActivity.this, "Download failed:" + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
// 回收Bitmap,避免内存泄漏
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
});
|
||||
downloadThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存临时文件到应用私有目录(用于设置壁纸,无需权限)
|
||||
@ -397,6 +290,7 @@ public class FullImageActivity extends AppCompatActivity implements WallpaperTyp
|
||||
* 显示壁纸设置类型弹窗(桌面/锁屏/两者)
|
||||
*/
|
||||
private void showWallpaperTypeDialog() {
|
||||
ISAdManager.loadAllAd();
|
||||
// 加载自定义弹窗布局
|
||||
View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_wallpapertype, null);
|
||||
|
||||
@ -11,11 +11,10 @@ import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.ad.tradpluslibrary.TPAdManager;
|
||||
import com.ad.ironsourcelibrary.ISAdManager;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class StartuppageActivity extends AppCompatActivity {
|
||||
|
||||
@ -35,21 +34,6 @@ public class StartuppageActivity extends AppCompatActivity {
|
||||
|
||||
// 初始化控件
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
TPAdManager.INSTANCE.init(
|
||||
this,
|
||||
WallpaperApplication.TAG,
|
||||
"11AFE68410E60AB7D990BD9CBA814411",
|
||||
"83D1FF0E14FCB01E5F26038F91114512",
|
||||
"BB1B407D3DC75FE8C6E3205D2E6B3E12",
|
||||
"FB5CA4DF6B924ADF06C3C0C25C880212",
|
||||
new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
) ;
|
||||
|
||||
// 初始化并启动CountDownTimer倒计时
|
||||
initCountDownTimer();
|
||||
|
||||
@ -68,7 +52,7 @@ public class StartuppageActivity extends AppCompatActivity {
|
||||
// CountDownTimer参数说明:
|
||||
// 第一个参数:总倒计时时长(ms)
|
||||
// 第二个参数:倒计时间隔(ms),每隔这个时间回调一次onTick
|
||||
countDownTimer = TPAdManager.INSTANCE.showWelcomeAd(this, totalTime, aLong -> {
|
||||
countDownTimer = ISAdManager.showWelcomeAd(this, totalTime, aLong -> {
|
||||
Long progressPercentage = (100 * aLong) / totalTime;
|
||||
Long percentage = 100 - progressPercentage;
|
||||
progressBar.setProgress(Integer.parseInt(percentage.toString()));
|
||||
@ -5,12 +5,16 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.ad.ironsourcelibrary.ISAdManager;
|
||||
import com.unity3d.mediation.LevelPlayConfiguration;
|
||||
import com.unity3d.mediation.LevelPlayInitError;
|
||||
import com.up.uploadlibrary.UpLoadManager;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
|
||||
// 导入你的收藏工具类
|
||||
@ -41,6 +45,17 @@ public class WallpaperApplication extends Application {
|
||||
initBasicTools();
|
||||
// 异步执行耗时数据准备
|
||||
initDataAsync();
|
||||
ISAdManager.INSTANCE.init("---------------", this, "24e10d635", "z99sdrvrcmrnsr4b", "q3apcnd67q25tkr7", "hrnbibnvrc7akls1", false, new Function1<LevelPlayConfiguration, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(LevelPlayConfiguration levelPlayConfiguration) {
|
||||
return null;
|
||||
}
|
||||
}, new Function1<LevelPlayInitError, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(LevelPlayInitError levelPlayInitError) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initBasicTools() {
|
||||
@ -0,0 +1,7 @@
|
||||
package com.wall.exquisite.wallpaper;
|
||||
|
||||
interface WallpaperType {
|
||||
int TYPE_HOME = 1; // 桌面
|
||||
int TYPE_LOCK = 2; // 锁屏
|
||||
int TYPE_BOTH = 3; // 桌面+锁屏
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
91
app/src/main/res/layout/activity_full_image.xml
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- 核心修改:添加DataBinding根标签 <layout> -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:background="@drawable/oval"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/left"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:background="@drawable/retc_16"
|
||||
android:gravity="center"
|
||||
android:minHeight="40dp"
|
||||
android:padding="10dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="#000000"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<!-- 新增父容器:包裹 button_set1 和 image_favorite,背景统一为 oval -->
|
||||
<RelativeLayout
|
||||
android:id="@+id/parent_set_favorite"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:background="@drawable/oval"
|
||||
android:paddingHorizontal="15dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<!-- button_set1:移除自身背景,仅保留图标相关属性 -->
|
||||
<ImageView
|
||||
android:id="@+id/button_set1"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/xiangp" />
|
||||
|
||||
<!-- image_favorite:移除自身背景,靠右排列,与 button_set1 保持间距 -->
|
||||
<ImageView
|
||||
android:id="@+id/image_favorite"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_toRightOf="@id/button_set1"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/aix" />
|
||||
|
||||
<!-- 原 button_set1 的 ProgressBar:位置调整为与 button_set1 重叠 -->
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_set1"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_alignLeft="@id/button_set1"
|
||||
android:layout_alignTop="@id/button_set1"
|
||||
android:indeterminateTint="@color/white"
|
||||
android:padding="13dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |