Commit d1841811 authored by wanglei's avatar wanglei

...

parent c357bb44
......@@ -27,6 +27,8 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
fun registerBatteryStatusReceiver(context: Context) {
val intentFilter = IntentFilter().apply {
addAction(Intent.ACTION_BATTERY_CHANGED)
addAction(Intent.ACTION_POWER_CONNECTED)
addAction(Intent.ACTION_POWER_DISCONNECTED)
}
val applicationContext = context.applicationContext
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
......@@ -116,7 +118,9 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
val action = intent?.action
if (action == Intent.ACTION_BATTERY_CHANGED) {
when (action) {
Intent.ACTION_BATTERY_CHANGED -> {
val batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
val batteryScale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
val batteryPercentage = (batteryLevel / batteryScale.toFloat()) * 100
......@@ -132,6 +136,12 @@ class BatteryStatusReceiver() : BroadcastReceiver() {
currentBatteryPercentage = batteryPercentage
}
Intent.ACTION_POWER_CONNECTED -> {
NotificationUiUtil.sendNotificationIfCan(context, POPUP_WHERE_BATTERY, null)
}
}
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ object NotificationHoverUtils {
val hoverStatus = popupConfigBean.popupHoverStatus
val hoverCount = popupConfigBean.popupHoverCount
val hoverDelay = popupConfigBean.popupHoverDelay.toLong()
if (hoverStatus) return
if (!hoverStatus) return
if (handlerThread == null) {
handlerThread = HandlerThread("NotificationHandlerThread")
......
......@@ -119,11 +119,16 @@ object NotificationUiUtil {
var hoverActionId = ""
private var isUnLimit: Boolean = if (BuildConfig.DEBUG) true else false
@SuppressLint("RemoteViewLayout")
fun sendNotificationIfCan(context: Context, where: String = "", id: String? = null) {
LogEx.logDebug(TAG, "sendNotificationIfCan where=$where")
EventUtils.event("Notification_Popup_Start", "where=$where")
val actionId = id ?: getNextActionId()
if (!isUnLimit) {
//总的限制条件
if (!canSendNotification(where, actionId)) return
......@@ -134,6 +139,7 @@ object NotificationUiUtil {
LogEx.logDebug(TAG, "APP Resumed")
return
}
}
//发送通知
setActionNotification(context, actionId, where)
......
......@@ -55,7 +55,7 @@ class TimerManager private constructor() {
companion object {
val instance: TimerManager by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) { TimerManager() }
private val instance: TimerManager by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) { TimerManager() }
fun changeTimer() {
......
......@@ -16,6 +16,7 @@ import com.base.locationsharewhite.fcm.BatteryStatusReceiver
import com.base.locationsharewhite.fcm.PackageStatusReceiver
import com.base.locationsharewhite.fcm.PopupConstObject
import com.base.locationsharewhite.fcm.ScreenStatusReceiver
import com.base.locationsharewhite.fcm.TimerManager.Companion.changeTimer
import com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm
import com.base.locationsharewhite.helper.config.AppConfig
import com.base.locationsharewhite.service.StayJobService.Companion.startJob
......@@ -210,6 +211,9 @@ class MyApplication : Application() {
//通知
PopupConstObject.popupConfigBean = configBean.popupConfigBean
//启动定时器
changeTimer()
}
}
......
......@@ -150,6 +150,7 @@ class StayJobService : JobService() {
}
override fun onFinish() {
LogEx.logDebug(TAG, "Timer onFinish")
notifyForeground()
Timer().start()
}
......
......@@ -4,6 +4,8 @@ import android.content.Intent
import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.databinding.ActivityHowUseBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.helper.MyApplication
......@@ -22,8 +24,7 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() {
BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
// val isRecreate = isLanguageRecreate(MyApplication.mainLanguage)
// if (isRecreate) return
AdsMgr.showNative(binding.flAd, R.layout.layout_admob_app_exit)
}
override fun initListener() {
......
......@@ -5,6 +5,7 @@ import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.databinding.ActivityLocationCodeBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationLoginUtils
......@@ -27,10 +28,27 @@ class LocationCodeActivity : BaseActivity<ActivityLocationCodeBinding>() {
binding.tvCode.text = LocationLoginUtils.invitationCodeSp
binding.tvCopy.setOnClickListener {
copyText("MyLocationCode", binding.tvCode.text.toString())
toast(resources.getString(R.string.copy))
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
override fun close(where: Int) {
copy()
}
override fun failed(where: Int) {
copy()
}
override fun googleFailed(where: Int) {
copy()
}
AdsMgr.showNative(binding.flAd,R.layout.layout_admob_app_exit,)
})
}
AdsMgr.showNative(binding.flAd, R.layout.layout_admob_app_exit)
}
fun copy() {
copyText("MyLocationCode", binding.tvCode.text.toString())
toast(resources.getString(R.string.copy), true)
}
override fun initListener() {
......
......@@ -107,7 +107,6 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
toast("code is empty", true)
return@setOnClickListener
}
if (code.length >= 8) {
hideKeyBoard()
AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
override fun close(where: Int) {
......@@ -123,10 +122,6 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
}
})
} else {
toast("code verification failed", true)
}
}
}
......@@ -142,7 +137,6 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
LocationShareUtils.shareMyLocationByInvitationCode(code) { status ->
LogEx.logDebug(TAG, "status=$status")
runOnUiThread {
toast("status=$status", true)
when (status) {
SHARE_STATE_FAILED -> {
toast("Code verification failed", true)
......
......@@ -56,7 +56,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="48dp">
android:layout_marginTop="36dp">
<FrameLayout
android:layout_width="match_parent"
......@@ -120,6 +120,11 @@
tools:ignore="ContentDescription" />
</FrameLayout>
<com.base.locationsharewhite.ads.NativeParentView
android:id="@+id/fl_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp" />
</LinearLayout>
......
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