V1.1(2)
This commit is contained in:
parent
71d4b68c7b
commit
f4a86c797c
@ -6,6 +6,8 @@ plugins {
|
||||
alias(libs.plugins.kotlin.android)
|
||||
id("kotlin-kapt")
|
||||
id("kotlin-parcelize")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
|
||||
android {
|
||||
@ -17,8 +19,8 @@ android {
|
||||
applicationId = "com.apps.quicksketchtrace"
|
||||
minSdk = 24
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
versionCode = 2
|
||||
versionName = "1.1"
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
"QuickSketch Trace_V" + versionName + "(${versionCode})_$timeStamp"
|
||||
@ -36,14 +38,14 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures{
|
||||
viewBinding=true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,10 +78,98 @@ dependencies {
|
||||
implementation(libs.glide)
|
||||
implementation(libs.androidsvg)
|
||||
|
||||
|
||||
|
||||
|
||||
// CameraX 相关依赖 (最新稳定版)
|
||||
implementation(libs.androidx.camera.core)
|
||||
implementation(libs.androidx.camera.camera2)
|
||||
implementation(libs.androidx.camera.lifecycle)
|
||||
implementation(libs.androidx.camera.view)
|
||||
implementation(libs.androidx.camera.extensions)
|
||||
implementation("com.google.guava:guava:31.1-android")
|
||||
|
||||
|
||||
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/UpLoadLibrary_07_03_11_54-release.aar"))
|
||||
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||||
|
||||
|
||||
// TradPlus
|
||||
implementation("com.tradplusad:tradplus:14.5.0.1")
|
||||
//noinspection GradleCompatible
|
||||
implementation("androidx.legacy:legacy-support-v4:1.0.0")
|
||||
implementation("androidx.appcompat:appcompat:1.3.0-alpha02")
|
||||
// Meta
|
||||
implementation("com.facebook.android:audience-network-sdk:6.20.0")
|
||||
implementation("com.tradplusad:tradplus-facebook:1.14.5.0.1")
|
||||
// Applovin
|
||||
implementation("com.applovin:applovin-sdk:13.3.1")
|
||||
implementation("com.tradplusad:tradplus-applovin:9.14.5.0.1")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.2.0")
|
||||
// Ironsource
|
||||
implementation("com.ironsource.sdk:mediationsdk:8.10.0")
|
||||
implementation("com.tradplusad:tradplus-ironsource:10.14.5.0.1")
|
||||
implementation("com.google.android.gms:play-services-appset:16.0.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
|
||||
implementation("com.google.android.gms:play-services-basement:17.5.0")
|
||||
// Adcolony
|
||||
implementation("com.adcolony:sdk:4.8.0")
|
||||
implementation("com.tradplusad:tradplus-adcolony:4.14.5.0.1")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
|
||||
// Pangle
|
||||
implementation("com.tradplusad:tradplus-pangle:19.14.5.0.1")
|
||||
implementation("com.pangle.global:pag-sdk:7.3.0.3")
|
||||
// UnityAds
|
||||
implementation("com.tradplusad:tradplus-unity:5.14.5.0.1")
|
||||
implementation("com.unity3d.ads:unity-ads:4.15.1")
|
||||
// Chartboost
|
||||
implementation("com.tradplusad:tradplus-chartboostx:15.14.5.0.1")
|
||||
implementation("com.chartboost:chartboost-sdk:9.8.3")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
|
||||
implementation("com.google.android.gms:play-services-base:17.4.0")
|
||||
// Inmobi
|
||||
implementation("com.tradplusad:tradplus-inmobix:23.14.5.0.1")
|
||||
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.8.3")
|
||||
implementation("androidx.core:core-ktx:1.5.0")
|
||||
implementation("com.inmobi.omsdk:inmobi-omsdk:1.5.2.0")
|
||||
// Fyber
|
||||
implementation("com.fyber:marketplace-sdk:8.3.7")
|
||||
implementation("com.tradplusad:tradplus-fyber:24.14.5.0.1")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:17.0.0")
|
||||
implementation("com.google.android.gms:play-services-base:17.4.0")
|
||||
// Start.io
|
||||
implementation("com.startapp:inapp-sdk:5.2.3")
|
||||
implementation("com.tradplusad:tradplus-startapp:28.14.5.0.1")
|
||||
// Mintegral
|
||||
implementation("com.tradplusad:tradplus-mintegralx_overseas:18.14.5.0.1")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
implementation("com.mbridge.msdk.oversea:mbridge_android_sdk:16.9.71")
|
||||
// Liftoff
|
||||
implementation("com.tradplusad:tradplus-vunglex:7.14.5.0.1")
|
||||
implementation("com.vungle:vungle-ads:7.5.0")
|
||||
// Yandex
|
||||
implementation("com.yandex.android:mobileads:7.13.0") {
|
||||
exclude(group = "com.caverock", module = "androidsvg-aar")
|
||||
}
|
||||
implementation("com.tradplusad:tradplus-yandex:50.14.6.10.1")
|
||||
// Bigo
|
||||
implementation("com.bigossp:bigo-ads:5.4.0")
|
||||
implementation("com.tradplusad:tradplus-bigo:57.14.5.0.1")
|
||||
// Cross Promotion
|
||||
implementation("com.tradplusad:tradplus-crosspromotion:27.14.5.0.1")
|
||||
// TP Exchange
|
||||
// 请注意保持与主包版本同步更新
|
||||
implementation("com.google.code.gson:gson:2.8.6")
|
||||
implementation("com.tradplusad:tp_exchange:40.14.5.0.1")
|
||||
|
||||
|
||||
|
||||
// Google UMP
|
||||
implementation ("com.google.android.ump:user-messaging-platform:3.2.0")
|
||||
}
|
||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "398831977726",
|
||||
"project_id": "quick-sketch-trace",
|
||||
"storage_bucket": "quick-sketch-trace.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:398831977726:android:c2769a8627d8fd1f9c91af",
|
||||
"android_client_info": {
|
||||
"package_name": "com.apps.quicksketchtrace"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyA7zndmFFcdekDHDvTMNAE-XiK--0r9nMw"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
BIN
app/libs/UpLoadLibrary_07_03_11_54-release.aar
Normal file
BIN
app/libs/UpLoadLibrary_07_03_11_54-release.aar
Normal file
Binary file not shown.
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -19,3 +19,5 @@
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keep public class com.tradplus.** { *; }
|
||||
-keep class com.tradplus.ads.** { *; }
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.AD_ID" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
@ -15,8 +15,15 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/net"
|
||||
tools:replace="android:networkSecurityConfig"
|
||||
android:theme="@style/Base.Theme.QuickSketchTrace"
|
||||
tools:targetApi="31">
|
||||
|
||||
<!-- Start.io设置COPPA-->
|
||||
<meta-data
|
||||
android:name="com.startapp.sdk.MIXED_AUDIENCE"
|
||||
android:value="true"/>
|
||||
<activity
|
||||
android:name=".activity.StartDrawActivity"
|
||||
android:theme="@style/Theme.QuickSketchTrace.Draw"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.apps.quicksketchtrace
|
||||
|
||||
import android.app.Application
|
||||
import com.up.uploadlibrary.UpLoadManager
|
||||
|
||||
public class BApplication: Application() {
|
||||
companion object{
|
||||
@ -35,7 +36,7 @@ public class BApplication: Application() {
|
||||
super.onCreate()
|
||||
context = this
|
||||
val database = AppDataBase.getDatabase(this)
|
||||
|
||||
UpLoadManager.init(this,"TP AD")
|
||||
classNameList = listOf(*CLASS_NAMES)
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.apps.quicksketchtrace.R
|
||||
import com.apps.quicksketchtrace.ad.TPManager
|
||||
import com.apps.quicksketchtrace.adapter.ThreeLineAdapter
|
||||
import com.apps.quicksketchtrace.databinding.ActivityEachCategoryBinding
|
||||
import com.apps.quicksketchtrace.listener.MainClickListener
|
||||
@ -35,6 +36,7 @@ class EachCategoryActivity : AppCompatActivity(),MainClickListener {
|
||||
binding.recyclerView.adapter=adapter
|
||||
binding.recyclerView.layoutManager=gridLayoutManager
|
||||
binding.imgBack.setOnClickListener { finish() }
|
||||
TPManager.showTPAD(this@EachCategoryActivity) { }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -24,10 +24,13 @@ import androidx.camera.core.Preview
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.apps.quicksketchtrace.activity.EachCategoryActivity
|
||||
import com.apps.quicksketchtrace.ad.TPManager
|
||||
import com.apps.quicksketchtrace.databinding.ActivityDrawPictureBinding
|
||||
import com.apps.quicksketchtrace.util.OpenConvert
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
|
||||
|
||||
class StartDrawActivity : AppCompatActivity(),View.OnTouchListener {
|
||||
private lateinit var binding:ActivityDrawPictureBinding
|
||||
private lateinit var defaultBackCamera: CameraSelector
|
||||
@ -82,12 +85,19 @@ class StartDrawActivity : AppCompatActivity(),View.OnTouchListener {
|
||||
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
TPManager.showTPAD(this@StartDrawActivity) { }
|
||||
init()
|
||||
}
|
||||
private fun init(){
|
||||
fullName=intent.getStringExtra(PATH_KEY)?:""
|
||||
Log.d("YYYYYY", fullName+"")
|
||||
binding.back.setOnClickListener { finish() }
|
||||
binding.back.setOnClickListener {
|
||||
|
||||
TPManager.showTPAD(this@StartDrawActivity) {
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
mainViewModel.isLocal.observe(this){isLike->
|
||||
binding.imgLike.isSelected=isLike
|
||||
}
|
||||
@ -120,7 +130,12 @@ class StartDrawActivity : AppCompatActivity(),View.OnTouchListener {
|
||||
}else{
|
||||
startCamera()
|
||||
}
|
||||
} private fun startCamera() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun startCamera() {
|
||||
val future: ListenableFuture<ProcessCameraProvider> = ProcessCameraProvider.getInstance(this)
|
||||
future.addListener({
|
||||
try {
|
||||
|
||||
@ -5,35 +5,174 @@ import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.apps.quicksketchtrace.ad.MetaFacebookLDUHelper
|
||||
import com.apps.quicksketchtrace.ad.TPManager
|
||||
import com.apps.quicksketchtrace.databinding.ActivityMainStartBinding
|
||||
|
||||
|
||||
import com.google.android.ump.ConsentForm
|
||||
import com.google.android.ump.ConsentInformation
|
||||
import com.google.android.ump.ConsentRequestParameters
|
||||
import com.google.android.ump.UserMessagingPlatform
|
||||
import com.tradplus.ads.base.common.TPPrivacyManager.OnPrivacyRegionListener
|
||||
import com.tradplus.ads.open.TradPlusSdk
|
||||
import com.tradplus.ads.open.TradPlusSdk.TradPlusInitListener
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class StartMainActivity : AppCompatActivity() {
|
||||
private lateinit var binding:ActivityMainStartBinding
|
||||
private lateinit var countDownTimer: CountDownTimer
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private lateinit var binding: ActivityMainStartBinding
|
||||
private var countDownTimer: CountDownTimer? = null
|
||||
private var isRunning = false
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding=ActivityMainStartBinding.inflate(layoutInflater)
|
||||
binding = ActivityMainStartBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
handler.postDelayed({
|
||||
startActivity(Intent(this@StartMainActivity, MainActivity::class.java))
|
||||
finish()
|
||||
}, 4000)
|
||||
countDownTimer = object : CountDownTimer(4000, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
val progress = ((4000 - millisUntilFinished) / 4000f * 100).toInt()
|
||||
binding.progressbar.progress = progress
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
binding.progressbar.progress = 100
|
||||
}
|
||||
}.start()
|
||||
setPrivacyConsent()
|
||||
}
|
||||
|
||||
private fun intentMain() {
|
||||
startActivity(Intent(this@StartMainActivity, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
countDownTimer.cancel()
|
||||
countDownTimer?.cancel()
|
||||
|
||||
}
|
||||
|
||||
private fun setPrivacyConsent() {
|
||||
// Google UMP
|
||||
val params: ConsentRequestParameters? =
|
||||
ConsentRequestParameters.Builder() // 指示用户是否低于同意年龄; true 低于同意年龄
|
||||
// 未满同意年龄的用户不会收到 GDPR 消息表单
|
||||
.setTagForUnderAgeOfConsent(false)
|
||||
.build()
|
||||
|
||||
val consentInformation: ConsentInformation =
|
||||
UserMessagingPlatform.getConsentInformation(this)
|
||||
consentInformation.requestConsentInfoUpdate(
|
||||
this,
|
||||
params,
|
||||
ConsentInformation.OnConsentInfoUpdateSuccessListener {
|
||||
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
|
||||
this,
|
||||
ConsentForm.OnConsentFormDismissedListener { loadAndShowError ->
|
||||
if (loadAndShowError != null) {
|
||||
// Consent gathering failed.
|
||||
}
|
||||
// Consent has been gathered.
|
||||
if (consentInformation.canRequestAds()) {
|
||||
Log.i("TP AD", "授权完成,初始化SDK: ")
|
||||
// 授权完成,初始化SDK
|
||||
initTPSDK()
|
||||
}
|
||||
} as ConsentForm.OnConsentFormDismissedListener)
|
||||
} as ConsentInformation.OnConsentInfoUpdateSuccessListener,
|
||||
ConsentInformation.OnConsentInfoUpdateFailureListener { requestConsentError -> } as ConsentInformation.OnConsentInfoUpdateFailureListener)
|
||||
|
||||
|
||||
// 用户已经进行过UMP选择
|
||||
if (consentInformation.canRequestAds()) {
|
||||
// 授权完成,初始化SDK
|
||||
Log.i("TP AD", "用户已经进行过UMP选择,初始化SDK: ")
|
||||
initTPSDK()
|
||||
}
|
||||
|
||||
// 集成Google UMP后; 如果美国加州没有投放APP,无需调用
|
||||
checkAreaSetCCPA();
|
||||
}
|
||||
|
||||
|
||||
private fun checkAreaSetCCPA() {
|
||||
// 判断用户是否已经选择过,返回true表示已经进行过选择,就不需要再次进行GDPR弹窗
|
||||
val firstShowGDPR = TradPlusSdk.isFirstShowGDPR(this)
|
||||
// 查询地区
|
||||
TradPlusSdk.checkCurrentArea(this, object : OnPrivacyRegionListener {
|
||||
override fun onSuccess(isEu: Boolean, isCn: Boolean, isCalifornia: Boolean) {
|
||||
// 获取到相关地域配置后,设置相关隐私API
|
||||
|
||||
// 集成Google UMP后无需处理欧洲地区
|
||||
// 表明是欧洲地区,设置GDPR弹窗
|
||||
// if (isEu) {
|
||||
// if (!firstShowGDPR) {
|
||||
// TradPlusSdk.showUploadDataNotifyDialog(application, new TradPlusSdk.TPGDPRAuthListener() {
|
||||
// @Override
|
||||
// public void onAuthResult(int level) {
|
||||
// // 获取设置结果并做记录,true 表明用户 进行过选择
|
||||
// TradPlusSdk.setIsFirstShowGDPR(application, true);
|
||||
// }
|
||||
// }, Const.URL.GDPR_URL); // Const.URL.GDPR_URL 为TradPlus 定义的授权页面
|
||||
// }
|
||||
// }
|
||||
|
||||
// 表明是美国加州地区,设置CCPA
|
||||
Log.i("TP AD", "onSuccess isCalifornia=${isCalifornia} ")
|
||||
if (isCalifornia) {
|
||||
// false 加州用户均不上报数据 ;true 接受上报数据
|
||||
// 默认不上报,如果上报数据,需要让用户选择
|
||||
TradPlusSdk.setCCPADoNotSell(this@StartMainActivity, false)
|
||||
MetaFacebookLDUHelper.enableLDUForCalifornia()
|
||||
}
|
||||
|
||||
if (!isEu) {
|
||||
Log.i("TP AD", "isEu= initTPSDK ")
|
||||
initTPSDK()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed() {
|
||||
// 一般为网络问题导致查询失败,开发者需要自己判断地区,然后进行隐私设置
|
||||
// 然后在初始化SDK
|
||||
Log.i("TP AD", "onFailed ")
|
||||
MetaFacebookLDUHelper.checkAndEnableLDU(this@StartMainActivity)
|
||||
initTPSDK()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
private fun initTPSDK() {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
if (!TradPlusSdk.getIsInit()) {
|
||||
TradPlusSdk.setTradPlusInitListener(object : TradPlusInitListener {
|
||||
override fun onInitSuccess() {
|
||||
Log.i("TP AD", "onInitSuccess: ")
|
||||
startCountDown()
|
||||
TPManager.loadAllAd(this@StartMainActivity)
|
||||
}
|
||||
})
|
||||
TradPlusSdk.initSdk(this@StartMainActivity, "4A8326375DB61EDF3B8AD4CD231177E8")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun startCountDown() {
|
||||
val total = 12000L
|
||||
countDownTimer = countDownTimer ?: TPManager.showWelcomeAd(
|
||||
this@StartMainActivity,
|
||||
total,
|
||||
{ millisUntilFinished ->
|
||||
isRunning = true
|
||||
var progressPercentage = ((100 * millisUntilFinished) / total)
|
||||
val i = (100 - progressPercentage).toInt()
|
||||
Log.i("TP AD", "=${i} ")
|
||||
binding.progressbar.progress = i
|
||||
}) {
|
||||
binding.progressbar.progress = 100
|
||||
intentMain()
|
||||
}
|
||||
if (!isRunning) {
|
||||
countDownTimer?.start()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.apps.quicksketchtrace.R
|
||||
import com.apps.quicksketchtrace.ad.TPManager
|
||||
import com.apps.quicksketchtrace.adapter.ThreeLineAdapter
|
||||
import com.apps.quicksketchtrace.database.Upload
|
||||
import com.apps.quicksketchtrace.databinding.FragmentUploadBinding
|
||||
@ -42,15 +43,16 @@ class UploadFragment : Fragment(), MainClickListener {
|
||||
private var galleryPermission: ActivityResultLauncher<Array<String>>? = null
|
||||
private var galleryLauncher: ActivityResultLauncher<Intent>? = null
|
||||
private var imgFile: File? = null
|
||||
private var delPosition=-1
|
||||
private var delPosition = -1
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentUploadBinding.inflate(inflater,container,false)
|
||||
binding = FragmentUploadBinding.inflate(inflater, container, false)
|
||||
mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
init()
|
||||
@ -61,13 +63,13 @@ class UploadFragment : Fragment(), MainClickListener {
|
||||
setupRecyclerView()
|
||||
mainViewModel.uploads.observe(viewLifecycleOwner) { list ->
|
||||
if (list.isNotEmpty()) {
|
||||
if(delPosition!=-1){
|
||||
if (delPosition != -1) {
|
||||
adapter.notifyItemRemoved(delPosition)
|
||||
binding.recyclerView.postDelayed({
|
||||
adapter.setUploadList(list, 1)
|
||||
},3000)
|
||||
delPosition=-1
|
||||
}else{
|
||||
}, 3000)
|
||||
delPosition = -1
|
||||
} else {
|
||||
adapter.notifyDataSetChanged()
|
||||
adapter.setUploadList(list, 1)
|
||||
}
|
||||
@ -77,9 +79,19 @@ class UploadFragment : Fragment(), MainClickListener {
|
||||
refreshData()
|
||||
}
|
||||
registerCameraAndGallery()
|
||||
binding.llCamera.setOnClickListener { openPermissionCamera() }
|
||||
binding.llGallery.setOnClickListener { openPermissionGallery() }
|
||||
binding.llCamera.setOnClickListener {
|
||||
TPManager.showTPAD(requireActivity()) {
|
||||
openPermissionCamera()
|
||||
}
|
||||
|
||||
}
|
||||
binding.llGallery.setOnClickListener {
|
||||
TPManager.showTPAD(requireActivity()) {
|
||||
openPermissionGallery()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
// 先设置空适配器,让UI快速显示
|
||||
binding.recyclerView.adapter = adapter
|
||||
@ -221,7 +233,8 @@ class UploadFragment : Fragment(), MainClickListener {
|
||||
mainViewModel.isUpload.observe(viewLifecycleOwner, isUploadObserver)
|
||||
|
||||
// 开始检查
|
||||
mainViewModel.checkIsUpload(finalFilePath)}
|
||||
mainViewModel.checkIsUpload(finalFilePath)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
requireActivity().runOnUiThread {
|
||||
binding.progress.visibility = View.GONE
|
||||
@ -270,12 +283,12 @@ class UploadFragment : Fragment(), MainClickListener {
|
||||
|
||||
override fun onClick(name: String) {
|
||||
val intent = Intent(requireActivity(), StartDrawActivity::class.java)
|
||||
intent.putExtra(StartDrawActivity.PATH_KEY,name)
|
||||
intent.putExtra(StartDrawActivity.PATH_KEY, name)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
override fun onDelete(name: String,position:Int) {
|
||||
delPosition=position
|
||||
override fun onDelete(name: String, position: Int) {
|
||||
delPosition = position
|
||||
mainViewModel.deleteUploadPath(name)
|
||||
}
|
||||
}
|
||||
11
app/src/main/java/com/apps/quicksketchtrace/ad/AdListener.kt
Normal file
11
app/src/main/java/com/apps/quicksketchtrace/ad/AdListener.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package com.apps.quicksketchtrace.ad
|
||||
|
||||
interface AdListener {
|
||||
|
||||
fun loadFail(){}
|
||||
fun showSuccess(){}
|
||||
|
||||
fun showFail(){}
|
||||
|
||||
fun showClose(){}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.apps.quicksketchtrace.ad
|
||||
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Geocoder
|
||||
import android.util.Log
|
||||
import com.facebook.ads.AdSettings
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
object MetaFacebookLDUHelper {
|
||||
|
||||
private const val TAG = "FacebookLDU"
|
||||
|
||||
/**
|
||||
* 检查用户是否在加州,并启用 LDU
|
||||
*/
|
||||
fun checkAndEnableLDU(context: Context) {
|
||||
try {
|
||||
val geocoder = Geocoder(context, Locale.getDefault())
|
||||
val locationList = geocoder.getFromLocationName("California, USA", 1)
|
||||
|
||||
if (!locationList.isNullOrEmpty()) {
|
||||
enableLDUForCalifornia()
|
||||
} else {
|
||||
disableLDU()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
enableLDUForCalifornia()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用加州 LDU 模式
|
||||
* country = 1 表示美国
|
||||
* state = 1000 表示加州
|
||||
*/
|
||||
fun enableLDUForCalifornia() {
|
||||
AdSettings.setDataProcessingOptions(arrayOf("LDU"), 1, 1000)
|
||||
Log.d(TAG, "Facebook LDU 已启用 (加州用户)")
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用 LDU 模式(恢复默认)
|
||||
*/
|
||||
private fun disableLDU() {
|
||||
AdSettings.setDataProcessingOptions(emptyArray())
|
||||
Log.d(TAG, "Facebook LDU 已关闭 (非加州用户)")
|
||||
}
|
||||
}
|
||||
206
app/src/main/java/com/apps/quicksketchtrace/ad/TPManager.kt
Normal file
206
app/src/main/java/com/apps/quicksketchtrace/ad/TPManager.kt
Normal file
@ -0,0 +1,206 @@
|
||||
package com.apps.quicksketchtrace.ad
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import com.tradplus.ads.base.bean.TPAdError
|
||||
import com.tradplus.ads.base.bean.TPAdInfo
|
||||
import com.tradplus.ads.open.interstitial.InterstitialAdListener
|
||||
import com.tradplus.ads.open.interstitial.TPInterstitial
|
||||
|
||||
|
||||
object TPManager {
|
||||
|
||||
|
||||
const val type_no_cache = 0
|
||||
const val type_has_cache = 1
|
||||
const val type_show_success = 2
|
||||
const val type_show_close = 3
|
||||
const val type_show_fail = 4
|
||||
|
||||
|
||||
|
||||
const val place1Id = "04F2A22A78D2075FF033C215C592982C"
|
||||
const val place2Id = "7B2314DD74A89187490A4E8A85A5D750"
|
||||
const val place3Id = "1657ABADE1AB9F07D1D4E8D9ACFEA5C2"
|
||||
|
||||
|
||||
var place1LoadFail = false
|
||||
var place2LoadFail = false
|
||||
var place3LoadFail = false
|
||||
|
||||
val list = mutableListOf<TPInterstitial>()
|
||||
|
||||
val mTAG = "TP AD"
|
||||
|
||||
|
||||
fun loadAllAd(activity: Activity) {
|
||||
if (list.size <= 0) {
|
||||
place1LoadFail = false
|
||||
place2LoadFail = false
|
||||
place3LoadFail = false
|
||||
val mInterstitialAd1 = TPInterstitial(activity, place1Id)
|
||||
val mInterstitialAd2 = TPInterstitial(activity, place2Id)
|
||||
val mInterstitialAd3 = TPInterstitial(activity, place3Id)
|
||||
list.add(mInterstitialAd1)
|
||||
list.add(mInterstitialAd2)
|
||||
list.add(mInterstitialAd3)
|
||||
}
|
||||
for (ad in list) {
|
||||
if (!ad.isReady) {
|
||||
setCallBack(ad, object : AdListener {
|
||||
override fun loadFail() {
|
||||
|
||||
}
|
||||
})
|
||||
ad.loadAd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun getReadyAd(): TPInterstitial? {
|
||||
list.shuffle()
|
||||
for (ad in list) {
|
||||
if (ad.isReady) {
|
||||
Log.d(mTAG, "-cache------------")
|
||||
return ad
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
fun showWelcomeAd(
|
||||
activity: Activity,
|
||||
totalTim: Long,
|
||||
countAction: (millisUntilFinished: Long) -> Unit,
|
||||
goMain: () -> Unit
|
||||
): CountDownTimer {
|
||||
var alreadyShow = false
|
||||
var timer: CountDownTimer? = null
|
||||
timer = object : CountDownTimer(totalTim, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
countAction(millisUntilFinished)
|
||||
Log.d(mTAG, "onTick ${Thread.currentThread().name} timer=${timer}")
|
||||
if (!alreadyShow) {
|
||||
showCheck(activity) {
|
||||
if (it == type_has_cache) {
|
||||
alreadyShow = true
|
||||
}
|
||||
if (it == type_show_close || it == type_show_fail) {
|
||||
Log.d(
|
||||
mTAG,
|
||||
"goMain 111 ${Thread.currentThread().name} "
|
||||
)
|
||||
goMain()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
Log.d(mTAG, "onFinish() ${Thread.currentThread().name} ")
|
||||
if (!alreadyShow) {
|
||||
showCheck(activity) {
|
||||
if (it == type_show_close || it == type_show_fail || it == type_no_cache) {
|
||||
Log.d(
|
||||
mTAG,
|
||||
"goMain 222 ${Thread.currentThread().name} "
|
||||
)
|
||||
goMain()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return timer
|
||||
}
|
||||
|
||||
|
||||
private fun setCallBack(ad: TPInterstitial, listener: AdListener) {
|
||||
ad.setAdListener(object : InterstitialAdListener {
|
||||
override fun onAdLoaded(p0: TPAdInfo?) {
|
||||
Log.d(mTAG, "----onAdLoaded ${p0?.tpAdUnitId}")
|
||||
|
||||
}
|
||||
|
||||
override fun onAdFailed(p0: TPAdError?) {
|
||||
listener.loadFail()
|
||||
Log.d(mTAG, "----onAdFailed code=${p0?.errorCode} msg=${p0?.errorMsg}")
|
||||
}
|
||||
|
||||
override fun onAdImpression(p0: TPAdInfo?) {
|
||||
listener.showSuccess()
|
||||
Log.d(mTAG, "----onAdImpression ${p0?.tpAdUnitId}")
|
||||
}
|
||||
|
||||
override fun onAdClicked(p0: TPAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdClosed(p0: TPAdInfo?) {
|
||||
listener.showClose()
|
||||
}
|
||||
|
||||
override fun onAdVideoError(
|
||||
p0: TPAdInfo?,
|
||||
p1: TPAdError?
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdVideoStart(p0: TPAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdVideoEnd(p0: TPAdInfo?) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun showCheck(activity: Activity, action: (type: Int) -> Unit) {
|
||||
val readyAd = getReadyAd()
|
||||
if (readyAd != null) {
|
||||
Log.d(mTAG, "readyAd ")
|
||||
action(type_has_cache)
|
||||
setCallBack(readyAd, object : AdListener {
|
||||
override fun loadFail() {
|
||||
|
||||
}
|
||||
|
||||
override fun showSuccess() {
|
||||
action(type_show_success)
|
||||
}
|
||||
|
||||
override fun showFail() {
|
||||
action(type_show_fail)
|
||||
}
|
||||
|
||||
override fun showClose() {
|
||||
action(type_show_close)
|
||||
}
|
||||
|
||||
})
|
||||
if (readyAd.isReady) {
|
||||
readyAd.showAd(activity, null)
|
||||
}
|
||||
} else {
|
||||
action(type_no_cache)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showTPAD(activity: Activity, listener: () -> Unit) {
|
||||
showCheck(activity) { type ->
|
||||
if (type == type_no_cache || type == type_show_close || type == type_show_fail) {
|
||||
listener()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,7 @@ import androidx.core.app.ActivityCompat
|
||||
import androidx.core.graphics.createBitmap
|
||||
import com.apps.quicksketchtrace.BApplication
|
||||
import com.caverock.androidsvg.SVG
|
||||
//import com.caverock.androidsvg.SVG
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginBottom="140dp"
|
||||
android:max="100"
|
||||
android:progress="80"
|
||||
android:progress="1"
|
||||
android:indeterminateTint="@color/white"
|
||||
android:progressDrawable="@drawable/start_pb" />
|
||||
</RelativeLayout>
|
||||
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>
|
||||
@ -2,4 +2,6 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
id("com.google.gms.google-services") version "4.4.2" apply false
|
||||
id ("com.google.firebase.crashlytics") version "3.0.2" apply false
|
||||
}
|
||||
@ -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. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
@ -22,3 +22,5 @@ kotlin.code.style=official
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
kapt.incremental.apt=false
|
||||
org.gradle.java.home=C\:\\Users\\ltt\\.jdks\\ms-17.0.15
|
||||
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,4 +1,4 @@
|
||||
#Tue Aug 12 13:54:22 CST 2025
|
||||
#Wed Sep 10 14:24:19 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
|
||||
@ -16,6 +16,33 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
|
||||
// TradPlus
|
||||
|
||||
// Ironsource
|
||||
maven {
|
||||
url = uri("https://android-sdk.is.com/")
|
||||
// Pangle
|
||||
maven {
|
||||
url = uri("https://artifact.bytedance.com/repository/pangle")
|
||||
}
|
||||
// Chartboost
|
||||
maven {
|
||||
url = uri("https://cboost.jfrog.io/artifactory/chartboost-ads/")
|
||||
maven {
|
||||
name = "Chartboost Mediation’s maven repo"
|
||||
url = uri("https://cboost.jfrog.io/artifactory/chartboost-mediation")
|
||||
}
|
||||
// Mintegral
|
||||
//Launch GP market application, Android X Version
|
||||
//If you fail to pull the code using gradle, add the maven warehouse configuration to the project root build.gradle file
|
||||
maven {
|
||||
url =
|
||||
uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user