Commit b648a580 authored by wanglei's avatar wanglei

...

parent 6578e535
...@@ -6,6 +6,7 @@ import android.content.Context ...@@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import com.base.locationsharewhite.R import com.base.locationsharewhite.R
import com.base.locationsharewhite.bean.ConstObject.appLanguageCountrySp import com.base.locationsharewhite.bean.ConstObject.appLanguageCountrySp
...@@ -14,6 +15,9 @@ import com.base.locationsharewhite.ui.main.MainActivity ...@@ -14,6 +15,9 @@ import com.base.locationsharewhite.ui.main.MainActivity
import com.base.locationsharewhite.utils.ActivityLauncher import com.base.locationsharewhite.utils.ActivityLauncher
import com.base.locationsharewhite.utils.LogEx import com.base.locationsharewhite.utils.LogEx
import com.hjq.language.MultiLanguages import com.hjq.language.MultiLanguages
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.Locale import java.util.Locale
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
import kotlin.random.Random import kotlin.random.Random
...@@ -35,7 +39,9 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() { ...@@ -35,7 +39,9 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
launcher = ActivityLauncher(this) launcher = ActivityLauncher(this)
setContentView(binding.root) setContentView(binding.root)
EventUtils.event("page_${javaClass.simpleName}") EventUtils.event("page_${javaClass.simpleName}")
currentLocale = Locale(appLanguageSp, appLanguageCountrySp) lifecycleScope.launch(Dispatchers.IO) {
currentLocale = Locale(appLanguageSp, appLanguageCountrySp)
}
initView() initView()
initListener() initListener()
} }
...@@ -46,12 +52,15 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() { ...@@ -46,12 +52,15 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
protected open fun initListener() {} protected open fun initListener() {}
fun finishToMain() { fun finishToMain(delay: Long = 0) {
val flag = this !is MainActivity && !ActivityManagerUtils.getInstance().isActivityInStack(MainActivity::class.java) val flag = this !is MainActivity && !ActivityManagerUtils.getInstance().isActivityInStack(MainActivity::class.java)
if (flag) { if (flag) {
startActivity(Intent(this, MainActivity::class.java)) startActivity(Intent(this, MainActivity::class.java))
} }
finish() lifecycleScope.launch(Dispatchers.Main) {
delay(delay)
finish()
}
} }
fun finishToMainTop() { fun finishToMainTop() {
...@@ -131,7 +140,7 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() { ...@@ -131,7 +140,7 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
private var onResumeOneShootI = 0 private var onResumeOneShootI = 0
open fun onResumeOneShoot() { open fun onResumeOneShoot() {
onResumeOneShootI++ onResumeOneShootI++
LogEx.logDebug(TAG, "lifecycle $tagNo onResumeOneShootI ${javaClass.simpleName} $onResumeOneShootI") LogEx.logDebug(TAG, "lifecycle $tagNo onResumeOneShoot ${javaClass.simpleName} $onResumeOneShootI")
} }
private var onResumeI = 0 private var onResumeI = 0
......
...@@ -99,9 +99,12 @@ class MyApplication : Application() { ...@@ -99,9 +99,12 @@ class MyApplication : Application() {
initConfig() initConfig()
InstallHelps.init { Thread {
initRemoteConfig() InstallHelps.init {
} initRemoteConfig()
}
}.start()
SolarEngineManager.getInstance().preInit(this, solarkey) SolarEngineManager.getInstance().preInit(this, solarkey)
initLifeListener() initLifeListener()
......
...@@ -26,8 +26,8 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() { ...@@ -26,8 +26,8 @@ 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 recreated = changeLanguage(this, intent.extras ?: Bundle()) // val recreated = changeLanguage(this, intent.extras ?: Bundle())
if (recreated) return // if (recreated) return
isGuide = intent.extras?.getBoolean("isGuide", false) ?: false isGuide = intent.extras?.getBoolean("isGuide", false) ?: false
LogEx.logDebug(TAG, "isGuide=$isGuide") LogEx.logDebug(TAG, "isGuide=$isGuide")
...@@ -52,7 +52,7 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() { ...@@ -52,7 +52,7 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() {
override fun onResumeOneShoot() { override fun onResumeOneShoot() {
super.onResumeOneShoot() super.onResumeOneShoot()
val recreated = changeLanguage(this) val recreated = changeLanguage(this, intent.extras ?: Bundle())
if (recreated) return if (recreated) return
} }
...@@ -62,15 +62,15 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() { ...@@ -62,15 +62,15 @@ class HowUseActivity : BaseActivity<ActivityHowUseBinding>() {
if (AdsMgr.adsConfigBean.functionBackShowAd) { if (AdsMgr.adsConfigBean.functionBackShowAd) {
AdsMgr.showInsert(this@HowUseActivity, false, object : AdsShowCallBack() { AdsMgr.showInsert(this@HowUseActivity, false, object : AdsShowCallBack() {
override fun close(where: Int) { override fun close(where: Int) {
finishToMain() finishToMain(200)
} }
override fun failed(where: Int) { override fun failed(where: Int) {
finishToMain() finishToMain(200)
} }
override fun googleFailed(where: Int) { override fun googleFailed(where: Int) {
finishToMain() finishToMain(200)
} }
}) })
} else { } else {
......
...@@ -66,37 +66,28 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback { ...@@ -66,37 +66,28 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mainPresenter = MainPresenter(this) mainPresenter = MainPresenter(this)
actionId = intent.extras?.getInt("actionId") actionId = intent.extras?.getInt("actionId")
LogEx.logDebug(TAG, "initView actionId=$actionId", true) // LogEx.logDebug(TAG, "initView actionId=$actionId", true)
//
// val flag1 = checkLocationPermission()
// val flag2 = checkBackgroundLocationPermission()
val flag1 = checkLocationPermission() // LogEx.logDebug(TAG, "权限自定义弹窗 flag1=$flag1 flag2=$flag2")
val flag2 = checkBackgroundLocationPermission()
LogEx.logDebug(TAG, "权限自定义弹窗 flag1=$flag1 flag2=$flag2") // val denyFlag1 = checkLocationPermissionDeniedByUser()
// val denyFlag2 = checkBackgroundLocationPermissionDeniedByUser()
val denyFlag1 = checkLocationPermissionDeniedByUser() // LogEx.logDebug(TAG, "用户拒绝 denyFlag1=$denyFlag1 denyFlag2=$denyFlag2")
val denyFlag2 = checkBackgroundLocationPermissionDeniedByUser()
LogEx.logDebug(TAG, "用户拒绝 denyFlag1=$denyFlag1 denyFlag2=$denyFlag2")
//访问运动数据 //访问运动数据
//https://developer.android.com/develop/sensors-and-location/location/transitions?hl=zh-cn //https://developer.android.com/develop/sensors-and-location/location/transitions?hl=zh-cn
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
launcher.launch(arrayOf(Manifest.permission.ACTIVITY_RECOGNITION)) { // launcher.launch(arrayOf(Manifest.permission.ACTIVITY_RECOGNITION)) {
//
} // }
} // }
val mapFragment =
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
LocationLoginUtils.login() LocationLoginUtils.login()
if (!checkAllLocationPermission()) {
showAllowAllTimeDialog()
} else {
requestServiceLocationUpdates()
}
val flag = areNotificationsEnabled() val flag = areNotificationsEnabled()
EventUtils.event("areNotificationsEnabled", "areNotificationsEnabled=$flag") EventUtils.event("areNotificationsEnabled", "areNotificationsEnabled=$flag")
} }
...@@ -107,6 +98,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback { ...@@ -107,6 +98,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
val recreated = changeLanguage(this) val recreated = changeLanguage(this)
if (recreated) return if (recreated) return
if (!checkAllLocationPermission()) {
showAllowAllTimeDialog()
} else {
requestServiceLocationUpdates()
}
val mapFragment =
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
mainPresenter.startLocationJob(lifecycleScope) mainPresenter.startLocationJob(lifecycleScope)
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"
tools:context=".ui.main.MainActivity"> tools:context=".ui.main.MainActivity">
<ImageView <ImageView
......
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