feat: statusBar ui
This commit is contained in:
@@ -6,8 +6,6 @@ import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.yuanxuan.rokid.databinding.ActivityMainBinding
|
||||
import com.yuanxuan.rokid.dependencies.AppDependencies
|
||||
@@ -43,12 +41,9 @@ class MainActivity : AppCompatActivity() {
|
||||
lifecycleScope.launch {
|
||||
AppDependencies.deviceServiceManager.wifiState.collect {
|
||||
when (it) {
|
||||
is DeviceServiceManager.WifiState.Connected -> {
|
||||
binding.wifiIv.setImageLevel(it.level)
|
||||
binding.wifiIv.isVisible = true
|
||||
}
|
||||
is DeviceServiceManager.WifiState.Connected -> binding.wifiIv.setImageLevel(it.level)
|
||||
|
||||
DeviceServiceManager.WifiState.Unconnected -> binding.wifiIv.isGone = true
|
||||
DeviceServiceManager.WifiState.Unconnected -> binding.wifiIv.setImageLevel(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.rokid.dcg.sprite.service.ISystemFuncService
|
||||
import com.rokid.dcg.sprite.service.ITTSService
|
||||
import com.rokid.dcg.sprite.service.ServiceManager
|
||||
import com.rokid.dcg.sprite.syskey.SysKeyAction
|
||||
import com.yuanxuan.rokid.toast.ToastUtils
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -277,6 +278,7 @@ class DeviceServiceManager(val context: Application) : ConnectivityManager.Netwo
|
||||
}
|
||||
|
||||
SysKeyAction.SPRITE_BUTTON_CLICK -> {
|
||||
ToastUtils.showLong("SysKeyAction.SPRITE_BUTTON_CLICK")
|
||||
Timber.d("点击拍照键 SPRITE_BUTTON_CLICK")
|
||||
}
|
||||
|
||||
@@ -306,8 +308,11 @@ class DeviceServiceManager(val context: Application) : ConnectivityManager.Netwo
|
||||
_wifiState.update {
|
||||
val level = wifiManager.calculateSignalLevel(networkCapabilities.signalStrength)
|
||||
WifiState.Connected(
|
||||
// maxSignalLevel是4 level区间应该是 0-3 这里却返回了4 限制一下
|
||||
level = level.coerceAtMost(wifiManager.maxSignalLevel - 1)
|
||||
/**
|
||||
* maxSignalLevel 是 4 level区间应该是 0-3 这里却返回了4 限制一下
|
||||
* 参考 [com.yuanxuan.rokid.R.drawable.wifi_level_list] 0 为wifi断开
|
||||
*/
|
||||
level = level.coerceAtMost(wifiManager.maxSignalLevel - 1) + 1
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user