Commit 2aab4089 authored by wanglei's avatar wanglei

...

parent c2ee277c
...@@ -128,4 +128,8 @@ dependencies { ...@@ -128,4 +128,8 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp") implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor") implementation("com.squareup.okhttp3:logging-interceptor")
//mintegral
implementation("com.reyun.solar.engine.oversea:solar-engine-core:1.2.8.3")
} }
\ No newline at end of file
...@@ -19,3 +19,19 @@ ...@@ -19,3 +19,19 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
-keep class com.reyun.** {*; }
-keep class route.**{*;}
-keep interface com.reyun.** {*; }
-keep interface route.**{*;}
-dontwarn com.reyun.**
-dontwarn org.json.**
-keep class org.json.**{*;}
# Google lib库
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
...@@ -6,10 +6,14 @@ ...@@ -6,10 +6,14 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application <application
android:name=".helper.MyApplication" android:name=".helper.MyApplication"
......
...@@ -20,7 +20,7 @@ public class MessagingService extends FirebaseMessagingService { ...@@ -20,7 +20,7 @@ public class MessagingService extends FirebaseMessagingService {
EventUtils.INSTANCE.event("FCM_Received", null, null, false); EventUtils.INSTANCE.event("FCM_Received", null, null, false);
String action = NotificationUiUtil.INSTANCE.getNextActionId(); String action = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(this, action, PopupConstObject.POPUP_WHERE_FCM); NotificationUiUtil.INSTANCE.sendNotificationIfCan(this, action, PopupConstObject.POPUP_WHERE_FCM);
} }
......
package com.base.pdfviewerscannerwhite.fcm
import android.content.Context
import android.os.Handler
import android.os.HandlerThread
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.AppPreferences
object NotificationHoverUtils {
private var handlerThread: HandlerThread? = null
private var handler: Handler? = null
/**
* 发送悬停通知
*/
fun sendHoverNotification(context: Context) {
if (handlerThread == null) {
handlerThread = HandlerThread("NotificationHandlerThread")
handlerThread?.start()
}
val hoverCount = AppPreferences.getInstance().getString("popup_hover_count", "0").toInt()
val hoverDelay = AppPreferences.getInstance().getString("popup_hover_delay", "0").toLong()
// 创建 Handler
if (handler == null) {
handlerThread?.let {
handler = Handler(it.getLooper())
}
}
for (i in 1..hoverCount) {
val time = i * hoverDelay
handler?.postDelayed(Runnable {
if (MyApplication.PAUSED_VALUE === 1) {
handler?.removeCallbacksAndMessages(null)
return@Runnable
}
if (MyApplication.PAUSED_VALUE !== 1) {
NotificationUiUtil.setActionNotification(context, NotificationUiUtil.hoverActionId)
}
}, time)
}
}
fun stopNotificationHandler() {
// 停止 HandlerThread
if (handler != null) {
handler?.removeCallbacksAndMessages(null)
}
if (handlerThread != null) {
handlerThread?.quit()
handlerThread = null
}
handler = null
}
}
\ No newline at end of file
...@@ -120,10 +120,30 @@ object NotificationUiUtil { ...@@ -120,10 +120,30 @@ object NotificationUiUtil {
return true return true
} }
var hoverActionId = ""
@SuppressLint("RemoteViewLayout") @SuppressLint("RemoteViewLayout")
fun sendNotification(context: Context, actionId: String, where: String = "") { fun sendNotificationIfCan(context: Context, actionId: String, where: String = "") {
if (!canSendNotification(where, actionId)) return if (!canSendNotification(where, actionId)) return
//发送通知
setActionNotification(context, actionId)
//上报通知
EventUtils.event("Notification_Popup", "where=$where actionId=$actionId")
//当天次数加一
dayPopupCount += 1
//推送时间
lastPopupTime = System.currentTimeMillis()
//悬停通知
hoverActionId = actionId
NotificationHoverUtils.sendHoverNotification(context)
}
fun setActionNotification(context: Context, actionId: String) {
val bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message) val bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
val smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message) val smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_message)
val intent = Intent(context, SplashActivity::class.java) val intent = Intent(context, SplashActivity::class.java)
...@@ -137,7 +157,7 @@ object NotificationUiUtil { ...@@ -137,7 +157,7 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle) smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc) bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews, where, actionId) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_READ_PDF -> { NOTIFICATION_ACTION_READ_PDF -> {
...@@ -147,7 +167,7 @@ object NotificationUiUtil { ...@@ -147,7 +167,7 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle) smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc) bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews, where, actionId) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_READ_DOCUMENTS -> { NOTIFICATION_ACTION_READ_DOCUMENTS -> {
...@@ -157,7 +177,7 @@ object NotificationUiUtil { ...@@ -157,7 +177,7 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle) smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc) bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews, where, actionId) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_UN_VIEW_FILES -> { NOTIFICATION_ACTION_UN_VIEW_FILES -> {
...@@ -167,7 +187,7 @@ object NotificationUiUtil { ...@@ -167,7 +187,7 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle) smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc) bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews, where, actionId) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_IMPORTANT_DOCUMENT -> { NOTIFICATION_ACTION_IMPORTANT_DOCUMENT -> {
...@@ -177,19 +197,20 @@ object NotificationUiUtil { ...@@ -177,19 +197,20 @@ object NotificationUiUtil {
smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle) smallRemoteViews.setTextViewText(R.id.tv_tittle, tittle)
bigRemoteViews.setTextViewText(R.id.tv_desc, desc) bigRemoteViews.setTextViewText(R.id.tv_desc, desc)
smallRemoteViews.setTextViewText(R.id.tv_desc, desc) smallRemoteViews.setTextViewText(R.id.tv_desc, desc)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews, where, actionId) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
else -> {
EventUtils.event("Notification_Error", "unKnow actionId actionId=$actionId")
} }
} }
} }
private fun sendCustomNotification( private fun sendCustomNotification(
context: Context, context: Context,
intent: Intent, intent: Intent,
bigRemoteViews: RemoteViews, bigRemoteViews: RemoteViews,
smallRemoteViews: RemoteViews, smallRemoteViews: RemoteViews,
where: String,
actionId: String,
) { ) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
...@@ -227,7 +248,6 @@ object NotificationUiUtil { ...@@ -227,7 +248,6 @@ object NotificationUiUtil {
.setPriority(NotificationCompat.PRIORITY_MAX) .setPriority(NotificationCompat.PRIORITY_MAX)
.setAutoCancel(true) .setAutoCancel(true)
var small: RemoteViews? = bigRemoteViews var small: RemoteViews? = bigRemoteViews
//Android 12以下需要适配小RemoteViews //Android 12以下需要适配小RemoteViews
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
...@@ -245,13 +265,6 @@ object NotificationUiUtil { ...@@ -245,13 +265,6 @@ object NotificationUiUtil {
builder.setCustomBigContentView(bigRemoteViews) builder.setCustomBigContentView(bigRemoteViews)
notificationManager.notify(NOTIFICATION_ID, builder.build()) notificationManager.notify(NOTIFICATION_ID, builder.build())
EventUtils.event("Notification_Popup", "where=$where actionId=$actionId")
//当天次数加一
dayPopupCount += 1
//推送时间
lastPopupTime = System.currentTimeMillis()
} }
val looper_actionId = listOf( val looper_actionId = listOf(
......
...@@ -8,6 +8,7 @@ object PopupConstObject { ...@@ -8,6 +8,7 @@ object PopupConstObject {
const val POPUP_WHERE_LOCK = "Lock" const val POPUP_WHERE_LOCK = "Lock"
const val POPUP_WHERE_FCM = "fcm" const val POPUP_WHERE_FCM = "fcm"
const val POPUP_WHERE_MEDIA_CHANGE = "media_change" const val POPUP_WHERE_MEDIA_CHANGE = "media_change"
const val POPUP_WHERE_HOVER_HANDLE = "hover_handle"//悬停调用
//推送总开关 0 关 1开 //推送总开关 0 关 1开
val popup_status = "popup_status" val popup_status = "popup_status"
......
...@@ -48,7 +48,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver { ...@@ -48,7 +48,7 @@ public class ScreenStatusReceiver extends BroadcastReceiver {
int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1")); int secureSetting = Integer.parseInt(AppPreferences.getInstance().getString("lockS", "1"));
if (secureSetting == 1) { if (secureSetting == 1) {
String actionId = NotificationUiUtil.INSTANCE.getNextActionId(); String actionId = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(context, actionId, PopupConstObject.POPUP_WHERE_LOCK); NotificationUiUtil.INSTANCE.sendNotificationIfCan(context, actionId, PopupConstObject.POPUP_WHERE_LOCK);
} }
} }
break; break;
......
...@@ -37,7 +37,7 @@ public class TimerManager { ...@@ -37,7 +37,7 @@ public class TimerManager {
MyApplication.PAUSED_VALUE != 1) { MyApplication.PAUSED_VALUE != 1) {
Log.d("glc", "Scheduled task conditions are met"); Log.d("glc", "Scheduled task conditions are met");
String actionId = NotificationUiUtil.INSTANCE.getNextActionId(); String actionId = NotificationUiUtil.INSTANCE.getNextActionId();
NotificationUiUtil.INSTANCE.sendNotification(MyApplication.context, actionId, PopupConstObject.POPUP_WHERE_TIMBER); NotificationUiUtil.INSTANCE.sendNotificationIfCan(MyApplication.context, actionId, PopupConstObject.POPUP_WHERE_TIMBER);
} }
} }
}; };
......
...@@ -5,6 +5,7 @@ import android.app.Application ...@@ -5,6 +5,7 @@ import android.app.Application
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.fcm.FCMManager import com.base.pdfviewerscannerwhite.fcm.FCMManager
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.topic_number import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.topic_number
import com.base.pdfviewerscannerwhite.fcm.ScreenStatusReceiver import com.base.pdfviewerscannerwhite.fcm.ScreenStatusReceiver
...@@ -12,10 +13,14 @@ import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity ...@@ -12,10 +13,14 @@ import com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatMinute import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatMinute
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime3
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.facebook.FacebookSdk import com.facebook.FacebookSdk
import com.reyun.solar.engine.OnAttributionListener
import com.reyun.solar.engine.OnInitializationCallback
import com.reyun.solar.engine.SolarEngineConfig
import com.reyun.solar.engine.SolarEngineManager
import com.tom_roush.pdfbox.android.PDFBoxResourceLoader import com.tom_roush.pdfbox.android.PDFBoxResourceLoader
import org.json.JSONObject
import java.util.Locale import java.util.Locale
import java.util.UUID import java.util.UUID
...@@ -66,6 +71,8 @@ class MyApplication : Application() { ...@@ -66,6 +71,8 @@ class MyApplication : Application() {
} }
fun initApp() { fun initApp() {
SolarEngineManager.getInstance().preInit(context, "81a11caa4076cd7c")
initSolarEngine()
FacebookSdk.sdkInitialize(applicationContext) FacebookSdk.sdkInitialize(applicationContext)
var topicNumber = System.currentTimeMillis().toFormatMinute() var topicNumber = System.currentTimeMillis().toFormatMinute()
LogEx.logDebug(TAG, "topicNumber=$topicNumber") LogEx.logDebug(TAG, "topicNumber=$topicNumber")
...@@ -83,6 +90,44 @@ class MyApplication : Application() { ...@@ -83,6 +90,44 @@ class MyApplication : Application() {
ScreenStatusReceiver.setupScreenStatusListener(this) ScreenStatusReceiver.setupScreenStatusListener(this)
} }
private fun initSolarEngine(gdprDeny: Boolean = false) {
val configBuilder = SolarEngineConfig.Builder()
if (BuildConfig.DEBUG) {
configBuilder.logEnabled() //开启本地调试日志
}
if (gdprDeny) {
configBuilder.isGDPRArea = true
configBuilder.adPersonalizationEnabled = true
configBuilder.adUserDataEnabled = true
}
configBuilder.isCoppaEnabled = true
configBuilder.setKidsAppEnabled(true)
configBuilder.fbAppID = ""
val config = configBuilder.build()
SolarEngineManager.getInstance().initialize(context, "81a11caa4076cd7c", config,
OnInitializationCallback { code ->
if (code == 0) {
//初始化成功
config.setOnAttributionListener(object : OnAttributionListener {
override fun onAttributionSuccess(attribution: JSONObject) {
//获取归因结果成功时执行的动作
}
override fun onAttributionFail(errorCode: Int) {
//获取归因结果失败时执行的动作
}
})
} else {
//初始化失败,具体失败原因参考下方code码释义
EventUtils.event("SolarEngineManager init error code=$code")
}
})
}
private var lastTimePause = 0L private var lastTimePause = 0L
private var lastTimeResume = 0L private var lastTimeResume = 0L
......
...@@ -23,7 +23,7 @@ class MediaContentObserver(val context: Context) : ContentObserver(null) { ...@@ -23,7 +23,7 @@ class MediaContentObserver(val context: Context) : ContentObserver(null) {
super.onChange(selfChange, uri) super.onChange(selfChange, uri)
LogEx.logDebug(TAG, "uri=${uri.toString()}") LogEx.logDebug(TAG, "uri=${uri.toString()}")
if (uri.toString().contains("images")) { if (uri.toString().contains("images")) {
NotificationUiUtil.sendNotification( NotificationUiUtil.sendNotificationIfCan(
context, context,
ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF, ConstObject.NOTIFICATION_ACTION_NEW_IMAGE_PDF,
PopupConstObject.POPUP_WHERE_MEDIA_CHANGE PopupConstObject.POPUP_WHERE_MEDIA_CHANGE
......
...@@ -14,6 +14,7 @@ import com.base.pdfviewerscannerwhite.ads.admob.AdmobOpenUtils ...@@ -14,6 +14,7 @@ import com.base.pdfviewerscannerwhite.ads.admob.AdmobOpenUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import com.base.pdfviewerscannerwhite.bean.ConstObject.isFirstStart import com.base.pdfviewerscannerwhite.bean.ConstObject.isFirstStart
import com.base.pdfviewerscannerwhite.databinding.ActivitySplash2Binding import com.base.pdfviewerscannerwhite.databinding.ActivitySplash2Binding
import com.base.pdfviewerscannerwhite.fcm.NotificationHoverUtils
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.MyApplication.Companion.umpCanAd import com.base.pdfviewerscannerwhite.helper.MyApplication.Companion.umpCanAd
import com.base.pdfviewerscannerwhite.service.StayNotificationService.Companion.startStayNotification import com.base.pdfviewerscannerwhite.service.StayNotificationService.Companion.startStayNotification
...@@ -56,6 +57,9 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView { ...@@ -56,6 +57,9 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
actionId = intent.extras?.getString("actionId") ?: "" actionId = intent.extras?.getString("actionId") ?: ""
LogEx.logDebug(TAG, "actionId=$actionId") LogEx.logDebug(TAG, "actionId=$actionId")
if (actionId.isNotEmpty()) {
NotificationHoverUtils.stopNotificationHandler()
}
// 获取当前日期 // 获取当前日期
...@@ -178,6 +182,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView { ...@@ -178,6 +182,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
firstStartJump() firstStartJump()
} else { } else {
LogEx.logDebug(TAG, "jumpNext actionId=$actionId") LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
when (actionId) { when (actionId) {
else -> { else -> {
startActivity(Intent(this, MainActivity::class.java).apply { startActivity(Intent(this, MainActivity::class.java).apply {
......
...@@ -18,11 +18,13 @@ dependencyResolutionManagement { ...@@ -18,11 +18,13 @@ dependencyResolutionManagement {
google() google()
mavenCentral() mavenCentral()
maven("https://s01.oss.sonatype.org/content/groups/public" ) maven("https://s01.oss.sonatype.org/content/groups/public")
maven("https://jitpack.io") maven("https://jitpack.io")
maven("https://android-sdk.is.com" ) maven("https://android-sdk.is.com")
maven("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" ) maven("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea")
maven("https://artifact.bytedance.com/repository/pangle" ) maven("https://artifact.bytedance.com/repository/pangle")
maven("https://dl-maven-android.mintegral.com/repository/se_sdk_for_android/")
} }
} }
......
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