소스 검색

1.记录app启动时间便于后续问题分析
2.调整按钮布局
3.调整时间显示

weizhengliang 3 년 전
부모
커밋
8d5f0eacdd

+ 9 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -64,6 +64,7 @@ import serialporttest.utils.SerialPortUtil
 @Router(path = "/callingdoor/main")
 class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, CallingdoorMainLayBinding>(), CallingdoorActivityContract.View, CallingdoorAgreement,
     SerialPortUtil.ISerialPortBedOnclickEvent, SerialPortUtil.ISerialPortBedOnclickString, IUserState {
+    var TAG = CallingdoorActivity::class.java.getSimpleName()
 
     private lateinit var receiver: TimeReceiver
     private lateinit var curFragment: String
@@ -127,6 +128,12 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
         //显示二维码界面
         switchFragment(R.id.callingdoor_main_frame, QrCodeFragment(), qrFragment)
+
+        //记录app启动时间
+        val lastTime = SettingConfig.getAppStartTime(activity)
+        val currentTime = TimeHandle.getDateTime(System.currentTimeMillis(), "MM-dd HH:mm:ss")
+        debugLog(TAG, "app last start time: $lastTime, current time: $currentTime")
+        SettingConfig.setAppStartTime(activity, currentTime)
     }
 
     override fun userLogin() {
@@ -793,9 +800,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
             } else if (intent.action == ConnectivityManager.CONNECTIVITY_ACTION) {
                 updateNetState()
                 if (initialized && NetHelper.getInstance().networkAvailable()) {
-                    if (!Constant.TCP_CONNECTED) {
+                    /*if (!Constant.TCP_CONNECTED) {
                         TcpClient.getInstance().doConnect()
-                    }
+                    }*/
                     if (SocketManager.getInstance().userState == 0) {
                         //如果socket断开了则重连
                         connectSocket()

+ 7 - 9
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/XCrashUtils.java

@@ -70,10 +70,8 @@ public class XCrashUtils {
             if (!BuildConfig.DEBUG) {
                 uploadCrashLog(logPath);
             } else {
-                AppUtils.relaunchApp(true);
+                restartApp();
             }
-
-            //restartApp();
         }
     };
 
@@ -83,7 +81,7 @@ public class XCrashUtils {
         public void onCrash(String logPath, String emergency) {
             Log.d(TAG, "log path: " + (logPath != null ? logPath : "(null)") + ", emergency: " + (emergency != null ? emergency : "(null)"));
 
-            if (emergency != null) {
+            /*if (emergency != null) {
                 debug(logPath, emergency);
 
                 // Disk is exhausted, send crash report immediately.
@@ -99,12 +97,12 @@ public class XCrashUtils {
                 // TombstoneManager.appendSection(logPath, "expanded_key_3", "expanded_content_row_1\n\nexpanded_content_row_2");
 
                 debug(logPath, null);
-            }
+            }*/
 
             if ("rk3128".equals(Build.MODEL)) {
                 AppUpdateHelper.reboot(app);
             } else {
-                AppUtils.relaunchApp(true);
+                restartApp();
             }
         }
     };
@@ -144,7 +142,7 @@ public class XCrashUtils {
                 @Override
                 public void onFail() {
                     Log.e(TAG,"错误日志文件上传失败!");
-                    AppUtils.relaunchApp(true);
+                    restartApp();
                 }
 
                 @Override
@@ -185,7 +183,7 @@ public class XCrashUtils {
                 @Override
                 public void onFailure(Call call, IOException e) {
                     Log.e(TAG,"错误日志名称上传失败"+e.getMessage());
-                    AppUtils.relaunchApp(true);
+                    restartApp();
                 }
 
                 @Override
@@ -194,7 +192,7 @@ public class XCrashUtils {
                     TombstoneManager.deleteTombstone(logPath);
                     //String data = response.body().string();
                     //Log.d(TAG,"错误日志数据 data "+data);
-                    AppUtils.relaunchApp(true);
+                    restartApp();
                 }
             });
         } catch (Exception e) {

+ 26 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/settings/SettingConfig.java

@@ -52,6 +52,9 @@ public class SettingConfig {
     //网络异常重启次数
     private static final String KEY_SP_NET_ERR_RESET_COUNT = "KEY_SP_NET_ERR_RESET_COUNT";
 
+    //app上次启动时间
+    private static final String KEY_SP_APP_START_TIME = "KEY_SP_APP_START_TIME";
+
     /**
      * 获取白天亮度
      *
@@ -233,7 +236,7 @@ public class SettingConfig {
      * @return
      */
     public static int getSipOverTime(Context context) {
-        return getSP(context).getInt(KEY_SP_SLEEP_TIME, sip_over_time);
+        return getSP(context).getInt(KEY_SP_SIP_OVERTIME, sip_over_time);
     }
 
     /**
@@ -251,7 +254,7 @@ public class SettingConfig {
      * @return
      */
     public static int getSleepTime(Context context) {
-        return getSP(context).getInt(KEY_SP_SIP_OVERTIME, sleep_time);
+        return getSP(context).getInt(KEY_SP_SLEEP_TIME, sleep_time);
     }
 
     /**
@@ -272,6 +275,27 @@ public class SettingConfig {
         getEditor(context).putInt(KEY_SP_NET_ERR_RESET_COUNT, value).apply();
     }
 
+    /**
+     * 设置App启动时间
+     *
+     * @param value
+     */
+    public static void setAppStartTime(Context context, String value) {
+        getEditor(context).putString(KEY_SP_APP_START_TIME, value).apply();
+    }
+
+    /**
+     * 获取App启动时间
+     *
+     * @return
+     */
+    public static String getAppStartTime(Context context) {
+        return getSP(context).getString(KEY_SP_APP_START_TIME, "Unknow");
+    }
+
+
+
+
 
     private static SharedPreferences getSP(Context context) {
         return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);

+ 11 - 11
callingdoor/src/main/res/layout/callingdoor_main_lay.xml

@@ -43,25 +43,25 @@
                 android:textSize="20sp"
                 android:textColor="@color/main_color"/>
             <TextView
-                android:id="@+id/room_action_call"
+                android:id="@+id/room_action_nurse"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_above="@id/app_version"
                 android:layout_marginBottom="10dp"
                 android:background="@mipmap/bg_bottom_btn"
-                android:drawableLeft="@mipmap/ic_call"
+                android:drawableLeft="@drawable/ic_nursing"
                 android:drawablePadding="6dp"
                 android:padding="10dp"
                 android:gravity="center_vertical"
-                android:text="呼叫护士"
+                android:text="进入护理"
                 android:textSize="20sp"
                 android:textColor="@drawable/selector_bottom_btn_text_color"/>
             <TextView
                 android:id="@+id/room_action_support"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_above="@id/room_action_call"
-                android:layout_marginBottom="30dp"
+                android:layout_above="@id/room_action_nurse"
+                android:layout_marginBottom="40dp"
                 android:background="@mipmap/bg_bottom_btn"
                 android:drawableLeft="@mipmap/ic_support"
                 android:drawablePadding="6dp"
@@ -71,25 +71,25 @@
                 android:textSize="20sp"
                 android:textColor="@drawable/selector_bottom_btn_text_color"/>
             <TextView
-                android:id="@+id/room_action_nurse"
+                android:id="@+id/room_action_call"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_above="@id/room_action_support"
-                android:layout_marginBottom="30dp"
+                android:layout_marginBottom="40dp"
                 android:background="@mipmap/bg_bottom_btn"
-                android:drawableLeft="@drawable/ic_nursing"
+                android:drawableLeft="@mipmap/ic_call"
                 android:drawablePadding="6dp"
                 android:padding="10dp"
                 android:gravity="center_vertical"
-                android:text="进入护理"
+                android:text="呼叫护士"
                 android:textSize="20sp"
                 android:textColor="@drawable/selector_bottom_btn_text_color"/>
             <TextView
                 android:id="@+id/room_action_call_bed"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_above="@id/room_action_nurse"
-                android:layout_marginBottom="30dp"
+                android:layout_above="@id/room_action_call"
+                android:layout_marginBottom="40dp"
                 android:background="@mipmap/bg_bottom_btn"
                 android:drawableLeft="@mipmap/ic_call"
                 android:drawablePadding="6dp"

+ 2 - 2
callingdoor/src/main/res/layout/view_title_layout.xml

@@ -32,8 +32,8 @@
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
-        android:format12Hour="yyyy-MM-dd HH:mm:ss EEEE"
-        android:format24Hour="yyyy-MM-dd HH:mm:ss EEEE"
+        android:format12Hour="yyyy-MM-dd HH:mm EEEE"
+        android:format24Hour="yyyy-MM-dd HH:mm EEEE"
         android:timeZone="GMT+8"
         android:textColor="@color/main_color"
         android:textSize="@dimen/font_size_20" />