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
16f75fc7
Commit
16f75fc7
authored
Oct 08, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...ad
parent
8759bdfd
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1565 additions
and
3 deletions
+1565
-3
build.gradle.kts
app/build.gradle.kts
+15
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+4
-0
AdDialog.kt
.../main/java/com/base/pdfviewerscannerwhite/ads/AdDialog.kt
+35
-0
AdDisplayUtils.java
...va/com/base/pdfviewerscannerwhite/ads/AdDisplayUtils.java
+307
-0
AdmobBannerColla.kt
.../base/pdfviewerscannerwhite/ads/admob/AdmobBannerColla.kt
+90
-0
AdmobEvent.kt
...va/com/base/pdfviewerscannerwhite/ads/admob/AdmobEvent.kt
+248
-0
AdmobHelper.kt
...a/com/base/pdfviewerscannerwhite/ads/admob/AdmobHelper.kt
+7
-0
AdmobInterstitialUtils.kt
...pdfviewerscannerwhite/ads/admob/AdmobInterstitialUtils.kt
+181
-0
AdmobNativeUtils.kt
.../base/pdfviewerscannerwhite/ads/admob/AdmobNativeUtils.kt
+141
-0
AdmobOpenUtils.kt
...om/base/pdfviewerscannerwhite/ads/admob/AdmobOpenUtils.kt
+145
-0
NativeView.kt
...va/com/base/pdfviewerscannerwhite/ads/admob/NativeView.kt
+62
-0
AESHelper.kt
...n/java/com/base/pdfviewerscannerwhite/helper/AESHelper.kt
+62
-0
ConfigHelper.kt
...ava/com/base/pdfviewerscannerwhite/helper/ConfigHelper.kt
+19
-0
EventUtils.kt
.../java/com/base/pdfviewerscannerwhite/helper/EventUtils.kt
+81
-0
MyApplication.kt
...va/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
+0
-1
ReportUtils.java
...va/com/base/pdfviewerscannerwhite/helper/ReportUtils.java
+56
-0
LogEx.kt
...c/main/java/com/base/pdfviewerscannerwhite/utils/LogEx.kt
+1
-1
bg_f2f2f2.xml
app/src/main/res/drawable/bg_f2f2f2.xml
+5
-0
bg_ff8a00_10.xml
app/src/main/res/drawable/bg_ff8a00_10.xml
+5
-0
layout_admob_native_custom.xml
app/src/main/res/layout/layout_admob_native_custom.xml
+99
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/build.gradle.kts
View file @
16f75fc7
...
...
@@ -81,7 +81,6 @@ dependencies {
implementation
(
"io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4"
)
implementation
(
"com.github.angcyo.DslTablayout:TabLayout:3.5.5"
)
implementation
(
"com.github.angcyo.DslTablayout:ViewPager2Delegate:3.5.5"
)
// implementation("com.github.lukelorusso:VerticalSeekBar:1.2.5")
//mlkit
implementation
(
"com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1"
)
...
...
@@ -96,5 +95,20 @@ dependencies {
//Excel库
api
(
project
(
":library"
))
//广告
implementation
(
"com.google.android.gms:play-services-ads:23.1.0"
)
implementation
(
"com.google.ads.mediation:applovin:12.4.3.0"
)
implementation
(
"com.google.ads.mediation:facebook:6.17.0.0"
)
implementation
(
"com.google.ads.mediation:mintegral:16.7.21.0"
)
implementation
(
"com.google.ads.mediation:pangle:5.9.0.4.0"
)
//firebase
implementation
(
platform
(
"com.google.firebase:firebase-bom:32.3.1"
))
implementation
(
"com.google.firebase:firebase-messaging"
)
implementation
(
"com.google.firebase:firebase-analytics-ktx"
)
implementation
(
"com.google.firebase:firebase-crashlytics"
)
//facebook
implementation
(
"com.facebook.android:facebook-android-sdk:[8,9)"
)
}
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
16f75fc7
...
...
@@ -118,6 +118,10 @@
android:name=
"android.support.FILE_PROVIDER_PATHS"
android:resource=
"@xml/file_paths"
/>
</provider>
<meta-data
android:name=
"com.facebook.sdk.ApplicationId"
android:value=
"@string/facebook_app_id"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/AdDialog.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads
import
android.animation.ObjectAnimator
import
android.animation.ValueAnimator.INFINITE
import
android.app.AlertDialog
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.animation.LinearInterpolator
object
AdDialog
{
// fun Context.showAdPreparingDialog(): AlertDialog {
// val binding = DialogAdPreparingBinding.inflate(LayoutInflater.from(this))
// val dialog = AlertDialog.Builder(this).create()
// dialog.setView(binding.root)
// dialog.setCancelable(false)
// dialog.setCanceledOnTouchOutside(false)
//
// dialog.show()
// val params = dialog.window?.attributes
// params?.width = resources.getDimensionPixelOffset(R.dimen.dp_200)
// params?.height = resources.getDimensionPixelOffset(R.dimen.dp_146)
// dialog.window?.attributes = params
// dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
//
// // 创建一个旋转动画
// val rotateAnimator = ObjectAnimator.ofFloat(binding.iv, "rotation", 0f, -360f)
// rotateAnimator.setDuration(1000) // 设置动画持续时间为1000毫秒
// rotateAnimator.repeatCount = INFINITE
// rotateAnimator.interpolator = LinearInterpolator() // 设置插值器为线性插值
// rotateAnimator.start()
//
// return dialog
// }
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/AdDisplayUtils.java
0 → 100644
View file @
16f75fc7
package
com
.
base
.
pdfviewerscannerwhite
.
ads
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.util.Log
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Locale
;
import
com.base.pdfviewerscannerwhite.BuildConfig
;
import
com.base.pdfviewerscannerwhite.helper.EventUtils
;
import
com.base.pdfviewerscannerwhite.helper.MyApplication
;
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
;
import
com.base.pdfviewerscannerwhite.utils.LogEx
;
import
com.facebook.appevents.AppEventsLogger
;
public
class
AdDisplayUtils
{
private
String
TAG
=
"AdDisplayUtils"
;
public
static
final
int
DEFAULT_MAX_AD_REQUEST_COUNT
=
100
;
// 广告请求次数限制默认值
public
static
final
int
DEFAULT_MAX_AD_REQUEST_FAIL_COUNT
=
20
;
// 单个广告点击次数限制默认值
public
static
final
int
DEFAULT_MAX_AD_DISPLAY_COUNT
=
45
;
// 总广告展示次数限制默认值
public
static
final
int
DEFAULT_MAX_AD_CLICK_COUNT
=
10
;
// 单个广告点击次数限制默认值
private
static
final
String
AD_PREFS_NAME
=
"ad_prefs"
;
// SharedPreferences 名称
private
static
AdDisplayUtils
instance
;
// 单例对象
private
String
currentDate
;
// 当前日期
private
Context
context
=
MyApplication
.
context
;
public
void
saveSp
()
{
this
.
maxAdRequestCount
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
"adMaxRequestCount"
,
String
.
valueOf
(
DEFAULT_MAX_AD_REQUEST_COUNT
)));
saveMaxAdRequestCount
();
this
.
maxAdRequestFailCount
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
"adRequestFailCount"
,
String
.
valueOf
(
DEFAULT_MAX_AD_REQUEST_FAIL_COUNT
)));
saveMaxAdRequestFailCount
();
this
.
maxAdDisplayCount
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
"adShowCount"
,
String
.
valueOf
(
DEFAULT_MAX_AD_DISPLAY_COUNT
)));
saveMaxAdDisplayCount
();
this
.
maxAdClickCount
=
Integer
.
parseInt
(
AppPreferences
.
getInstance
().
getString
(
"adClickCount"
,
String
.
valueOf
(
DEFAULT_MAX_AD_CLICK_COUNT
)));
saveMaxAdClickCount
();
}
private
AdDisplayUtils
()
{
currentDate
=
getCurrentDate
();
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
maxAdRequestCount
=
prefs
.
getInt
(
MAX_AD_REQUEST_COUNT_KEY
,
DEFAULT_MAX_AD_REQUEST_COUNT
);
maxAdRequestFailCount
=
prefs
.
getInt
(
MAX_AD_REQUEST_FAIL_COUNT_KEY
,
DEFAULT_MAX_AD_REQUEST_FAIL_COUNT
);
maxAdDisplayCount
=
prefs
.
getInt
(
MAX_AD_DISPLAY_COUNT_KEY
,
DEFAULT_MAX_AD_DISPLAY_COUNT
);
maxAdClickCount
=
prefs
.
getInt
(
MAX_AD_CLICK_COUNT_KEY
,
DEFAULT_MAX_AD_CLICK_COUNT
);
adRequestCount
=
prefs
.
getInt
(
getAdRequestCountKey
(),
0
);
adRequestFailCount
=
prefs
.
getInt
(
getAdRequestFailCountKey
(),
0
);
adDisplayCount
=
prefs
.
getInt
(
getAdDisplayCountKey
(),
0
);
adClickCount
=
prefs
.
getInt
(
getAdClickCountKey
(),
0
);
}
public
static
synchronized
AdDisplayUtils
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
AdDisplayUtils
();
}
return
instance
;
}
public
boolean
shouldSendAdRequest
()
{
return
adRequestCount
<
maxAdRequestCount
;
}
public
boolean
shouldIncrementRequestFailAd
()
{
return
adRequestFailCount
<
maxAdRequestFailCount
;
}
public
boolean
shouldDisplayAd
()
{
return
adDisplayCount
<
maxAdDisplayCount
;
}
public
boolean
shouldIncrementClickCount
()
{
return
adClickCount
<
maxAdClickCount
;
}
public
boolean
shouldShowAd
(
String
ad_unit
)
{
if
(
BuildConfig
.
DEBUG
)
{
return
true
;
}
boolean
shouldDisplayAd
=
shouldDisplayAd
();
boolean
shouldIncrementClickCount
=
shouldIncrementClickCount
();
boolean
shouldIncrementRequestFailAd
=
shouldIncrementRequestFailAd
();
boolean
shouldSendAdRequest
=
shouldSendAdRequest
();
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"shouldSendAdRequest="
+
shouldSendAdRequest
,
false
);
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"shouldIncrementRequestFailAd="
+
shouldIncrementRequestFailAd
,
false
);
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"shouldIncrementClickCount="
+
shouldIncrementClickCount
,
false
);
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"shouldDisplayAd="
+
shouldDisplayAd
,
false
);
boolean
show
=
shouldIncrementRequestFailAd
&&
shouldSendAdRequest
&&
shouldDisplayAd
&&
shouldIncrementClickCount
;
if
(!
show
)
{
LogEx
.
INSTANCE
.
logDebug
(
"glc"
,
"!shouldShowAd"
,
false
);
JSONObject
obj2
=
new
JSONObject
();
try
{
obj2
.
put
(
"reason"
,
"ad_limit"
);
obj2
.
put
(
"shouldSendAdRequest"
,
shouldSendAdRequest
);
obj2
.
put
(
"shouldIncrementRequestFailAd"
,
shouldIncrementRequestFailAd
);
obj2
.
put
(
"shouldDisplayAd"
,
shouldDisplayAd
);
obj2
.
put
(
"shouldIncrementClickCount"
,
shouldIncrementClickCount
);
obj2
.
put
(
"adDisplayCount"
,
adDisplayCount
);
obj2
.
put
(
"maxAdDisplayCount"
,
maxAdDisplayCount
);
obj2
.
put
(
"adClickCount"
,
adClickCount
);
obj2
.
put
(
"maxAdClickCount"
,
maxAdClickCount
);
obj2
.
put
(
"adRequestFailCount"
,
adRequestFailCount
);
obj2
.
put
(
"adRequestCount"
,
maxAdRequestFailCount
);
obj2
.
put
(
"adRequestCount"
,
adRequestCount
);
obj2
.
put
(
"ad_unit"
,
ad_unit
);
EventUtils
.
INSTANCE
.
event
(
"ad_limit"
,
null
,
obj2
,
false
);
}
catch
(
JSONException
ignored
)
{
}
}
return
show
;
}
//region AdRequestCount
private
int
maxAdRequestCount
=
0
;
// 最大广告请求次数
private
int
adRequestCount
=
0
;
// 当前广告请求次数
private
static
final
String
MAX_AD_REQUEST_COUNT_KEY
=
"max_ad_request_count"
;
// 广告请求次数限制的键
private
static
final
String
AD_REQUEST_COUNT_KEY
=
"ad_request_count"
;
//广告请求次数
private
void
saveMaxAdRequestCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
MAX_AD_REQUEST_COUNT_KEY
,
maxAdRequestCount
);
editor
.
apply
();
}
public
void
incrementAdRequestCount
()
{
if
(!
currentDate
.
equals
(
getCurrentDate
()))
{
currentDate
=
getCurrentDate
();
adRequestCount
=
0
;
}
adRequestCount
++;
saveAdRequestCount
();
}
private
String
getAdRequestCountKey
()
{
return
AD_REQUEST_COUNT_KEY
+
"_"
+
currentDate
;
}
private
void
saveAdRequestCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
getAdRequestCountKey
(),
adRequestCount
);
editor
.
apply
();
}
//endregion
//region AdRequestFailCount
private
int
maxAdRequestFailCount
;
// 请求失败总
private
int
adRequestFailCount
=
0
;
// 请求失败当前
private
static
final
String
MAX_AD_REQUEST_FAIL_COUNT_KEY
=
"max_ad_request_fail_count"
;
// 单个广告点击次数限制的键
private
static
final
String
AD_REQUEST_FAIL_COUNT_KEY
=
"ad_request_fail_count"
;
// 单个广告点击次数限制的键
private
void
saveMaxAdRequestFailCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
MAX_AD_REQUEST_FAIL_COUNT_KEY
,
maxAdRequestFailCount
);
editor
.
apply
();
}
public
void
incrementAdRequestFailCount
()
{
if
(!
currentDate
.
equals
(
getCurrentDate
()))
{
currentDate
=
getCurrentDate
();
adRequestFailCount
=
0
;
}
adRequestFailCount
++;
saveAdRequestFailCount
();
Log
.
d
(
"glc"
,
"广告请求失败:"
+
adRequestFailCount
);
}
private
String
getAdRequestFailCountKey
()
{
return
AD_REQUEST_FAIL_COUNT_KEY
+
"_"
+
currentDate
;
}
private
void
saveAdRequestFailCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
getAdRequestFailCountKey
(),
adRequestFailCount
);
editor
.
apply
();
}
//endregion
//region AdDisplayCount
private
int
maxAdDisplayCount
;
// 总广告展示次数限制
private
int
adDisplayCount
=
0
;
// 当前广告展示次数
private
static
final
String
MAX_AD_DISPLAY_COUNT_KEY
=
"max_ad_display_count"
;
// 总广告展示次数限制的键
private
static
final
String
AD_DISPLAY_COUNT_KEY
=
"ad_display_count"
;
// 广告展示次数的键
private
void
saveMaxAdDisplayCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
MAX_AD_DISPLAY_COUNT_KEY
,
maxAdDisplayCount
);
editor
.
apply
();
}
public
void
incrementAdDisplayCount
()
{
if
(!
currentDate
.
equals
(
getCurrentDate
()))
{
currentDate
=
getCurrentDate
();
adDisplayCount
=
0
;
}
adDisplayCount
++;
int
max
=
AppPreferences
.
getInstance
().
getInt
(
"facebookAdShowEventCount"
,
3
);
if
(
adClickCount
>=
max
&&
max
!=
-
1
)
{
AppEventsLogger
logger
=
AppEventsLogger
.
newLogger
(
context
);
logger
.
logEvent
(
"ad_show"
);
AppPreferences
.
getInstance
().
put
(
"facebookAdShowEventCount"
,
-
1
);
}
saveAdDisplayCount
();
}
private
String
getAdDisplayCountKey
()
{
return
AD_DISPLAY_COUNT_KEY
+
"_"
+
currentDate
;
}
private
void
saveAdDisplayCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
getAdDisplayCountKey
(),
adDisplayCount
);
editor
.
apply
();
}
//endregion
//region AdClickCount
public
int
maxAdClickCount
;
// 单个广告点击次数限制
private
int
adClickCount
=
0
;
// 当前广告点击次数
private
static
final
String
MAX_AD_CLICK_COUNT_KEY
=
"max_ad_click_count"
;
// 单个广告点击次数限制的键
private
static
final
String
AD_CLICK_COUNT_KEY
=
"ad_click_count"
;
// 广告点击次数的键
private
void
saveMaxAdClickCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
MAX_AD_CLICK_COUNT_KEY
,
maxAdClickCount
);
editor
.
apply
();
}
public
void
incrementAdClickCount
()
{
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"incrementAdClickCount"
,
false
);
if
(!
currentDate
.
equals
(
getCurrentDate
()))
{
currentDate
=
getCurrentDate
();
adClickCount
=
0
;
}
adClickCount
++;
saveAdClickCount
();
}
private
String
getAdClickCountKey
()
{
return
AD_CLICK_COUNT_KEY
+
"_"
+
currentDate
;
}
public
void
setAdClickCount
(
int
s
)
{
if
(!
currentDate
.
equals
(
getCurrentDate
()))
{
currentDate
=
getCurrentDate
();
adClickCount
=
0
;
}
adClickCount
=
s
;
saveAdClickCount
();
}
private
void
saveAdClickCount
()
{
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
AD_PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
editor
.
putInt
(
getAdClickCountKey
(),
adClickCount
);
editor
.
apply
();
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"adClickCount="
+
adClickCount
,
false
);
}
//endregion
public
String
getCurrentDate
()
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
,
Locale
.
getDefault
());
Date
currentDate
=
Calendar
.
getInstance
().
getTime
();
return
dateFormat
.
format
(
currentDate
);
}
}
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobBannerColla.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.content.Context
import
android.os.Bundle
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewTreeObserver
import
androidx.core.view.children
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.helper.ConfigHelper
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.ads.mediation.admob.AdMobAdapter
import
com.google.android.gms.ads.AdListener
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.AdSize
import
com.google.android.gms.ads.AdView
import
java.util.UUID
object
AdmobBannerUtils
{
private
const
val
TAG
=
"AdmobBannerUtils"
private
var
adView
:
AdView
?
=
null
private
var
listener
:
ViewTreeObserver
.
OnGlobalLayoutListener
?
=
null
fun
showCollapsibleBannerAd
(
context
:
Context
,
parent
:
ViewGroup
)
{
val
isShowBanner
=
AppPreferences
.
getInstance
().
getString
(
"isShowBanner"
,
"0"
).
toInt
()
if
(
isShowBanner
==
0
)
{
return
}
if
(
adView
!=
null
)
{
adView
?.
destroy
()
}
adView
=
AdView
(
context
)
adView
?.
tag
=
"CollapsibleBannerAd"
// parent.removeAllViews()
val
list
=
parent
.
children
list
.
forEach
{
if
(
it
.
tag
!=
"zhanweitu"
)
{
parent
.
removeView
(
it
)
}
}
parent
.
addView
(
adView
)
listener
=
ViewTreeObserver
.
OnGlobalLayoutListener
{
val
screenPixelDensity
=
context
.
resources
.
displayMetrics
.
density
val
adWidth
=
(
parent
.
width
/
screenPixelDensity
).
toInt
()
val
adSize
=
AdSize
.
getCurrentOrientationAnchoredAdaptiveBannerAdSize
(
context
,
adWidth
)
adView
?.
adUnitId
=
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
bannerAdmobIdTest
else
ConfigHelper
.
bannerAdmobId
adView
?.
setAdSize
(
adSize
)
loadCollapsibleBanner
(
parent
)
parent
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
listener
)
}
parent
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
listener
)
}
private
fun
loadCollapsibleBanner
(
parent
:
ViewGroup
)
{
val
extras
=
Bundle
()
extras
.
putString
(
"collapsible"
,
"bottom"
)
extras
.
putString
(
"collapsible_request_id"
,
UUID
.
randomUUID
().
toString
())
val
adRequest
=
AdRequest
.
Builder
().
addNetworkExtrasBundle
(
AdMobAdapter
::
class
.
java
,
extras
).
build
()
adView
?.
adListener
=
object
:
AdListener
()
{
override
fun
onAdLoaded
()
{
LogEx
.
logDebug
(
TAG
,
"onAdLoaded"
)
}
override
fun
onAdOpened
()
{
LogEx
.
logDebug
(
TAG
,
"onAdOpened"
)
}
override
fun
onAdClosed
()
{
super
.
onAdClosed
()
LogEx
.
logDebug
(
TAG
,
"onAdClosed"
)
val
removeList
=
arrayListOf
<
View
>()
parent
.
children
.
forEach
{
if
(
it
.
tag
!=
"CollapsibleBannerAd"
)
{
removeList
.
add
(
it
)
}
}
removeList
.
forEach
{
parent
.
removeView
(
it
)
}
}
}
adView
?.
loadAd
(
adRequest
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobEvent.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.app.Activity
import
android.os.Bundle
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
com.base.pdfviewerscannerwhite.helper.MyApplication
import
com.facebook.appevents.AppEventsConstants
import
com.facebook.appevents.AppEventsLogger
import
com.google.android.gms.ads.AdValue
import
com.google.android.gms.ads.OnPaidEventListener
import
com.google.android.gms.ads.ResponseInfo
import
com.google.android.gms.ads.appopen.AppOpenAd
import
com.google.android.gms.ads.interstitial.InterstitialAd
import
com.google.android.gms.ads.nativead.NativeAd
import
com.google.android.gms.ads.rewarded.RewardedAd
import
com.google.firebase.analytics.FirebaseAnalytics
import
com.google.firebase.analytics.ktx.analytics
import
com.google.firebase.ktx.Firebase
import
org.json.JSONObject
object
AdmobEvent
{
fun
pullAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
)
{
val
obj
=
JSONObject
()
if
(
responseInfo
!=
null
)
{
val
response
=
responseInfo
.
adapterResponses
.
getOrNull
(
0
)
if
(
response
!=
null
)
{
obj
.
put
(
"source"
,
response
.
adSourceName
)
val
credentials
=
mapOf
(
"placementid"
to
response
.
credentials
.
get
(
"placementid"
),
"appid"
to
response
.
credentials
.
get
(
"appid"
),
"pubid"
to
response
.
credentials
.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
}
obj
.
put
(
"session_id"
,
responseInfo
.
responseId
)
}
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"req_id"
,
reqId
)
if
(
error
==
null
)
{
obj
.
put
(
"status"
,
"1"
)
}
else
{
obj
.
put
(
"errMsg"
,
error
)
obj
.
put
(
"status"
,
"2"
)
}
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
}
private
val
taichiPref
by
lazy
{
MyApplication
.
context
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
}
private
val
taichiSharedPreferencesEditor
by
lazy
{
taichiPref
.
edit
()
}
class
EventOnPaidEventListener
(
private
val
ad
:
Any
?)
:
OnPaidEventListener
{
override
fun
onPaidEvent
(
adValue
:
AdValue
)
{
val
valueMicros
=
adValue
.
valueMicros
val
currencyCode
=
adValue
.
currencyCode
val
precision
=
adValue
.
precisionType
val
obj
=
JSONObject
()
obj
.
put
(
"valueMicros"
,
valueMicros
)
obj
.
put
(
"currencyCode"
,
currencyCode
)
obj
.
put
(
"precision"
,
precision
)
Firebase
.
analytics
.
logEvent
(
"ad_price"
,
Bundle
().
apply
{
putDouble
(
"valueMicros"
,
valueMicros
/
1000000.0
)
})
val
params
=
Bundle
()
val
currentImpressionRevenue
=
adValue
.
valueMicros
.
toDouble
()
/
1000000.0
params
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentImpressionRevenue
)
params
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
val
precisionType
=
when
(
adValue
.
precisionType
)
{
0
->
"UNKNOWN"
1
->
"ESTIMATED"
2
->
"PUBLISHER_PROVIDED"
3
->
"PRECISE"
else
->
"Invalid"
}
params
.
putString
(
"precisionType"
,
precisionType
)
Firebase
.
analytics
.
logEvent
(
"Ad_Impression_Revenue"
,
params
)
val
previousTaichiTroasCache
=
taichiPref
.
getFloat
(
"TaichiTroasCache"
,
0f
)
val
currentTaichiTroasCache
=
(
previousTaichiTroasCache
+
currentImpressionRevenue
).
toFloat
()
if
(
currentTaichiTroasCache
>=
0.01
)
{
//如果超过0.01就触发一次tROAS taichi事件
val
roasbundle
=
Bundle
()
roasbundle
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentTaichiTroasCache
.
toDouble
()
)
roasbundle
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
Firebase
.
analytics
.
logEvent
(
"Total_Ads_Revenue_001"
,
roasbundle
)
taichiSharedPreferencesEditor
.
putFloat
(
"TaichiTroasCache"
,
0f
)
//重新清零,开始计算
val
logger
=
AppEventsLogger
.
newLogger
(
MyApplication
.
context
)
val
parameters
=
Bundle
()
parameters
.
putString
(
AppEventsConstants
.
EVENT_PARAM_CURRENCY
,
"USD"
)
logger
.
logEvent
(
"ad_value"
,
currentTaichiTroasCache
.
toDouble
(),
parameters
)
}
else
{
taichiSharedPreferencesEditor
.
putFloat
(
"TaichiTroasCache"
,
currentTaichiTroasCache
)
}
taichiSharedPreferencesEditor
.
commit
()
when
(
ad
)
{
is
AppOpenAd
->
{
val
adUnitId
=
ad
.
adUnitId
val
loadedAdapterResponseInfo
=
ad
.
responseInfo
.
loadedAdapterResponseInfo
val
adSourceName
=
loadedAdapterResponseInfo
?.
adSourceName
val
adSourceId
=
loadedAdapterResponseInfo
?.
adSourceId
val
adSourceInstanceName
=
loadedAdapterResponseInfo
?.
adSourceInstanceName
val
adSourceInstanceId
=
loadedAdapterResponseInfo
?.
adSourceInstanceId
val
sessionId
=
ad
.
responseInfo
.
responseId
val
extras
=
ad
.
responseInfo
.
responseExtras
val
mediationGroupName
=
extras
.
getString
(
"mediation_group_name"
)
val
mediationABTestName
=
extras
.
getString
(
"mediation_ab_test_name"
)
val
mediationABTestVariant
=
extras
.
getString
(
"mediation_ab_test_variant"
)
obj
.
put
(
"adUnitId"
,
adUnitId
)
obj
.
put
(
"adSourceName"
,
adSourceName
)
obj
.
put
(
"adSourceId"
,
adSourceId
)
obj
.
put
(
"adSourceInstanceName"
,
adSourceInstanceName
)
obj
.
put
(
"adSourceInstanceId"
,
adSourceInstanceId
)
obj
.
put
(
"mediationGroupName"
,
mediationGroupName
)
obj
.
put
(
"mediationABTestName"
,
mediationABTestName
)
obj
.
put
(
"mediationABTestVariant"
,
mediationABTestVariant
)
obj
.
put
(
"session_id"
,
sessionId
)
}
is
InterstitialAd
->
{
val
adUnitId
=
ad
.
adUnitId
val
loadedAdapterResponseInfo
=
ad
.
responseInfo
.
loadedAdapterResponseInfo
val
adSourceName
=
loadedAdapterResponseInfo
?.
adSourceName
val
adSourceId
=
loadedAdapterResponseInfo
?.
adSourceId
val
adSourceInstanceName
=
loadedAdapterResponseInfo
?.
adSourceInstanceName
val
adSourceInstanceId
=
loadedAdapterResponseInfo
?.
adSourceInstanceId
val
sessionId
=
ad
.
responseInfo
.
responseId
val
extras
=
ad
.
responseInfo
.
responseExtras
val
mediationGroupName
=
extras
.
getString
(
"mediation_group_name"
)
val
mediationABTestName
=
extras
.
getString
(
"mediation_ab_test_name"
)
val
mediationABTestVariant
=
extras
.
getString
(
"mediation_ab_test_variant"
)
obj
.
put
(
"adUnitId"
,
adUnitId
)
obj
.
put
(
"adSourceName"
,
adSourceName
)
obj
.
put
(
"adSourceId"
,
adSourceId
)
obj
.
put
(
"adSourceInstanceName"
,
adSourceInstanceName
)
obj
.
put
(
"adSourceInstanceId"
,
adSourceInstanceId
)
obj
.
put
(
"mediationGroupName"
,
mediationGroupName
)
obj
.
put
(
"mediationABTestName"
,
mediationABTestName
)
obj
.
put
(
"mediationABTestVariant"
,
mediationABTestVariant
)
obj
.
put
(
"session_id"
,
sessionId
)
}
is
RewardedAd
->
{
val
loadedAdapterResponseInfo
=
ad
.
responseInfo
.
loadedAdapterResponseInfo
val
adSourceName
=
loadedAdapterResponseInfo
?.
adSourceName
val
adSourceId
=
loadedAdapterResponseInfo
?.
adSourceId
val
adSourceInstanceName
=
loadedAdapterResponseInfo
?.
adSourceInstanceName
val
adSourceInstanceId
=
loadedAdapterResponseInfo
?.
adSourceInstanceId
val
sessionId
=
ad
.
responseInfo
.
responseId
val
extras
=
ad
.
responseInfo
.
responseExtras
val
mediationGroupName
=
extras
.
getString
(
"mediation_group_name"
)
val
mediationABTestName
=
extras
.
getString
(
"mediation_ab_test_name"
)
val
mediationABTestVariant
=
extras
.
getString
(
"mediation_ab_test_variant"
)
obj
.
put
(
"adSourceName"
,
adSourceName
)
obj
.
put
(
"adSourceId"
,
adSourceId
)
obj
.
put
(
"adSourceInstanceName"
,
adSourceInstanceName
)
obj
.
put
(
"adSourceInstanceId"
,
adSourceInstanceId
)
obj
.
put
(
"mediationGroupName"
,
mediationGroupName
)
obj
.
put
(
"mediationABTestName"
,
mediationABTestName
)
obj
.
put
(
"mediationABTestVariant"
,
mediationABTestVariant
)
obj
.
put
(
"session_id"
,
sessionId
)
}
is
NativeAd
->
{
val
loadedAdapterResponseInfo
=
ad
.
responseInfo
?.
loadedAdapterResponseInfo
val
adSourceName
=
loadedAdapterResponseInfo
?.
adSourceName
val
adSourceId
=
loadedAdapterResponseInfo
?.
adSourceId
val
adSourceInstanceName
=
loadedAdapterResponseInfo
?.
adSourceInstanceName
val
adSourceInstanceId
=
loadedAdapterResponseInfo
?.
adSourceInstanceId
val
sessionId
=
ad
.
responseInfo
?.
responseId
val
extras
=
ad
.
responseInfo
?.
responseExtras
val
mediationGroupName
=
extras
?.
getString
(
"mediation_group_name"
)
val
mediationABTestName
=
extras
?.
getString
(
"mediation_ab_test_name"
)
val
mediationABTestVariant
=
extras
?.
getString
(
"mediation_ab_test_variant"
)
obj
.
put
(
"adSourceName"
,
adSourceName
)
obj
.
put
(
"adSourceId"
,
adSourceId
)
obj
.
put
(
"adSourceInstanceName"
,
adSourceInstanceName
)
obj
.
put
(
"adSourceInstanceId"
,
adSourceInstanceId
)
obj
.
put
(
"mediationGroupName"
,
mediationGroupName
)
obj
.
put
(
"mediationABTestName"
,
mediationABTestName
)
obj
.
put
(
"mediationABTestVariant"
,
mediationABTestVariant
)
obj
.
put
(
"session_id"
,
sessionId
)
}
}
EventUtils
.
event
(
"ad_price"
,
ext
=
obj
)
}
}
fun
clickAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
val
obj
=
JSONObject
()
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_click"
,
ext
=
obj
)
}
}
fun
showAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
activity
:
Activity
?
=
null
)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
val
obj
=
JSONObject
()
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"from"
,
activity
?.
javaClass
?.
simpleName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_show"
,
ext
=
obj
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobHelper.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
object
AdmobHelper
{
//展示广告关闭时赋值
var
lastShowedOnHiddenTime
=
0L
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobInterstitialUtils.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.app.Activity
import
android.app.Dialog
import
android.widget.Toast
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobHelper.lastShowedOnHiddenTime
import
com.base.pdfviewerscannerwhite.helper.ConfigHelper
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
com.base.pdfviewerscannerwhite.helper.MyApplication
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.FullScreenContentCallback
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.interstitial.InterstitialAd
import
com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
import
org.json.JSONObject
import
java.util.UUID
object
AdmobInterstitialUtils
{
private
var
interAd
:
InterstitialAd
?
=
null
private
var
interLoadTime
=
Long
.
MAX_VALUE
private
var
adLastDisplayTime
:
Long
=
0
private
val
mRequest
=
AdRequest
.
Builder
().
build
()
private
var
dialog
:
Dialog
?
=
null
private
fun
isAdExpired
():
Boolean
{
return
System
.
currentTimeMillis
()
-
interLoadTime
>
1000
*
60
*
60
}
fun
showInterstitialAd
(
activity
:
Activity
,
isReLoadAd
:
Boolean
=
false
,
isShowDialog
:
Boolean
=
true
,
onHidden
:
((
showed
:
Boolean
)
->
Unit
)?
=
null
)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
return
}
if
(
isAdExpired
())
{
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
interAd
=
null
loadInterstitialAd
(
activity
)
onHidden
?.
invoke
(
false
)
return
}
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
onHidden
?.
invoke
(
false
)
return
}
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
if
(
interAd
!=
null
)
{
if
(!
activity
.
isFinishing
&&
!
activity
.
isDestroyed
)
{
// dialog = activity.showAdPreparingDialog()
}
displayInterstitialAd
(
activity
,
onHidden
)
}
else
{
showAdDialogAndLoadInterstitial
(
activity
,
isReLoadAd
,
isShowDialog
,
onHidden
)
}
}
fun
loadInterstitialAd
(
activity
:
Activity
,
onLoad
:
(()
->
Unit
)?
=
null
)
{
if
(
interAd
!=
null
)
{
onLoad
?.
invoke
()
return
}
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
onLoad
?.
invoke
()
return
}
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"interAd"
)
obj
.
put
(
"from"
,
activity
.
javaClass
.
simpleName
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
InterstitialAd
.
load
(
activity
,
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
interAdmobIdTest
else
ConfigHelper
.
interAdmobId
,
mRequest
,
object
:
InterstitialAdLoadCallback
()
{
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
interAd
=
null
onLoad
?.
invoke
()
pullAd
(
p0
.
responseInfo
,
"interAd"
,
p0
.
message
,
reqId
=
reqId
)
if
(
BuildConfig
.
DEBUG
)
{
Toast
.
makeText
(
MyApplication
.
context
,
"拉取失败"
+
p0
.
message
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
override
fun
onAdLoaded
(
ad
:
InterstitialAd
)
{
interAd
=
ad
onLoad
?.
invoke
()
interLoadTime
=
System
.
currentTimeMillis
()
pullAd
(
ad
.
responseInfo
,
"interAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
ad
)
}
})
}
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
isReLoadAd
:
Boolean
,
isShowDialog
:
Boolean
,
onHidden
:
((
showed
:
Boolean
)
->
Unit
)?
)
{
if
(!
isShowDialog
)
{
onHidden
?.
invoke
(
false
)
return
}
var
mDialog
:
Dialog
?
=
null
// if (!activity.isFinishing && !activity.isDestroyed) {
// mDialog = activity.showAdPreparingDialog()
// mDialog?.show()
// }
loadInterstitialAd
(
activity
)
{
mDialog
?.
dismiss
()
if
(!
isReLoadAd
)
{
showInterstitialAd
(
activity
,
true
,
false
)
{
onHidden
?.
invoke
(
it
)
}
}
}
if
(
isReLoadAd
)
{
mDialog
?.
dismiss
()
onHidden
?.
invoke
(
false
)
}
}
private
fun
displayInterstitialAd
(
activity
:
Activity
,
onHidden
:
((
showed
:
Boolean
)
->
Unit
)?
=
null
)
{
val
thisInterAd
=
interAd
interAd
=
null
thisInterAd
?.
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
override
fun
onAdClicked
()
{
clickAd
(
thisInterAd
?.
responseInfo
,
"interAd"
)
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
}
override
fun
onAdDismissedFullScreenContent
()
{
interAd
=
null
onHidden
?.
invoke
(
true
)
loadInterstitialAd
(
activity
)
lastShowedOnHiddenTime
=
System
.
currentTimeMillis
()
}
override
fun
onAdFailedToShowFullScreenContent
(
p0
:
AdError
)
{
dialog
?.
dismiss
()
interAd
=
null
onHidden
?.
invoke
(
false
)
loadInterstitialAd
(
activity
)
}
override
fun
onAdShowedFullScreenContent
()
{
dialog
?.
dismiss
()
showAd
(
thisInterAd
?.
responseInfo
,
"interAd"
,
activity
)
AdDisplayUtils
.
getInstance
().
incrementAdDisplayCount
()
adLastDisplayTime
=
System
.
currentTimeMillis
()
/
1000
}
}
thisInterAd
?.
show
(
activity
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobNativeUtils.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.app.Activity
import
android.view.ViewGroup
import
androidx.core.view.isVisible
import
com.base.browserwhite.ads.admob.NativeView
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import
com.base.pdfviewerscannerwhite.helper.ConfigHelper
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
com.base.pdfviewerscannerwhite.helper.MyApplication
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.android.gms.ads.AdListener
import
com.google.android.gms.ads.AdLoader
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.nativead.NativeAd
import
org.json.JSONObject
import
java.util.UUID
object
AdmobNativeUtils
{
private
const
val
TAG
=
"AdmobNativeUtils"
private
var
nativeAd
:
NativeAd
?
=
null
private
var
isLoading
=
false
private
var
nativeLoadTime
=
Long
.
MAX_VALUE
private
var
loadingListener
:
(()
->
Unit
)?
=
null
private
val
mRequest
=
AdRequest
.
Builder
().
build
()
var
onAdLoaded
:
(()
->
Unit
)?
=
null
private
fun
loadNativeAd
()
{
if
(
nativeAd
!=
null
)
{
return
}
if
(
isLoading
)
{
return
}
isLoading
=
true
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"nativeAd"
))
{
return
}
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"nativeAd"
)
val
adLoader
=
AdLoader
.
Builder
(
MyApplication
.
context
,
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
nativeAdmobIdTest
else
ConfigHelper
.
nativeAdmobId
).
forNativeAd
{
nativeLoadTime
=
System
.
currentTimeMillis
()
nativeAd
=
it
LogEx
.
logDebug
(
TAG
,
"nativeAd=${nativeAd.toString()}"
)
isLoading
=
false
loadingListener
?.
invoke
()
pullAd
(
it
.
responseInfo
,
"nativeAd"
,
reqId
=
reqId
)
it
.
setOnPaidEventListener
(
AdmobEvent
.
EventOnPaidEventListener
(
it
))
}.
withAdListener
(
object
:
AdListener
()
{
override
fun
onAdLoaded
()
{
super
.
onAdLoaded
()
onAdLoaded
?.
invoke
()
onAdLoaded
=
null
}
override
fun
onAdClicked
()
{
clickAd
(
nativeAd
?.
responseInfo
,
"nativeAd"
)
}
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdFailedToLoad=${p0.message}"
)
nativeAd
=
null
isLoading
=
false
pullAd
(
p0
.
responseInfo
,
"nativeAd"
,
p0
.
message
,
reqId
=
reqId
)
// Log.e("MXL", "NativeAdFailedToLoad: " + p0.message)
}
}).
build
()
adLoader
.
loadAd
(
mRequest
)
}
fun
showNativeAd
(
activity
:
Activity
?,
parent
:
ViewGroup
,
layout
:
Int
=
R
.
layout
.
layout_admob_native_custom
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"NativeAd"
)
EventUtils
.
event
(
"ad_prepare_show_native"
,
ext
=
obj
)
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"nativeAd"
))
{
return
}
loadingListener
=
{
if
(
System
.
currentTimeMillis
()
-
nativeLoadTime
<=
1000
*
60
*
60
)
{
nativeAd
?.
let
{
NativeView
(
parent
.
context
,
layout
).
run
{
parent
.
removeAllViews
()
setNativeAd
(
it
)
parent
.
addView
(
this
)
parent
.
isVisible
=
true
showAd
(
nativeAd
?.
responseInfo
,
"nativeAd"
,
activity
)
}
}
}
nativeAd
=
null
loadingListener
=
null
loadNativeAd
()
}
if
(
nativeAd
==
null
)
{
loadNativeAd
()
val
obj2
=
JSONObject
()
obj2
.
put
(
"reason"
,
"no_ad"
)
obj2
.
put
(
"ad_unit"
,
"nativeAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
}
else
{
loadingListener
?.
invoke
()
}
}
fun
showReadyNativeAd
(
activity
:
Activity
?,
readyNativeAd
:
NativeAd
?,
parent
:
ViewGroup
,
layout
:
Int
=
R
.
layout
.
layout_admob_native_custom
)
{
readyNativeAd
?.
let
{
NativeView
(
parent
.
context
,
layout
).
run
{
parent
.
removeAllViews
()
setNativeAd
(
it
)
parent
.
addView
(
this
)
parent
.
isVisible
=
true
showAd
(
nativeAd
?.
responseInfo
,
"nativeAd"
,
activity
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/AdmobOpenUtils.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.app.Activity
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import
com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import
com.base.pdfviewerscannerwhite.helper.ConfigHelper
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
com.base.pdfviewerscannerwhite.helper.MyApplication
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.FullScreenContentCallback
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.appopen.AppOpenAd
import
org.json.JSONObject
import
java.util.UUID
object
AdmobOpenUtils
{
private
const
val
TAG
=
"AdmobOpenUtils"
private
val
mRequest
=
AdRequest
.
Builder
().
build
()
private
var
openLoadTime
=
Long
.
MAX_VALUE
private
var
mOpenAd
:
AppOpenAd
?
=
null
fun
isOpenAdLoaded
()
=
mOpenAd
!=
null
fun
loadAppOpenAd
(
skip
:
Boolean
=
false
,
onLoad
:
((
where
:
Int
)
->
Unit
)?
=
null
)
{
if
(
mOpenAd
!=
null
||
skip
)
{
onLoad
?.
invoke
(
1
)
return
}
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"openAd"
))
{
onLoad
?.
invoke
(
2
)
return
}
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"openAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
AppOpenAd
.
load
(
MyApplication
.
context
,
if
(
BuildConfig
.
DEBUG
)
ConfigHelper
.
openAdmobIdTest
else
ConfigHelper
.
openAdmobId
,
mRequest
,
object
:
AppOpenAd
.
AppOpenAdLoadCallback
()
{
override
fun
onAdLoaded
(
ad
:
AppOpenAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoaded"
)
openLoadTime
=
System
.
currentTimeMillis
()
mOpenAd
=
ad
onLoad
?.
invoke
(
3
)
pullAd
(
ad
.
responseInfo
,
"openAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
ad
)
}
override
fun
onAdFailedToLoad
(
p0
:
LoadAdError
)
{
LogEx
.
logDebug
(
TAG
,
"LoadAdError ${p0.message}"
)
mOpenAd
=
null
onLoad
?.
invoke
(
4
)
pullAd
(
p0
.
responseInfo
,
"openAd"
,
p0
.
message
,
reqId
=
reqId
)
}
})
}
fun
showAppOpenAd
(
activity
:
Activity
,
isRetry
:
Boolean
=
false
,
showBefore
:
((
flag
:
Boolean
)
->
Unit
)?
=
null
,
onHidden
:
((
showed
:
Boolean
)
->
Unit
)?
=
null
)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
return
}
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"openAd"
))
{
onHidden
?.
invoke
(
false
)
return
}
if
(
System
.
currentTimeMillis
()
-
openLoadTime
>
1000
*
60
*
60
)
{
LogEx
.
logDebug
(
TAG
,
"openLoadTime out time"
)
mOpenAd
=
null
loadAppOpenAd
()
onHidden
?.
invoke
(
false
)
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
return
}
if
(!
isRetry
)
{
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
LogEx
.
logDebug
(
TAG
,
"open ad_prepare_show"
)
}
if
(
mOpenAd
!=
null
)
{
LogEx
.
logDebug
(
TAG
,
"mOpenAd!=null"
)
val
thisMOpenAd
=
mOpenAd
mOpenAd
=
null
thisMOpenAd
?.
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
override
fun
onAdClicked
()
{
clickAd
(
thisMOpenAd
?.
responseInfo
,
"openAd"
)
}
override
fun
onAdDismissedFullScreenContent
()
{
mOpenAd
=
null
onHidden
?.
invoke
(
true
)
loadAppOpenAd
()
}
override
fun
onAdFailedToShowFullScreenContent
(
p0
:
AdError
)
{
mOpenAd
=
null
onHidden
?.
invoke
(
false
)
loadAppOpenAd
()
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
p0
.
message
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
override
fun
onAdShowedFullScreenContent
()
{
showBefore
?.
invoke
(
true
)
showAd
(
thisMOpenAd
?.
responseInfo
,
"openAd"
,
activity
)
}
}
thisMOpenAd
?.
show
(
activity
)
}
else
{
LogEx
.
logDebug
(
TAG
,
"mOpenAd=null"
)
loadAppOpenAd
{
if
(
mOpenAd
!=
null
)
{
showAppOpenAd
(
activity
,
true
,
showBefore
,
onHidden
)
}
else
{
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
onHidden
?.
invoke
(
false
)
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ads/admob/NativeView.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.ads.admob
import
android.annotation.SuppressLint
import
android.content.Context
import
android.util.AttributeSet
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.TextView
import
com.google.android.gms.ads.nativead.NativeAd
import
com.google.android.gms.ads.nativead.NativeAdView
import
com.base.pdfviewerscannerwhite.R
@SuppressLint
(
"ViewConstructor"
)
class
NativeView
(
context
:
Context
,
val
layout
:
Int
,
attrs
:
AttributeSet
?
=
null
)
:
FrameLayout
(
context
,
attrs
)
{
init
{
layoutParams
=
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
}
fun
setNativeAd
(
nativeAd
:
NativeAd
?)
{
nativeAd
?:
return
val
adView
=
LayoutInflater
.
from
(
context
)
.
inflate
(
layout
,
this
,
false
)
as
NativeAdView
adView
.
mediaView
=
adView
.
findViewById
(
R
.
id
.
ad_media
)
adView
.
headlineView
=
adView
.
findViewById
(
R
.
id
.
ad_headline
)
adView
.
bodyView
=
adView
.
findViewById
(
R
.
id
.
ad_body
)
adView
.
callToActionView
=
adView
.
findViewById
(
R
.
id
.
ad_call_to_action
)
adView
.
iconView
=
adView
.
findViewById
(
R
.
id
.
ad_app_icon
)
(
adView
.
headlineView
as
TextView
?)
?.
text
=
nativeAd
.
headline
adView
.
mediaView
!!
.
mediaContent
=
nativeAd
.
mediaContent
if
(
nativeAd
.
body
==
null
)
{
adView
.
bodyView
!!
.
visibility
=
View
.
INVISIBLE
}
else
{
adView
.
bodyView
!!
.
visibility
=
View
.
VISIBLE
(
adView
.
bodyView
as
TextView
?)
?.
text
=
nativeAd
.
body
}
if
(
nativeAd
.
callToAction
==
null
)
{
adView
.
callToActionView
!!
.
visibility
=
View
.
INVISIBLE
}
else
{
adView
.
callToActionView
!!
.
visibility
=
View
.
VISIBLE
(
adView
.
callToActionView
as
Button
?)
?.
text
=
nativeAd
.
callToAction
}
if
(
nativeAd
.
icon
==
null
)
{
adView
.
iconView
!!
.
visibility
=
View
.
GONE
}
else
{
(
adView
.
iconView
as
ImageView
?)
?.
setImageDrawable
(
nativeAd
.
icon
!!
.
drawable
)
adView
.
iconView
!!
.
visibility
=
View
.
VISIBLE
}
adView
.
setNativeAd
(
nativeAd
)
removeAllViews
()
addView
(
adView
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/AESHelper.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.helper
import
android.util.Base64
import
java.security.SecureRandom
import
javax.crypto.Cipher
import
javax.crypto.spec.GCMParameterSpec
import
javax.crypto.spec.SecretKeySpec
object
AESHelper
{
private
const
val
aesKey
=
"7vwdrlk6bp8rihe4"
private
val
cipher
by
lazy
{
Cipher
.
getInstance
(
"AES/GCM/NoPadding"
)
}
fun
encrypt
(
content
:
String
):
String
{
try
{
val
iv
=
ByteArray
(
12
).
apply
{
SecureRandom
().
nextBytes
(
this
)
}
val
contentBytes
=
content
.
toByteArray
(
Charsets
.
UTF_8
)
val
params
=
GCMParameterSpec
(
128
,
iv
)
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
,
params
)
val
encryptData
=
cipher
.
doFinal
(
contentBytes
)
if
(
encryptData
.
size
!=
contentBytes
.
size
+
16
)
{
throw
IllegalStateException
(
"Encryption failed"
)
}
val
message
=
ByteArray
(
12
+
contentBytes
.
size
+
16
)
System
.
arraycopy
(
iv
,
0
,
message
,
0
,
12
)
System
.
arraycopy
(
encryptData
,
0
,
message
,
12
,
encryptData
.
size
)
return
String
(
Base64
.
encode
(
message
,
Base64
.
NO_WRAP
),
Charsets
.
UTF_8
)
}
catch
(
_
:
Exception
)
{
}
return
content
}
@Synchronized
fun
decrypt
(
content
:
String
):
String
{
try
{
val
con
=
content
.
replace
(
" "
.
toRegex
(),
"+"
)
val
contentByte
=
Base64
.
decode
(
con
,
Base64
.
NO_WRAP
)
require
(
contentByte
.
size
>=
12
+
16
)
val
params
=
GCMParameterSpec
(
128
,
contentByte
,
0
,
12
)
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
params
)
val
decryptData
=
cipher
.
doFinal
(
contentByte
,
12
,
contentByte
.
size
-
12
)
return
String
(
decryptData
,
Charsets
.
UTF_8
)
}
catch
(
_
:
Exception
)
{
}
return
content
}
private
val
secretKey
by
lazy
{
SecretKeySpec
(
aesKey
.
toByteArray
(),
"AES"
)
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/ConfigHelper.kt
View file @
16f75fc7
...
...
@@ -4,4 +4,23 @@ object ConfigHelper {
const
val
privacyPolicy
:
String
=
"https://sites.google.com/view/pdf-reader-scan/pdf-reader"
const
val
termService
:
String
=
"https://sites.google.com/view/term-of-service-s/term-of-service"
// 正式包名
const
val
packageName
=
"com.lol.pdfscanner.libstdc.chovey"
// 域名
const
val
eventUrl
=
"https://rp.gamexzonerk.xyz"
const
val
apiUrl
=
"https://api.gamexzonerk.xyz"
//admob test id
const
val
openAdmobIdTest
=
"ca-app-pub-3940256099942544/9257395921"
const
val
bannerAdmobIdTest
=
"ca-app-pub-3940256099942544/9214589741"
const
val
interAdmobIdTest
=
"ca-app-pub-3940256099942544/1033173712"
const
val
nativeAdmobIdTest
=
"ca-app-pub-3940256099942544/2247696110"
// admob广告id
const
val
interAdmobId
=
"ca-app-pub-3940256099942544/1033173111"
const
val
nativeAdmobId
=
"ca-app-pub-3940256099942544/2247696111"
const
val
openAdmobId
=
"/6499/example/app-open"
const
val
bannerAdmobId
=
"ca-app-pub-3940256099942544/9214581111"
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/EventUtils.kt
0 → 100644
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.helper
import
android.os.Build
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import
com.base.pdfviewerscannerwhite.helper.ReportUtils.doPost
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
org.json.JSONException
import
org.json.JSONObject
object
EventUtils
{
private
val
TAG
=
"EventUtils"
fun
event
(
key
:
String
,
value
:
String
?
=
null
,
ext
:
JSONObject
?
=
null
,
isSingleEvent
:
Boolean
=
false
)
{
if
(!
ifAgreePrivacy
)
{
return
}
if
(
isSingleEvent
)
{
val
stringSet
=
AppPreferences
.
getInstance
().
getStringSet
(
"singleEvent"
,
setOf
())
if
(
stringSet
.
contains
(
key
))
{
return
}
}
Thread
{
var
paramJson
:
String
?
=
""
try
{
val
pkg
=
ConfigHelper
.
packageName
val
s
=
JSONObject
()
.
put
(
"action"
,
key
)
.
put
(
"value"
,
value
)
.
put
(
"ext"
,
ext
)
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
()
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
LogEx
.
logDebug
(
TAG
,
"gid=${AppPreferences.getInstance().getString("
gid
", "")}"
)
paramJson
=
AESHelper
.
encrypt
(
data
)
}
catch
(
e
:
JSONException
)
{
paramJson
=
""
}
LogEx
.
logDebug
(
TAG
,
"report!"
)
doPost
(
url
,
HashMap
(),
paramJson
)
}.
start
()
}
private
val
url
by
lazy
{
val
pkg
=
ConfigHelper
.
packageName
val
url
=
StringBuilder
(
"${ConfigHelper.eventUrl}/${
pkg
.
filter
{
it
.
isLowerCase
()
}.
substring
(
4
,
9
)
}
sp
"
)
url
.
append
(
"?pkg=$pkg"
)
url
.
toString
()
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
View file @
16f75fc7
package
com.base.pdfviewerscannerwhite.helper
import
android.app.Activity
import
android.app.Application
import
android.text.TextUtils
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/helper/ReportUtils.java
0 → 100644
View file @
16f75fc7
package
com
.
base
.
pdfviewerscannerwhite
.
helper
;
import
android.text.TextUtils
;
import
com.base.pdfviewerscannerwhite.utils.LogEx
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.Map
;
public
class
ReportUtils
{
private
static
String
TAG
=
"ReportUtils"
;
public
static
String
doPost
(
String
urlPath
,
Map
<
String
,
String
>
paramsMap
,
String
json
)
{
try
{
HttpURLConnection
conn
=
(
HttpURLConnection
)
new
URL
(
urlPath
).
openConnection
();
conn
.
setRequestMethod
(
"POST"
);
conn
.
setDoOutput
(
true
);
conn
.
setConnectTimeout
(
600000
);
if
(!
TextUtils
.
isEmpty
(
json
))
{
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Content-Length"
,
Integer
.
toString
(
json
.
getBytes
().
length
));
conn
.
getOutputStream
().
write
(
json
.
getBytes
());
}
StringBuilder
result
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
paramsMap
.
entrySet
())
{
result
.
append
(
"&"
).
append
(
entry
.
getKey
()).
append
(
"="
).
append
(
entry
.
getValue
());
}
if
(
result
.
length
()
>
0
)
{
conn
.
getOutputStream
().
write
(
result
.
substring
(
1
).
getBytes
());
}
else
{
// conn.getOutputStream().write(result.substring(0).getBytes());
}
if
(
conn
.
getResponseCode
()
==
200
)
{
String
s
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
())).
readLine
();
if
(!
TextUtils
.
isEmpty
(
s
))
{
}
else
{
s
=
""
;
}
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"code=200"
,
false
);
return
s
;
}
else
{
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"code!=200"
,
false
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
"{ \"success\": false,\n \"errorMsg\": \"后台服务器开小差了!\",\n \"result\":{}}"
;
}
}
app/src/main/java/com/base/pdfviewerscannerwhite/utils/LogEx.kt
View file @
16f75fc7
...
...
@@ -7,7 +7,7 @@ object LogEx {
val
isOpen
=
true
val
filterTAG
=
arrayOf
(
""
,
"
MediaStoreUtils
"
,
""
,
)
fun
logDebug
(
tag
:
String
,
content
:
String
,
isMust
:
Boolean
=
false
)
{
...
...
app/src/main/res/drawable/bg_f2f2f2.xml
0 → 100644
View file @
16f75fc7
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#F2F2F2"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/bg_ff8a00_10.xml
0 → 100644
View file @
16f75fc7
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#FF8A00"
/>
<corners
android:radius=
"10dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/layout_admob_native_custom.xml
0 → 100644
View file @
16f75fc7
<com.google.android.gms.ads.nativead.NativeAdView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@drawable/bg_f2f2f2"
android:baselineAligned=
"false"
>
<com.google.android.gms.ads.nativead.MediaView
android:id=
"@+id/ad_media"
android:layout_width=
"91dp"
android:layout_height=
"91dp"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"5dp"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"8dp"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/ad_headline"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:maxLines=
"2"
android:textColor=
"@color/black"
android:textSize=
"14sp"
android:textStyle=
"bold"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:background=
"#FF923E"
android:padding=
"2dp"
android:text=
"Ad"
android:textColor=
"@color/white"
android:textSize=
"12sp"
tools:ignore=
"HardcodedText"
/>
<TextView
android:id=
"@+id/ad_body"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"10dp"
android:ellipsize=
"end"
android:maxLines=
"2"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingVertical=
"5dp"
>
<ImageView
android:id=
"@+id/ad_app_icon"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_gravity=
"center_vertical"
tools:ignore=
"ContentDescription"
/>
<androidx.appcompat.widget.AppCompatButton
android:id=
"@+id/ad_call_to_action"
android:layout_width=
"match_parent"
android:layout_height=
"26dp"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"12dp"
android:background=
"@drawable/bg_ff8a00_10"
android:gravity=
"center"
android:textColor=
"@color/white"
android:textSize=
"15sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</com.google.android.gms.ads.nativead.NativeAdView>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
16f75fc7
...
...
@@ -3,6 +3,8 @@
<string
name=
"next"
tools:ignore=
"MissingTranslation"
>
Next
</string>
<string
name=
"previous"
tools:ignore=
"MissingTranslation"
>
Previous
</string>
<string
name=
"facebook_app_id"
tools:ignore=
"MissingTranslation"
>
421266364258459
</string>
<string
name=
"lorem_ipsum"
tools:ignore=
"MissingTranslation"
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris volutpat, dolor id interdum
ullamcorper, risus dolor egestas lectus, sit amet mattis purus dui nec risus. Maecenas non sodales nisi, vel dictum dolor.
...
...
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