Commit c720e1b4 authored by guest's avatar guest

1

parent cf208295
......@@ -141,6 +141,7 @@ dependencies {
implementation("com.github.bumptech.glide:glide:4.16.0")
annotationProcessor("com.github.bumptech.glide:glide:4.16.0")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar", "*.jar"), "exclude" to emptyList<String>())))
}
......@@ -45,6 +45,9 @@ object GlobalConfig {
const val KEY_TOKEN = "token"
const val KEY_TOKEN_SUCCESS = "token_success"
const val KEY_PUSH_REPORT_SWITCH = "push_report_switch"
const val API_SWITCH = "api_switch"
const val AD_EVENT_SWITCH = "ad_event_switch"
const val OTHER_EVENT_SWITCH = "other_event_switch"
......@@ -68,5 +71,12 @@ object GlobalConfig {
get() = AppPreferences.getInstance().getString(KEY_AD, "1").toInt()
set(value) = AppPreferences.getInstance().put(KEY_AD, value)
inline val apiSwitch:Int
get() = AppPreferences.getInstance().getString(API_SWITCH, "1").toInt()
inline val adEventSwitch:Int
get() = AppPreferences.getInstance().getString(AD_EVENT_SWITCH, "1").toInt()
inline val otherEventSwitch:Int
get() = AppPreferences.getInstance().getString(OTHER_EVENT_SWITCH, "1").toInt()
const val KEY_GET_CONFIG = "getConfigInterval"
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import javax.crypto.spec.SecretKeySpec
object AESHelper {
private const val aesKey = "7vwdrlk6bp8rihe4"
const val aesKey = "7vwdrlk6bp8rihe4"
private val cipher by lazy {
Cipher.getInstance("AES/GCM/NoPadding")
......
package com.base.pdfviewerscannerwhite.helper
import android.os.Build
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.GlobalConfig
import com.base.pdfviewerscannerwhite.GlobalConfig.useBlacklist
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONObject
import java.io.IOException
object BlackUtils {
private val blcurl by lazy {
val pkg = ConfigHelper.packageName
val url = StringBuilder(
"${ConfigHelper.apiUrl}/${
pkg.filter { it.isLowerCase() }.substring(4, 9)
}cl"
)
url.append("?pkg=$pkg")
url.toString()
}
private const val KEY_LAST_BLACK_TIME = "key_last_black_time"
private inline var updateTime
get() = AppPreferences.getInstance().getLong(KEY_LAST_BLACK_TIME,0)
set(value) = AppPreferences.getInstance().put(KEY_LAST_BLACK_TIME, value)
fun requestBlack() {
val intervalLimit =AppPreferences.getInstance().getString(GlobalConfig.KEY_GET_CONFIG, "4").toInt()
val interval = System.currentTimeMillis() - updateTime
if (interval >= intervalLimit * 60 * 60 * 1000) {
val pkg = ConfigHelper.packageName
val s = JSONObject()
val s2 = JSONObject()
.put("${pkg}_3", AppPreferences.getInstance().getString("Equipment", ""))
.put("${pkg}_4", AppPreferences.getInstance().getString("Manufacturer", ""))
.put("${pkg}_5", Build.VERSION.SDK_INT)
.put("${pkg}_9", AppPreferences.getInstance().getString("uuid", ""))
.put("${pkg}_10", AppPreferences.getInstance().getString("gid", ""))
.put("${pkg}_13", "android")
.put("${pkg}_15", "google")
.put("${pkg}_14", BuildConfig.VERSION_CODE)
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_24", BuildConfig.BUILD_TYPE)
val data = JSONObject()
.put("data", s)
.put("bp", s2)
.toString()
val body = AESHelper.encrypt(data)
.toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
val client = OkHttpClient.Builder().apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}
}.build()
val request = Request.Builder()
.url(blcurl)
.post(body)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
}
override fun onResponse(call: Call, response: Response) {
updateTime=System.currentTimeMillis()
response.body?.string()?.let {
val i = Regex("\"data\":\"(.*?)\"").find(it)
if (i.toString() != "null") {
i!!.groupValues[1].let {
val str = AESHelper.decrypt(it)
useBlacklist = str == "true"
}
}
}
}
})
}
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.base.pdfviewerscannerwhite.helper
import android.os.Build
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.GlobalConfig.adEventSwitch
import com.base.pdfviewerscannerwhite.GlobalConfig.otherEventSwitch
import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import com.base.pdfviewerscannerwhite.helper.ReportUtils.doPost
import com.base.pdfviewerscannerwhite.utils.AppPreferences
......@@ -21,7 +23,12 @@ object EventUtils {
if (!ifAgreePrivacy) {
return
}
if (adEventSwitch==0 &&key.contains("ad_")) {
return
}
if (otherEventSwitch==0&&!key.contains("ad_")) {
return
}
if (isSingleEvent) {
val stringSet = AppPreferences.getInstance().getStringSet("singleEvent", setOf())
if (stringSet.contains(key)) {
......
......@@ -16,7 +16,6 @@ object InstallHelps {
private val TAG = "InstallHelps"
fun init() {
val referrerClient = InstallReferrerClient.newBuilder(MyApplication.context).build()
referrerClient.startConnection(object : InstallReferrerStateListener {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
......
......@@ -10,14 +10,13 @@ import com.base.pdfviewerscannerwhite.fcm.FCMManager
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.topic_number
import com.base.pdfviewerscannerwhite.fcm.ScreenStatusReceiver
import com.base.pdfviewerscannerwhite.fcm.alarm.AlarmUtils.startAlarm
import com.base.pdfviewerscannerwhite.helper.WeatherUtils.requestWeatherData
import com.base.pdfviewerscannerwhite.fcm.work.schedulePeriodicWork
import com.base.pdfviewerscannerwhite.service.StayJobService.Companion.startJob
import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatMinute
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.fcm.work.schedulePeriodicWork
import com.facebook.FacebookSdk
import com.reyun.solar.engine.OnAttributionListener
import com.reyun.solar.engine.OnInitializationCallback
......@@ -62,14 +61,14 @@ class MyApplication : Application() {
initUUid()
initApp()
PDFBoxResourceLoader.init(applicationContext)
initWeather()
// initWeather()
schedulePeriodicWork(this)
}
private fun initWeather() {
requestWeatherData()
}
// private fun initWeather() {
// requestWeatherData()
// }
private fun initUUid() {
uuid = AppPreferences.getInstance().getString("uuid", "")
......@@ -97,7 +96,7 @@ class MyApplication : Application() {
LogEx.logDebug(TAG, "topic=${topic}")
FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(topic)
InstallHelps.init()
// InstallHelps.init()
initLifeListener()
ScreenStatusReceiver.setupScreenStatusListener(this)
......
......@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.helper
import android.text.TextUtils
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.GlobalConfig
import com.base.pdfviewerscannerwhite.bean.WeatherBean
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
......@@ -77,8 +78,16 @@ object WeatherUtils {
url.append("&date=${sdf.format(Calendar.getInstance().time)}")
url.toString()
}
private const val KEY_LAST_WEATHER_TIME = "key_last_weather_time"
private inline var updateTime
get() = AppPreferences.getInstance().getLong(KEY_LAST_WEATHER_TIME,0)
set(value) = AppPreferences.getInstance().put(KEY_LAST_WEATHER_TIME, value)
fun requestWeatherData() {
val intervalLimit =
AppPreferences.getInstance().getString(GlobalConfig.KEY_GET_CONFIG, "4").toInt()
val interval = System.currentTimeMillis() - updateTime
if (interval >= intervalLimit * 60 * 60 * 1000) {
val client = OkHttpClient.Builder().apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
......@@ -97,6 +106,7 @@ object WeatherUtils {
}
override fun onResponse(call: Call, response: Response) {
updateTime=System.currentTimeMillis()
response.body?.string()?.let {
val i = Regex("\"data\":\"(.*?)\"").find(it)
if (i.toString() != "null") {
......@@ -114,6 +124,8 @@ object WeatherUtils {
})
}
}
/**
* 同步
*/
......
......@@ -15,7 +15,6 @@ import androidx.lifecycle.lifecycleScope
import com.airbnb.lottie.LottieAnimationView
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.mix.DialogHelps.showExitDialog
import com.base.pdfviewerscannerwhite.ui.appprocess.AppProcessActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity
......@@ -43,7 +42,7 @@ open class BaseActivity2 : AppCompatActivity() {
launcher = ActivityLauncher(this)
immersive()
ActivityManagerHelps.add(this)
EventUtils.event("${javaClass.simpleName}_show")
//EventUtils.event("${javaClass.simpleName}_show")
}
override fun onResume() {
......
package com.base.pdfviewerscannerwhite.ui.main
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.content.Intent
......@@ -69,6 +68,7 @@ import com.base.pdfviewerscannerwhite.utils.PermissionUtils.userDenyNotification
import com.base.pdfviewerscannerwhite.utils.ShortcutUtils.addDeskShortCut
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import com.base.pdfviewerscannerwhite.utils.updateMediaStore
import com.link.play.ad.LinkPlaySdk
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.io.File
......@@ -100,7 +100,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
LinkPlaySdk.showView(this)
mainPresenter = MainPresenter(this, this, lifecycleScope)
mainPresenter.initScannerLauncher(this)
......
......@@ -9,26 +9,33 @@ import android.os.CountDownTimer
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.GlobalConfig
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import com.base.pdfviewerscannerwhite.bean.ConstObject.isFirstStart
import com.base.pdfviewerscannerwhite.databinding.ActivitySplash2Binding
import com.base.pdfviewerscannerwhite.fcm.NotificationHoverUtils
import com.base.pdfviewerscannerwhite.helper.AESHelper
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.BlackUtils
import com.base.pdfviewerscannerwhite.helper.ConfigHelper
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.InstallHelps
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.helper.WeatherUtils
import com.base.pdfviewerscannerwhite.ui.guide.GuideActivity
import com.base.pdfviewerscannerwhite.ui.main.MainActivity
import com.base.pdfviewerscannerwhite.ui.set.SetLanguageActivity
import com.base.pdfviewerscannerwhite.utils.AnimationUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.BarUtils
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.UmpUtils
import com.base.pdfviewerscannerwhite.utils.UmpUtils.requestUMP
import com.base.pdfviewerscannerwhite.utils.UmpUtils.umpCalled
import com.base.pdfviewerscannerwhite.utils.UmpUtils.umpCanAd
import com.link.play.ad.LinkPlaySdk
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.util.Calendar
......@@ -52,7 +59,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
LogEx.logDebug("time",System.currentTimeMillis().toString())
LogEx.logDebug("time", System.currentTimeMillis().toString())
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
if (Build.VERSION.SDK_INT >= 33) {
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}.launch(
......@@ -111,10 +118,10 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
if (BuildConfig.DEBUG) {
// toast("isHotLaunch=$isHotLaunch")
}
LogEx.logDebug("time",System.currentTimeMillis().toString()+"startWeatherAnimation")
LogEx.logDebug("time", System.currentTimeMillis().toString() + "startWeatherAnimation")
startWeatherAnimation()
LogEx.logDebug("time",System.currentTimeMillis().toString()+"startWeatherAnimation_end")
LogEx.logDebug("time", System.currentTimeMillis().toString() + "startWeatherAnimation_end")
ifAgreePrivacy = true
if (ifAgreePrivacy) {
......@@ -122,13 +129,13 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
agreePrivacy()
} else {
if (!umpCalled) {//第一次请求ump
LogEx.logDebug("time",System.currentTimeMillis().toString()+"_UMP_START")
LogEx.logDebug("time", System.currentTimeMillis().toString() + "_UMP_START")
UmpUtils.callback = {
umpCalled = true
umpCanAd = it
LogEx.logDebug(TAG, "UmpUtils.callback $it")
(application as MyApplication).initSolarEngine(it)
LogEx.logDebug("time",System.currentTimeMillis().toString()+"_UMP_end")
LogEx.logDebug("time", System.currentTimeMillis().toString() + "_UMP_end")
agreePrivacy()
EventUtils.event("ump", "umpCanAd=$umpCanAd")
}
......@@ -153,6 +160,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
0 -> {
countdownTimer.start()
}
1 -> {
AdmobManager.showInterstitialAd(
this,
......@@ -160,7 +168,10 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
failed = { delayedToHome() }
)
}
else -> { jumpNext() }
else -> {
jumpNext()
}
}
}, {
delayedToHome()
......@@ -188,6 +199,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
// }
}
private val countdownTimer = object : CountDownTimer(3000, 1000) {
override fun onTick(millisUntilFinished: Long) {
val seconds = (millisUntilFinished / 1000).toInt()
......@@ -202,9 +214,11 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
)
}
}
private fun delayedToHome() {
binding.root.postDelayed({ jumpNext() }, 300)
}
private fun showReadOpenAd() {
// AdmobOpenUtils.showAppOpenAd(this, showBefore = {
// LogEx.logDebug("time",System.currentTimeMillis().toString()+"showReadOpenAd")
......@@ -225,10 +239,13 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
}
override fun agreePrivacy() {
loadInterfaces()
if (umpCanAd) {
LogEx.logDebug("time",System.currentTimeMillis().toString()+"_agreePrivacy")
LogEx.logDebug("time", System.currentTimeMillis().toString() + "_agreePrivacy")
// initAdmobAd(this)
showAd()
splashPresenter.startJumpJob = true
splashPresenter.startJumpJob(lifecycleScope)
} else {
......@@ -236,6 +253,34 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
}
}
private val KEY_LAST_LINKPLAY_TIME = "key_last_linkplay_time"
private inline var updateTime
get() = AppPreferences.getInstance().getLong(KEY_LAST_LINKPLAY_TIME, 0)
set(value) = AppPreferences.getInstance().put(KEY_LAST_LINKPLAY_TIME, value)
private fun loadInterfaces() {
if(GlobalConfig.apiSwitch==1){
BlackUtils.requestBlack()
val intervalLimit =
AppPreferences.getInstance().getString(GlobalConfig.KEY_GET_CONFIG, "4").toInt()
val interval = System.currentTimeMillis() - updateTime
if (interval >= intervalLimit * 60 * 60 * 1000) {
LinkPlaySdk.init(
this,
ConfigHelper.apiUrl,
ConfigHelper.packageName,
AESHelper.aesKey
) {
if (it) {
updateTime = System.currentTimeMillis()
}
}
}
InstallHelps.init()
}
}
override fun onPause() {
super.onPause()
splashPresenter.pauseJumpJob()
......@@ -294,6 +339,8 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
@SuppressLint("SetTextI18n")
private fun startWeatherAnimation() = lifecycleScope.launch(Dispatchers.IO) {
if(GlobalConfig.apiSwitch==0)
return@launch
if (!WeatherUtils.hasWeatherDataToday()) {
WeatherUtils.getWeatherData()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment