制作分享功能

This commit is contained in:
coldmint 2022-10-01 18:31:54 +08:00
parent b3385adf4a
commit c044de7906
23 changed files with 119 additions and 37 deletions

Binary file not shown.

View File

@ -27,8 +27,8 @@ android {
applicationId "com.coldmint.rust.pro" applicationId "com.coldmint.rust.pro"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 32 targetSdkVersion 32
versionCode 22 versionCode 23
versionName "2.1 Bata1_patch5(2022-9-4)" versionName "2.1 Bata1_patch6(2022-10-1)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -11,8 +11,8 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 22, "versionCode": 23,
"versionName": "2.1 Bata1_patch5(2022-9-4)", "versionName": "2.1 Bata1_patch6(2022-10-1)",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
], ],

View File

@ -24,6 +24,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.rust.Concept" android:theme="@style/Theme.rust.Concept"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity
android:name=".FeedbackActivity"
android:exported="false" />
<activity <activity
android:name=".ChangePasswordActivity" android:name=".ChangePasswordActivity"
android:exported="false" /> android:exported="false" />

View File

@ -29,7 +29,6 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
class ErrorActivity() : BaseActivity<ActivityErrorBinding>() { class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
private lateinit var logFile: File
private val errorInfo by lazy { private val errorInfo by lazy {
ErrorInfo() ErrorInfo()
} }
@ -109,14 +108,13 @@ class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
* 创建错误日志 * 创建错误日志
*/ */
fun saveLog(): Boolean { fun saveLog(): Boolean {
// errorInfo.describe = viewBinding.inputEditView.text.toString()
return errorInfo.save() return errorInfo.save()
} }
private fun initAction() { private fun initAction() {
viewBinding.shareLogButton.setOnClickListener(View.OnClickListener { viewBinding.shareLogButton.setOnClickListener(View.OnClickListener {
saveLog() saveLog()
if (!logFile.exists()) { if (!errorInfo.getLogFile().exists()) {
Snackbar.make( Snackbar.make(
viewBinding.shareLogButton, viewBinding.shareLogButton,
R.string.file_not_exist, R.string.file_not_exist,
@ -124,7 +122,7 @@ class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
) )
.show() .show()
} else { } else {
FileOperator.shareFile(this@ErrorActivity, logFile) FileOperator.shareFile(this@ErrorActivity, errorInfo.getLogFile())
} }
}) })

View File

@ -0,0 +1,19 @@
package com.coldmint.rust.pro
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivityFeedbackBinding
class FeedbackActivity : BaseActivity<ActivityFeedbackBinding>() {
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
setReturnButton()
title = getString(R.string.feedback)
}
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityFeedbackBinding {
return ActivityFeedbackBinding.inflate(layoutInflater)
}
}

View File

@ -701,7 +701,19 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
}.setGestureInsetBottomIgnored(true).show() }.setGestureInsetBottomIgnored(true).show()
} else if (viewModel.startTypeData == FileManagerViewModel.StartType.DEFAULT) { } else if (viewModel.startTypeData == FileManagerViewModel.StartType.DEFAULT) {
val type = FileOperator.getFileType(file) val type = FileOperator.getFileType(file)
if (type == "ini" || type == "txt") { val data = AppSettings.getValue(AppSettings.Setting.SourceFileType,"ini,template")
val line = LineParser(data)
var isSourceFile = false
line.symbol = ","
line.analyse { lineNum, lineData, isEnd ->
if (type == lineData)
{
isSourceFile = true
return@analyse false
}
true
}
if (isSourceFile) {
val intent = Intent(this, EditActivity::class.java) val intent = Intent(this, EditActivity::class.java)
val bundle = Bundle() val bundle = Bundle()
bundle.putString("path", file.absolutePath) bundle.putString("path", file.absolutePath)

View File

@ -18,19 +18,21 @@ import java.util.*
*/ */
data class ErrorInfo( data class ErrorInfo(
private val nowTime: Long = System.currentTimeMillis(), private val nowTime: Long = System.currentTimeMillis(),
private var logFile: File? = null,
val time: String = ServerConfiguration.toStringTime(nowTime), val time: String = ServerConfiguration.toStringTime(nowTime),
val id: String = UUID.randomUUID().toString(), val id: String = UUID.randomUUID().toString(),
var allErrorDetails: String = "", var allErrorDetails: String = "",
var activityLog: String? = null, var activityLog: String? = null,
var autoSave: Boolean = true, var autoSave: Boolean = true
) { ) {
/** /**
* 保存ErrorInfo * 获取Log文件
* @return Boolean * @return String
*/ */
fun save(): Boolean { fun getLogFile(): File {
if (logFile == null)
{
val filePath = StringBuilder() val filePath = StringBuilder()
filePath.append(AppSettings.dataRootDirectory) filePath.append(AppSettings.dataRootDirectory)
filePath.append("/carsh/") filePath.append("/carsh/")
@ -46,8 +48,18 @@ data class ErrorInfo(
val fileName = dateFormat.format(nowTime) val fileName = dateFormat.format(nowTime)
filePath.append(fileName) filePath.append(fileName)
filePath.append(".log") filePath.append(".log")
logFile = File(filePath.toString())
}
return logFile!!
}
/**
* 保存ErrorInfo
* @return Boolean
*/
fun save(): Boolean {
val gson = Gson() val gson = Gson()
val logFile = File(filePath.toString()) val logFile = getLogFile()
return FileOperator.writeFile(logFile, gson.toJson(this)) return FileOperator.writeFile(logFile, gson.toJson(this))
} }

View File

@ -38,7 +38,8 @@ object AppSettings {
} }
enum class Setting { enum class Setting {
DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeywordColor, KeywordColorDark, AnnotationColor, AnnotationColorDark, TextColor, TextColorDark, SectionColor, SectionColorDark, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave, ServerAddress, Token, LoginStatus, DynamicColor, ExperiencePlan, FileSortType, CodeEditBackGroundEnable, BlurTransformationValue, CodeEditBackGroundPath, SimpleDisplayOfAutoCompleteMenu DatabaseDirectory, DatabasePath, TemplateDirectory, AppLanguage, DeveloperMode, CustomSymbol, AutoCreateNomedia, OnlyLoadConantLanguageTemple, NightMode, GamePackage, KeywordColor, KeywordColorDark, AnnotationColor, AnnotationColorDark, TextColor, TextColorDark, SectionColor, SectionColorDark, KeepRwmodFile, EnableRecoveryStation, RecoveryStationFileSaveDays, RecoveryStationFolder, IndependentFolder, SetGameStorage, PackDirectory, IdentifiersPromptNumber, UserName, UseJetBrainsMonoFont, AppID, Account, PassWord, ExpirationTime, CheckBetaUpdate, UpdateData, ShareTip, AgreePolicy, EnglishEditingMode, NightModeFollowSystem, UseMobileNetwork, MapFolder, ModFolder, UseTheCommunityAsTheLaunchPage, AutoSave, ServerAddress, Token, LoginStatus, DynamicColor, ExperiencePlan, FileSortType, CodeEditBackGroundEnable, BlurTransformationValue, CodeEditBackGroundPath, SimpleDisplayOfAutoCompleteMenu, SourceFileType
} }
@ -132,6 +133,8 @@ object AppSettings {
map[Setting.FileSortType] = mApplication.getString(R.string.setting_file_sort_type) map[Setting.FileSortType] = mApplication.getString(R.string.setting_file_sort_type)
map[Setting.SimpleDisplayOfAutoCompleteMenu] = map[Setting.SimpleDisplayOfAutoCompleteMenu] =
mApplication.getString(R.string.setting_simple_display_of_auto_complete_menu) mApplication.getString(R.string.setting_simple_display_of_auto_complete_menu)
//setting_source_file_type
map[Setting.SourceFileType] = mApplication.getString(R.string.setting_source_file_type)
//仅保存不可显示 //仅保存不可显示
map[Setting.SetGameStorage] = "SetGameStorage" map[Setting.SetGameStorage] = "SetGameStorage"
map[Setting.AppID] = "AppId" map[Setting.AppID] = "AppId"

View File

@ -6,6 +6,7 @@ import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import android.util.Log import android.util.Log
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import com.coldmint.rust.core.tool.LineParser
import com.coldmint.rust.pro.base.BaseAppendAutoCompleteHelper import com.coldmint.rust.pro.base.BaseAppendAutoCompleteHelper
import com.coldmint.rust.pro.interfaces.AutoCompleteHelper import com.coldmint.rust.pro.interfaces.AutoCompleteHelper
import com.google.android.material.textfield.MaterialAutoCompleteTextView import com.google.android.material.textfield.MaterialAutoCompleteTextView
@ -15,11 +16,20 @@ import com.google.android.material.textfield.MaterialAutoCompleteTextView
*/ */
class UnitAutoCompleteHelper(context: Context) : BaseAppendAutoCompleteHelper(context) { class UnitAutoCompleteHelper(context: Context) : BaseAppendAutoCompleteHelper(context) {
val dataList by lazy {
val arrayList = ArrayList<String>()
val data = AppSettings.getValue(AppSettings.Setting.SourceFileType,"ini,template")
val line = LineParser(data)
line.symbol = ","
line.analyse { lineNum, lineData, isEnd ->
arrayList.add(".${lineData}")
true
}
arrayList
}
override fun getDataList(): List<String> { override fun getDataList(): List<String> {
return listOf<String>( return dataList
".ini", ".txt", ".template"
)
} }
override fun getSymbol(): Char { override fun getSymbol(): Char {

View File

@ -263,6 +263,7 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio
AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundEnable, false) AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundEnable, false)
AppSettings.initSetting(AppSettings.Setting.BlurTransformationValue, 1) AppSettings.initSetting(AppSettings.Setting.BlurTransformationValue, 1)
AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundPath, "") AppSettings.initSetting(AppSettings.Setting.CodeEditBackGroundPath, "")
AppSettings.initSetting(AppSettings.Setting.SourceFileType, "ini,template,txt")
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FeedbackActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -933,5 +933,8 @@
<string name="simple_display_of_auto_complete_menu">简版自动完成菜单</string> <string name="simple_display_of_auto_complete_menu">简版自动完成菜单</string>
<string name="search_key">搜索关键字</string> <string name="search_key">搜索关键字</string>
<string name="share_mod_msg">我分享模组了 %1$s下载链接%2$s\n下载铁锈助手即可参与评论给作品投币。App下载链接%3$s</string> <string name="share_mod_msg">我分享模组了 %1$s下载链接%2$s\n下载铁锈助手即可参与评论给作品投币。App下载链接%3$s</string>
<string name="setting_source_file_type" translatable="false">sourceFileType</string>
<string name="setting_source_file_type_title">源文件类型</string>
<string name="setting_source_file_type_describe">配置源文件类型,符合配置格式的文件将以文本编辑形式打开。以逗号分割不同格式。</string>
</resources> </resources>

View File

@ -53,6 +53,14 @@
app:key="@string/setting_file_sort_type" app:key="@string/setting_file_sort_type"
app:title="@string/file_sort_type" app:title="@string/file_sort_type"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:key="@string/setting_source_file_type"
app:title="@string/setting_source_file_type_title"
android:summary="@string/setting_source_file_type_describe"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/data_transfer"> <PreferenceCategory android:title="@string/data_transfer">

View File

@ -65,11 +65,11 @@ class TurretManager(val sourceFile: SourceFile) {
var y = 0 var y = 0
val xData = sourceFile.readValueFromSection("x", it) val xData = sourceFile.readValueFromSection("x", it)
if (xData != null) { if (xData != null) {
x = xData.toInt() x = xData.toFloat().toInt()
} }
val yData = sourceFile.readValueFromSection("y", it) val yData = sourceFile.readValueFromSection("y", it)
if (yData != null) { if (yData != null) {
y = yData.toInt() y = yData.toFloat().toInt()
} }
val turretData = TurretData(name, CoordinateData(x, y)) val turretData = TurretData(name, CoordinateData(x, y))
val fileList = sourceFile.findResourceFilesFromSection("image", it, false) val fileList = sourceFile.findResourceFilesFromSection("image", it, false)

View File

@ -149,10 +149,14 @@ class TurretView(context: Context, attributeSet: AttributeSet? = null) :
return return
} }
val paint = Paint() val paint = Paint()
var bitmap = if (turretData.imageFile == null) { var bitmap: Bitmap? = if (turretData.imageFile != null) {
BitmapFactory.decodeResource(this.resources, R.drawable.image)
} else {
BitmapFactory.decodeFile(turretData.imageFile!!.absolutePath) BitmapFactory.decodeFile(turretData.imageFile!!.absolutePath)
} else {
null
}
if (bitmap == null) {
Log.e(debugKey, "无法加载炮塔图像。")
return
} }
if (turretData.scaleValue != 1f) { if (turretData.scaleValue != 1f) {
bitmap = TurretSketchpadView.scaleBitmap( bitmap = TurretSketchpadView.scaleBitmap(