create warning notification.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 17 Jul 2021 08:29:44 +0000 (16:29 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 17 Jul 2021 08:29:44 +0000 (16:29 +0800)
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/provider/ICDatabaseHelper.java
app/src/main/java/com/enqualcomm/support/provider/ICNotificationProvider.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
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 [new file with mode: 0644]
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml

index 3aaee43..f31c83a 100644 (file)
@@ -1096,8 +1096,6 @@ public class CoreService extends Service {
         } else {
             Runtime.lastSitCheckStepCount = -1; //不在时间段就重置数据,以便下一次使用能过重新开始计数。
         }
-
-
     }
 
     public void updateSleepDate() {
index 8c59825..ad72b6c 100644 (file)
@@ -243,9 +243,9 @@ public class ICDatabaseHelper extends SQLiteOpenHelper {
                 notification_title +
                 " text, " +
                 notification_type +
-                " integer, " +
+                " text, " +
                 notification_category +
-                " integer, " +
+                " text, " +
                 notification_order +
                 " integer, " +
                 notification_date +
index 7acdab0..a3c2614 100644 (file)
@@ -13,7 +13,7 @@ public class ICNotificationProvider extends ContentProvider {
 
     public static final String PATH = "notification";
     public static final String AUTHORITY = "com.ic.notification";
-    public static final String MEMBERS = "content://" + AUTHORITY + "/" + PATH;
+    public static final String NOTIFICATIONS = "content://" + AUTHORITY + "/" + PATH;
 
     private static final int MATH_CODE_TABLE = 1;
     private static final UriMatcher sUriMatcher;
index 90d0f5c..e48d623 100644 (file)
@@ -2,10 +2,13 @@ package com.enqualcomm.support.service;
 
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.net.Uri;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
@@ -14,9 +17,12 @@ import com.enqualcomm.support.Config;
 import com.enqualcomm.support.CoreService;
 import com.enqualcomm.support.ICApplication;
 import com.enqualcomm.support.LocationClient;
+import com.enqualcomm.support.R;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.heartRateStatus;
+import com.enqualcomm.support.provider.ICDatabaseHelper;
+import com.enqualcomm.support.provider.ICNotificationProvider;
 import com.enqualcomm.support.service.base.AbstractInvokeHandlerService;
 import com.enqualcomm.support.utils.Connection;
 import com.enqualcomm.support.utils.HeartRateOxygenTestType;
@@ -192,8 +198,58 @@ public class HeartRateManager extends AbstractInvokeHandlerService {
         int heartRateValue = heartRate.getHeartRate();
         int bloodHeightValue = heartRate.getBloodHeight();
         int bloodLowValue = heartRate.getBloodLow();
-        //TODO:
+        Context context = runtime.getContextProxy().context;
+        if (oxygenValue != 0 && Config.LIMIT_VALUE_OXYGEN != 0 && oxygenValue < Config.LIMIT_VALUE_OXYGEN) {
+            //发出警告
+            createWarningNotification(context.getString(R.string.oxygen_exception_tips_text) + oxygenValue + "%)",
+                    NOTIFICATION_TYPE_BLOOD_OXYGEN);
+        }
+        if (heartRateValue != 0 && Config.LIMIT_VALUE_PPGH != 0 && heartRateValue > Config.LIMIT_VALUE_PPGH) {
+            //判断是否超出阀值,上限
+            createWarningNotification(context.getString(R.string.heart_rate_exception_tips_text) + heartRateValue + ")",
+                    NOTIFICATION_TYPE_HEART_RATE);
+        }
+
+        if (heartRateValue != 0 && Config.LIMIT_VALUE_PPGH != 0 && heartRateValue < Config.LIMIT_VALUE_PPGL) {
+            //判断是否超出阀值,下限
+            createWarningNotification(context.getString(R.string.heart_rate_exception_tips_text) + heartRateValue + ")",
+                    NOTIFICATION_TYPE_HEART_RATE);
+        }
+
+        if (bloodHeightValue != 0 && Config.LIMIT_VALUE_BPH_H != 0 && Config.LIMIT_VALUE_BPH_L != 0) {
+            //如果不在这两个范围内,那么就警报
+            if (bloodHeightValue > Config.LIMIT_VALUE_BPH_H || bloodHeightValue < Config.LIMIT_VALUE_BPH_L) {
+                //警报,血压高值超出范围
+                createWarningNotification(context.getString(R.string.blood_presure_exception_tips_text) + bloodHeightValue + "/100mmHg)",
+                        NOTIFICATION_TYPE_BLOOD_PRESSURE);
+            }
+        }
+
+        if (bloodLowValue != 0 && Config.LIMIT_VALUE_BPL_H != 0 && Config.LIMIT_VALUE_BPL_L != 0) {
+            //如果不在这两个范围内,那么就警报
+            if (bloodHeightValue > Config.LIMIT_VALUE_BPL_H || bloodHeightValue < Config.LIMIT_VALUE_BPL_L) {
+                //警报,血压低值超出范围
+                createWarningNotification(context.getString(R.string.blood_presure_exception_tips_text) + bloodHeightValue + "/100mmHg)",
+                        NOTIFICATION_TYPE_BLOOD_PRESSURE);
+            }
+        }
+    }
 
+    public static final String NOTIFICATION_TYPE_HEART_RATE = "heart_rate";
+    public static final String NOTIFICATION_TYPE_BLOOD_PRESSURE = "blood_pressure";
+    public static final String NOTIFICATION_TYPE_BLOOD_OXYGEN = "blood_oxygen";
+
+    private void createWarningNotification(String title, String type) {
+        ContentValues contentValues = new ContentValues();
+        //分类是心率的包名
+        contentValues.put(ICDatabaseHelper.notification_category, "com.ic.blood");
+        contentValues.put(ICDatabaseHelper.notification_title, title);
+        contentValues.put(ICDatabaseHelper.notification_type, type);
+        contentValues.put(ICDatabaseHelper.notification_date, System.currentTimeMillis());
+        contentValues.put(ICDatabaseHelper.notification_order, 0);
+        contentValues.put(ICDatabaseHelper.notification_create_time, System.currentTimeMillis());
+        ContentResolver resolver = runtime.getContextProxy().getResolver();
+        resolver.insert(Uri.parse(ICNotificationProvider.NOTIFICATIONS), contentValues);
     }
 
 
index 8d57142..9da45ae 100644 (file)
     <string name="fr">法语</string>\r
     <string name="de">德语</string>\r
     <string name="ru">俄语</string>\r
+    <string name="oxygen_exception_tips_text">血氧异常(</string>\r
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>\r
+    <string name="blood_presure_exception_tips_text">血压异常(</string>\r
     <!--    法语,德语,意大利-->\r
 </resources>\r
index 8d57142..9da45ae 100644 (file)
     <string name="fr">法语</string>\r
     <string name="de">德语</string>\r
     <string name="ru">俄语</string>\r
+    <string name="oxygen_exception_tips_text">血氧异常(</string>\r
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>\r
+    <string name="blood_presure_exception_tips_text">血压异常(</string>\r
     <!--    法语,德语,意大利-->\r
 </resources>\r
index 8d57142..9da45ae 100644 (file)
     <string name="fr">法语</string>\r
     <string name="de">德语</string>\r
     <string name="ru">俄语</string>\r
+    <string name="oxygen_exception_tips_text">血氧异常(</string>\r
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>\r
+    <string name="blood_presure_exception_tips_text">血压异常(</string>\r
     <!--    法语,德语,意大利-->\r
 </resources>\r
index 00a1bc8..d6d5bc9 100644 (file)
 
     <string name="next_msg_tips_text">次の</string>
     <string name="read_end_tips_text">完了</string>
+    <string name="oxygen_exception_tips_text">血氧异常(</string>
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>
+    <string name="blood_presure_exception_tips_text">血压异常(</string>
 
 </resources>
diff --git a/app/src/main/res/values-w820dp/strings.xml b/app/src/main/res/values-w820dp/strings.xml
new file mode 100644 (file)
index 0000000..4f58501
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="oxygen_exception_tips_text">血氧异常(</string>
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>
+    <string name="blood_presure_exception_tips_text">血压异常(</string>
+</resources>
\ No newline at end of file
index 373daa2..e6da334 100644 (file)
     <string name="fr">法语</string>
     <string name="de">德语</string>
     <string name="ru">俄语</string>
+    <string name="oxygen_exception_tips_text">血氧异常(</string>
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>
+    <string name="blood_presure_exception_tips_text">血压异常(</string>
 </resources>
index 3c432d8..6f3ae5b 100644 (file)
     <string name="close_text">Close</string>
     <string name="commit_text">Confirm</string>
     <string name="sport_aim_achieve_tips_text">Congratulations!</string>
+    <string name="oxygen_exception_tips_text">血氧异常(</string>
+    <string name="heart_rate_exception_tips_text">心率异常(BPM</string>
+    <string name="blood_presure_exception_tips_text">血压异常(</string>
     <!--    法语,德语,意大利-->
 </resources>