import com.enqualcomm.support.service.Deliver;
import com.ic.protocols.protocolAPIHelper;
import com.ic.protocols.protocol_s123;
+import com.ic.view.battery.BatteryLowLevTipsView;
import com.ic.view.battery.ChargeTipsView;
import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
mRuntime.setHaveBatteryChange(true);
mRuntime.setBatteryLow(false);
} else if (batLevel <= 15 && batLevel > 10) {
- ChargeTipsView.getInstance().showMsgDialog();
+ ChargeTipsView.getInstance().showDialog();
+ BatteryLowLevTipsView.getInstance().dismiss();
ICLogger.d("on lower power please get charge...");
if (Config.LOG_TOFILE) ICLogger.logToFile("Battery", "BatteryLow less than 15%!");
checkAndSendBatteryEvent(param1Context, mRuntime);
mRuntime.setBatteryLow(true);
} else {
ChargeTipsView.getInstance().dismiss();
+ BatteryLowLevTipsView.getInstance().showDialog();
//这里则会显示可能会关机
ICLogger.d("on lower then 5 percent..." + batLevel);
if (Config.LOG_TOFILE) ICLogger.logToFile("Battery", "BatteryLow less than 5% !");
--- /dev/null
+package com.ic.view.battery;
+
+import android.content.Context;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.enqualcomm.support.ICApplication;
+import com.enqualcomm.support.R;
+import com.enqualcomm.support.utils.ICLogger;
+
+/**
+ * 低电量提示的UI,提示可能会关机
+ * 提示时机:电量到5%的时候
+ * 消失时机,电量超过5%
+ */
+public class BatteryLowLevTipsView {
+
+ private WindowManager windowManager;
+ private View view;
+
+ private BatteryLowLevTipsView() {
+
+ }
+
+ private static BatteryLowLevTipsView sInstance;
+
+ public static BatteryLowLevTipsView getInstance() {
+ if (sInstance == null) {
+ sInstance = new BatteryLowLevTipsView();
+ }
+ return sInstance;
+ }
+
+ private boolean isShow = false;
+
+ public void showDialog() {
+ ICLogger.d("showMsgDialog..." + isShow);
+ if (isShow) {
+ return;
+ }
+ isShow = true;
+ Context context = ICApplication.sContext;
+ windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ //设置属性
+ WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+ layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+ layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.packageName = context.getPackageName();
+ layoutParams.gravity = Gravity.CENTER;
+ //加载布局
+ view = View.inflate(context, R.layout.battery_low_tips_dialog_layout, null);
+ windowManager.addView(view, layoutParams);
+ }
+
+
+ public void dismiss() {
+ this.isShow = false;
+ if (windowManager != null) {
+ windowManager.removeView(view);
+ }
+ sInstance = null;
+ windowManager = null;
+ }
+
+
+}
\ No newline at end of file
private View btnView;
private ChargeTipsView() {
- //获取到数据库里的数据,显示快捷回复列表
+
}
private static ChargeTipsView sInstance;
private boolean isShow = false;
- public void showMsgDialog() {
+ public void showDialog() {
ICLogger.d("showMsgDialog..." + isShow);
if (isShow) {
return;
public void dismiss() {
this.isShow = false;
- contentResolver.unregisterContentObserver(observer);
- windowManager.removeView(view);
- executorService.shutdown();
+ if (contentResolver != null) {
+ contentResolver.unregisterContentObserver(observer);
+ }
+ if (windowManager != null) {
+ windowManager.removeView(view);
+ }
+ if (executorService != null) {
+ executorService.shutdown();
+ }
executorService = null;
sInstance = null;
contentResolver = null;
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#000000">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@mipmap/battery_low_icon" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center"
+ android:layout_marginBottom="10dp"
+ android:text="@string/battery_to_low"
+ android:textColor="@color/white"
+ android:textSize="26sp" />
+
+ </FrameLayout>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/device_shutdown_tips_text"
+ android:textColor="#CCCCCC"
+ android:textSize="22sp" />
+
+ </LinearLayout>
+
+</FrameLayout>
\ No newline at end of file
<string name="out_temp_too_low_text">环境温度过低</string>\r
<string name="tips_charge_text">低电,请充电</string>\r
<string name="urgent_call_text">紧急呼救</string>\r
+ <string name="battery_to_low">电量过低</string>\r
+ <string name="device_shutdown_tips_text">设备随时关机</string>\r
</resources>\r
<string name="out_temp_too_low_text">环境温度过低</string>\r
<string name="tips_charge_text">低电,请充电</string>\r
<string name="urgent_call_text">紧急呼救</string>\r
+ <string name="battery_to_low">电量过低</string>\r
+ <string name="device_shutdown_tips_text">设备随时关机</string>\r
</resources>\r
<string name="out_temp_too_low_text">环境温度过低</string>\r
<string name="tips_charge_text">低电,请充电</string>\r
<string name="urgent_call_text">紧急呼救</string>\r
+ <string name="battery_to_low">电量过低</string>\r
+ <string name="device_shutdown_tips_text">设备随时关机</string>\r
</resources>\r
<string name="out_temp_too_low_text">環境温度が低すぎる</string>
<string name="tips_charge_text">低电,请充电</string>
<string name="urgent_call_text">紧急呼救</string>
+ <string name="battery_to_low">电量过低</string>
+ <string name="device_shutdown_tips_text">设备随时关机</string>
</resources>
<string name="out_temp_too_low_text">环境温度过低</string>
<string name="tips_charge_text">低电,请充电</string>
<string name="urgent_call_text">紧急呼救</string>
+ <string name="battery_to_low">电量过低</string>
+ <string name="device_shutdown_tips_text">设备随时关机</string>
</resources>
\ No newline at end of file
<string name="out_temp_too_low_text">环境温度过低</string>
<string name="tips_charge_text">低电,请充电</string>
<string name="urgent_call_text">紧急呼救</string>
+ <string name="battery_to_low">电量过低</string>
+ <string name="device_shutdown_tips_text">设备随时关机</string>
</resources>
<string name="out_temp_too_low_text">环境温度过低</string>
<string name="tips_charge_text">低电,请充电</string>
<string name="urgent_call_text">紧急呼救</string>
+ <string name="battery_to_low">电量过低</string>
+ <string name="device_shutdown_tips_text">设备随时关机,请及时充电</string>
</resources>