refactor iclauncher.
authorkfl_614 <kfl_614@163.com>
Mon, 30 Nov 2020 06:28:44 +0000 (14:28 +0800)
committerkfl_614 <kfl_614@163.com>
Mon, 30 Nov 2020 06:28:44 +0000 (14:28 +0800)
app/release/ICL02Launcher_V183_202011282129_release.apk [deleted file]
app/release/output-metadata.json
app/src/main/java/com/ic/launcher/AnimalHeatActivity.java
app/src/main/java/com/ic/launcher/fragment/S123MainFragment.java
app/src/main/java/com/ic/launcher/util/OsUtil.java
app/src/main/res/values/strings.xml

diff --git a/app/release/ICL02Launcher_V183_202011282129_release.apk b/app/release/ICL02Launcher_V183_202011282129_release.apk
deleted file mode 100644 (file)
index 7c75e68..0000000
Binary files a/app/release/ICL02Launcher_V183_202011282129_release.apk and /dev/null differ
index d355464..06ef586 100644 (file)
       "type": "SINGLE",
       "filters": [],
       "properties": [],
-      "versionCode": 183,
-      "versionName": "202011282129",
+      "versionCode": 184,
+      "versionName": "202011282148",
       "enabled": true,
-      "outputFile": "ICL02Launcher_V183_202011282129_release.apk"
+      "outputFile": "ICL02Launcher_V184_202011282148_release.apk"
     }
   ]
 }
\ No newline at end of file
index d77e873..891454e 100644 (file)
@@ -19,6 +19,7 @@ import android.os.IBinder;
 import android.os.Message;
 import android.os.PowerManager;
 import android.os.RemoteException;
+import android.system.Os;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -33,6 +34,7 @@ import com.ic.aidl.temp.ITempRemoteService;
 import com.ic.launcher.databinding.ActivityAnimalHeatBinding;
 import com.ic.launcher.listener.MainClockGestureDetectorImpl;
 import com.ic.launcher.util.IcLog;
+import com.ic.launcher.util.OsUtil;
 import com.ic.launcher.util.ServiceUtil;
 import com.ic.launcher.util.SystemUtils;
 
@@ -62,6 +64,9 @@ public class AnimalHeatActivity extends AppCompatActivity implements
 
     public static final String TAG = "AnimalHeatActivity";
     public static final String ACTION_ANTI_OFF0 = "com.ic.ACTION_ANTIOFF";
+    public static final String ACTION_REMOTE_WORK_SERVICE = "com.ic.action.WORK_SERVICE";
+    public static final String PACKAGE_REMOTE_WORK_SERVICE = "com.ic.temp";
+
 
     @BindString(R.string.activity_temp_tips_check)
     String tipsCheck;
@@ -87,6 +92,7 @@ public class AnimalHeatActivity extends AppCompatActivity implements
         registerBroadcast();
         //读取佩戴值,如果没有佩戴显提示佩戴
         //接收到了佩戴的广播去获取数据
+        //true表示没佩戴了,false表示有佩戴
         boolean isAntiOff = SystemUtils.getSystemPropertiesBoolean("persist.sys.ic_antioff", true);
         IcLog.i(TAG, "isAntiOff == > " + isAntiOff);
         //如果已经佩戴了,就去获取数据
@@ -97,34 +103,29 @@ public class AnimalHeatActivity extends AppCompatActivity implements
             heatBinding.setCheckTips(getString(R.string.no_wearing_device_tips_text));
         }
         //initWakeLock(this);
+        //保持屏幕常量
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         heatBinding.setBodyTemp("--.-");
         heatBinding.setWristTemp("--.-");
         heatBinding.setTempout("--.-");
-        boolean disablewristtemp = SystemUtils.getSystemPropertiesBoolean("persyst.sys.disableWristTemp", false);
-        boolean disabletempOUt = SystemUtils.getSystemPropertiesBoolean("persyst.sys.disableTempOut", true);
-        heatBinding.setDisableWristTemp(disablewristtemp);
-        heatBinding.setDisableTempOut(disabletempOUt);
+        boolean disableWristTemp = SystemUtils.getSystemPropertiesBoolean("persyst.sys.disableWristTemp", false);
+        boolean disableTempOUt = SystemUtils.getSystemPropertiesBoolean("persyst.sys.disableTempOut", true);
+        //是否显示腕部温度
+        heatBinding.setDisableWristTemp(disableWristTemp);
+        //是否显示环境温度
+        heatBinding.setDisableTempOut(disableTempOUt);
     }
 
 
-    @Override
-    protected void onPause() {
-        super.onPause();
-//        IcLog.i("Temperature","Temperature Activity onPause");
-//        try {
-//            mService.onStopQueryTemp();
-//        } catch (Exception e) {
-//           IcLog.i("Temperature", e.getMessage());
-//        }
-    }
-
     @Override
     protected void onDestroy() {
         super.onDestroy();
         IcLog.i("Temperature", "Temperature Activity onDestroy");
         try {
-            mService.onStopQueryTemp();
+            //停止温度检测
+            if (mService != null) {
+                mService.onStopQueryTemp();
+            }
         } catch (Exception e) {
             e.printStackTrace();
             //e.getMessage may be null.
@@ -168,6 +169,10 @@ public class AnimalHeatActivity extends AppCompatActivity implements
     }
 
     private int currentTestType = -1;
+    //测试中
+    private static final int STATE_TESTING = 0;
+    //测试结束
+    private static final int STATE_TEST_END = 1;
 
     private void setTemperatureUi(int type, double temp, double animal, double tempOut) {
         IcLog.i(TAG, "type -- >  " + type);
@@ -175,33 +180,27 @@ public class AnimalHeatActivity extends AppCompatActivity implements
         IcLog.i(TAG, "animal -- >  " + animal);
         IcLog.i(TAG, "tempOut -- >  " + tempOut);
         //这里有个瞬间过大的bug,人腕温不可能大于45度的。
-        if (temp > 45) {
-            temp = 45.0d;
-        }
         currentTestType = type;
-        DecimalFormat df = new DecimalFormat("#.0");
+        //
         switch (type) {
-            case 0:
+            case STATE_TESTING:
                 if (heatBinding.getDisableWristTemp()) {
-                    heatBinding.setBodyTemp(df.format(temp));
-                    heatBinding.setTempout(df.format(tempOut));
+                    heatBinding.setBodyTemp(OsUtil.formatTem(temp));
+                    heatBinding.setTempout(OsUtil.formatTem(tempOut));
                 } else {
-                    if (".0".equals(df.format(animal))) {
-                        heatBinding.setBodyTemp("0.0");
-                    } else {
-                        heatBinding.setBodyTemp(df.format(animal));
-                    }
-                    heatBinding.setWristTemp(df.format(temp));
-                    heatBinding.setTempout(df.format(tempOut));
+                    heatBinding.setBodyTemp(OsUtil.formatTem(animal));
+                    heatBinding.setWristTemp(OsUtil.formatTem(temp));
+                    heatBinding.setTempout(OsUtil.formatTem(tempOut));
                 }
                 break;
-            case 1:
+            case STATE_TEST_END:
                 heatBinding.setShowLoading(false);
                 heatBinding.setCheckTips(tipsEnd);
                 break;
         }
     }
 
+
     /**
      * 绑定远程服务
      *
@@ -210,9 +209,9 @@ public class AnimalHeatActivity extends AppCompatActivity implements
     private void bindWorkService(Context context) {
         IcLog.i(TAG, "bind remote service..");
         ServiceUtil.bindServiceUtil(context,
-                "com.ic.action.WORK_SERVICE",
+                ACTION_REMOTE_WORK_SERVICE,
                 connection,
-                "com.ic.temp");
+                PACKAGE_REMOTE_WORK_SERVICE);
     }
 
     private void unbindWorkService(Context context) {
@@ -235,11 +234,16 @@ public class AnimalHeatActivity extends AppCompatActivity implements
         public void onServiceConnected(ComponentName name, IBinder service) {
             try {
                 mService = ITempRemoteService.Stub.asInterface(service);
+                //把回调接口设置给对方
                 mService.registerCallback(tempInterface);
+                //调用开始查询温度
                 mService.onStartQueryTemp();
+                //展示Loading,也 就是进度条那个
                 heatBinding.setShowLoading(true);
+                //设置UI正在检测中
                 heatBinding.setCheckTips(tipsCheck);
             } catch (Exception e) {
+                e.printStackTrace();
             }
         }
 
@@ -260,6 +264,13 @@ public class AnimalHeatActivity extends AppCompatActivity implements
         }
     };
 
+    /**
+     * @param type    类型,
+     * @param value   体温
+     * @param animal  腕温
+     * @param tempOut 环境温度
+     * @return
+     */
     private Message obtainMessage(int type, double value, double animal, double tempOut) {
         Message message = Message.obtain();
         message.what = 1;
@@ -306,22 +317,37 @@ public class AnimalHeatActivity extends AppCompatActivity implements
                 bindWorkService(AnimalHeatActivity.this);
             }
 
-            if (state == STATE_ANTI_ON && currentTestType == 1) {
+            if (state == STATE_ANTI_ON && currentTestType == STATE_TEST_END) {
                 //判断状态,如果已经检测完了,就显示检测完成
-                heatBinding.setCheckTips(getString(R.string.activity_temp_tips_end));
+                // 按客户需求,马上进来显示检测完成,看起来不爽
+                //那就再次检测吧,底层做了处理,多次调用测试也没关系,如果判断到繁忙的话会不处理的。
+                //heatBinding.setCheckTips(getString(R.string.activity_temp_tips_end));
+
             }
         }
     };
 
+    private void getRemoteData() {
+        
+        if (mService == null) {
+            return;
+        }
+        try {
+            mService.onStartQueryTemp();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
             if (intent != null) {
-                String acyion = intent.getAction();
-                if (TextUtils.isEmpty(acyion)) {
+                String action = intent.getAction();
+                if (TextUtils.isEmpty(action)) {
                     return;
                 }
-                switch (acyion) {
+                switch (action) {
                     case Intent.ACTION_CLOSE_SYSTEM_DIALOGS:
                         String reason = intent.getStringExtra("reason");
                         if ("homekey".equals(reason)) {
index 27526ce..36eb4f5 100644 (file)
@@ -108,6 +108,13 @@ public class S123MainFragment extends BaseFragment {
     }
 
     private void observePhoneValue(L02MainModel model) {
+
+        model.getObservableTransport().observe(this, resID -> {
+            if(mainBinding != null){
+                mainBinding.setPhoneTransport(resID);
+            }
+        });
+
         model.getObservablePhoneType().observe(this, resID -> {
             if (mainBinding != null) {
                 mainBinding.setPhoneNetType(resID);
index 9667d8f..2ba2a1f 100644 (file)
@@ -4,8 +4,9 @@ import android.app.Activity;
 import android.content.res.Resources;
 import android.util.DisplayMetrics;
 
+import java.text.DecimalFormat;
+
 /**
- *
  * @author RyanLee
  * @date 2017/11/29
  */
@@ -49,4 +50,20 @@ public class OsUtil {
         return outMetrics.widthPixels;
 
     }
+
+
+    private static DecimalFormat sDf = new DecimalFormat("#.0");
+
+    public static final double MAX_TEM = 99.9;
+
+    public static String formatTem(double temp) {
+        if (temp > MAX_TEM) {
+            temp = MAX_TEM;
+        }
+        String format = sDf.format(temp);
+        if (".0".equals(format)) {
+            format = "0.0";
+        }
+        return format;
+    }
 }
index ce9a487..37478eb 100644 (file)
        <string name="activity_temp_tips_check">MEASURING</string>
        <string name="activity_temp_tips_end">COMPLETE</string>
        <string name="activity_temp_outside">TEMPOut</string>
-    <string name="no_wearing_device_tips_text">未配戴设备</string>
+    <string name="no_wearing_device_tips_text">Not wearing a device</string>
 </resources>
\ No newline at end of file