diff --git a/.gitignore b/.gitignore index b24d71e..bb16f49 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,16 @@ Thumbs.db *.mov *.wmv +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Gradle build files +.gradle/ +build/ +release/ + +# Local configuration file (sdk path, etc) +local.properties \ No newline at end of file diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock index 589627f..9add36e 100644 Binary files a/.gradle/7.3.3/checksums/checksums.lock and b/.gradle/7.3.3/checksums/checksums.lock differ diff --git a/.gradle/7.3.3/checksums/md5-checksums.bin b/.gradle/7.3.3/checksums/md5-checksums.bin index 15445af..a97a8c7 100644 Binary files a/.gradle/7.3.3/checksums/md5-checksums.bin and b/.gradle/7.3.3/checksums/md5-checksums.bin differ diff --git a/.gradle/7.3.3/checksums/sha1-checksums.bin b/.gradle/7.3.3/checksums/sha1-checksums.bin index 6329ebd..da756f8 100644 Binary files a/.gradle/7.3.3/checksums/sha1-checksums.bin and b/.gradle/7.3.3/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index af1800c..738891a 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index 78d1323..845d53e 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index a25a2ea..ee78eb6 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index 0472718..5302f0c 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index b266af7..22d0d4f 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 7955758..694392e 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 9167928..d6000c5 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 770e428..9734d6b 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt index d59bb22..109e110 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt @@ -123,6 +123,11 @@ class LoginActivity : BaseActivity() { isLogin = false viewBinding.button.setText(R.string.login) if (userData.code == ServerConfiguration.Success_Code) { + //记录登录事件 + val bundle = Bundle() + bundle.putString("账号", userData.data.account) + firebaseAnalytics.logEvent(GlobalMethod.Event_LOGIN, bundle) + firebaseAnalytics.setUserId(userData.data.account) AppSettings.forceSetValue(AppSettings.Setting.PassWord, passWord) AppSettings.forceSetValue( AppSettings.Setting.Account, diff --git a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt index 25fab8e..1a589d9 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -642,6 +642,7 @@ class MainActivity : BaseActivity() { opIntent.putExtra("userId", account) startActivity(opIntent) } + firebaseAnalytics.setUserId(account) } startViewModel.needLoginLiveData.observe(this) { diff --git a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt index 62ec184..522bad7 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt @@ -197,10 +197,10 @@ class UserHomePageActivity : BaseActivity() { val gender = spaceInfoData.data.gender if (gender > 0) { - Glide.with(this).load(R.drawable.boy).apply(GlobalMethod.getRequestOptions()) + Glide.with(application).load(R.drawable.boy).apply(GlobalMethod.getRequestOptions()) .into(viewBinding.genderView) } else { - Glide.with(this).load(R.drawable.girl).apply(GlobalMethod.getRequestOptions()) + Glide.with(application).load(R.drawable.girl).apply(GlobalMethod.getRequestOptions()) .into(viewBinding.genderView) } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/UnitAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/UnitAdapter.kt index 262fe83..24852f8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/UnitAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/UnitAdapter.kt @@ -25,7 +25,6 @@ class UnitAdapter( ) : BaseAdapter(context, dataList), PopupTextProvider { - private val language: String by lazy { AppSettings.getValue( AppSettings.Setting.AppLanguage, @@ -72,20 +71,14 @@ class UnitAdapter( } viewBinding.unitTimeView.text = formatter.format(sourceFile.file.lastModified()) val imageView = viewBinding.iconView - val drawable = sourceFile.getIcon() - if (drawable != null) { - Glide.with(context).load(drawable).apply( - RequestOptions().override(200).diskCacheStrategy(DiskCacheStrategy.RESOURCE) - ).into(imageView) + val path = sourceFile.getIcon() + if (path != null) { + Glide.with(context).load(path).apply(GlobalMethod.getRequestOptions()).into(imageView) } else { - Glide.with(context).load( - GlobalMethod.tintDrawable( - context.getDrawable(R.drawable.image), - ColorStateList.valueOf(GlobalMethod.getColorPrimary(context)) - ) - ).apply( - RequestOptions().override(200).diskCacheStrategy(DiskCacheStrategy.RESOURCE) - ).into(imageView) + Glide.with(context).load( GlobalMethod.tintDrawable( + context.getDrawable(R.drawable.image), + ColorStateList.valueOf(GlobalMethod.getColorPrimary(context)) + )).apply(GlobalMethod.getRequestOptions().override(200)).into(imageView) } } catch (e: Exception) { viewBinding.unitDescribeView.text = e.toString() @@ -93,7 +86,11 @@ class UnitAdapter( } override fun getPopupText(position: Int): String { - return getInitial(dataList[position].getName(language)).toString() + return if (dataList.size > position) { + getInitial(dataList[position].getName(language)).toString() + } else { + "#" + } } diff --git a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt index cac73c6..f276af5 100644 --- a/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/base/BaseActivity.kt @@ -24,6 +24,9 @@ import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColorsOptions import com.google.android.material.snackbar.Snackbar import com.google.android.material.textfield.TextInputLayout +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase import com.hjq.language.MultiLanguages import java.util.* @@ -31,6 +34,7 @@ import java.util.* abstract class BaseActivity : AppCompatActivity() { + protected lateinit var firebaseAnalytics: FirebaseAnalytics abstract fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) @@ -46,6 +50,7 @@ abstract class BaseActivity : } override fun onCreate(savedInstanceState: Bundle?) { + firebaseAnalytics = Firebase.analytics WindowCompat.setDecorFitsSystemWindows(window, false) super.onCreate(savedInstanceState) whenCreateActivity(savedInstanceState, false) diff --git a/app/src/main/java/com/coldmint/rust/pro/base/BaseFragment.kt b/app/src/main/java/com/coldmint/rust/pro/base/BaseFragment.kt index 85b0fc8..cd644f6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/base/BaseFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/base/BaseFragment.kt @@ -8,8 +8,12 @@ import android.widget.Toast import androidx.fragment.app.Fragment import androidx.viewbinding.ViewBinding import com.coldmint.rust.pro.tool.AppSettings +import com.google.firebase.analytics.FirebaseAnalytics +import com.google.firebase.analytics.ktx.analytics +import com.google.firebase.ktx.Firebase abstract class BaseFragment : Fragment() { + protected lateinit var firebaseAnalytics: FirebaseAnalytics val viewBinding: T by lazy { getViewBindingObject(layoutInflater) @@ -53,6 +57,7 @@ abstract class BaseFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + firebaseAnalytics = Firebase.analytics whenViewCreated(layoutInflater, savedInstanceState) } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt index 3a3bc3b..e42a0c3 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt @@ -25,6 +25,9 @@ class CommunityFragment : BaseFragment() { fun loadTab() { + if (!isAdded) { + return + } val mainActivity = requireActivity() as MainActivity val tabLayout: TabLayout? = mainActivity.tabLayout if (tabLayout != null) { @@ -52,9 +55,6 @@ class CommunityFragment : BaseFragment() { } - - - override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentCommunityBinding { return FragmentCommunityBinding.inflate(layoutInflater) } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt index 35fd9e6..5c04b60 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt @@ -168,6 +168,10 @@ class UserInfoFragment : BaseFragment() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { viewBinding.logOutButton.setOnClickListener { + val bundle = Bundle() + bundle.putString("账号", account) + firebaseAnalytics.setUserId(null); + firebaseAnalytics.logEvent(GlobalMethod.Event_LOGOUT, bundle) AppSettings.setValue(AppSettings.Setting.LoginStatus, false) // GlobalMethod.isActive = false AppSettings.setValue( diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt index 907c576..740b052 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/EditViewModel.kt @@ -99,7 +99,6 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application fun getNowOpenFilePath(): String { val temPath = nowFilePath return if (temPath == null) { - throw NullPointerException("无法获取最近打开的文件,请先打开文件") "" } else { temPath diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/SourceFile.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/SourceFile.kt index 37a8817..7172f19 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/SourceFile.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/SourceFile.kt @@ -119,10 +119,10 @@ class SourceFile(text: String) { fun findResourceFiles(value: String?, checkExists: Boolean): Array? { var value = value if (modclass == null || !this::file.isInitialized) { - DebugHelper.printLog("搜索资源文件","无法搜索,因为没有初始化文件或模组类。", isError = true) + DebugHelper.printLog("搜索资源文件", "无法搜索,因为没有初始化文件或模组类。", isError = true) return null } - DebugHelper.printLog("搜索资源文件","准备开始 文件路径${file.absolutePath}值${value}") + DebugHelper.printLog("搜索资源文件", "准备开始 文件路径${file.absolutePath}值${value}") val none = "NONE" val auto = "AUTO" val shared = "SHARED:" @@ -139,15 +139,22 @@ class SourceFile(text: String) { if (checkExists) { if (target.exists()) { result.add(target) - }else{ - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}解析Root路径为 ${target.absolutePath} 文件不存在!", isError = true) + } else { + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath}解析Root路径为 ${target.absolutePath} 文件不存在!", + isError = true + ) } } else { result.add(target) } - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}解析Root路径为 ${target.absolutePath}") + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath}解析Root路径为 ${target.absolutePath}" + ) } else if (value.contains(",")) { - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}启用多文件解析。") + DebugHelper.printLog("搜索资源文件", "文件${file.absolutePath}启用多文件解析。") val lineParser = LineParser(value) lineParser.needTrim = true lineParser.symbol = "," @@ -163,13 +170,20 @@ class SourceFile(text: String) { if (checkExists) { if (target.exists()) { result.add(target) - }else{ - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath} 不存在!", isError = true) + } else { + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath} 不存在!", + isError = true + ) } } else { result.add(target) } - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath}") + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath}" + ) } return true } @@ -183,13 +197,20 @@ class SourceFile(text: String) { if (checkExists) { if (target.exists()) { result.add(target) - }else{ - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 解析常规文件 ${target.absolutePath} 不存在!", isError = true) + } else { + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath} 解析常规文件 ${target.absolutePath} 不存在!", + isError = true + ) } } else { result.add(target) } - DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 解析常规文件 ${target.absolutePath}") + DebugHelper.printLog( + "搜索资源文件", + "文件${file.absolutePath} 解析常规文件 ${target.absolutePath}" + ) } if (result.size > 0) { result.toTypedArray() @@ -459,6 +480,7 @@ class SourceFile(text: String) { * @param section 节 */ fun writeValueOrAddKey(key: String, value: String, section: String) { + //先尝试改 val modify = writeValueFromSection(key, value, section) if (!modify) { @@ -481,42 +503,47 @@ class SourceFile(text: String) { * @return Boolean 是否修改成功 */ fun writeValueFromSection(key: String, value: String, section: String): Boolean { - var key = key - var section = section - key = "\n$key:" - section = "\n[$section]\n" - val info: String - var hasSymbol = true - if (text.startsWith("\n")) { - info = "\n$text\n[" - } else { - info = "\n\n$text\n[" - hasSymbol = false - } - val sectionstartnum = info.indexOf(section) - if (sectionstartnum > -1) { - val sectionendnum = info.indexOf("\n[", sectionstartnum + section.length) - val result = - info.substring(sectionstartnum + section.length, sectionendnum).trim() - val sinfo = "\n${result}\n" - if (sinfo.contains(key)) { - val startnum = sinfo.indexOf(key) - val symbolnum = sinfo.indexOf(":", startnum) - val endnum = sinfo.indexOf("\n", symbolnum) - val stringBuilder = StringBuilder() - stringBuilder.append(info.substring(1, sectionstartnum)) - stringBuilder.append(section) - stringBuilder.append(sinfo.substring(1, symbolnum + 1)) - stringBuilder.append(value) - stringBuilder.append(sinfo.substring(endnum, sinfo.length - 1)) - stringBuilder.append(info.substring(sectionendnum, info.length - 2)) - text = if (hasSymbol) { - stringBuilder.toString() - } else { - stringBuilder.substring(1) - } - return true + try { + var key = key + var section = section + key = "\n$key:" + section = "\n[$section]\n" + val info: String + var hasSymbol = true + if (text.startsWith("\n")) { + info = "\n$text\n[" + } else { + info = "\n\n$text\n[" + hasSymbol = false } + val sectionstartnum = info.indexOf(section) + if (sectionstartnum > -1) { + val sectionendnum = info.indexOf("\n[", sectionstartnum + section.length) + val result = + info.substring(sectionstartnum + section.length, sectionendnum).trim() + val sinfo = "\n${result}\n" + if (sinfo.contains(key)) { + val startnum = sinfo.indexOf(key) + val symbolnum = sinfo.indexOf(":", startnum) + val endnum = sinfo.indexOf("\n", symbolnum) + val stringBuilder = StringBuilder() + stringBuilder.append(info.substring(1, sectionstartnum)) + stringBuilder.append(section) + stringBuilder.append(sinfo.substring(1, symbolnum + 1)) + stringBuilder.append(value) + stringBuilder.append(sinfo.substring(endnum, sinfo.length - 1)) + stringBuilder.append(info.substring(sectionendnum, info.length - 2)) + text = if (hasSymbol) { + stringBuilder.toString() + } else { + stringBuilder.substring(1) + } + return true + } + } + } catch (e: Exception) { + e.printStackTrace() + return false } return false } @@ -525,12 +552,12 @@ class SourceFile(text: String) { * 获取单位图标 * @return Drawable? */ - fun getIcon(): Drawable? { - var mainIcon: Drawable? = null + fun getIcon(): String? { + var mainIcon: String? = null val baseImages = findResourceFilesFromSection("image", "graphics", true) if (baseImages != null && baseImages.isNotEmpty()) { val file = baseImages[0] - mainIcon = Drawable.createFromPath(file.absolutePath) + mainIcon = file.absolutePath } return mainIcon } diff --git a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/tool/FileOperator.kt b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/tool/FileOperator.kt index ac6b2d4..38a48d7 100644 --- a/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/tool/FileOperator.kt +++ b/assistantCoreLibrary/src/main/java/com/coldmint/rust/core/tool/FileOperator.kt @@ -117,8 +117,6 @@ object FileOperator { } - - /** * 调用app打开文件 * @@ -638,11 +636,13 @@ object FileOperator { if (target.exists()) { result = if (target.isDirectory) { val files = target.listFiles() - for (mfile in files) { - if (mfile.isDirectory) { - delete_files(mfile) - } else { - mfile.delete() + if (files != null) { + for (mfile in files) { + if (mfile.isDirectory) { + delete_files(mfile) + } else { + mfile.delete() + } } } target.delete()