Commit f52ae86a authored by wanglei's avatar wanglei

初始化

parent bb98a0e7
...@@ -43,16 +43,25 @@ ...@@ -43,16 +43,25 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".ui.main.MainActivity" android:name=".ui.main.MainActivity"
android:exported="false" android:exported="false"
android:theme="@style/Theme.PdfReaderAllPdfReader.NoActionBar" /> android:theme="@style/Theme.PdfReaderAllPdfReader.NoActionBar" />
<activity <activity
android:name=".ui.language.LanguageActivity" android:name=".ui.language.LanguageActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" /> tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
tools:ignore="DiscouragedApi,LockedOrientationActivity"
android:name=".ui.pdf.PdfActivity"
android:exported="false"
android:launchMode="singleTop" />
<meta-data <meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID" android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" /> android:value="ca-app-pub-3940256099942544~3347511713" />
......
package com.base.pdfreaderallpdfreader.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
import com.base.pdfreaderallpdfreader.R
import com.base.pdfreaderallpdfreader.databinding.DialogAdPreparingBinding
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
package com.base.pdfreaderallpdfreader.ads
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.open_limit_request
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.open_limit_show
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.open_limit_click
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.inter_limit_request
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.inter_limit_show
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.inter_limit_click
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.native_limit_request
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.native_limit_show
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.utils.AppPreferences
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import com.base.pdfreaderallpdfreader.utils.LogEx
object AdDisplayUtils {
//region open
private val open_max_request = AppPreferences.getInstance().getString(open_limit_request, "15").toInt()
private val open_max_show = AppPreferences.getInstance().getString(open_limit_show, "10").toInt()
private val open_max_click = AppPreferences.getInstance().getString(open_limit_click, "1").toInt()
fun incrementOpenRequestCount() {
currentOpenRequest += 1
}
fun incrementOpenShow() {
currentOpenShow += 1
}
fun incrementClickShow() {
currentOpenClick += 1
}
//当前开屏请求次数
private var currentOpenRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenRequest_${currentDate()}", value, true)
}
//当前开屏展示次数
private var currentOpenShow = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenShow_${currentDate()}", value, true)
}
//当前开屏点击次数
private var currentOpenClick = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenClick_${currentDate()}", value, true)
}
fun shouldShowOpenAd(): Boolean {
if (currentOpenRequest > open_max_request) {
LogEx.logDebug(TAG, "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
EventUtils.event("ad_limit", "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
return false
}
if (currentOpenShow > open_max_show) {
LogEx.logDebug(TAG, "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
EventUtils.event("ad_limit", "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
return false
}
if (currentOpenClick > open_max_click) {
LogEx.logDebug(TAG, "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
EventUtils.event("ad_limit", "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
return false
}
return true
}
//endregion
//region inter
private val inter_max_request = AppPreferences.getInstance().getString(inter_limit_request, "15").toInt()
private val inter_max_show = AppPreferences.getInstance().getString(inter_limit_show, "10").toInt()
private val inter_max_click = AppPreferences.getInstance().getString(inter_limit_click, "1").toInt()
fun incrementInterRequestCount() {
currentInterRequest += 1
}
fun incrementInterShowCount() {
currentInterShow += 1
}
fun incrementInterClickCount() {
currentInterClick += 1
}
//当前插页请求次数
private var currentInterRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentInterRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterRequest_${currentDate()}", value, true)
}
//当前插页展示次数
private var currentInterShow = 0
get() {
return AppPreferences.getInstance().getInt("currentInterShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterShow_${currentDate()}", value, true)
}
//当前插页点击次数
private var currentInterClick = 0
get() {
return AppPreferences.getInstance().getInt("currentInterClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterClick_${currentDate()}", value, true)
}
fun shouldShowInterAd(): Boolean {
if (currentInterRequest > inter_max_request) {
LogEx.logDebug(TAG, "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
EventUtils.event("ad_limit", "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
return false
}
if (currentInterShow > inter_max_show) {
LogEx.logDebug(TAG, "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
EventUtils.event("ad_limit", "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
return false
}
if (currentInterClick > inter_max_click) {
LogEx.logDebug(TAG, "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
EventUtils.event("ad_limit", "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
return false
}
return true
}
//endregion
//region native
private val native_max_request = AppPreferences.getInstance().getString(native_limit_request, "15").toInt()
private val native_max_show = AppPreferences.getInstance().getString(native_limit_show, "10").toInt()
private val native_max_click = AppPreferences.getInstance().getString(native_limit_show, "1").toInt()
fun incrementNativeRequestCount() {
currentNativeRequest += 1
}
fun incrementNativeShowCount() {
currentNativeShow += 1
}
fun incrementNativeClickCount() {
currentNativeClick += 1
}
private var currentNativeRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeRequest_${currentDate()}", value, true)
}
private var currentNativeShow = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeShow_${currentDate()}", value, true)
}
private var currentNativeClick = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeClick_${currentDate()}", value, true)
}
fun shouldShowNative(): Boolean {
if (currentNativeRequest > native_max_request) {
LogEx.logDebug(TAG, "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
EventUtils.event("ad_limit", "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
return false
}
if (currentNativeShow > native_max_show) {
LogEx.logDebug(TAG, "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
EventUtils.event("ad_limit", "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
return false
}
if (currentNativeClick > native_max_click) {
LogEx.logDebug(TAG, "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
EventUtils.event("ad_limit", "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
return false
}
return true
}
//endregion
private val TAG = "AdDisplayUtils"
private fun currentDate(): String {
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val currentDate = Calendar.getInstance().time
return dateFormat.format(currentDate)
}
}
package com.base.pdfreaderallpdfreader.ads
import android.app.Activity
import com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils
import com.base.pdfreaderallpdfreader.ads.admob.AdmobNativeUtils
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.helper.MyApplication
import com.base.pdfreaderallpdfreader.utils.AppPreferences
import com.google.android.gms.ads.MobileAds
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 showLanPage = "showLanPage"
//开屏加载ad时间
val open_ad_loading = "open_ad_loading"
var isAdInit = AtomicBoolean(false)
fun initAdmobAd(activity: Activity) {
MobileAds.initialize(MyApplication.context) { initializationStatus ->
isAdInit.set(true)
EventUtils.event("AdmobInit", "AdmobInit")
AdmobNativeUtils.loadNativeAd()
AdmobInterstitialUtils.loadInterstitialAd(activity)
}
}
//上次展示广告时间关闭赋值,通用开屏和插页
var lastShowedOnHiddenTime = 0L
get() {
return AppPreferences.getInstance().getLong("lastShowedOnHiddenTime", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastShowedOnHiddenTime", value, true)
}
/**
* 通用广告条件判断
*/
fun canCommonShowAd(): Boolean {
val interval = AppPreferences.getInstance().getString("ad_interval", "10").toInt()
if (System.currentTimeMillis() - lastShowedOnHiddenTime < interval * 1000L) {
return false
}
return true
}
//上次scan展示ad时间
var lastScanShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastScanShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastScanShowAd", value, true)
}
//是否显示扫描功能ad
fun isShowScanInter(): Boolean {
val interval = AppPreferences.getInstance().getString("scan_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastScanShowAd > interval * 1000L
}
//上次打开文档展示ad时间
var lastOpenDocumentShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastOpenDocumentShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastOpenDocumentShowAd", value, true)
}
//打开文档是否展示广告
fun isShowOpenDocumentInter(): Boolean {
val interval = AppPreferences.getInstance().getString("open_document_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastOpenDocumentShowAd > interval * 1000L
}
var lastCloseDocumentShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastCloseDocumentShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastCloseDocumentShowAd", value, true)
}
fun isShowCloseDocumentInter(): Boolean {
val interval = AppPreferences.getInstance().getString("close_document_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastCloseDocumentShowAd > interval * 1000L
}
fun isShowCloseDocument(): Boolean {
val status = AppPreferences.getInstance().getString("close_document_ad_show", "0").toInt()
return status == 1
}
fun isShowRvNativeAd(): Boolean {
val status = AppPreferences.getInstance().getString("rv_native_ad_show", "0").toInt()
return status == 1
}
fun isBackShowAd(): Boolean {
val status = AppPreferences.getInstance().getString("is_back_show_ad", "0").toInt()
return status == 1
}
}
\ No newline at end of file
package com.base.pdfreaderallpdfreader.ads.admob
import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import android.view.ViewTreeObserver
import com.base.pdfreaderallpdfreader.BuildConfig
import com.base.pdfreaderallpdfreader.helper.ConfigHelper
import com.base.pdfreaderallpdfreader.utils.AppPreferences
import com.base.pdfreaderallpdfreader.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, adClose: (() -> Unit)? = null) {
val isShowBanner = AppPreferences.getInstance().getString("isShowBanner", "0").toInt()
if (isShowBanner == 0) {
return
}
parent.removeAllViews()
adView?.destroy()
adView = null
adView = AdView(context)
parent.addView(adView)
adView?.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(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(adClose)
parent.viewTreeObserver.removeOnGlobalLayoutListener(listener)
}
parent.viewTreeObserver.addOnGlobalLayoutListener(listener)
}
private fun loadCollapsibleBanner(adClose: (() -> Unit)?) {
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")
adClose?.invoke()
}
}
adView?.loadAd(adRequest)
}
}
\ No newline at end of file
package com.base.pdfreaderallpdfreader.ads.admob
import android.app.Activity
import android.os.Bundle
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.helper.MyApplication
import com.base.pdfreaderallpdfreader.utils.LogEx
import com.facebook.appevents.AppEventsConstants
import com.facebook.appevents.AppEventsLogger
import com.google.android.gms.ads.AdValue
import com.google.android.gms.ads.AdView
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 {
private val TAG = "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")
}
LogEx.logDebug(TAG, "obj=$obj")
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")
LogEx.logDebug("EventOnPaidEventListener", "precisionType=${adValue.precisionType}")
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()
var key = "ad_price"
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("ad_unit", "openAd")
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("ad_unit", "interAd")
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 -> {
key = "ad_price"
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", "nativeAd")
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)
}
else -> {
runCatching {
val adView = ad as AdView
val adUnitId = adView.adUnitId
val loadedAdapterResponseInfo = adView.responseInfo?.loadedAdapterResponseInfo
val adSourceName = loadedAdapterResponseInfo?.adSourceName
val adSourceId = loadedAdapterResponseInfo?.adSourceId
val adSourceInstanceName = loadedAdapterResponseInfo?.adSourceInstanceName
val adSourceInstanceId = loadedAdapterResponseInfo?.adSourceInstanceId
val sessionId = adView.responseInfo?.responseId
val extras = adView.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("ad_unit", "banner")
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)
}
}
}
EventUtils.event(key, 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("ad_show", ext = obj)
}
}
}
\ No newline at end of file
package com.base.pdfreaderallpdfreader.ads.admob
import android.app.Activity
import android.app.Dialog
import android.widget.Toast
import com.base.pdfreaderallpdfreader.BuildConfig
import com.base.pdfreaderallpdfreader.ads.AdDialog.showAdPreparingDialog
import com.base.pdfreaderallpdfreader.ads.AdDisplayUtils
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.lastShowedOnHiddenTime
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.clickAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.pullAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.showAd
import com.base.pdfreaderallpdfreader.helper.ConfigHelper
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.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 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.shouldShowInterAd()) {
onHidden?.invoke(false)
return
}
val obj1 = JSONObject()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
if (interAd != null) {
var dialog: Dialog? = null
if (!activity.isFinishing && !activity.isDestroyed) {
dialog = activity.showAdPreparingDialog()
}
displayInterstitialAd(activity, dialog, onHidden)
} else {
showAdDialogAndLoadInterstitial(activity, isReLoadAd, isShowDialog, onHidden)
}
}
fun loadInterstitialAd(activity: Activity, onLoad: (() -> Unit)? = null) {
if (interAd != null) {
onLoad?.invoke()
return
}
if (!AdDisplayUtils.shouldShowInterAd()) {
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)
AdDisplayUtils.incrementInterRequestCount()
}
})
}
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,
dialog: Dialog? = null,
onHidden: ((showed: Boolean) -> Unit)? = null
) {
val thisInterAd = interAd
interAd = null
thisInterAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdClicked() {
clickAd(thisInterAd?.responseInfo, "interAd")
AdDisplayUtils.incrementInterClickCount()
}
override fun onAdDismissedFullScreenContent() {
dialog?.dismiss()
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.incrementInterShowCount()
adLastDisplayTime = System.currentTimeMillis() / 1000
}
}
thisInterAd?.show(activity)
}
fun haveReadAd(): Boolean {
return interAd != null
}
}
\ No newline at end of file
package com.base.pdfreaderallpdfreader.ads.admob
import android.app.Activity
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.base.pdfreaderallpdfreader.BuildConfig
import com.base.pdfreaderallpdfreader.R
import com.base.pdfreaderallpdfreader.ads.AdDisplayUtils
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.clickAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.pullAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.showAd
import com.base.pdfreaderallpdfreader.helper.ConfigHelper
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.helper.MyApplication
import com.base.pdfreaderallpdfreader.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
fun loadNativeAd() {
if (nativeAd != null) {
return
}
if (isLoading) {
return
}
isLoading = true
if (!AdDisplayUtils.shouldShowNative()) {
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
it.setOnPaidEventListener(AdmobEvent.EventOnPaidEventListener(it))
LogEx.logDebug(TAG, "nativeAd=${nativeAd.toString()}")
isLoading = false
loadingListener?.invoke()
loadingListener = null
pullAd(it.responseInfo, "nativeAd", reqId = reqId)
}.withAdListener(object : AdListener() {
override fun onAdLoaded() {
super.onAdLoaded()
onAdLoaded?.invoke()
onAdLoaded = null
AdDisplayUtils.incrementNativeRequestCount()
}
override fun onAdClicked() {
clickAd(nativeAd?.responseInfo, "nativeAd")
AdDisplayUtils.incrementNativeClickCount()
}
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", ext = obj)
if (!AdDisplayUtils.shouldShowNative()) {
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
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()
loadingListener = null
}
}
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)
}
}
}
fun onDestroy() {
nativeAd?.destroy()
nativeAd = null
}
}
\ No newline at end of file
package com.base.pdfreaderallpdfreader.ads.admob
import android.app.Activity
import com.base.pdfreaderallpdfreader.BuildConfig
import com.base.pdfreaderallpdfreader.ads.AdDisplayUtils
import com.base.pdfreaderallpdfreader.ads.AdmobHelper.lastShowedOnHiddenTime
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.clickAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.pullAd
import com.base.pdfreaderallpdfreader.ads.admob.AdmobEvent.showAd
import com.base.pdfreaderallpdfreader.helper.ConfigHelper
import com.base.pdfreaderallpdfreader.helper.EventUtils
import com.base.pdfreaderallpdfreader.helper.MyApplication
import com.base.pdfreaderallpdfreader.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
private fun isAdExpired(): Boolean {
return System.currentTimeMillis() - openLoadTime > 1000 * 60 * 60
}
fun haveReadAd(): Boolean {
return mOpenAd != null
}
fun loadAppOpenAd(onLoad: ((loaded: Boolean) -> Unit)? = null) {
if (mOpenAd != null) {
onLoad?.invoke(true)
return
}
if (!AdDisplayUtils.shouldShowOpenAd()) {
onLoad?.invoke(false)
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(true)
pullAd(ad.responseInfo, "openAd", reqId = reqId)
ad.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(ad)
AdDisplayUtils.incrementOpenRequestCount()
}
override fun onAdFailedToLoad(p0: LoadAdError) {
LogEx.logDebug(TAG, "LoadAdError ${p0.message}")
mOpenAd = null
onLoad?.invoke(false)
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) {
LogEx.logDebug(TAG, "activity isDestroyed")
return
}
if (!AdDisplayUtils.shouldShowOpenAd()) {
onHidden?.invoke(false)
return
}
if (isAdExpired()) {
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")
AdDisplayUtils.incrementClickShow()
}
override fun onAdDismissedFullScreenContent() {
mOpenAd = null
onHidden?.invoke(true)
loadAppOpenAd()
lastShowedOnHiddenTime = System.currentTimeMillis()
}
override fun onAdFailedToShowFullScreenContent(p0: AdError) {
mOpenAd = null
onHidden?.invoke(false)
loadAppOpenAd()
val obj = JSONObject()
obj.put("reason", p0.message)
obj.put("code", p0.code)
obj.put("ad_unit", "openAd")
EventUtils.event("ad_show_error", ext = obj)
}
override fun onAdShowedFullScreenContent() {
showBefore?.invoke(true)
showAd(thisMOpenAd?.responseInfo, "openAd", activity)
AdDisplayUtils.incrementOpenShow()
}
}
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
package com.base.pdfreaderallpdfreader.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.base.pdfreaderallpdfreader.R
import com.google.android.gms.ads.nativead.NativeAd
import com.google.android.gms.ads.nativead.NativeAdView
@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
...@@ -4,7 +4,7 @@ import android.net.Uri ...@@ -4,7 +4,7 @@ import android.net.Uri
data class DocumentBean( data class DocumentBean(
var path: String = "", var path: String = "",
var uri: Uri = Uri.EMPTY, var uri: Uri? = null,
var type: String = "", var type: String = "",
var isBookmarked: Boolean = false, var isBookmarked: Boolean = false,
) { ) {
......
package com.base.pdfreaderallpdfreader.helper
import android.os.Build
import com.base.pdfreaderallpdfreader.BuildConfig
import com.base.pdfreaderallpdfreader.bean.ConstObject.ifAgreePrivacy
import com.base.pdfreaderallpdfreader.helper.ReportUtils.doPost
import com.base.pdfreaderallpdfreader.utils.AppPreferences
import com.base.pdfreaderallpdfreader.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, "url=$url")
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
...@@ -18,6 +18,7 @@ import com.base.pdfreaderallpdfreader.ui.main.getExcelDocument ...@@ -18,6 +18,7 @@ import com.base.pdfreaderallpdfreader.ui.main.getExcelDocument
import com.base.pdfreaderallpdfreader.ui.main.getPdfDocument import com.base.pdfreaderallpdfreader.ui.main.getPdfDocument
import com.base.pdfreaderallpdfreader.ui.main.getPptDocument import com.base.pdfreaderallpdfreader.ui.main.getPptDocument
import com.base.pdfreaderallpdfreader.ui.main.getWordDocument import com.base.pdfreaderallpdfreader.ui.main.getWordDocument
import com.base.pdfreaderallpdfreader.ui.pdf.PdfActivity
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
...@@ -45,6 +46,9 @@ class DocumentFragment() : Fragment() { ...@@ -45,6 +46,9 @@ class DocumentFragment() : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
adapter = DocumentAdapter() adapter = DocumentAdapter()
adapter?.itemClickAction = { item: DocumentBean ->
PdfActivity.jumpPdfActivity(requireActivity(), item)
}
binding.rv.adapter = adapter binding.rv.adapter = adapter
} }
...@@ -106,6 +110,18 @@ class DocumentFragment() : Fragment() { ...@@ -106,6 +110,18 @@ class DocumentFragment() : Fragment() {
} }
} }
fun renameDocumentBean(file: File, newName: String) {
try {
val newFile = File(file.parentFile, newName)
val result = file.renameTo(newFile)
if (result) {
initData()
}
} catch (e: Exception) {
e.printStackTrace()
}
}
companion object { companion object {
var pdfNeedRefresh: Boolean = true var pdfNeedRefresh: Boolean = true
} }
......
...@@ -32,7 +32,7 @@ class LanguageActivity : BaseActivity<ActivityLanguageBinding>() { ...@@ -32,7 +32,7 @@ class LanguageActivity : BaseActivity<ActivityLanguageBinding>() {
adapter = LanguageAdapter() adapter = LanguageAdapter()
binding.rv.adapter = adapter binding.rv.adapter = adapter
// AdmobNativeUtils.showNativeAd(this, binding.flAd) // com.base.pdfreaderallpdfreader.ads.admob.AdmobNativeUtils.showNativeAd(this, binding.flAd)
initData() initData()
} }
......
...@@ -26,6 +26,7 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV ...@@ -26,6 +26,7 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
inner class DocumentViewHolder(view: View) : ViewHolder(view) inner class DocumentViewHolder(view: View) : ViewHolder(view)
var moreAction: ((item: DocumentBean) -> Unit)? = null var moreAction: ((item: DocumentBean) -> Unit)? = null
var itemClickAction: ((item: DocumentBean) -> Unit)? = null
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: DocumentViewHolder, position: Int, item: DocumentBean?) { override fun onBindViewHolder(holder: DocumentViewHolder, position: Int, item: DocumentBean?) {
...@@ -61,6 +62,9 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV ...@@ -61,6 +62,9 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
binding.flMore.setOnClickListener { binding.flMore.setOnClickListener {
moreAction?.invoke(item) moreAction?.invoke(item)
} }
binding.root.setOnClickListener {
itemClickAction?.invoke(item)
}
} }
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DocumentViewHolder { override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DocumentViewHolder {
......
...@@ -84,8 +84,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -84,8 +84,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
private fun starAdGmsScan() { private fun starAdGmsScan() {
// if (AdmobHelper.isShowScanInter() && AdmobHelper.canCommonShowAd()) { // if (com.base.pdfreaderallpdfreader.ads.AdmobHelper.isShowScanInter() && com.base.pdfreaderallpdfreader.ads.AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(activity) { // com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils.showInterstitialAd(activity) {
// if (it) { // if (it) {
// lastScanShowAd = System.currentTimeMillis() // lastScanShowAd = System.currentTimeMillis()
// } // }
......
...@@ -35,7 +35,7 @@ class DocumentPdfAdapter() : BaseQuickAdapter<DocumentBean, DocumentPdfAdapter.D ...@@ -35,7 +35,7 @@ class DocumentPdfAdapter() : BaseQuickAdapter<DocumentBean, DocumentPdfAdapter.D
if (item.isAd) { if (item.isAd) {
//todo //todo
// val binding = ItemAdBinding.bind(holder.itemView) // val binding = ItemAdBinding.bind(holder.itemView)
// AdmobNativeUtils.showNativeAd(null, binding.flAd, R.layout.layout_admob_document) // com.base.pdfreaderallpdfreader.ads.admob.AdmobNativeUtils.showNativeAd(null, binding.flAd, R.layout.layout_admob_document)
} else { } else {
val binding = ItemDocumentPdfBinding.bind(holder.itemView) val binding = ItemDocumentPdfBinding.bind(holder.itemView)
changeIcon(item, binding) changeIcon(item, binding)
......
...@@ -30,9 +30,12 @@ import com.artifex.mupdfdemo.SearchTaskResult ...@@ -30,9 +30,12 @@ import com.artifex.mupdfdemo.SearchTaskResult
import com.base.pdfreaderallpdfreader.R import com.base.pdfreaderallpdfreader.R
import com.base.pdfreaderallpdfreader.base.BaseActivity import com.base.pdfreaderallpdfreader.base.BaseActivity
import com.base.pdfreaderallpdfreader.bean.ConstObject import com.base.pdfreaderallpdfreader.bean.ConstObject
import com.base.pdfreaderallpdfreader.bean.ConstObject.DO_SAVE_PDF
import com.base.pdfreaderallpdfreader.bean.ConstObject.haveGuideGesture import com.base.pdfreaderallpdfreader.bean.ConstObject.haveGuideGesture
import com.base.pdfreaderallpdfreader.bean.DocumentBean
import com.base.pdfreaderallpdfreader.databinding.ActivityPdfBinding import com.base.pdfreaderallpdfreader.databinding.ActivityPdfBinding
import com.base.pdfreaderallpdfreader.ui.view.PdfDialog.showPdfMoreDialog import com.base.pdfreaderallpdfreader.ui.view.PdfDialog.showPdfMoreDialog
import com.base.pdfreaderallpdfreader.ui.view.PwdDialog.showPdfPwdDialog
import com.base.pdfreaderallpdfreader.utils.KeyBoardUtils.hideKeyboard import com.base.pdfreaderallpdfreader.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfreaderallpdfreader.utils.KeyBoardUtils.showKeyBoard import com.base.pdfreaderallpdfreader.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfreaderallpdfreader.utils.LogEx import com.base.pdfreaderallpdfreader.utils.LogEx
...@@ -81,7 +84,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -81,7 +84,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
muPDFCore?.onDestroy() muPDFCore?.onDestroy()
// AdmobNativeUtils.onDestroy() // com.base.pdfreaderallpdfreader.ads.admob.AdmobNativeUtils.onDestroy()
} }
...@@ -151,7 +154,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -151,7 +154,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
} }
} }
// AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in) // com.base.pdfreaderallpdfreader.ads.admob.AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in)
} }
fun jumpPage(pageIndex: Int) { fun jumpPage(pageIndex: Int) {
...@@ -200,10 +203,10 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -200,10 +203,10 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
return@addCallback return@addCallback
} }
// if (AdmobHelper.isShowCloseDocumentInter() && isShowCloseDocument()) { // if (com.base.pdfreaderallpdfreader.ads.AdmobHelper.isShowCloseDocumentInter() && isShowCloseDocument()) {
// AdmobInterstitialUtils.showInterstitialAd(this@PdfActivity) { // com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils.showInterstitialAd(this@PdfActivity) {
// if (it) { // if (it) {
// AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis() // com.base.pdfreaderallpdfreader.ads.AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
// } // }
// binding.root.postDelayed({ finishToMain() }, 500) // binding.root.postDelayed({ finishToMain() }, 500)
// } // }
...@@ -264,14 +267,13 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -264,14 +267,13 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
} }
binding.tvBtnSave.setOnClickListener { binding.tvBtnSave.setOnClickListener {
//todo PdfLoadingActivity.muPDFCore = muPDFCore
// PdfLoadingActivity.muPDFCore = muPDFCore reallySave()
// reallySave() startActivity(Intent(this, PdfLoadingActivity::class.java).apply {
// startActivity(Intent(this, PdfLoadingActivity::class.java).apply { putExtra("doWhat", DO_SAVE_PDF)
// putExtra("doWhat", DO_SAVE_PDF) putExtra("srcPath", path)
// putExtra("srcPath", path) })
// }) finish()
// finish()
} }
binding.ivXuanzhuan.setOnClickListener { binding.ivXuanzhuan.setOnClickListener {
switchOrientation() switchOrientation()
...@@ -289,7 +291,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -289,7 +291,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
} }
binding.ivMore.setOnClickListener { binding.ivMore.setOnClickListener {
val count = muPDFCore?.countPages() ?: 0 val count = muPDFCore?.countPages() ?: 0
showPdfMoreDialog(this, count - 1, path) showPdfMoreDialog(this, count - 1, path, uri, pwd)
} }
} }
...@@ -358,7 +360,6 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -358,7 +360,6 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
binding.rvPager.adapter = pdfPageAdapter binding.rvPager.adapter = pdfPageAdapter
} }
private var isShowTopBottomLayout = true private var isShowTopBottomLayout = true
private fun hideTopBottomLayout() { private fun hideTopBottomLayout() {
if (isShowTopBottomLayout) { if (isShowTopBottomLayout) {
...@@ -428,6 +429,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -428,6 +429,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
} }
private fun bianJiScaleDa() { private fun bianJiScaleDa() {
if (uiMode != UI_MODE_NORMAL) return
if (binding.ivBianji.scaleX == 0f) { if (binding.ivBianji.scaleX == 0f) {
val scaleXAnimator = ObjectAnimator.ofFloat(binding.ivBianji, "scaleX", 0f, 1.0f) val scaleXAnimator = ObjectAnimator.ofFloat(binding.ivBianji, "scaleX", 0f, 1.0f)
scaleXAnimator.duration = 200 scaleXAnimator.duration = 200
...@@ -442,6 +445,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -442,6 +445,8 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
} }
private fun bianJiScaleXiao(endAction: (() -> Unit)? = null) { private fun bianJiScaleXiao(endAction: (() -> Unit)? = null) {
if (uiMode != UI_MODE_NORMAL) return
if (binding.ivBianji.scaleX == 1f) { if (binding.ivBianji.scaleX == 1f) {
val scaleXAnimator = ObjectAnimator.ofFloat(binding.ivBianji, "scaleX", 1.0f, 0f) val scaleXAnimator = ObjectAnimator.ofFloat(binding.ivBianji, "scaleX", 1.0f, 0f)
scaleXAnimator.duration = 200 scaleXAnimator.duration = 200
...@@ -626,13 +631,45 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() { ...@@ -626,13 +631,45 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
const val SAVE_MODE_STRIKETHROUGH = "Strikethrough" const val SAVE_MODE_STRIKETHROUGH = "Strikethrough"
const val SAVE_MODE_PAINTING_BRUSH = "Painting Brush" const val SAVE_MODE_PAINTING_BRUSH = "Painting Brush"
//todo
fun jumpSplit(activity: Activity) { fun jumpPdfActivity(activity: Activity, item: DocumentBean) {
// activity.startActivity(Intent(activity, PdfSplitActivity::class.java).apply { if (item.type == DocumentBean.TYPE_PDF) {
// putExtra("path", path) if (item.state == 0) {
// putExtra("pwd", pwd) activity.startActivity(Intent(activity, PdfActivity::class.java).apply {
// putExtra("uri", uri) putExtra("path", item.path)
// }) putExtra("uri", item.uri)
})
}
if (item.state == 1) {
activity.showPdfPwdDialog(
state = item.state,
path = item.path,
isCheckPwd = true,
verificationAction = { pwd ->
activity.startActivity(Intent(activity, PdfActivity::class.java).apply {
putExtra("path", item.path)
putExtra("uri", item.uri)
putExtra("pwd", pwd)
})
})
}
}
}
fun jumpSplit(activity: Activity, path: String, uri: String? = null, pwd: String? = null) {
activity.startActivity(Intent(activity, PdfSplitActivity::class.java).apply {
putExtra("path", path)
putExtra("uri", uri)
putExtra("pwd", pwd)
})
}
fun jumpSplit(activity: Activity, item: DocumentBean) {
activity.startActivity(Intent(activity, PdfSplitActivity::class.java).apply {
putExtra("path", item.path)
putExtra("uri", item.uri)
putExtra("pwd", item.password)
})
} }
fun jumpMerge(activity: Activity) { fun jumpMerge(activity: Activity) {
......
...@@ -46,8 +46,8 @@ class PdfLoadingActivity : BaseActivity<ActivityPdfLoadingBinding>() { ...@@ -46,8 +46,8 @@ class PdfLoadingActivity : BaseActivity<ActivityPdfLoadingBinding>() {
fun progressFinishAd(next: () -> Unit) { fun progressFinishAd(next: () -> Unit) {
//todo //todo
// if (AdmobHelper.canCommonShowAd()) { // if (com.base.pdfreaderallpdfreader.ads.AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) { // com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils.showInterstitialAd(this) {
// next.invoke() // next.invoke()
// } // }
// } else { // } else {
......
...@@ -150,8 +150,8 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() { ...@@ -150,8 +150,8 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
} }
if (doWhat == DO_LOCK_PDF) { if (doWhat == DO_LOCK_PDF) {
showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = { showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = {
// if (AdmobHelper.canCommonShowAd()) { // if (com.base.pdfreaderallpdfreader.ads.AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) { flag -> // com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
// adapter.remove(it) // adapter.remove(it)
// binding.llEmpty.isVisible = adapter.items.isEmpty() // binding.llEmpty.isVisible = adapter.items.isEmpty()
// } // }
...@@ -163,8 +163,8 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() { ...@@ -163,8 +163,8 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
} }
if (doWhat == DO_UNLOCK_PDF) { if (doWhat == DO_UNLOCK_PDF) {
showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = { showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = {
// if (AdmobHelper.canCommonShowAd()) { // if (com.base.pdfreaderallpdfreader.ads.AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) { flag -> // com.base.pdfreaderallpdfreader.ads.admob.AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
// adapter.remove(it) // adapter.remove(it)
// binding.llEmpty.isVisible = adapter.items.isEmpty() // binding.llEmpty.isVisible = adapter.items.isEmpty()
// } // }
......
...@@ -16,6 +16,7 @@ import com.base.pdfreaderallpdfreader.databinding.DialogDocumentHomeMoreBinding ...@@ -16,6 +16,7 @@ import com.base.pdfreaderallpdfreader.databinding.DialogDocumentHomeMoreBinding
import com.base.pdfreaderallpdfreader.databinding.DialogPageNumberBinding import com.base.pdfreaderallpdfreader.databinding.DialogPageNumberBinding
import com.base.pdfreaderallpdfreader.ui.document.DocumentFragment import com.base.pdfreaderallpdfreader.ui.document.DocumentFragment
import com.base.pdfreaderallpdfreader.ui.view.DialogView.showDeleteDialog import com.base.pdfreaderallpdfreader.ui.view.DialogView.showDeleteDialog
import com.base.pdfreaderallpdfreader.ui.view.NameDialog.showDocumentRenameDialog
import com.base.pdfreaderallpdfreader.utils.IntentShareUtils.documentShare import com.base.pdfreaderallpdfreader.utils.IntentShareUtils.documentShare
import com.base.pdfreaderallpdfreader.utils.KotlinExt.toFormatSize import com.base.pdfreaderallpdfreader.utils.KotlinExt.toFormatSize
import com.base.pdfreaderallpdfreader.utils.KotlinExt.toFormatTime3 import com.base.pdfreaderallpdfreader.utils.KotlinExt.toFormatTime3
...@@ -70,11 +71,10 @@ object DocumentDialog { ...@@ -70,11 +71,10 @@ object DocumentDialog {
} }
} }
binding.llRename.setOnClickListener { binding.llRename.setOnClickListener {
//todo showDocumentRenameDialog(file.name, okAction = { newName ->
// showDocumentRenameDialog(file.name, okAction = { newName -> dialog.dismiss()
// dialog.dismiss() documentFragment.renameDocumentBean(file, newName)
// documentPresenter.renameDocumentBean(file, newName, documentFragment) })
// })
} }
binding.llDetail.setOnClickListener { binding.llDetail.setOnClickListener {
showDocumentDetail(item.path) showDocumentDetail(item.path)
......
...@@ -128,6 +128,8 @@ object PdfDialog { ...@@ -128,6 +128,8 @@ object PdfDialog {
pdfActivity: PdfActivity, pdfActivity: PdfActivity,
pageNumber: Int, pageNumber: Int,
pafPath: String, pafPath: String,
uri: String? = null,
pwd: String? = null,
) { ) {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog) val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogPdfMoreBinding.inflate(LayoutInflater.from(this)) val binding = DialogPdfMoreBinding.inflate(LayoutInflater.from(this))
...@@ -154,7 +156,7 @@ object PdfDialog { ...@@ -154,7 +156,7 @@ object PdfDialog {
} }
binding.llSplit.setOnClickListener { binding.llSplit.setOnClickListener {
dialog.dismiss() dialog.dismiss()
jumpSplit(pdfActivity) jumpSplit(pdfActivity, pafPath, uri, pwd)
} }
binding.llDetail.setOnClickListener { binding.llDetail.setOnClickListener {
showDocumentDetail(pafPath) showDocumentDetail(pafPath)
......
<?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
<?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
...@@ -353,6 +353,7 @@ ...@@ -353,6 +353,7 @@
android:id="@+id/fl_ad" android:id="@+id/fl_ad"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent">
<ImageView <ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="180dp"
android:layout_height="136dp"
android:layout_margin="5dp"
app:cardCornerRadius="25dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="23dp"
android:src="@mipmap/jiazai_ad"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18dp"
android:layout_marginBottom="22dp"
android:includeFontPadding="false"
android:text="@string/preparing_advertisement"
android:textColor="@color/black"
android:textSize="13sp"
tools:ignore="HardcodedText" />
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<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
...@@ -5,4 +5,6 @@ ...@@ -5,4 +5,6 @@
<dimen name="nav_header_vertical_spacing">8dp</dimen> <dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen> <dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen> <dimen name="fab_margin">16dp</dimen>
<dimen name="dp_200">200dp</dimen>
<dimen name="dp_146">146dp</dimen>
</resources> </resources>
\ No newline at end of file
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
<string name="rate_us">Rate US</string> <string name="rate_us">Rate US</string>
<string name="share">Share</string> <string name="share">Share</string>
<string name="privacy_policy">Privacy Policy</string> <string name="privacy_policy">Privacy Policy</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="follow_system">Follow System</string> <string name="follow_system">Follow System</string>
<string name="select_language">Select Language</string> <string name="select_language">Select Language</string>
...@@ -63,6 +62,7 @@ ...@@ -63,6 +62,7 @@
<string name="splitting_pdf_please_wait">Splitting PDF, please wait.</string> <string name="splitting_pdf_please_wait">Splitting PDF, please wait.</string>
<string name="add">Add</string> <string name="add">Add</string>
<string name="merge">Merge</string> <string name="merge">Merge</string>
<string name="preparing_advertisement">Preparing advertisement…</string>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment