Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White ago
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kuxulei
PDF Viewer Scanner White ago
Commits
2b82585b
Commit
2b82585b
authored
Oct 10, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
565b2889
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
195 additions
and
6 deletions
+195
-6
build.gradle.kts
app/build.gradle.kts
+3
-0
ConfigHelper.kt
...ava/com/base/pdfviewerscannerwhite/helper/ConfigHelper.kt
+12
-0
MyApplication.kt
...va/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
+76
-0
SplashActivity.kt
...om/base/pdfviewerscannerwhite/ui/splash/SplashActivity.kt
+23
-6
UmpUtils.kt
...ain/java/com/base/pdfviewerscannerwhite/utils/UmpUtils.kt
+81
-0
No files found.
app/build.gradle.kts
View file @
2b82585b
...
@@ -105,6 +105,9 @@ dependencies {
...
@@ -105,6 +105,9 @@ dependencies {
implementation
(
"com.google.ads.mediation:mintegral:16.7.21.0"
)
implementation
(
"com.google.ads.mediation:mintegral:16.7.21.0"
)
implementation
(
"com.google.ads.mediation:pangle:5.9.0.4.0"
)
implementation
(
"com.google.ads.mediation:pangle:5.9.0.4.0"
)
//ump
implementation
(
"com.google.android.ump:user-messaging-platform:3.0.0"
)
//firebase
//firebase
implementation
(
platform
(
"com.google.firebase:firebase-bom:32.3.1"
))
implementation
(
platform
(
"com.google.firebase:firebase-bom:32.3.1"
))
implementation
(
"com.google.firebase:firebase-messaging"
)
implementation
(
"com.google.firebase:firebase-messaging"
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/helper/ConfigHelper.kt
View file @
2b82585b
package
com.base.pdfviewerscannerwhite.helper
package
com.base.pdfviewerscannerwhite.helper
import
com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
object
ConfigHelper
{
object
ConfigHelper
{
const
val
privacyPolicy
:
String
=
"https://sites.google.com/view/pdf-reader-scan/pdf-reader"
const
val
privacyPolicy
:
String
=
"https://sites.google.com/view/pdf-reader-scan/pdf-reader"
...
@@ -23,4 +25,14 @@ object ConfigHelper {
...
@@ -23,4 +25,14 @@ object ConfigHelper {
const
val
nativeAdmobId
=
"ca-app-pub-3940256099942544/2247696111"
const
val
nativeAdmobId
=
"ca-app-pub-3940256099942544/2247696111"
const
val
openAdmobId
=
"/6499/example/app-open"
const
val
openAdmobId
=
"/6499/example/app-open"
const
val
bannerAdmobId
=
"ca-app-pub-3940256099942544/9214581111"
const
val
bannerAdmobId
=
"ca-app-pub-3940256099942544/9214581111"
val
noLoadingActivities
=
listOf
(
"full"
,
// 过滤全屏广告
"adActivity"
,
"AdActivity"
,
"AppLovinFullscreenActivity"
,
SplashActivity
::
class
.
java
.
simpleName
// 返回前台时不跳转启动页的 activity
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
View file @
2b82585b
package
com.base.pdfviewerscannerwhite.helper
package
com.base.pdfviewerscannerwhite.helper
import
android.app.Activity
import
android.app.Application
import
android.app.Application
import
android.content.Intent
import
android.os.Bundle
import
android.text.TextUtils
import
android.text.TextUtils
import
com.base.pdfviewerscannerwhite.fcm.FCMManager
import
com.base.pdfviewerscannerwhite.fcm.FCMManager
import
com.base.pdfviewerscannerwhite.ui.splash.SplashActivity
import
com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.facebook.FacebookSdk
import
com.facebook.FacebookSdk
...
@@ -60,7 +65,78 @@ class MyApplication : Application() {
...
@@ -60,7 +65,78 @@ class MyApplication : Application() {
FCMManager
.
initFirebase
(
this
)
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
FCMManager
.
subscribeToTopic
(
topic
)
InstallHelps
.
init
()
InstallHelps
.
init
()
initLifeListener
()
}
}
private
var
lastTimePause
=
0L
private
var
lastTimeResume
=
0L
private
fun
isHotLaunch
():
Boolean
{
if
((
lastTimeResume
-
lastTimePause
)
>
2000
)
{
return
true
}
return
false
}
private
fun
initLifeListener
()
{
registerActivityLifecycleCallbacks
(
object
:
ActivityLifecycleCallbacks
{
private
var
count
=
0
override
fun
onActivityCreated
(
activity
:
Activity
,
savedInstanceState
:
Bundle
?)
{
ActivityManagerUtils
.
getInstance
().
addActivity
(
activity
)
}
override
fun
onActivityStarted
(
activity
:
Activity
)
{
LogEx
.
logDebug
(
TAG
,
"onActivityStarted"
)
count
++
lastTimeResume
=
System
.
currentTimeMillis
()
if
(
count
==
1
&&
isHotLaunch
())
{
val
topActivity
:
Activity
?
=
ActivityManagerUtils
.
getInstance
().
topActivity
val
flag
=
if
(
topActivity
==
null
)
{
true
}
else
{
ConfigHelper
.
noLoadingActivities
.
all
{
!
topActivity
.
localClassName
.
contains
(
it
,
true
)
}
}
LogEx
.
logDebug
(
TAG
,
"flag=$flag"
+
" activity:"
+
activity
.
localClassName
)
if
(
flag
)
{
topActivity
?.
startActivity
(
Intent
(
topActivity
,
SplashActivity
::
class
.
java
).
apply
{
putExtra
(
"isHotLaunch"
,
true
)
putExtra
(
"type"
,
-
1
)
})
}
}
lastTimeResume
=
0
}
override
fun
onActivityResumed
(
activity
:
Activity
)
{
// LogEx.logDebug(TAG, "onActivityResumed")
PAUSED_VALUE
=
1
}
override
fun
onActivityPaused
(
activity
:
Activity
)
{
// LogEx.logDebug(TAG, "onActivityPaused")
PAUSED_VALUE
=
2
lastTimePause
=
System
.
currentTimeMillis
()
}
override
fun
onActivityStopped
(
activity
:
Activity
)
{
count
--
}
override
fun
onActivitySaveInstanceState
(
activity
:
Activity
,
outState
:
Bundle
)
{}
override
fun
onActivityDestroyed
(
activity
:
Activity
)
{
ActivityManagerUtils
.
getInstance
().
removeActivity
(
activity
)
}
})
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/splash/SplashActivity.kt
View file @
2b82585b
...
@@ -19,6 +19,8 @@ import com.base.pdfviewerscannerwhite.ui.main.MainActivity
...
@@ -19,6 +19,8 @@ import com.base.pdfviewerscannerwhite.ui.main.MainActivity
import
com.base.pdfviewerscannerwhite.ui.set.SetLanguageActivity
import
com.base.pdfviewerscannerwhite.ui.set.SetLanguageActivity
import
com.base.pdfviewerscannerwhite.utils.BarUtils
import
com.base.pdfviewerscannerwhite.utils.BarUtils
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.UmpUtils
import
com.base.pdfviewerscannerwhite.utils.UmpUtils.requestUMP
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.cancel
import
kotlinx.coroutines.cancel
...
@@ -39,7 +41,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
...
@@ -39,7 +41,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
ActivitySplashBinding
.
inflate
(
layoutInflater
)
ActivitySplashBinding
.
inflate
(
layoutInflater
)
}
}
var
canAd
:
Boolean
=
true
override
fun
initView
()
{
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
TRANSPARENT
)
...
@@ -53,12 +55,25 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
...
@@ -53,12 +55,25 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
ifAgreePrivacy
=
true
ifAgreePrivacy
=
true
if
(
ifAgreePrivacy
)
{
if
(
ifAgreePrivacy
)
{
agreePrivacy
()
requestUMP
(
this
,
}
else
{
loadAndShowErrorAction
=
{
LogEx
.
logDebug
(
TAG
,
"loadAndShowErrorAction"
)
agreePrivacy
()
},
formErrorAction
=
{
LogEx
.
logDebug
(
TAG
,
"formErrorAction"
)
agreePrivacy
()
},
dialogAction
=
{
LogEx
.
logDebug
(
TAG
,
"dialogAction $it"
)
canAd
=
it
agreePrivacy
()
})
}
}
}
}
override
fun
showAd
()
{
override
fun
showAd
()
{
AdmobOpenUtils
.
loadAppOpenAd
{
AdmobOpenUtils
.
loadAppOpenAd
{
AdmobOpenUtils
.
showAppOpenAd
(
this
,
showBefore
=
{
AdmobOpenUtils
.
showAppOpenAd
(
this
,
showBefore
=
{
...
@@ -74,8 +89,10 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
...
@@ -74,8 +89,10 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
override
fun
agreePrivacy
()
{
override
fun
agreePrivacy
()
{
startStayNotification
()
startStayNotification
()
initAdmobAd
()
if
(
canAd
)
{
showAd
()
initAdmobAd
()
showAd
()
}
startProgressJob
()
startProgressJob
()
splashPresenter
.
startJumpJob
(
lifecycleScope
)
splashPresenter
.
startJumpJob
(
lifecycleScope
)
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/utils/UmpUtils.kt
0 → 100644
View file @
2b82585b
package
com.base.pdfviewerscannerwhite.utils
import
android.app.Activity
import
android.content.Context
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.google.android.ump.ConsentDebugSettings
import
com.google.android.ump.ConsentInformation
import
com.google.android.ump.ConsentRequestParameters
import
com.google.android.ump.FormError
import
com.google.android.ump.UserMessagingPlatform
object
UmpUtils
{
// requireActivity().requestUMP(loadAndShowErrorAction = {
// Toast.makeText(context, "loadAndShowErrorAction", Toast.LENGTH_SHORT).show()
// }, formErrorAction = {
// Toast.makeText(context, "formErrorAction", Toast.LENGTH_SHORT).show()
// },
// dialogAction = {
// Toast.makeText(context, "dialogAction flag=$it", Toast.LENGTH_SHORT).show()
//
// })
private
fun
Context
.
umpTest
():
ConsentDebugSettings
{
val
debugSettings
=
ConsentDebugSettings
.
Builder
(
this
)
debugSettings
.
addTestDeviceHashedId
(
"TEST-DEVICE-HASHED-ID"
)
debugSettings
.
addTestDeviceHashedId
(
"33BE2250B43518CCDA7DE426D04EE231"
)
return
debugSettings
.
build
()
}
private
val
TAG
=
"UmpHelp"
fun
requestUMP
(
activity
:
Activity
,
loadAndShowErrorAction
:
(()
->
Unit
)?
=
null
,
//加载弹出错误
formErrorAction
:
(()
->
Unit
)?
=
null
,
//请求错误
dialogAction
:
((
flag
:
Boolean
)
->
Unit
)?
=
null
,
//dialog授权
)
{
var
callBacked
:
Boolean
=
false
val
paramsBuild
=
ConsentRequestParameters
.
Builder
()
if
(
BuildConfig
.
DEBUG
)
{
paramsBuild
.
setConsentDebugSettings
(
activity
.
umpTest
())
}
// 指示用户是否低于同意年龄; true 低于同意年龄
// 未满同意年龄的用户不会收到 GDPR 消息表单
paramsBuild
.
setTagForUnderAgeOfConsent
(
false
)
val
params
=
paramsBuild
.
build
()
val
consentInformation
=
UserMessagingPlatform
.
getConsentInformation
(
activity
)
val
updateSuccessListener
=
ConsentInformation
.
OnConsentInfoUpdateSuccessListener
{
UserMessagingPlatform
.
loadAndShowConsentFormIfRequired
(
activity
)
{
loadAndShowError
:
FormError
?
->
if
(
loadAndShowError
!=
null
)
{
if
(!
callBacked
)
{
callBacked
=
true
loadAndShowErrorAction
?.
invoke
()
}
}
else
{
// Consent has been gathered.
// 授权完成,初始化SDK
if
(!
callBacked
)
{
callBacked
=
true
dialogAction
?.
invoke
(
consentInformation
.
canRequestAds
())
}
}
}
}
val
updateFailureListener
=
ConsentInformation
.
OnConsentInfoUpdateFailureListener
{
if
(!
callBacked
)
{
callBacked
=
true
formErrorAction
?.
invoke
()
}
}
consentInformation
.
requestConsentInfoUpdate
(
activity
,
params
,
updateSuccessListener
,
updateFailureListener
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment