Commit b648a580 authored by wanglei's avatar wanglei

...

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