|
@@ -6,6 +6,7 @@ import android.content.Intent
|
|
import android.content.IntentFilter
|
|
import android.content.IntentFilter
|
|
import android.graphics.Color
|
|
import android.graphics.Color
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
|
|
+import android.os.BatteryManager
|
|
import android.os.Build
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.os.CountDownTimer
|
|
import android.os.CountDownTimer
|
|
@@ -61,6 +62,7 @@ import kotlinx.android.synthetic.main.watch_activity_register.*
|
|
import org.greenrobot.eventbus.Subscribe
|
|
import org.greenrobot.eventbus.Subscribe
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
|
|
|
|
|
+
|
|
//@Router(path = "/watch/home")
|
|
//@Router(path = "/watch/home")
|
|
class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivityHome2Binding>(), WatchHomeActivityContract.View, View.OnClickListener {
|
|
class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivityHome2Binding>(), WatchHomeActivityContract.View, View.OnClickListener {
|
|
|
|
|
|
@@ -86,8 +88,10 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
if (!isTaskRoot) {
|
|
if (!isTaskRoot) {
|
|
finish()
|
|
finish()
|
|
}
|
|
}
|
|
- loadingDialog = CommonTool.createLoadingDialog(this, R.layout.custom_loading, R.id.loadding_image)
|
|
|
|
- netOffLoadingDialog = CommonTool.createLoadingDialog(this, R.layout.netoff_loading, R.id.netoff_loading_image)
|
|
|
|
|
|
+ loadingDialog =
|
|
|
|
+ CommonTool.createLoadingDialog(this, R.layout.custom_loading, R.id.loadding_image)
|
|
|
|
+ netOffLoadingDialog =
|
|
|
|
+ CommonTool.createLoadingDialog(this, R.layout.netoff_loading, R.id.netoff_loading_image)
|
|
|
|
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
}
|
|
}
|
|
@@ -117,7 +121,8 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
initCountDownTimer()
|
|
initCountDownTimer()
|
|
|
|
|
|
//网络强度监听
|
|
//网络强度监听
|
|
- teleManager = (applicationContext.getSystemService(Context.TELEPHONY_SERVICE)) as TelephonyManager
|
|
|
|
|
|
+ teleManager =
|
|
|
|
+ (applicationContext.getSystemService(Context.TELEPHONY_SERVICE)) as TelephonyManager
|
|
netType = NetHelper.getInstance().getNetworkState(applicationContext)
|
|
netType = NetHelper.getInstance().getNetworkState(applicationContext)
|
|
Log.i(TAG, "网络类型:" + netType)
|
|
Log.i(TAG, "网络类型:" + netType)
|
|
/*
|
|
/*
|
|
@@ -131,7 +136,9 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
if (teleManager != null) {
|
|
if (teleManager != null) {
|
|
teleManager.listen(object : PhoneStateListener() {
|
|
teleManager.listen(object : PhoneStateListener() {
|
|
override fun onSignalStrengthsChanged(signalStrength: SignalStrength) {
|
|
override fun onSignalStrengthsChanged(signalStrength: SignalStrength) {
|
|
- if (NetHelper.getInstance().getNetworkState(applicationContext) == NetHelper.NETWORK_NONE) {
|
|
|
|
|
|
+ if (NetHelper.getInstance()
|
|
|
|
+ .getNetworkState(applicationContext) == NetHelper.NETWORK_NONE
|
|
|
|
+ ) {
|
|
tv_signal_strength.text = "网络断开"
|
|
tv_signal_strength.text = "网络断开"
|
|
} else {
|
|
} else {
|
|
val signalinfo = signalStrength.toString()
|
|
val signalinfo = signalStrength.toString()
|
|
@@ -171,8 +178,9 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
if (!Settings.canDrawOverlays(this)) {
|
|
if (!Settings.canDrawOverlays(this)) {
|
|
val intent = Intent(
|
|
val intent = Intent(
|
|
- Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
|
|
- Uri.parse("package:$packageName"))
|
|
|
|
|
|
+ Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
|
|
+ Uri.parse("package:$packageName")
|
|
|
|
+ )
|
|
startActivityForResult(intent, 10)
|
|
startActivityForResult(intent, 10)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -640,6 +648,8 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
onTcpConnectFailed()
|
|
onTcpConnectFailed()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ updatePower()
|
|
|
|
+
|
|
Constants.allowVoiceMsg = true
|
|
Constants.allowVoiceMsg = true
|
|
tv_im_count.text = "" + WdKeepAliveService.channelImList.size
|
|
tv_im_count.text = "" + WdKeepAliveService.channelImList.size
|
|
|
|
|
|
@@ -745,6 +755,32 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
//super.onBackPressed()
|
|
//super.onBackPressed()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun getPower(): Int {
|
|
|
|
+ val mBatteryManager = getSystemService(BATTERY_SERVICE) as BatteryManager
|
|
|
|
+ val power = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
|
|
|
+ Log.d(TAG, "power energy: power percent: $power")
|
|
|
|
+
|
|
|
|
+ return power
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun updatePower() {
|
|
|
|
+ val power = getPower()
|
|
|
|
+ if (10 < power && power < 20) {
|
|
|
|
+ electric_quantity_tv.text = "" + power
|
|
|
|
+ battery_warning_tv.setTextColor(Color.parseColor("#FF3030"))
|
|
|
|
+ battery_warning_tv.visibility = View.VISIBLE
|
|
|
|
+ battery_warning_tv.text = "低电量,请注意充电"
|
|
|
|
+ } else if (10 > power) {
|
|
|
|
+ electric_quantity_tv.text = "" + power
|
|
|
|
+ battery_warning_tv.setTextColor(Color.parseColor("#8B2323"))
|
|
|
|
+ battery_warning_tv.visibility = View.VISIBLE
|
|
|
|
+ battery_warning_tv.text = "电量过低,请充电"
|
|
|
|
+ } else {
|
|
|
|
+ battery_warning_tv.visibility = View.GONE
|
|
|
|
+ electric_quantity_tv.text = "" + power
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onDestroy() {
|
|
override fun onDestroy() {
|
|
super.onDestroy()
|
|
super.onDestroy()
|
|
if (loadingDialog != null) {
|
|
if (loadingDialog != null) {
|
|
@@ -762,7 +798,9 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
list_item_img_icon_num.text = "" + message.size
|
|
list_item_img_icon_num.text = "" + message.size
|
|
} else if (messageEvent.tag == Constants.EVENT_BATTERY_PERCENT) {
|
|
} else if (messageEvent.tag == Constants.EVENT_BATTERY_PERCENT) {
|
|
var message = messageEvent.getMessage() as Int
|
|
var message = messageEvent.getMessage() as Int
|
|
- if (10 < message && message < 20) {
|
|
|
|
|
|
+ updatePower()
|
|
|
|
+
|
|
|
|
+ /*if (10 < message && message < 20) {
|
|
electric_quantity_tv.text = "" + message
|
|
electric_quantity_tv.text = "" + message
|
|
battery_warning_tv.setTextColor(Color.parseColor("#FF3030"))
|
|
battery_warning_tv.setTextColor(Color.parseColor("#FF3030"))
|
|
battery_warning_tv.visibility = View.VISIBLE
|
|
battery_warning_tv.visibility = View.VISIBLE
|
|
@@ -775,7 +813,7 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
} else {
|
|
} else {
|
|
battery_warning_tv.visibility = View.GONE
|
|
battery_warning_tv.visibility = View.GONE
|
|
electric_quantity_tv.text = "" + message
|
|
electric_quantity_tv.text = "" + message
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
} else if (messageEvent.tag == Constants.EVENT_RTC_STATE) {
|
|
} else if (messageEvent.tag == Constants.EVENT_RTC_STATE) {
|
|
runOnUiThread(Runnable {
|
|
runOnUiThread(Runnable {
|
|
sip_state_tv.setBackgroundColor(Color.parseColor("#00FFFF"))
|
|
sip_state_tv.setBackgroundColor(Color.parseColor("#00FFFF"))
|