diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java index 6af5b92..1d62b68 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java @@ -25,22 +25,23 @@ public class XLog { /** * 日志总开关 */ - public static boolean LOG_SWITCH = true; + public static Boolean LOG_SWITCH = true; /** * 是否写入到文件 */ - public static boolean LOG_SWITCH_TO_FILE = true; + public static Boolean LOG_SWITCH_TO_FILE = true; /** * 日志级别 默认info */ - public static int SET_ROOT_LEVEL = Level.INFO; + public static Integer SET_ROOT_LEVEL = Level.INFO; + public static String SET_ROOT_LEVEL_NAME = Level.INFO_NAME; /** * 日志保存最长时间 */ - public static int LOG_SAVE_DAYS = 7; + public static Integer LOG_KEEP_DAY = 7; /** *
diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/db/util/DBHelper.java b/app/src/main/java/cc/niushuai/project/devcontrol/db/util/DBHelper.java
index cccd349..79f449b 100644
--- a/app/src/main/java/cc/niushuai/project/devcontrol/db/util/DBHelper.java
+++ b/app/src/main/java/cc/niushuai/project/devcontrol/db/util/DBHelper.java
@@ -4,6 +4,7 @@ import java.util.List;
 
 import cc.niushuai.project.devcontrol.db.DB;
 import cc.niushuai.project.devcontrol.db.entity.SysConfig;
+import cn.hutool.core.collection.CollUtil;
 
 /**
  * 抽取的公共方法
@@ -19,4 +20,10 @@ public class DBHelper {
 
         return DB.getSysConfigDao().queryRaw(WHERE_KEY, key);
     }
+
+    public static SysConfig configOneByKey(String key) {
+
+        List list = DB.getSysConfigDao().queryRaw(WHERE_KEY, key);
+        return CollUtil.isEmpty(list) ? null : list.get(0);
+    }
 }
diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/setup/NavSetUpFragment.java b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/setup/NavSetUpFragment.java
index bae4656..4c491bb 100644
--- a/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/setup/NavSetUpFragment.java
+++ b/app/src/main/java/cc/niushuai/project/devcontrol/ui/nav/setup/NavSetUpFragment.java
@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
 
 import java.util.List;
 
+import cc.niushuai.project.devcontrol.R;
 import cc.niushuai.project.devcontrol.base.ui.BaseFragment;
 import cc.niushuai.project.devcontrol.base.util.IdWorker;
 import cc.niushuai.project.devcontrol.base.util.Keys;
@@ -43,6 +44,34 @@ public class NavSetUpFragment extends BaseFragment {
 
     private void init() {
 
+        SysConfig switchConfig = DBHelper.configOneByKey(Keys.SETUP_LOG_SWITCH);
+        if (null == switchConfig) {
+            dealConfig(Keys.SETUP_LOG_SWITCH, XLog.LOG_SWITCH.toString());
+        } else {
+            binding.setupLogSwitchSwitch.setChecked(Boolean.parseBoolean(switchConfig.getValue()));
+        }
+
+        SysConfig levelConfig = DBHelper.configOneByKey(Keys.SETUP_LOG_LEVEL);
+        if (null == levelConfig) {
+            dealConfig(Keys.SETUP_LOG_LEVEL, XLog.SET_ROOT_LEVEL_NAME);
+        } else {
+            String[] logLevel = getResources().getStringArray(R.array.logLevel);
+            for (int i = 0; i < logLevel.length; i++) {
+                String level = logLevel[i];
+                if (level.equals(levelConfig.getValue())) {
+                    binding.setupLogLevelSpinner.setSelection(i);
+                    break;
+                }
+            }
+        }
+
+        SysConfig keepDayConfig = DBHelper.configOneByKey(Keys.SETUP_LOG_KEEP_DAY);
+        if (null == keepDayConfig) {
+            dealConfig(Keys.SETUP_LOG_KEEP_DAY, XLog.LOG_KEEP_DAY.toString());
+        } else {
+            binding.setupLogKeepDayDisplay.setText(keepDayConfig.getValue());
+        }
+
     }
 
     private void addListener() {
@@ -95,15 +124,17 @@ public class NavSetUpFragment extends BaseFragment {
 
 
     private void setupKeepDayClickListener(View view) {
+
+
     }
 
-    private void dealConfig(String key, String level) {
+    private void dealConfig(String key, String value) {
         List list = DBHelper.configListByKey(key);
         if (CollUtil.isNotEmpty(list)) {
-            configUpdate(level, list.get(0));
+            configUpdate(value, list.get(0));
             return;
         }
-        configInsert(key, level);
+        configInsert(key, value);
     }
 
     private void configInsert(String key, String value) {
diff --git a/app/src/main/res/layout/main_nav_fragment_set_up.xml b/app/src/main/res/layout/main_nav_fragment_set_up.xml
index 9770e32..3bdb04c 100644
--- a/app/src/main/res/layout/main_nav_fragment_set_up.xml
+++ b/app/src/main/res/layout/main_nav_fragment_set_up.xml
@@ -110,6 +110,7 @@
                 
@@ -133,6 +134,7 @@
                 
             
 
diff --git a/app/src/main/res/values/setup_styles.xml b/app/src/main/res/values/setup_styles.xml
index a6a29b3..ca3e64a 100644
--- a/app/src/main/res/values/setup_styles.xml
+++ b/app/src/main/res/values/setup_styles.xml
@@ -49,7 +49,7 @@