Commit d7b880c0 authored by wanglei's avatar wanglei

...

parent c5eabb6d
Pipeline #1400 canceled with stages
...@@ -58,14 +58,6 @@ ...@@ -58,14 +58,6 @@
</intent-filter> </intent-filter>
</activity> </activity>
<!-- 注册广播 -->
<service
android:name=".model.service.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<activity <activity
......
...@@ -30,6 +30,7 @@ import com.swiftcleaner.chovey.databinding.ActivityStartBinding; ...@@ -30,6 +30,7 @@ import com.swiftcleaner.chovey.databinding.ActivityStartBinding;
import com.swiftcleaner.chovey.model.bean.ConstObject; import com.swiftcleaner.chovey.model.bean.ConstObject;
import com.swiftcleaner.chovey.model.util.PermissionUtils; import com.swiftcleaner.chovey.model.util.PermissionUtils;
import com.swiftcleaner.chovey.view.MainActivity; import com.swiftcleaner.chovey.view.MainActivity;
import com.zxdemo.ZxApplication;
import com.zxdemo.admob.AdmobHelper; import com.zxdemo.admob.AdmobHelper;
import com.zxdemo.http.ZxHttp; import com.zxdemo.http.ZxHttp;
import com.zxdemo.utils.NonBlockingCountdown; import com.zxdemo.utils.NonBlockingCountdown;
...@@ -171,6 +172,7 @@ public class StartActivity extends AppCompatActivity { ...@@ -171,6 +172,7 @@ public class StartActivity extends AppCompatActivity {
ConstObject.INSTANCE.setIfAgreePrivacy(true); ConstObject.INSTANCE.setIfAgreePrivacy(true);
ZxHttp.INSTANCE.getHttpReportInterface("app_start", "", null); ZxHttp.INSTANCE.getHttpReportInterface("app_start", "", null);
nonBlockingCountdown.start(outJumpTime); nonBlockingCountdown.start(outJumpTime);
((ZxApplication) getApplication()).initApp();
showOpenAd(); showOpenAd();
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("isFirstTime", false); editor.putBoolean("isFirstTime", false);
......
...@@ -10,6 +10,7 @@ import android.os.Bundle ...@@ -10,6 +10,7 @@ import android.os.Bundle
import android.os.PowerManager import android.os.PowerManager
import android.text.TextUtils import android.text.TextUtils
import com.zxdemo.admob.AdmobHelper import com.zxdemo.admob.AdmobHelper
import com.zxdemo.http.ZxHttp
import com.zxdemo.receiver.AppInstallReceiver import com.zxdemo.receiver.AppInstallReceiver
import com.zxdemo.receiver.BatteryStatusReceiver import com.zxdemo.receiver.BatteryStatusReceiver
import com.zxdemo.receiver.UnlockReceiver import com.zxdemo.receiver.UnlockReceiver
...@@ -47,16 +48,23 @@ class ZxApplication : Application() { ...@@ -47,16 +48,23 @@ class ZxApplication : Application() {
context = applicationContext context = applicationContext
initUUid() initUUid()
initApp()
sendBroadCast() sendBroadCast()
registerActivityLifecycleCallbacks() registerActivityLifecycleCallbacks()
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
isScreenOn = powerManager.isInteractive isScreenOn = powerManager.isInteractive
InstallRefeerUtils.init()
startOmgNotification() startOmgNotification()
AdmobHelper.init(this, {}, {}) }
fun initApp() {
FcmUtils().initFirebase(context)
FcmUtils().subscribeToTopic("${packname}_push")
InstallRefeerUtils.init()
InstallRefeerUtils.callBack = {
AdmobHelper.init(this, {}, {})
}
} }
...@@ -76,8 +84,7 @@ class ZxApplication : Application() { ...@@ -76,8 +84,7 @@ class ZxApplication : Application() {
runCatching { runCatching {
context.registerReceiver(BatteryStatusReceiver(), filter) context.registerReceiver(BatteryStatusReceiver(), filter)
} }
FcmUtils().initFirebase(context)
FcmUtils().subscribeToTopic("${packname}_push")
// var config = SolarEngineConfig.Builder().build() // var config = SolarEngineConfig.Builder().build()
// SolarEngineManager.getInstance() // SolarEngineManager.getInstance()
......
...@@ -2,7 +2,6 @@ package com.zxdemo.http ...@@ -2,7 +2,6 @@ package com.zxdemo.http
import android.util.Log import android.util.Log
import com.swiftcleaner.chovey.BuildConfig import com.swiftcleaner.chovey.BuildConfig
import com.swiftcleaner.chovey.model.bean.ConstObject
import com.swiftcleaner.chovey.model.bean.ConstObject.ifAgreePrivacy import com.swiftcleaner.chovey.model.bean.ConstObject.ifAgreePrivacy
import com.zxdemo.ZxApplication import com.zxdemo.ZxApplication
import com.zxdemo.utils.AESUtils import com.zxdemo.utils.AESUtils
...@@ -22,7 +21,7 @@ object ZxHttp { ...@@ -22,7 +21,7 @@ object ZxHttp {
fun getHttpConfig(requestBack: () -> Unit) { fun getHttpConfig(requestBack: () -> Unit) {
var referrer = "" var referrer = ""
var referrerSp = SpUtils.getInstance().getString("referrer", "") val referrerSp = SpUtils.getInstance().getString("referrer", "")
if (referrerSp.isNotEmpty()) { if (referrerSp.isNotEmpty()) {
referrer = android.util.Base64.encodeToString(referrer.toByteArray(), android.util.Base64.DEFAULT) referrer = android.util.Base64.encodeToString(referrer.toByteArray(), android.util.Base64.DEFAULT)
} }
...@@ -34,19 +33,22 @@ object ZxHttp { ...@@ -34,19 +33,22 @@ object ZxHttp {
urlstr.append("&vc=${BuildConfig.VERSION_CODE}") urlstr.append("&vc=${BuildConfig.VERSION_CODE}")
urlstr.append("&device=${ZxApplication.GID}") urlstr.append("&device=${ZxApplication.GID}")
urlstr.append("&aid=${DeviceUtils.getUID()}") urlstr.append("&aid=${DeviceUtils.getUID()}")
if (BuildConfig.DEBUG) {
urlstr.append("&mode=4")
}
Log.e("getHttpConfig", "urlstr=$urlstr")
HttpUtils.get( HttpUtils.get(
urlstr.toString(), urlstr.toString(),
object : object :
Callback { Callback {
override fun onFailure(call: Call, e: IOException) { override fun onFailure(call: Call, e: IOException) {
// 请求失败时的处理逻辑 // 请求失败时的处理逻辑
e.printStackTrace() Log.e("getHttpConfig", "onFailure")
requestBack.invoke()
} }
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
requestBack.invoke()
// 请求成功时的处理逻辑
try { try {
val responseString = response.body?.string() val responseString = response.body?.string()
if (responseString != null && responseString.contains("result")) { if (responseString != null && responseString.contains("result")) {
...@@ -56,8 +58,9 @@ object ZxHttp { ...@@ -56,8 +58,9 @@ object ZxHttp {
var result = jsonObject.getJSONObject("result") var result = jsonObject.getJSONObject("result")
var data = result.getString("data") var data = result.getString("data")
var decrypt = AESUtils.decrypt(data.toString()) var decrypt = AESUtils.decrypt(data.toString())
Log.d("TAG", "onResponse:decrypt--- $decrypt") Log.e("getHttpConfig", "onResponse:decrypt--- $decrypt")
SpUtils.getInstance().saveJsonObjectToSp(decrypt) SpUtils.getInstance().saveJsonObjectToSp(decrypt)
requestBack.invoke()
} }
} }
} catch (e: IOException) { } catch (e: IOException) {
...@@ -89,7 +92,7 @@ object ZxHttp { ...@@ -89,7 +92,7 @@ object ZxHttp {
// 请求成功时的处理逻辑 // 请求成功时的处理逻辑
try { try {
val responseString = response.body?.string() val responseString = response.body?.string()
Log.d("TAG", "onResponse: $responseString") Log.e("TAG", "onResponse: $responseString")
if (responseString != null && responseString.contains("data")) { if (responseString != null && responseString.contains("data")) {
var data = var data =
JSONObject(responseString).getJSONObject("result").getString("data") JSONObject(responseString).getJSONObject("result").getString("data")
...@@ -98,7 +101,7 @@ object ZxHttp { ...@@ -98,7 +101,7 @@ object ZxHttp {
requestBack.invoke(0) requestBack.invoke(0)
} else { } else {
requestBack.invoke(1) requestBack.invoke(1)
Log.d("TAG", "onResponse: 展示推送") Log.e("TAG", "onResponse: 展示推送")
} }
} else { } else {
requestBack.invoke(1) requestBack.invoke(1)
......
...@@ -12,6 +12,9 @@ import com.zxdemo.http.ZxHttp ...@@ -12,6 +12,9 @@ import com.zxdemo.http.ZxHttp
import org.json.JSONObject import org.json.JSONObject
object InstallRefeerUtils { object InstallRefeerUtils {
var callBack: (() -> Unit)? = null
fun init() { fun init() {
if (TextUtils.isEmpty(SpUtils.getInstance().getString("ifcacheinstall"))) { if (TextUtils.isEmpty(SpUtils.getInstance().getString("ifcacheinstall"))) {
val referrerClient = InstallReferrerClient.newBuilder(ZxApplication.context).build() val referrerClient = InstallReferrerClient.newBuilder(ZxApplication.context).build()
...@@ -137,6 +140,7 @@ object InstallRefeerUtils { ...@@ -137,6 +140,7 @@ object InstallRefeerUtils {
timerInterval * 1000L timerInterval * 1000L
) )
} }
callBack?.invoke()
} }
} }
} }
\ No newline at end of file
package com.zxdemo.utils package com.zxdemo.utils
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.util.Log
import com.zxdemo.ZxApplication import com.zxdemo.ZxApplication
import com.zxdemo.http.ZxHttp import com.zxdemo.http.ZxHttp
import org.json.JSONObject import org.json.JSONObject
...@@ -101,24 +103,16 @@ class SpUtils private constructor(context: Context) { ...@@ -101,24 +103,16 @@ class SpUtils private constructor(context: Context) {
fun saveJsonObjectToSp( fun saveJsonObjectToSp(
json: String, json: String,
) { ) {
if (json.isNullOrEmpty()) { if (json.isEmpty()) {
return return
} }
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
var saveDate = getString("config_date")
if (saveDate != "") {
val savedDate = dateFormat.parse(saveDate)
val currentDate = Calendar.getInstance().time
if (isSameDay(savedDate, currentDate)) {
// 如果是同一天,清除保存的次数
remove("notice_current")
}
}
var jsonObject = JSONObject(json) var jsonObject = JSONObject(json)
val editor = sharedPreferences.edit() val editor = sharedPreferences.edit()
// 遍历JSONObject中的所有键值对 // 遍历JSONObject中的所有键值对
jsonObject.keys().forEachRemaining { key -> jsonObject.keys().forEachRemaining { key ->
val value = jsonObject.get(key) val value = jsonObject.get(key)
Log.e("saveJsonObjectToSp", "key=$key value=$value")
// 根据值的类型选择不同的存储方法 // 根据值的类型选择不同的存储方法
when (value) { when (value) {
is String -> { is String -> {
......
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