Commit d1841811 authored by wanglei's avatar wanglei

...

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