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
92fede40
Commit
92fede40
authored
Oct 09, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
33f475df
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
414 additions
and
222 deletions
+414
-222
build.gradle.kts
app/build.gradle.kts
+10
-2
AdDisplayUtils.kt
...java/com/base/pdfviewerscannerwhite/ads/AdDisplayUtils.kt
+8
-8
AdmobHelper.kt
...in/java/com/base/pdfviewerscannerwhite/ads/AdmobHelper.kt
+73
-0
FirebaseDatabase.kt
...va/com/base/pdfviewerscannerwhite/ads/FirebaseDatabase.kt
+85
-156
RemoteConfigHelper.kt
.../com/base/pdfviewerscannerwhite/ads/RemoteConfigHelper.kt
+49
-49
InstallHelper.kt
...va/com/base/pdfviewerscannerwhite/helper/InstallHelper.kt
+73
-0
MyApplication.kt
...va/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
+1
-0
NewComUtils.kt
...java/com/base/pdfviewerscannerwhite/helper/NewComUtils.kt
+112
-0
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+0
-3
SplashActivity.kt
...om/base/pdfviewerscannerwhite/ui/splash/SplashActivity.kt
+2
-2
SplashPresenter.kt
...m/base/pdfviewerscannerwhite/ui/splash/SplashPresenter.kt
+1
-2
No files found.
app/build.gradle.kts
View file @
92fede40
...
...
@@ -109,11 +109,19 @@ dependencies {
implementation
(
"com.google.firebase:firebase-messaging"
)
implementation
(
"com.google.firebase:firebase-analytics-ktx"
)
implementation
(
"com.google.firebase:firebase-crashlytics"
)
implementation
(
"com.google.firebase:firebase-database-ktx"
)
implementation
(
"com.google.firebase:firebase-config-ktx"
)
//
implementation("com.google.firebase:firebase-database-ktx")
//
implementation("com.google.firebase:firebase-config-ktx")
//facebook
implementation
(
"com.facebook.android:facebook-android-sdk:[8,9)"
)
//网络请求和解析
implementation
(
"com.google.code.gson:gson:2.11.0"
)
// define a BOM and its version
implementation
(
platform
(
"com.squareup.okhttp3:okhttp-bom:4.12.0"
))
// define any required OkHttp artifacts without version
implementation
(
"com.squareup.okhttp3:okhttp"
)
implementation
(
"com.squareup.okhttp3:logging-interceptor"
)
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/AdDisplayUtils.kt
View file @
92fede40
package
com.base.pdfviewerscannerwhite.ads
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.inter_limit_click
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.inter_limit_request
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.inter_limit_show
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.native_limit_request
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.native_limit_show
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.open_limit_click
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.open_limit_request
import
com.base.pdfviewerscannerwhite.ads.
FirebaseDatabase
.open_limit_show
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.inter_limit_click
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.inter_limit_request
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.inter_limit_show
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.native_limit_request
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.native_limit_show
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.open_limit_click
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.open_limit_request
import
com.base.pdfviewerscannerwhite.ads.
AdmobHelper
.open_limit_show
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ads/AdmobHelper.kt
View file @
92fede40
...
...
@@ -7,6 +7,79 @@ import java.util.concurrent.atomic.AtomicBoolean
object
AdmobHelper
{
//开屏限制
const
val
open_limit_request
=
"open_limit_request"
const
val
open_limit_show
=
"open_limit_show"
const
val
open_limit_click
=
"open_limit_click"
//插页限制
const
val
inter_limit_request
=
"inter_limit_request"
const
val
inter_limit_show
=
"inter_limit_show"
const
val
inter_limit_click
=
"inter_limit_click"
//原生广告限制
const
val
native_limit_request
=
"native_limit_request"
const
val
native_limit_show
=
"native_limit_show"
const
val
native_limit_click
=
"native_limit_click"
//推送总数量现在
val
popup_count
=
"popup_count"
//所有常规推送的当日推送次数限制,0 为不限制
//推送总开关 0 关 1开
val
popup_status
=
"popup_status"
//推送样式一配置
val
popup_style1_start
=
"popup_style1_start"
val
popup_style1_end
=
"popup_style1_end"
val
popup_style1_status
=
"popup_style1_status"
val
popup_style1_count
=
"popup_style1_count"
val
popup_style1_interval
=
"popup_style1_interval"
//推送样式二配置
val
popup_style2_start
=
"popup_style2_start"
val
popup_style2_end
=
"popup_style2_end"
val
popup_style2_status
=
"popup_style2_status"
val
popup_style2_count
=
"popup_style2_count"
val
popup_style2_interval
=
"popup_style2_interval"
//推送样式三配置
val
popup_style3_start
=
"popup_style3_start"
val
popup_style3_end
=
"popup_style3_end"
val
popup_style3_status
=
"popup_style3_status"
val
popup_style3_count
=
"popup_style3_count"
val
popup_style3_interval
=
"popup_style3_interval"
//是否展示多语言
val
showLanPage
=
"showLanPage"
//开屏加载ad时间
val
open_ad_loading
=
"open_loading"
//创建pdf加载ad时间
val
create_pdf_loading
=
"create_pdf_loading"
//删除文件
val
delete_loading
=
"delete_loading"
//打开文件
val
open_file_loading
=
"open_file_loading"
//合并pdf
val
merge_loading
=
"merge_loading"
//拆分pdf
val
split_loading
=
"split_loading"
//可请求时间段(由 x 定义)
const
val
ad_request_period
=
"ad_request_interval"
//可请求时间段内允许的最大请求数(由 y 定义)
const
val
ad_period_max_request
=
"ad_period_max_request"
//可请求时间段间隔时间
const
val
ad_request_period_interval
=
"ad_request_period_interval"
//展示广告关闭时赋值
var
lastShowedOnHiddenTime
=
0L
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ads/FirebaseDatabase.kt
View file @
92fede40
package
com.base.pdfviewerscannerwhite.ads
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.firebase.database.DataSnapshot
import
com.google.firebase.database.DatabaseError
import
com.google.firebase.database.ValueEventListener
import
com.google.firebase.database.ktx.database
import
com.google.firebase.ktx.Firebase
//Realtime Database
object
FirebaseDatabase
{
private
val
TAG
=
"FirebaseDatabase"
// Write a message to the database
val
database
=
Firebase
.
database
var
rootRef
=
database
.
reference
//开屏限制
const
val
open_limit_request
=
"open_limit_request"
const
val
open_limit_show
=
"open_limit_show"
const
val
open_limit_click
=
"open_limit_click"
//插页限制
const
val
inter_limit_request
=
"inter_limit_request"
const
val
inter_limit_show
=
"inter_limit_show"
const
val
inter_limit_click
=
"inter_limit_click"
//原生广告限制
const
val
native_limit_request
=
"native_limit_request"
const
val
native_limit_show
=
"native_limit_show"
const
val
native_limit_click
=
"native_limit_click"
//推送总数量现在
val
popup_count
=
"popup_count"
//所有常规推送的当日推送次数限制,0 为不限制
//推送总开关 0 关 1开
val
popup_status
=
"popup_status"
//推送样式一配置
val
popup_style1_start
=
"popup_style1_start"
val
popup_style1_end
=
"popup_style1_end"
val
popup_style1_status
=
"popup_style1_status"
val
popup_style1_count
=
"popup_style1_count"
val
popup_style1_interval
=
"popup_style1_interval"
//推送样式二配置
val
popup_style2_start
=
"popup_style2_start"
val
popup_style2_end
=
"popup_style2_end"
val
popup_style2_status
=
"popup_style2_status"
val
popup_style2_count
=
"popup_style2_count"
val
popup_style2_interval
=
"popup_style2_interval"
//推送样式三配置
val
popup_style3_start
=
"popup_style3_start"
val
popup_style3_end
=
"popup_style3_end"
val
popup_style3_status
=
"popup_style3_status"
val
popup_style3_count
=
"popup_style3_count"
val
popup_style3_interval
=
"popup_style3_interval"
//是否展示多语言
val
showLanPage
=
"showLanPage"
//开屏加载ad时间
val
open_ad_loading
=
"open_loading"
//创建pdf加载ad时间
val
create_pdf_loading
=
"create_pdf_loading"
//删除文件
val
delete_loading
=
"delete_loading"
//打开文件
val
open_file_loading
=
"open_file_loading"
//合并pdf
val
merge_loading
=
"merge_loading"
//拆分pdf
val
split_loading
=
"split_loading"
//可请求时间段(由 x 定义)
const
val
ad_request_period
=
"ad_request_interval"
//可请求时间段内允许的最大请求数(由 y 定义)
const
val
ad_period_max_request
=
"ad_period_max_request"
//可请求时间段间隔时间
const
val
ad_request_period_interval
=
"ad_request_period_interval"
fun
saveDatabase2Sp
()
{
// add(open_limit_request, "15")
// add(open_limit_show, "10")
// add(open_limit_click, "1")
//package com.base.pdfviewerscannerwhite.ads
//
//import com.base.pdfviewerscannerwhite.utils.AppPreferences
//import com.base.pdfviewerscannerwhite.utils.LogEx
//import com.google.firebase.database.DataSnapshot
//import com.google.firebase.database.DatabaseError
//import com.google.firebase.database.ValueEventListener
//import com.google.firebase.database.ktx.database
//import com.google.firebase.ktx.Firebase
//
// add(inter_limit_request, "15")
// add(inter_limit_show, "10")
// add(inter_limit_click, "1")
////Realtime Database
//object FirebaseDatabase {
//
// add(native_limit_request, "15")
// add(native_limit_show, "10")
// add(native_limit_click, "1")
// private val TAG = "FirebaseDatabase"
//
// add(popup_count, "0")
// add(popup_status, "1")
// // Write a message to the database
// val database = Firebase.database
// var rootRef = database.reference
//
// add(popup_style1_start, "7")
// add(popup_style1_end, "11")
// add(popup_style1_count, "0")
// add(popup_style1_status, "1")
// add(popup_style1_interval, "120")
//
// add(popup_style2_start, "12")
// add(popup_style2_end, "17")
// add(popup_style2_count, "0")
// add(popup_style2_status, "1")
// add(popup_style2_interval, "120")
//
// add(popup_style3_start, "18")
// add(popup_style3_end, "24")
// add(popup_style3_count, "0")
// add(popup_style3_status, "1")
// add(popup_style3_interval, "120")
// fun saveDatabase2Sp() {
//// add(open_limit_request, "15")
//// add(open_limit_show, "10")
//// add(open_limit_click, "1")
////
////
//// add(inter_limit_request, "15")
//// add(inter_limit_show, "10")
//// add(inter_limit_click, "1")
////
//// add(native_limit_request, "15")
//// add(native_limit_show, "10")
//// add(native_limit_click, "1")
////
//// add(popup_count, "0")
//// add(popup_status, "1")
////
//// add(popup_style1_start, "7")
//// add(popup_style1_end, "11")
//// add(popup_style1_count, "0")
//// add(popup_style1_status, "1")
//// add(popup_style1_interval, "120")
////
//// add(popup_style2_start, "12")
//// add(popup_style2_end, "17")
//// add(popup_style2_count, "0")
//// add(popup_style2_status, "1")
//// add(popup_style2_interval, "120")
////
//// add(popup_style3_start, "18")
//// add(popup_style3_end, "24")
//// add(popup_style3_count, "0")
//// add(popup_style3_status, "1")
//// add(popup_style3_interval, "120")
////
//// add(showLanPage, "1")
////
//// add(open_ad_loading, "8000")
//// add(create_pdf_loading, "8000")
//// add(delete_loading, "8000")
//// add(open_file_loading, "8000")
//// add(merge_loading, "8000")
//// add(split_loading, "8000")
////
//// add(ad_request_period, "1")
//// add(ad_period_max_request, "10")
//// add(ad_request_period_interval, "60")
//
// add(showLanPage, "1")
//
// add(open_ad_loading, "8000")
// add(create_pdf_loading, "8000")
// add(delete_loading, "8000")
// add(open_file_loading, "8000")
// add(merge_loading, "8000")
// add(split_loading, "8000")
// rootRef.addListenerForSingleValueEvent(object : ValueEventListener {
// override fun onDataChange(dataSnapshot: DataSnapshot) {
// var i = 0
// for (snapshot in dataSnapshot.getChildren()) {
// val key1 = snapshot.key
// val value1 = snapshot.value
// i++
// LogEx.logDebug("Database", "Key: $key1, Value: $value1 $i")
// AppPreferences.getInstance().put(key1, value1)
// }
// }
//
// add(ad_request_period, "1")
// add(ad_period_max_request, "10")
// add(ad_request_period_interval, "60")
rootRef
.
addListenerForSingleValueEvent
(
object
:
ValueEventListener
{
override
fun
onDataChange
(
dataSnapshot
:
DataSnapshot
)
{
var
i
=
0
for
(
snapshot
in
dataSnapshot
.
getChildren
())
{
val
key1
=
snapshot
.
key
val
value1
=
snapshot
.
value
i
++
LogEx
.
logDebug
(
"Database"
,
"Key: $key1, Value: $value1 $i"
)
AppPreferences
.
getInstance
().
put
(
key1
,
value1
)
}
}
override
fun
onCancelled
(
databaseError
:
DatabaseError
)
{
LogEx
.
logDebug
(
"Database"
,
"onCancelled"
)
}
})
}
fun
add
(
ref
:
String
,
value
:
String
)
{
database
.
getReference
(
ref
).
setValue
(
value
)
}
}
\ No newline at end of file
// override fun onCancelled(databaseError: DatabaseError) {
// LogEx.logDebug("Database", "onCancelled")
// }
// })
//
// }
//
// fun add(ref: String, value: String) {
// database.getReference(ref).setValue(value)
// }
//
//
//}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/RemoteConfigHelper.kt
View file @
92fede40
package
com.base.pdfviewerscannerwhite.ads
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.firebase.ktx.Firebase
import
com.google.firebase.remoteconfig.ConfigUpdate
import
com.google.firebase.remoteconfig.ConfigUpdateListener
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
com.google.firebase.remoteconfig.FirebaseRemoteConfigException
import
com.google.firebase.remoteconfig.ktx.get
import
com.google.firebase.remoteconfig.ktx.remoteConfig
import
com.google.firebase.remoteconfig.ktx.remoteConfigSettings
object
RemoteConfigHelper
{
private
val
TAG
=
"RemoteConfigHelper"
fun
test
()
{
val
remoteConfig
:
FirebaseRemoteConfig
=
Firebase
.
remoteConfig
val
configSettings
=
remoteConfigSettings
{
minimumFetchIntervalInSeconds
=
3600
}
remoteConfig
.
setConfigSettingsAsync
(
configSettings
)
remoteConfig
.
setDefaultsAsync
(
R
.
xml
.
remote_config_defaults
)
//提取并激活值
remoteConfig
.
fetchAndActivate
().
addOnCompleteListener
{
task
->
if
(
task
.
isSuccessful
)
{
val
aa
=
remoteConfig
[
"a"
].
asString
()
LogEx
.
logDebug
(
TAG
,
"fetchAndActivate aa=$aa"
)
}
}
//监听跟新值
remoteConfig
.
addOnConfigUpdateListener
(
object
:
ConfigUpdateListener
{
override
fun
onUpdate
(
configUpdate
:
ConfigUpdate
)
{
remoteConfig
.
activate
().
addOnCompleteListener
{
val
aa2
=
remoteConfig
[
"a"
].
asString
()
LogEx
.
logDebug
(
TAG
,
"onUpdate aa=$aa2"
)
}
}
override
fun
onError
(
error
:
FirebaseRemoteConfigException
)
{
}
})
}
}
\ No newline at end of file
//package com.base.pdfviewerscannerwhite.ads
//
//import com.base.pdfviewerscannerwhite.R
//import com.base.pdfviewerscannerwhite.utils.LogEx
//import com.google.firebase.ktx.Firebase
//import com.google.firebase.remoteconfig.ConfigUpdate
//import com.google.firebase.remoteconfig.ConfigUpdateListener
//import com.google.firebase.remoteconfig.FirebaseRemoteConfig
//import com.google.firebase.remoteconfig.FirebaseRemoteConfigException
//import com.google.firebase.remoteconfig.ktx.get
//import com.google.firebase.remoteconfig.ktx.remoteConfig
//import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
//
//
//object RemoteConfigHelper {
// private val TAG = "RemoteConfigHelper"
// fun test() {
// val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
// val configSettings = remoteConfigSettings {
// minimumFetchIntervalInSeconds = 3600
// }
// remoteConfig.setConfigSettingsAsync(configSettings)
//
// remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
//
// //提取并激活值
// remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
// if (task.isSuccessful) {
// val aa = remoteConfig["a"].asString()
// LogEx.logDebug(TAG, "fetchAndActivate aa=$aa")
// }
// }
//
// //监听跟新值
// remoteConfig.addOnConfigUpdateListener(object : ConfigUpdateListener {
// override fun onUpdate(configUpdate: ConfigUpdate) {
// remoteConfig.activate().addOnCompleteListener {
// val aa2 = remoteConfig["a"].asString()
// LogEx.logDebug(TAG, "onUpdate aa=$aa2")
// }
// }
//
// override fun onError(error: FirebaseRemoteConfigException) {
// }
//
// })
// }
//
//}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/InstallHelper.kt
0 → 100644
View file @
92fede40
package
com.base.pdfviewerscannerwhite.helper
import
com.android.installreferrer.api.InstallReferrerClient
import
com.android.installreferrer.api.InstallReferrerStateListener
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
org.json.JSONObject
/**
* call before agree
*/
object
InstallHelps
{
private
val
TAG
=
"InstallHelps"
fun
init
()
{
val
referrerClient
=
InstallReferrerClient
.
newBuilder
(
MyApplication
.
context
).
build
()
referrerClient
.
startConnection
(
object
:
InstallReferrerStateListener
{
override
fun
onInstallReferrerSetupFinished
(
responseCode
:
Int
)
{
try
{
when
(
responseCode
)
{
InstallReferrerClient
.
InstallReferrerResponse
.
OK
->
{
val
response
=
referrerClient
.
installReferrer
val
installInfo
=
response
.
installReferrer
val
obj
=
JSONObject
()
obj
.
put
(
"referrerUrl"
,
response
.
installReferrer
)
obj
.
put
(
"referrerClickTime"
,
response
.
referrerClickTimestampSeconds
)
obj
.
put
(
"appInstallTime"
,
response
.
installBeginTimestampSeconds
)
obj
.
put
(
"instantExperienceLaunched"
,
installInfo
.
toString
())
EventUtils
.
event
(
"install_referrer"
,
ext
=
obj
,
isSingleEvent
=
true
)
AppPreferences
.
getInstance
().
put
(
"referrer"
,
response
.
installReferrer
)
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
}
)
{
//自然用户
if
(
BuildConfig
.
DEBUG
)
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
}
else
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"origin"
)
}
}
else
{
//渠道用户
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
}
requestCfg
()
}
else
->
{
EventUtils
.
event
(
"install_referrer_error"
)
requestCfg
()
}
}
}
catch
(
_
:
Exception
)
{
EventUtils
.
event
(
"install_referrer_error"
)
}
}
override
fun
onInstallReferrerServiceDisconnected
()
{
}
})
}
private
fun
requestCfg
()
{
NewComUtils
.
requestCfg
{
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
View file @
92fede40
...
...
@@ -49,6 +49,7 @@ class MyApplication : Application() {
LogEx
.
logDebug
(
TAG
,
"topic=${topic}"
)
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
InstallHelps
.
init
()
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/helper/NewComUtils.kt
0 → 100644
View file @
92fede40
package
com.base.pdfviewerscannerwhite.helper
import
android.util.Log
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.gson.Gson
import
com.google.gson.reflect.TypeToken
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
org.json.JSONObject
import
java.io.BufferedReader
import
java.io.InputStreamReader
import
java.net.HttpURLConnection
import
java.net.URL
import
java.util.Locale
object
NewComUtils
{
private
val
TAG
=
"NewComUtils"
private
const
val
API_URL
=
ConfigHelper
.
apiUrl
private
const
val
PACKAGE_NAME_PREFIX
=
ConfigHelper
.
packageName
private
const
val
DATA_KEY
=
"data"
private
val
url
:
String
by
lazy
{
val
packageName
=
ConfigHelper
.
packageName
val
appCode
=
packageName
.
substringAfter
(
PACKAGE_NAME_PREFIX
).
take
(
5
).
toLowerCase
(
Locale
.
getDefault
())
val
bRefer
=
android
.
util
.
Base64
.
encodeToString
(
AppPreferences
.
getInstance
().
getString
(
"referrerUrl"
,
""
).
toByteArray
(),
android
.
util
.
Base64
.
DEFAULT
)
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences
.
getInstance
().
getString
(
"gid"
,
""
)
}&
aid
=
$
{
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
)}
"
// &mode=3
}
fun
requestCfg
(
callback
:
()
->
Unit
)
{
CoroutineScope
(
Dispatchers
.
IO
).
launch
{
val
response
=
doGet
()
if
(
response
==
null
)
{
withContext
(
Dispatchers
.
Main
)
{
callback
()
}
return
@launch
}
val
data
=
extractData
(
response
)
if
(
data
==
null
)
{
withContext
(
Dispatchers
.
Main
)
{
callback
()
}
return
@launch
}
val
decryptedData
=
AESHelper
.
decrypt
(
data
)
parseConfigBean
(
decryptedData
)
withContext
(
Dispatchers
.
Main
)
{
callback
()
}
}
}
private
fun
doGet
():
String
?
{
val
urlPath
=
url
Log
.
d
(
"okhttp"
,
urlPath
)
try
{
val
conn
:
HttpURLConnection
=
URL
(
urlPath
).
openConnection
()
as
HttpURLConnection
conn
.
setRequestMethod
(
"GET"
)
conn
.
connectTimeout
=
150000
if
(
200
==
conn
.
getResponseCode
())
{
val
json
=
BufferedReader
(
InputStreamReader
(
conn
.
inputStream
)).
readLine
()
Log
.
d
(
"okhttp"
,
json
)
return
json
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
Log
.
d
(
"okhttp"
,
e
.
toString
())
}
return
null
}
private
fun
extractData
(
response
:
String
):
String
?
{
val
regex
=
Regex
(
"\"$DATA_KEY\":\"(.*?)\""
)
val
match
=
regex
.
find
(
response
)
return
match
?.
groupValues
?.
get
(
1
)
}
private
fun
parseConfigBean
(
json
:
String
)
{
Log
.
d
(
"okhttp"
,
json
)
val
gson
=
Gson
()
val
type
=
object
:
TypeToken
<
Map
<
String
,
String
>>()
{}.
type
val
configMap
=
gson
.
fromJson
<
Map
<
String
,
String
>>(
json
,
type
)
configMap
.
forEach
{
t
,
u
->
// 对于整型值使用parseInt, 长整型使用parseLong
AppPreferences
.
getInstance
().
put
(
t
,
u
)
LogEx
.
logDebug
(
TAG
,
"t=$t u=$u"
)
}
val
jsonObject
=
JSONObject
()
jsonObject
.
put
(
"ut"
,
AppPreferences
.
getInstance
().
getString
(
"ut"
,
""
))
EventUtils
.
event
(
"user_type"
,
ext
=
jsonObject
)
}
}
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
92fede40
...
...
@@ -4,13 +4,11 @@ import android.app.Activity
import
android.content.Intent
import
android.net.Uri
import
android.os.Bundle
import
android.util.Log
import
android.view.View
import
androidx.activity.OnBackPressedCallback
import
androidx.fragment.app.Fragment
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.ads.FirebaseDatabase
import
com.base.pdfviewerscannerwhite.ads.RemoteConfigHelper
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
...
...
@@ -61,7 +59,6 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
mainPresenter
.
initScannerLauncher
(
this
)
FirebaseDatabase
.
saveDatabase2Sp
()
RemoteConfigHelper
.
test
()
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/splash/SplashActivity.kt
View file @
92fede40
...
...
@@ -83,8 +83,8 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
if
(
job
==
null
&&
binding
.
progressBar
.
progress
!=
100
)
{
job
=
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
while
(
isActive
)
{
binding
.
progressBar
.
progress
+=
2
delay
(
20
0
)
binding
.
progressBar
.
progress
+=
1
delay
(
15
0
)
if
(
binding
.
progressBar
.
progress
==
100
)
{
cancel
()
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/splash/SplashPresenter.kt
View file @
92fede40
...
...
@@ -2,7 +2,6 @@ package com.base.pdfviewerscannerwhite.ui.splash
import
androidx.lifecycle.LifecycleCoroutineScope
import
com.base.pdfviewerscannerwhite.ads.FirebaseDatabase.open_ad_loading
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
kotlinx.coroutines.Job
...
...
@@ -22,7 +21,7 @@ class SplashPresenter(
* 超时跳转
*/
fun
startJumpJob
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
)
{
AppPreferences
.
getInstance
().
put
(
open_ad_loading
,
"8"
)
loadingTime
=
30
if
(
jumpJob
==
null
)
{
val
startTime
=
System
.
currentTimeMillis
()
jumpJob
=
lifecycleCoroutineScope
.
launch
{
...
...
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