更新类库,精简代码。
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Wed Feb 12 07:19:38 GMT 2025 | ||||
| #Wed Feb 12 11:47:13 GMT 2025 | ||||
| stageCount=2 | ||||
| libraryProject=libapputils | ||||
| baseVersion=9.3 | ||||
| publishVersion=9.3.1 | ||||
| buildCount=18 | ||||
| buildCount=23 | ||||
| baseBetaVersion=9.3.2 | ||||
|   | ||||
| @@ -7,15 +7,12 @@ package cc.winboll.studio.apputils; | ||||
|  */ | ||||
| import android.app.Application; | ||||
| import android.content.Context; | ||||
| import android.view.Gravity; | ||||
| import android.widget.Toast; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.app.MyActivityLifecycleCallbacks; | ||||
| import cc.winboll.studio.libapputils.app.WinBollActivityManager; | ||||
| import cc.winboll.studio.libapputils.bean.DebugBean; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import com.hjq.toast.ToastUtils; | ||||
| import com.hjq.toast.style.WhiteToastStyle; | ||||
|  | ||||
| public class App extends GlobalApplication { | ||||
|  | ||||
| @@ -57,15 +54,15 @@ public class App extends GlobalApplication { | ||||
|         // 应用环境初始化, 基本调试环境 | ||||
|         // | ||||
|         // 初始化日志模块 | ||||
|         LogUtils.init(this); | ||||
|         //LogUtils.init(this); | ||||
|  | ||||
|         try { | ||||
|             // 初始化 Toast 框架 | ||||
|             ToastUtils.init(this); | ||||
|             // 设置 Toast 布局样式 | ||||
|             //ToastUtils.setView(R.layout.view_toast); | ||||
|             ToastUtils.setStyle(new WhiteToastStyle()); | ||||
|             ToastUtils.setGravity(Gravity.BOTTOM, 0, 200); | ||||
| //            ToastUtils.init(this); | ||||
| //            // 设置 Toast 布局样式 | ||||
| //            //ToastUtils.setView(R.layout.view_toast); | ||||
| //            ToastUtils.setStyle(new WhiteToastStyle()); | ||||
| //            ToastUtils.setGravity(Gravity.BOTTOM, 0, 200); | ||||
|             // 设置应用调试标志 | ||||
|             DebugBean debugBean = DebugBean.loadBean(this, DebugBean.class); | ||||
|             if (debugBean == null) { | ||||
|   | ||||
| @@ -13,6 +13,7 @@ import android.widget.Toast; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
| import androidx.appcompat.widget.Toolbar; | ||||
| import cc.winboll.studio.apputils.R; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.activities.AssetsHtmlActivity; | ||||
| import cc.winboll.studio.libapputils.activities.QRCodeDecodeActivity; | ||||
| import cc.winboll.studio.libapputils.app.AboutActivityFactory; | ||||
| @@ -20,7 +21,6 @@ import cc.winboll.studio.libapputils.app.IWinBollActivity; | ||||
| import cc.winboll.studio.libapputils.app.WinBollActivityManager; | ||||
| import cc.winboll.studio.libapputils.bean.APPInfo; | ||||
| import cc.winboll.studio.libapputils.log.LogActivity; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libapputils.view.AboutView; | ||||
| import cc.winboll.studio.libapputils.view.YesNoAlertDialog; | ||||
| import com.hjq.toast.ToastUtils; | ||||
|   | ||||
| @@ -4,7 +4,4 @@ | ||||
|     <color name="colorPrimary">#FF196ABC</color> | ||||
|     <color name="colorPrimaryDark">#FF002B57</color> | ||||
|     <color name="colorAccent">#FF80BFFF</color> | ||||
|     <color name="colorToastFrame">#FFA9A9A9</color> | ||||
|     <color name="colorToastShadow">#FF000000</color> | ||||
|     <color name="colorToastBackgroung">#FFFFFFFF</color> | ||||
| </resources> | ||||
|   | ||||
| @@ -38,7 +38,7 @@ dependencies { | ||||
|     api 'androidx.fragment:fragment:1.1.0' | ||||
|     api 'com.google.android.material:material:1.1.0' | ||||
|      | ||||
|     api 'cc.winboll.studio:libappbase:1.4.0' | ||||
|     api 'cc.winboll.studio:libappbase:1.4.1' | ||||
|      | ||||
|     api fileTree(dir: 'libs', include: ['*.jar']) | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Wed Feb 12 07:19:38 GMT 2025 | ||||
| #Wed Feb 12 11:47:13 GMT 2025 | ||||
| stageCount=2 | ||||
| libraryProject=libapputils | ||||
| baseVersion=9.3 | ||||
| publishVersion=9.3.1 | ||||
| buildCount=18 | ||||
| buildCount=23 | ||||
| baseBetaVersion=9.3.2 | ||||
|   | ||||
| @@ -11,16 +11,15 @@ import android.net.Uri; | ||||
| import android.os.Bundle; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
| import androidx.appcompat.widget.Toolbar; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import cc.winboll.studio.libapputils.app.IWinBollActivity; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libapputils.bean.APPInfo; | ||||
| import cc.winboll.studio.libapputils.view.SimpleWebView; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import cc.winboll.studio.libapputils.bean.APPInfo; | ||||
|  | ||||
| public class AssetsHtmlActivity extends AppCompatActivity implements IWinBollActivity { | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,7 @@ package cc.winboll.studio.libapputils.app; | ||||
|  * @Date 2024/08/12 14:45:35 | ||||
|  * @Describe 应用版本工具集 | ||||
|  */ | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
|   | ||||
| @@ -8,9 +8,8 @@ import android.app.Activity; | ||||
| import android.app.Application; | ||||
| import android.content.Intent; | ||||
| import android.os.Bundle; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import com.hjq.toast.ToastUtils; | ||||
| import android.content.Context;  | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import com.hjq.toast.ToastUtils;  | ||||
|  | ||||
| public class MyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {  | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import android.app.ActivityManager; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import androidx.core.app.TaskStackBuilder; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
|   | ||||
| @@ -10,7 +10,7 @@ package cc.winboll.studio.libapputils.bean; | ||||
| import android.content.Context; | ||||
| import android.util.JsonReader; | ||||
| import android.util.JsonWriter; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.util.FileUtils; | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| package cc.winboll.studio.libapputils.git; | ||||
| import android.content.Context; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.util.HashMap; | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import android.os.Bundle; | ||||
| import androidx.appcompat.app.AppCompatActivity; | ||||
| import androidx.appcompat.widget.Toolbar; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import cc.winboll.studio.libapputils.app.IWinBollActivity; | ||||
| import cc.winboll.studio.libapputils.bean.APPInfo; | ||||
|   | ||||
| @@ -1,371 +0,0 @@ | ||||
| package cc.winboll.studio.libapputils.log; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|  * @Date 2024/08/12 13:44:06 | ||||
|  * @Describe LogUtils | ||||
|  * @Describe 应用日志类 | ||||
|  */ | ||||
| import android.content.Context; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libapputils.util.FileUtils; | ||||
| import dalvik.system.DexFile; | ||||
| import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStreamReader; | ||||
| import java.io.OutputStreamWriter; | ||||
| import java.lang.reflect.Field; | ||||
| import java.lang.reflect.Modifier; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Enumeration; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Locale; | ||||
| import java.util.Map; | ||||
|  | ||||
|  | ||||
| public class LogUtils { | ||||
|  | ||||
|     public static final String TAG = "LogUtils"; | ||||
|  | ||||
|     public static enum LOG_LEVEL { Off, Error, Warn, Info, Debug, Verbose } | ||||
|  | ||||
|     static volatile boolean _IsInited = false; | ||||
|     static Context _mContext; | ||||
|     // 日志显示时间格式 | ||||
|     static SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("[yyyyMMdd_HHmmSS]", Locale.getDefault()); | ||||
|     // 应用日志文件夹 | ||||
|     static File _mfLogCacheDir; | ||||
|     static File _mfLogDataDir; | ||||
|     // 应用日志文件 | ||||
|     static File _mfLogCatchFile; | ||||
|     static File _mfLogUtilsBeanFile; | ||||
|     static LogUtilsBean _mLogUtilsBean; | ||||
|     public static Map<String, Boolean> mapTAGList = new HashMap<String, Boolean>(); | ||||
|  | ||||
|     // | ||||
|     // 初始化函数 | ||||
|     // | ||||
|     public static void init(Context context) { | ||||
|         _mContext = context; | ||||
|         init(context, LOG_LEVEL.Off); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 初始化函数 | ||||
|     // | ||||
|     public static void init(Context context, LOG_LEVEL logLevel) { | ||||
|         if (GlobalApplication.isDebuging()) { | ||||
|             // 初始化日志缓存文件路径 | ||||
|             _mfLogCacheDir = new File(context.getApplicationContext().getExternalCacheDir(), TAG); | ||||
|             if (!_mfLogCacheDir.exists()) { | ||||
|                 _mfLogCacheDir.mkdirs(); | ||||
|             } | ||||
|             _mfLogCatchFile = new File(_mfLogCacheDir, "log.txt"); | ||||
|  | ||||
|             // 初始化日志配置文件路径 | ||||
|             _mfLogDataDir = context.getApplicationContext().getExternalFilesDir(TAG); | ||||
|             if (!_mfLogDataDir.exists()) { | ||||
|                 _mfLogDataDir.mkdirs(); | ||||
|             } | ||||
|             _mfLogUtilsBeanFile = new File(_mfLogDataDir, TAG + ".json"); | ||||
|         } else { | ||||
|             // 初始化日志缓存文件路径 | ||||
|             _mfLogCacheDir = new File(context.getApplicationContext().getCacheDir(), TAG); | ||||
|             if (!_mfLogCacheDir.exists()) { | ||||
|                 _mfLogCacheDir.mkdirs(); | ||||
|             } | ||||
|             _mfLogCatchFile = new File(_mfLogCacheDir, "log.txt"); | ||||
|  | ||||
|             // 初始化日志配置文件路径 | ||||
|             _mfLogDataDir = new File(context.getApplicationContext().getFilesDir(), TAG); | ||||
|             if (!_mfLogDataDir.exists()) { | ||||
|                 _mfLogDataDir.mkdirs(); | ||||
|             } | ||||
|             _mfLogUtilsBeanFile = new File(_mfLogDataDir, TAG + ".json"); | ||||
|         } | ||||
|  | ||||
| //        Toast.makeText(context, | ||||
| //                       "_mfLogUtilsBeanFile : " + _mfLogUtilsBeanFile | ||||
| //                       + "\n_mfLogCatchFile : " + _mfLogCatchFile, | ||||
| //                       Toast.LENGTH_SHORT).show(); | ||||
| // | ||||
|         _mLogUtilsBean = LogUtilsBean.loadBeanFromFile(_mfLogUtilsBeanFile.getPath(), LogUtilsBean.class); | ||||
|         if (_mLogUtilsBean == null) { | ||||
|             _mLogUtilsBean = new LogUtilsBean(); | ||||
|             _mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean); | ||||
|         } | ||||
|  | ||||
|         // 加载当前应用下的所有类的 TAG | ||||
|         addClassTAGList(); | ||||
|         loadTAGBeanSettings(); | ||||
|         _IsInited = true; | ||||
|         LogUtils.d(TAG, String.format("mapTAGList : %s", mapTAGList.toString())); | ||||
|     } | ||||
|  | ||||
|     public static Map<String, Boolean> getMapTAGList() { | ||||
|         return mapTAGList; | ||||
|     } | ||||
|  | ||||
|     static void loadTAGBeanSettings() { | ||||
|         ArrayList<LogUtilsClassTAGBean> list = new ArrayList<LogUtilsClassTAGBean>(); | ||||
|         LogUtilsClassTAGBean.loadBeanList(_mContext, list, LogUtilsClassTAGBean.class); | ||||
|         for (int i = 0; i < list.size(); i++) { | ||||
|             LogUtilsClassTAGBean beanSetting = list.get(i); | ||||
|             for (Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) { | ||||
|                 if (entry.getKey().equals(beanSetting.getTag())) { | ||||
|                     entry.setValue(beanSetting.getEnable()); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static void saveTAGBeanSettings() { | ||||
|         ArrayList<LogUtilsClassTAGBean> list = new ArrayList<LogUtilsClassTAGBean>(); | ||||
|         for (Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) { | ||||
|             list.add(new LogUtilsClassTAGBean(entry.getKey(), entry.getValue())); | ||||
|         } | ||||
|         LogUtilsClassTAGBean.saveBeanList(_mContext, list, LogUtilsClassTAGBean.class); | ||||
|     } | ||||
|  | ||||
|     static void addClassTAGList() { | ||||
|         //ClassLoader classLoader = getClass().getClassLoader(); | ||||
|         try { | ||||
|             //String packageName = context.getPackageName(); | ||||
|             String packageNamePrefix = "cc.winboll.studio"; | ||||
|             List<String> classNames = new ArrayList<>(); | ||||
|             String apkPath = _mContext.getPackageCodePath(); | ||||
|             //Log.d("APK_PATH", "The APK path is: " + apkPath); | ||||
|             LogUtils.d(TAG, String.format("apkPath : %s", apkPath)); | ||||
|             //String apkPath = "/data/app/" + packageName + "-"; | ||||
|  | ||||
|             //DexFile dexfile = new DexFile(apkPath + "1/base.apk"); | ||||
|             DexFile dexfile = new DexFile(apkPath); | ||||
|  | ||||
|             int countTemp = 0; | ||||
|             Enumeration<String> entries = dexfile.entries(); | ||||
|             while (entries.hasMoreElements()) { | ||||
|                 countTemp++; | ||||
|                 String className = entries.nextElement(); | ||||
|                 if (className.startsWith(packageNamePrefix)) { | ||||
|                     classNames.add(className); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             LogUtils.d(TAG, String.format("countTemp : %d\nClassNames size : %d", countTemp, classNames.size())); | ||||
|  | ||||
|             for (String className : classNames) { | ||||
|                 try { | ||||
|                     Class<?> clazz = Class.forName(className); | ||||
|                     Field[] fields = clazz.getDeclaredFields(); | ||||
|                     for (Field field : fields) { | ||||
|                         if (Modifier.isStatic(field.getModifiers()) && Modifier.isPublic(field.getModifiers()) && field.getType() == String.class && "TAG".equals(field.getName())) { | ||||
|                             String tagValue = (String) field.get(null); | ||||
|                             //Log.d("TAG_INFO", "Class: " + className + ", TAG value: " + tagValue); | ||||
|                             //LogUtils.d(TAG, String.format("Tag Value : %s", tagValue)); | ||||
|                             //mapTAGList.put(tagValue, true); | ||||
|                             mapTAGList.put(tagValue, false); | ||||
|                         } | ||||
|                     } | ||||
|                 } catch (NoClassDefFoundError | ClassNotFoundException | IllegalAccessException e) { | ||||
|                     LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace()); | ||||
|                     //LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
|                     //Toast.makeText(context, TAG + " : " + e.getMessage(), Toast.LENGTH_SHORT).show(); | ||||
|                 } | ||||
|             } | ||||
|         } catch (IOException e) { | ||||
|             LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
|             //Toast.makeText(context, TAG + " : " + e.getMessage(), Toast.LENGTH_SHORT).show(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static void setTAGListEnable(String tag, boolean isEnable) { | ||||
|         Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator(); | ||||
|         while (iterator.hasNext()) { | ||||
|             Map.Entry<String, Boolean> entry = iterator.next(); | ||||
|             if (tag.equals(entry.getKey())) { | ||||
|                 entry.setValue(isEnable); | ||||
|                 //System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue()); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         saveTAGBeanSettings(); | ||||
|         LogUtils.d(TAG, String.format("mapTAGList : %s", mapTAGList.toString())); | ||||
|     } | ||||
|  | ||||
|     public static void setALlTAGListEnable(boolean isEnable) { | ||||
|         Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator(); | ||||
|         while (iterator.hasNext()) { | ||||
|             Map.Entry<String, Boolean> entry = iterator.next(); | ||||
|             entry.setValue(isEnable); | ||||
|             //System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue()); | ||||
|         } | ||||
|         saveTAGBeanSettings(); | ||||
|         LogUtils.d(TAG, String.format("mapTAGList : %s", mapTAGList.toString())); | ||||
|     } | ||||
|  | ||||
|     public static void setLogLevel(LOG_LEVEL logLevel) { | ||||
|         LogUtils._mLogUtilsBean.setLogLevel(logLevel); | ||||
|         _mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean); | ||||
|     } | ||||
|  | ||||
|     public static LOG_LEVEL getLogLevel() { | ||||
|         return LogUtils._mLogUtilsBean.getLogLevel(); | ||||
|     } | ||||
|  | ||||
|     static boolean isLoggable(String tag, LOG_LEVEL logLevel) { | ||||
|         return _IsInited && mapTAGList.get(tag) && isInTheLevel(logLevel); | ||||
|     } | ||||
|  | ||||
|     static boolean isInTheLevel(LOG_LEVEL logLevel) { | ||||
|         return (LogUtils._mLogUtilsBean.getLogLevel().ordinal() == logLevel.ordinal() | ||||
|             || LogUtils._mLogUtilsBean.getLogLevel().ordinal() > logLevel.ordinal()); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 获取应用日志文件夹 | ||||
|     // | ||||
|     public static File getLogCacheDir() { | ||||
|         return _mfLogCacheDir; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // | ||||
|     public static void e(String szTAG, String szMessage) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Error)) { | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Error, szMessage); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // | ||||
|     public static void w(String szTAG, String szMessage) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Warn)) { | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Warn, szMessage); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // | ||||
|     public static void i(String szTAG, String szMessage) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Info)) { | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Info, szMessage); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // | ||||
|     public static void d(String szTAG, String szMessage) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Debug)) { | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Debug, szMessage); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // 包含线程调试堆栈信息 | ||||
|     // | ||||
|     public static void d(String szTAG, String szMessage, StackTraceElement[] listStackTrace) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Debug)) { | ||||
|             StringBuilder sbMessage = new StringBuilder(szMessage); | ||||
|             sbMessage.append(" \nAt "); | ||||
|             sbMessage.append(listStackTrace[2].getMethodName()); | ||||
|             sbMessage.append(" ("); | ||||
|             sbMessage.append(listStackTrace[2].getFileName()); | ||||
|             sbMessage.append(":"); | ||||
|             sbMessage.append(listStackTrace[2].getLineNumber()); | ||||
|             sbMessage.append(")"); | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Debug, sbMessage.toString()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // 包含异常信息和线程调试堆栈信息 | ||||
|     // | ||||
|     public static void d(String szTAG, Exception e, StackTraceElement[] listStackTrace) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Debug)) { | ||||
|             StringBuilder sbMessage = new StringBuilder(e.getClass().toGenericString()); | ||||
|             sbMessage.append(" : "); | ||||
|             sbMessage.append(e.getMessage()); | ||||
|             sbMessage.append(" \nAt "); | ||||
|             sbMessage.append(listStackTrace[2].getMethodName()); | ||||
|             sbMessage.append(" ("); | ||||
|             sbMessage.append(listStackTrace[2].getFileName()); | ||||
|             sbMessage.append(":"); | ||||
|             sbMessage.append(listStackTrace[2].getLineNumber()); | ||||
|             sbMessage.append(")"); | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Debug, sbMessage.toString()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 调试日志写入函数 | ||||
|     // | ||||
|     public static void v(String szTAG, String szMessage) { | ||||
|         if (isLoggable(szTAG, LogUtils.LOG_LEVEL.Verbose)) { | ||||
|             saveLog(szTAG, LogUtils.LOG_LEVEL.Verbose, szMessage); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 日志文件保存函数 | ||||
|     // | ||||
|     static void saveLog(String szTAG, LogUtils.LOG_LEVEL logLevel, String szMessage) { | ||||
|         try { | ||||
|             BufferedWriter out = null; | ||||
|             out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_mfLogCatchFile, true), "UTF-8")); | ||||
|             out.write("[" + logLevel + "]  " + mSimpleDateFormat.format(System.currentTimeMillis()) + "  [" + szTAG + "]\n" + szMessage + "\n"); | ||||
|             out.close(); | ||||
|         } catch (IOException e) { | ||||
|             LogUtils.d(TAG, "IOException : " + e.getMessage()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 历史日志加载函数 | ||||
|     // | ||||
|     public static String loadLog() { | ||||
|         if (_mfLogCatchFile.exists()) { | ||||
|             StringBuffer sb = new StringBuffer(); | ||||
|             try { | ||||
|                 BufferedReader in = null; | ||||
|                 in = new BufferedReader(new InputStreamReader(new FileInputStream(_mfLogCatchFile), "UTF-8")); | ||||
|                 String line = ""; | ||||
|                 while ((line = in.readLine()) != null) { | ||||
|                     sb.append(line); | ||||
|                     sb.append("\n"); | ||||
|                 } | ||||
|             } catch (IOException e) { | ||||
|                 LogUtils.d(TAG, "IOException : " + e.getMessage()); | ||||
|             }  | ||||
|             return sb.toString(); | ||||
|         } | ||||
|         return ""; | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     // 清理日志函数 | ||||
|     // | ||||
|     public static void cleanLog() { | ||||
|         if (_mfLogCatchFile.exists()) { | ||||
|             try { | ||||
|                 FileUtils.writeStringToFile(_mfLogCatchFile.getPath(), ""); | ||||
|                 //LogUtils.d(TAG, "cleanLog"); | ||||
|             } catch (IOException e) { | ||||
|                 LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,71 +0,0 @@ | ||||
| package cc.winboll.studio.libapputils.log; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|  * @Date 2024/08/23 15:39:07 | ||||
|  * @Describe LogUtils 数据配置类。 | ||||
|  */ | ||||
| import android.util.JsonReader; | ||||
| import android.util.JsonWriter; | ||||
| import cc.winboll.studio.libapputils.bean.BaseBean; | ||||
| import java.io.IOException; | ||||
| public class LogUtilsBean extends BaseBean { | ||||
|  | ||||
|     public static final String TAG = "LogUtilsBean"; | ||||
|  | ||||
|     LogUtils.LOG_LEVEL logLevel; | ||||
|  | ||||
|     public LogUtilsBean() { | ||||
|         this.logLevel = LogUtils.LOG_LEVEL.Off; | ||||
|     } | ||||
|  | ||||
|     public LogUtilsBean(LogUtils.LOG_LEVEL logLevel) { | ||||
|         this.logLevel = logLevel; | ||||
|     } | ||||
|  | ||||
|     public void setLogLevel(LogUtils.LOG_LEVEL logLevel) { | ||||
|         this.logLevel = logLevel; | ||||
|     } | ||||
|  | ||||
|     public LogUtils.LOG_LEVEL getLogLevel() { | ||||
|         return logLevel; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return LogUtilsBean.class.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException { | ||||
|         super.writeThisToJsonWriter(jsonWriter); | ||||
|         LogUtilsBean bean = this; | ||||
|         jsonWriter.name("logLevel").value(bean.getLogLevel().ordinal()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException { | ||||
|         if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else { | ||||
|             if (name.equals("logLevel")) { | ||||
|                 setLogLevel(LogUtils.LOG_LEVEL.values()[jsonReader.nextInt()]); | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException { | ||||
|         jsonReader.beginObject(); | ||||
|         while (jsonReader.hasNext()) { | ||||
|             String name = jsonReader.nextName(); | ||||
|             if (!initObjectsFromJsonReader(jsonReader, name)) { | ||||
|                 jsonReader.skipValue(); | ||||
|             } | ||||
|         } | ||||
|         // 结束 JSON 对象 | ||||
|         jsonReader.endObject(); | ||||
|         return this; | ||||
|     } | ||||
| } | ||||
| @@ -1,88 +0,0 @@ | ||||
| package cc.winboll.studio.libapputils.log; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|  * @Date 2025/01/04 14:17:02 | ||||
|  * @Describe 日志类class TAG 标签数据类 | ||||
|  */ | ||||
| import android.util.JsonReader; | ||||
| import android.util.JsonWriter; | ||||
| import cc.winboll.studio.libapputils.bean.BaseBean; | ||||
| import java.io.IOException; | ||||
|  | ||||
| public class LogUtilsClassTAGBean extends BaseBean { | ||||
|  | ||||
|     public static final String TAG = "LogUtilsClassTAGBean"; | ||||
|  | ||||
|     // 标签名 | ||||
|     String tag; | ||||
|     // 是否启用 | ||||
|     Boolean enable; | ||||
|  | ||||
|     public LogUtilsClassTAGBean() { | ||||
|         this.tag = TAG; | ||||
|         this.enable = true; | ||||
|     } | ||||
|  | ||||
|     public LogUtilsClassTAGBean(String tag, Boolean enable) { | ||||
|         this.tag = tag; | ||||
|         this.enable = enable; | ||||
|     } | ||||
|  | ||||
|     public void setTag(String tag) { | ||||
|         this.tag = tag; | ||||
|     } | ||||
|  | ||||
|     public String getTag() { | ||||
|         return tag; | ||||
|     } | ||||
|  | ||||
|     public void setEnable(Boolean enable) { | ||||
|         this.enable = enable; | ||||
|     } | ||||
|  | ||||
|     public Boolean getEnable() { | ||||
|         return enable; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return LogUtilsClassTAGBean.class.getName(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException { | ||||
|         super.writeThisToJsonWriter(jsonWriter); | ||||
|         LogUtilsClassTAGBean bean = this; | ||||
|         jsonWriter.name("tag").value(bean.getTag()); | ||||
|         jsonWriter.name("enable").value(bean.getEnable()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException { | ||||
|         if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else { | ||||
|             if (name.equals("tag")) { | ||||
|                 setTag(jsonReader.nextString()); | ||||
|             } else if (name.equals("enable")) { | ||||
|                 setEnable(jsonReader.nextBoolean()); | ||||
|             } else { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException { | ||||
|         jsonReader.beginObject(); | ||||
|         while (jsonReader.hasNext()) { | ||||
|             String name = jsonReader.nextName(); | ||||
|             if (!initObjectsFromJsonReader(jsonReader, name)) { | ||||
|                 jsonReader.skipValue(); | ||||
|             } | ||||
|         } | ||||
|         // 结束 JSON 对象 | ||||
|         jsonReader.endObject(); | ||||
|         return this; | ||||
|     } | ||||
| } | ||||
| @@ -24,6 +24,7 @@ import android.widget.TextView; | ||||
| import androidx.annotation.NonNull; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import java.text.Collator; | ||||
| import java.util.ArrayList; | ||||
|   | ||||
| @@ -6,6 +6,7 @@ package cc.winboll.studio.libapputils.log; | ||||
|  * @Describe 日志视图线程类 | ||||
|  */ | ||||
| import android.os.FileObserver; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import java.lang.ref.WeakReference; | ||||
|  | ||||
| public class LogViewThread extends Thread { | ||||
|   | ||||
| @@ -5,15 +5,11 @@ import android.content.ComponentName; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.ServiceConnection; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.IBinder; | ||||
| import android.os.IInterface; | ||||
| import android.os.Parcel; | ||||
| import android.os.RemoteException; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.util.ServiceUtils; | ||||
| import com.hjq.toast.ToastUtils; | ||||
| import java.io.FileDescriptor; | ||||
| import android.graphics.drawable.Drawable; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import android.content.Intent; | ||||
| import android.content.res.AssetManager; | ||||
| import android.net.Uri; | ||||
| import androidx.core.content.FileProvider; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | ||||
|   | ||||
| @@ -6,18 +6,12 @@ package cc.winboll.studio.libapputils.util; | ||||
|  * @Describe 二维码工具 | ||||
|  */ | ||||
| import android.graphics.Bitmap; | ||||
| import android.widget.TextView; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import com.google.zxing.BarcodeFormat; | ||||
| import com.google.zxing.Result; | ||||
| import com.google.zxing.WriterException; | ||||
| import com.google.zxing.common.BitMatrix; | ||||
| import com.google.zxing.qrcode.QRCodeWriter; | ||||
| import com.journeyapps.barcodescanner.BarcodeEncoder; | ||||
| import java.util.concurrent.Executors; | ||||
| import java.util.concurrent.ScheduledExecutorService; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| public class QRCodeGenerator { | ||||
|  | ||||
|   | ||||
| @@ -17,12 +17,12 @@ import android.view.View; | ||||
| import android.widget.EditText; | ||||
| import android.widget.LinearLayout; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import cc.winboll.studio.libapputils.app.AppVersionUtils; | ||||
| import cc.winboll.studio.libapputils.app.WinBollActivityManager; | ||||
| import cc.winboll.studio.libapputils.bean.APPInfo; | ||||
| import cc.winboll.studio.libapputils.bean.DebugBean; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libapputils.util.PrefUtils; | ||||
| import com.hjq.toast.ToastUtils; | ||||
| import java.io.IOException; | ||||
|   | ||||
| @@ -19,8 +19,8 @@ import android.widget.ImageView; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.TextView; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libapputils.R; | ||||
| import cc.winboll.studio.libapputils.log.LogUtils; | ||||
| import cc.winboll.studio.libapputils.service.IWinBollClientServiceBinder; | ||||
| import cc.winboll.studio.libapputils.service.WinBollClientService; | ||||
| import cc.winboll.studio.libapputils.service.WinBollClientServiceBean; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen