|
|
|
@ -15,6 +15,7 @@ import android.widget.TextView
|
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
|
import com.yinuo.safetywatcher.databinding.LayoutTopbarBinding
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.AppData
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.BatteryHelper
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SimHelper
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.WifiHelper
|
|
|
|
@ -95,19 +96,27 @@ class CommonTopBar : LinearLayout {
|
|
|
|
|
private val simCallback = object : SimHelper.OnSimLevelCallback {
|
|
|
|
|
override fun onEnable(enable: Boolean) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "simCallback onEnable = $enable")
|
|
|
|
|
mBinding?.fourG?.post {
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
if (enable) {
|
|
|
|
|
mBinding?.fourG?.visibility = VISIBLE
|
|
|
|
|
if (mBinding?.fourG?.visibility != VISIBLE) {
|
|
|
|
|
mBinding?.fourG?.visibility = VISIBLE
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mBinding?.fourG?.visibility = GONE
|
|
|
|
|
if (mBinding?.fourG?.visibility != GONE) {
|
|
|
|
|
mBinding?.fourG?.visibility = GONE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onLevel(level: Int) {
|
|
|
|
|
Log.i(this@CommonTopBar.javaClass.name, "simCallback onLevel = $level")
|
|
|
|
|
mBinding?.fourG?.post {
|
|
|
|
|
val showLevel = (level + 1) * 20
|
|
|
|
|
mBinding?.root?.post {
|
|
|
|
|
var showLevel =
|
|
|
|
|
if (AppData.hasCameraData()) (level / 15 + 1) * 20 else (level + 1) * 20
|
|
|
|
|
if (showLevel > 100) {
|
|
|
|
|
showLevel = 100
|
|
|
|
|
}
|
|
|
|
|
mBinding?.fourG?.setImageLevel(showLevel)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|