..
@@ -34,9 +34,13 @@ class FuncConfigNetWorkModel {
|
||||
if (error == null) {
|
||||
error = onError
|
||||
}
|
||||
//todo test
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
// map["sn"] = "20220118J1V4G9W"
|
||||
map["mac"] = DeviceUtils.getMacAddress()
|
||||
// map["mac"] = "48:b0:2d:3a:9d:34"
|
||||
map["channelVersion"] = FuncConfigConst.getChannelCode()
|
||||
// map["channelVersion"] = 2
|
||||
}
|
||||
loader {
|
||||
apiCall {
|
||||
|
||||
@@ -12,10 +12,12 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class BatteryGroupView : LinearLayout {
|
||||
class BatteryGroupView : LinearLayout, IMoGoSkinModeChangeListener {
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
@@ -29,6 +31,7 @@ class BatteryGroupView : LinearLayout {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_battery_group, this, true)
|
||||
private var batteryView: BatteryView = (view as BatteryGroupView).findViewById(R.id.viewBattery)
|
||||
private var ivBatteryCharge: ImageView = (view as BatteryGroupView).findViewById(R.id.ivBatteryCharge)
|
||||
private var mSkinMode = 0
|
||||
|
||||
private val batteryStateReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
@@ -49,6 +52,9 @@ class BatteryGroupView : LinearLayout {
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG = "BatteryGroupView"
|
||||
|
||||
class BatteryHandler(batteryGroupView: BatteryGroupView) : Handler() {
|
||||
|
||||
//虚引用
|
||||
@@ -69,6 +75,10 @@ class BatteryGroupView : LinearLayout {
|
||||
it.batteryView.setCharging(isCharging)
|
||||
if (isCharging) {
|
||||
it.ivBatteryCharge.visibility = View.VISIBLE
|
||||
when(it.mSkinMode){
|
||||
0 -> it.ivBatteryCharge.setImageResource(R.drawable.battery_charge_light)
|
||||
1 -> it.ivBatteryCharge.setImageResource(R.drawable.battery_charge_dark)
|
||||
}
|
||||
} else {
|
||||
it.ivBatteryCharge.visibility = View.GONE
|
||||
}
|
||||
@@ -83,10 +93,17 @@ class BatteryGroupView : LinearLayout {
|
||||
val intentFilter = IntentFilter()
|
||||
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED)
|
||||
context.registerReceiver(batteryStateReceiver, intentFilter)
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
context.unregisterReceiver(batteryStateReceiver)
|
||||
CallerSkinModeListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onSkinModeChange(skinMode: Int) {
|
||||
mSkinMode = skinMode
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
@@ -17,7 +19,7 @@ class WifiStateView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||
) : AppCompatImageView(context, attrs, defStyleAttr), IMoGoSkinModeChangeListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "WifiStateView"
|
||||
@@ -34,15 +36,8 @@ class WifiStateView @JvmOverloads constructor(
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
val wifiStateView = stateViewWeakReference?.get()
|
||||
wifiStateView?.let {
|
||||
when (msg.what) {
|
||||
-1 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_close)
|
||||
0 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_one)
|
||||
1 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_two)
|
||||
2 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_three)
|
||||
3 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_four)
|
||||
4 -> wifiStateView.setImageResource(R.drawable.wifi_light_state_five)
|
||||
}
|
||||
wifiStateView?.updateView(msg.what) {
|
||||
wifiStateView.setImageResource(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +46,12 @@ class WifiStateView @JvmOverloads constructor(
|
||||
private var wifiManager: WifiManager? = null
|
||||
private var wifiHandler: WifiHandler? = null
|
||||
|
||||
@Volatile
|
||||
private var mSkinMode: Int = 0
|
||||
|
||||
@Volatile
|
||||
private var level: Int = 0
|
||||
|
||||
init {
|
||||
wifiManager =
|
||||
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager?
|
||||
@@ -62,12 +63,13 @@ class WifiStateView @JvmOverloads constructor(
|
||||
when (intent.action) {
|
||||
WifiManager.WIFI_STATE_CHANGED_ACTION, WifiManager.RSSI_CHANGED_ACTION -> {
|
||||
if (wifiManager!!.wifiState == WifiManager.WIFI_STATE_DISABLED
|
||||
|| wifiManager!!.wifiState ==WifiManager.WIFI_STATE_DISABLING) {
|
||||
|| wifiManager!!.wifiState == WifiManager.WIFI_STATE_DISABLING
|
||||
) {
|
||||
wifiHandler?.sendEmptyMessage(-1)
|
||||
return
|
||||
}
|
||||
val wifiInfo = wifiManager!!.connectionInfo
|
||||
val level = WifiManager.calculateSignalLevel(wifiInfo.rssi, 5)
|
||||
level = WifiManager.calculateSignalLevel(wifiInfo.rssi, 5)
|
||||
wifiHandler?.sendEmptyMessage(level)
|
||||
}
|
||||
}
|
||||
@@ -82,11 +84,44 @@ class WifiStateView @JvmOverloads constructor(
|
||||
//Wifi信号强度变化
|
||||
intentFilter.addAction(WifiManager.RSSI_CHANGED_ACTION)
|
||||
context.registerReceiver(wifiStateReceiver, intentFilter)
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
wifiHandler?.removeCallbacksAndMessages(null)
|
||||
context.unregisterReceiver(wifiStateReceiver)
|
||||
CallerSkinModeListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onSkinModeChange(skinMode: Int) {
|
||||
mSkinMode = skinMode
|
||||
wifiHandler?.sendEmptyMessage(level)
|
||||
}
|
||||
|
||||
fun updateView(wifiState: Int, resId: ((Int) -> Unit)) {
|
||||
when (mSkinMode) {
|
||||
0 -> {
|
||||
when (wifiState) {
|
||||
-1 -> resId.invoke(R.drawable.wifi_light_state_close)
|
||||
0 -> resId.invoke(R.drawable.wifi_light_state_one)
|
||||
1 -> resId.invoke(R.drawable.wifi_light_state_two)
|
||||
2 -> resId.invoke(R.drawable.wifi_light_state_three)
|
||||
3 -> resId.invoke(R.drawable.wifi_light_state_four)
|
||||
4 -> resId.invoke(R.drawable.wifi_light_state_five)
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
when (wifiState) {
|
||||
-1 -> resId.invoke(R.drawable.wifi_light_state_close)
|
||||
0 -> resId.invoke(R.drawable.wifi_dark_state_one)
|
||||
1 -> resId.invoke(R.drawable.wifi_dark_state_two)
|
||||
2 -> resId.invoke(R.drawable.wifi_dark_state_three)
|
||||
3 -> resId.invoke(R.drawable.wifi_dark_state_four)
|
||||
4 -> resId.invoke(R.drawable.wifi_dark_state_five)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 640 B |
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 467 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -17,6 +17,6 @@
|
||||
android:layout_height="@dimen/dp_22"
|
||||
android:layout_marginStart="@dimen/dp_6"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/battery_charge"
|
||||
android:src="@drawable/battery_charge_light"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||