completed low power tips page.
authorTrillGates <williamtrillgates@gmail.com>
Tue, 14 Sep 2021 09:07:13 +0000 (17:07 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Tue, 14 Sep 2021 09:07:13 +0000 (17:07 +0800)
13 files changed:
app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java
app/src/main/java/com/ic/view/battery/BatteryLowLevTipsView.java [new file with mode: 0644]
app/src/main/java/com/ic/view/battery/ChargeTipsView.java
app/src/main/java/com/ic/view/webmsgresponse/WebMsgView.java
app/src/main/res/layout/battery_low_tips_dialog_layout.xml [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/battery_low_icon.png [new file with mode: 0644]
app/src/main/res/values-de-rCH/strings.xml
app/src/main/res/values-fr-rCH/strings.xml
app/src/main/res/values-it-rCH/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-w820dp/strings.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml

index b329522..3f5fd82 100644 (file)
@@ -26,6 +26,7 @@ import com.enqualcomm.support.service.AudioService;
 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;
@@ -151,7 +152,8 @@ public class BatteryUtil {
             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);
@@ -168,6 +170,7 @@ public class BatteryUtil {
             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% !");
diff --git a/app/src/main/java/com/ic/view/battery/BatteryLowLevTipsView.java b/app/src/main/java/com/ic/view/battery/BatteryLowLevTipsView.java
new file mode 100644 (file)
index 0000000..5bac70a
--- /dev/null
@@ -0,0 +1,68 @@
+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
index 1fb25e2..c492088 100644 (file)
@@ -24,7 +24,7 @@ public class ChargeTipsView {
     private View btnView;
 
     private ChargeTipsView() {
-        //获取到数据库里的数据,显示快捷回复列表
+
     }
 
     private static ChargeTipsView sInstance;
@@ -38,7 +38,7 @@ public class ChargeTipsView {
 
     private boolean isShow = false;
 
-    public void showMsgDialog() {
+    public void showDialog() {
         ICLogger.d("showMsgDialog..." + isShow);
         if (isShow) {
             return;
index 0cd900e..20576ba 100644 (file)
@@ -127,9 +127,15 @@ public class WebMsgView {
 
     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;
diff --git a/app/src/main/res/layout/battery_low_tips_dialog_layout.xml b/app/src/main/res/layout/battery_low_tips_dialog_layout.xml
new file mode 100644 (file)
index 0000000..d554e8a
--- /dev/null
@@ -0,0 +1,43 @@
+<?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
diff --git a/app/src/main/res/mipmap-mdpi/battery_low_icon.png b/app/src/main/res/mipmap-mdpi/battery_low_icon.png
new file mode 100644 (file)
index 0000000..9b4a032
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/battery_low_icon.png differ
index f072f66..6cdb52c 100644 (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
index 4efcfa0..c8957bc 100644 (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
index 1fe9f4b..7d26e5b 100644 (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
index 2b75cc5..323fbf2 100644 (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>
index c40ed36..d9bd37b 100644 (file)
@@ -8,4 +8,6 @@
     <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
index 1b23000..6ee98ff 100644 (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>
index f5a1251..977fd69 100644 (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>