增加minVersion的上传与获取。

This commit is contained in:
Cold-Mint 2023-05-09 13:04:19 +08:00
parent a1a8341d93
commit dd8b2117f3
21 changed files with 172 additions and 81 deletions

View File

@ -108,6 +108,11 @@ class CreateModActivity : BaseActivity<ActivityCreateModBinding>() {
stringBuilder.append(name)
stringBuilder.append("\ndescription: ")
stringBuilder.append(describe)
val minVersion:String = viewBinding.minVersionEdit.text.toString()
if (minVersion.isNotBlank()){
stringBuilder.append("\nminVersion: ")
stringBuilder.append(minVersion)
}
val mod_directory =
File(Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/units/" + name)
if (mod_directory.exists()) {

View File

@ -119,6 +119,10 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
if (description != null) {
viewBinding.modDescribeEdit.setText(description)
}
val minVersion = mModClass.readValueFromInfoSection("minVersion", "mod")
if (minVersion!= null) {
viewBinding.minVersionEdit.setText(minVersion)
}
val modIcon = mModClass.modIcon
if (modIcon == null) {
loadDefaultImage()
@ -216,6 +220,11 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
return false
}
resultBuilder.append(description)
val minVersion = viewBinding.minVersionEdit.text.toString()
if (minVersion.isNotBlank()) {
resultBuilder.append("\nminVersion:")
resultBuilder.append(minVersion)
}
if (mNeedIcon) {
var iconName = mModClass.readValueFromInfoSection("thumbnail", "mod")
if (iconName == null) {

View File

@ -220,6 +220,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
viewBinding.modUpdateInputLayout.isVisible = true
viewBinding.versionNameEdit.setText(t.data.versionName)
viewBinding.modDescribeEdit.setText(t.data.describe)
viewBinding.minVersionEdit.setText(t.data.minVersion)
val outputTags: StringBuilder = StringBuilder()
lineParser.text = t.data.tags
lineParser.parserSymbol = true
@ -724,6 +725,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
return
}
}
val minVersion: String = viewBinding.minVersionEdit.text.toString()
val tagsBuilder = StringBuilder()
val lineParser = LineParser(tags)
lineParser.symbol = ","
@ -783,7 +785,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
} else {
releaseModWork(
modId, modName, modDescribe, versionName,
tagsBuilder, file
minVersion, tagsBuilder, file
)
}
} else {
@ -804,7 +806,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
} else {
releaseModWork(
modId, modName, modDescribe, versionName,
tagsBuilder, file
minVersion, tagsBuilder, file
)
}
}.setNegativeButton(R.string.always_allow) {
@ -823,7 +825,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
} else {
releaseModWork(
modId, modName, modDescribe, versionName,
tagsBuilder, file
minVersion, tagsBuilder, file
)
}
}.setNeutralButton(R.string.dialog_cancel) {
@ -846,7 +848,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
} else {
releaseModWork(
modId, modName, modDescribe, versionName,
tagsBuilder, file
minVersion, tagsBuilder, file
)
}
}
@ -868,6 +870,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
modName: String,
modDescribe: String,
versionName: String,
minVersion: String?,
tagsBuilder: StringBuilder, file: File
) {
val loadFileLayoutBinding = LoadFileLayoutBinding.inflate(layoutInflater)
@ -881,7 +884,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
modName,
modDescribe,
tagsBuilder.toString(),
unitnum,
unitnum, minVersion = minVersion,
iconLink = iconLink, file = file, screenshotList = list, versionName = versionName,
apiCallBack = object : ApiCallBack<ApiResponse> {
override fun onResponse(t: ApiResponse) {

View File

@ -1,6 +1,7 @@
package com.coldmint.rust.pro.adapters
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
@ -45,7 +46,10 @@ class CommentAdapter(context: Context, dataList: MutableList<WebModCommentData.D
position: Int
) {
val icon = data.headIcon
if (icon != null) {
Log.d("CommentAdapter", "图标路径" + icon)
if (icon == null || icon.isBlank()) {
viewBinding.iconView.setImageResource(R.drawable.head_icon)
} else {
Glide.with(context).load(ServerConfiguration.getRealLink(icon))
.apply(GlobalMethod.getRequestOptions(true))
.into(viewBinding.iconView)
@ -57,7 +61,11 @@ class CommentAdapter(context: Context, dataList: MutableList<WebModCommentData.D
data.time + " " + data.location
}
viewBinding.thumbUpImageView.setOnClickListener {
Snackbar.make(viewBinding.thumbUpImageView,R.string.temporarily_unavailable,Snackbar.LENGTH_SHORT).show()
Snackbar.make(
viewBinding.thumbUpImageView,
R.string.temporarily_unavailable,
Snackbar.LENGTH_SHORT
).show()
}
viewBinding.shareImageView.setOnClickListener {
AppOperator.shareText(context, context.getString(R.string.share_message), data.content);
@ -78,7 +86,7 @@ class CommentAdapter(context: Context, dataList: MutableList<WebModCommentData.D
context.getString(R.string.delete_comment_tip),
data.userName
)
).setPositiveButton(R.string.dialog_ok){
).setPositiveButton(R.string.dialog_ok) {
val token = AppSettings.getValue(AppSettings.Setting.Token, "")
if (token.isNullOrBlank()) {
Snackbar.make(
@ -117,7 +125,7 @@ class CommentAdapter(context: Context, dataList: MutableList<WebModCommentData.D
}
})
}
}.setNegativeButton(R.string.dialog_cancel){
}.setNegativeButton(R.string.dialog_cancel) {
}.show()
}

View File

@ -25,6 +25,7 @@ import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContentProviderCompat.requireContext
import com.coldmint.dialog.CoreDialog
import com.coldmint.dialog.InputDialog
import com.coldmint.rust.core.*
import com.google.android.material.snackbar.Snackbar
@ -323,23 +324,19 @@ class ModActionAdapter(
if (file.isDirectory) {
val needShowTip = AppSettings.getValue(AppSettings.Setting.ShareTip, true)
if (needShowTip) {
val materialDialog = MaterialDialog(mContext, MaterialDialog.DEFAULT_BEHAVIOR)
materialDialog.title(R.string.packmod, null)
materialDialog.message(R.string.share_tip, null, null)
materialDialog.positiveButton(
R.string.dialog_ok,
null
) { materialDialog: MaterialDialog? ->
val materialDialog = CoreDialog(mContext)
materialDialog.setTitle(R.string.packmod)
materialDialog.setMessage(R.string.share_tip)
materialDialog.setPositiveButton(
R.string.dialog_ok
) {
packShare(file)
null
}
materialDialog.negativeButton(
R.string.no_longer_prompt,
null
) { materialDialog: MaterialDialog? ->
materialDialog.setNegativeButton(
R.string.no_longer_prompt
) {
AppSettings.setValue(AppSettings.Setting.ShareTip, false)
packShare(file)
null
}
materialDialog.show()
} else {
@ -357,17 +354,16 @@ class ModActionAdapter(
*/
private fun packShare(file: File) {
val modClass = ModClass(file)
val materialDialog = MaterialDialog(mContext)
val materialDialog = CoreDialog(mContext)
Thread(object : Runnable {
override fun run() {
handler.post {
materialDialog.title(R.string.packmod).message(
text =
materialDialog.setTitle(R.string.packmod).setMessage(
String.format(
mContext.getString(R.string.dialog_packing),
modClass.modName
)
).cancelable(false).positiveButton(R.string.dialog_close2) {
).setCancelable(false).setPositiveButton(R.string.dialog_close2) {
Snackbar.make(
mModFragment.requireView(),
R.string.dialog_close_tip3,
@ -385,8 +381,7 @@ class ModActionAdapter(
compressionManager.compression(file, toFile, object : CompressionListener {
override fun whenCompressionFile(file: File): Boolean {
handler.post {
materialDialog.message(
text =
materialDialog.setMessage(
String.format(
mContext.getString(R.string.dialog_packing),
file.name
@ -398,8 +393,7 @@ class ModActionAdapter(
override fun whenCompressionFolder(folder: File): Boolean {
handler.post {
materialDialog.message(
text =
materialDialog.setMessage(
String.format(
mContext.getString(R.string.dialog_packing),
folder.name
@ -412,17 +406,18 @@ class ModActionAdapter(
override fun whenCompressionComplete(result: Boolean) {
handler.post {
if (result) {
materialDialog.title(R.string.share_mod).message(
text =
materialDialog.dismiss()
CoreDialog(mContext)
.setTitle(R.string.share_mod).setMessage(
String.format(
mContext.getString(R.string.pack_success),
modClass.modName
)
).clearPositiveListeners().positiveButton(R.string.share_mod) {
).setPositiveButton(R.string.share_mod) {
FileOperator.shareFile(
mContext, toFile
)
}.negativeButton(R.string.dialog_cancel) {
}.setNegativeButton(R.string.dialog_cancel) {
toFile.delete()
}.show()
} else {

View File

@ -13,6 +13,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.afollestad.materialdialogs.MaterialDialog
import com.coldmint.dialog.CoreDialog
import com.coldmint.rust.core.CompressionManager
import com.coldmint.rust.core.LocalTemplatePackage
import com.coldmint.rust.core.interfaces.CompressionListener
@ -61,7 +62,7 @@ class TemplateListAdapter(
* @param localTemplatePackage LocalTemplatePackage
*/
private fun share(context: Context, localTemplatePackage: LocalTemplatePackage) {
val materialDialog = MaterialDialog(context)
val materialDialog = CoreDialog(context)
val handler = Handler(Looper.getMainLooper())
Thread {
val cacheDirectory =
@ -77,8 +78,10 @@ class TemplateListAdapter(
toFile.delete()
}
handler.post {
materialDialog.title(R.string.packmod)
.positiveButton(R.string.dialog_close2)
materialDialog.setTitle(R.string.packmod)
.setPositiveButton(R.string.dialog_close2){
}
materialDialog.show()
}
val compressionManager =
@ -94,7 +97,7 @@ class TemplateListAdapter(
file.name
)
handler.post {
materialDialog.message(text = msg)
materialDialog.setMessage(msg)
}
return true
}
@ -105,7 +108,7 @@ class TemplateListAdapter(
folder.name
)
handler.post {
materialDialog.message(text = msg)
materialDialog.setMessage(msg)
}
return true
}
@ -114,23 +117,22 @@ class TemplateListAdapter(
handler.post {
materialDialog.dismiss()
if (result) {
MaterialDialog(context).show {
title(R.string.share_mod).message(
text = String.format(
CoreDialog(context).setTitle(R.string.share_mod).setMessage(
String.format(
context.getString(R.string.pack_success),
localTemplatePackage.getName()
)
).positiveButton(R.string.share) {
).setPositiveButton(R.string.share) {
FileOperator.shareFile(
context,
toFile
)
}.negativeButton(R.string.dialog_cancel)
}
}.setNegativeButton(R.string.dialog_cancel) {
}.show()
} else {
MaterialDialog(context).show {
title(R.string.share_mod).message(R.string.pack_failed)
.positiveButton(R.string.dialog_ok)
CoreDialog(context).setTitle(R.string.share_mod).setMessage(R.string.pack_failed).setPositiveButton(R.string.dialog_ok){
}
}
}

View File

@ -43,6 +43,8 @@ class WebModAdapter( context: Context, dataList: MutableList<WebModListData.Dat
val path: String = ServerConfiguration.getRealLink(icon)
Glide.with(context).load(path).apply(GlobalMethod.getRequestOptions())
.into(viewBinding.modIcon)
}else{
viewBinding.modIcon.setImageResource(R.drawable.image)
}
}

View File

@ -33,6 +33,7 @@ import com.coldmint.rust.pro.databinding.FragmentAllUnitsBinding
import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.ui.StableLinearLayoutManager
import com.google.android.material.divider.MaterialDividerItemDecoration
import com.google.android.material.snackbar.Snackbar
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.io.File
import java.text.SimpleDateFormat
@ -143,7 +144,11 @@ class AllUnitsFragment(
* 加载列表
* @param file File
*/
fun loadFiles(file: File = modClass!!.modFile) {
fun loadFiles(file: File? = modClass?.modFile) {
if (file == null) {
Snackbar.make(viewBinding.unitList,R.string.file_not_exist,Snackbar.LENGTH_SHORT).show()
return
}
val handler = Handler(Looper.getMainLooper())
executorService.submit {
handler.post {

View File

@ -226,7 +226,11 @@ class WebModDetailsFragment(val modId: String, val modNameLiveData: MutableLiveD
t.data.versionName
)
viewBinding.updateTimeView.text =
String.format(getString(R.string.recent_update), t.data.updateTime)
String.format(
getString(R.string.recent_update),
t.data.minVersion,
t.data.updateTime
)
if (t.data.hidden == 0) {
viewBinding.hideTextView.isVisible = false
}

View File

@ -83,6 +83,8 @@
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:layout_width="match_parent"
android:hint="@string/minVersion"
android:id="@+id/minVersionEdit"
app:simpleItems="@array/game_versions"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>

View File

@ -121,6 +121,22 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/minVersionInputLayout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:counterEnabled="true"
app:counterMaxLength="20">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/minVersionEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/minVersion"
app:simpleItems="@array/game_versions" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
@ -173,7 +189,6 @@
android:text="@string/add" />
<ImageView
android:visibility="gone"
android:id="@+id/expandMusicList"
android:layout_width="24dp"
android:layout_height="24dp"
@ -182,6 +197,7 @@
android:layout_alignParentEnd="true"
android:padding="2dp"
android:src="@drawable/expand_icon"
android:visibility="gone"
app:tint="?android:colorControlNormal" />
<LinearLayout
@ -261,7 +277,6 @@
android:text="@string/add" />
<ImageView
android:visibility="gone"
android:id="@+id/expandMapList"
android:layout_width="24dp"
android:layout_height="24dp"
@ -270,6 +285,7 @@
android:layout_alignParentEnd="true"
android:padding="2dp"
android:src="@drawable/expand_icon"
android:visibility="gone"
app:tint="?android:colorControlNormal" />
<LinearLayout

View File

@ -136,6 +136,24 @@
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/minVersionInputLayout"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:counterEnabled="true"
app:counterMaxLength="20"
app:helperText="@string/minVersion_tip">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/minVersionEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/minVersion"
app:simpleItems="@array/game_versions" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/modUpdateInputLayout"

View File

@ -77,22 +77,24 @@
android:layout_alignBottom="@id/nameView"
android:layout_marginLeft="8dp"
android:layout_toEndOf="@id/nameView"
style="@style/Widget.Material3.CardView.Filled"
android:visibility="gone"
app:cardBackgroundColor="@color/blue_500"
app:cardCornerRadius="3dp">
app:cardCornerRadius="4dp"
app:cardBackgroundColor="@color/blue_500">
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="1dp">
android:padding="4dp">
<TextView
android:id="@+id/positionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/path"
android:textColor="@color/white"
android:textSize="13dp" />
android:textSize="10sp"
android:textColor="@color/white" />
</LinearLayout>
@ -108,6 +110,15 @@
android:layout_toEndOf="@id/cardView"
android:src="@drawable/boy" />
<ImageView
android:id="@+id/github"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignBottom="@id/genderView"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/genderView"
android:src="@drawable/github" />
<TextView
android:id="@+id/describeView"

View File

@ -765,7 +765,6 @@
<string name="version_name_error2">A commit with version number %1$s already exists.</string>
<string name="update_tip">Write your update log.</string>
<string name="update_log">Update log</string>
<string name="recent_update">Last updated :%1$s</string>
<string name="update_record">Update record</string>
<string name="search_mod_key">Search results for "%1$s"</string>
<string name="result">The results of</string>

View File

@ -765,7 +765,6 @@
<string name="version_name_error2">バージョン番号名が%1$sのコミットが存在する。</string>
<string name="update_tip">更新履歴を作成します。</string>
<string name="update_log">日誌を更新する</string>
<string name="recent_update">最近の更新:%1$s</string>
<string name="update_record">記録を更新する</string>
<string name="search_mod_key">\\"%1$s\\"に関する検索結果</string>
<string name="result">結果</string>

View File

@ -764,7 +764,6 @@
<string name="version_name_error2">Существующая версия под названием % $.</string>
<string name="update_tip">Напиши свой новый журнал.</string>
<string name="update_log">Обновить журнал</string>
<string name="recent_update">Последние новости :% $</string>
<string name="update_record">Обновить запись.</string>
<string name="search_mod_key">Результаты поиска \"% \ $\ \\"</string>
<string name="result">результат</string>

View File

@ -81,6 +81,13 @@
</string-array>
<string-array name="game_versions">
<item>1.15</item>
<item>1.15p11</item>
<item>1.15p9</item>
</string-array>
<string-array name="dateset_read_tips">
<item>@string/read_mode_additional_tip</item>
<item>@string/read_mode_update_tip</item>

View File

@ -809,7 +809,7 @@
<string name="version_name_error2">已存在版本号名为%1$s的提交。</string>
<string name="update_tip">编写您的更新日志。</string>
<string name="update_log">更新日志</string>
<string name="recent_update">近更新:%1$s</string>
<string name="recent_update">低版本:%1$s 最近更新:%2$s</string>
<string name="update_record">更新记录</string>
<string name="search_mod_key">关于\"%1$s\"的搜索结果</string>
<string name="result">结果</string>
@ -962,6 +962,7 @@
<string name="public_mod">公开</string>
<string name="private_mod">私有</string>
<string name="minVersion">最低游戏版本</string>
<string name="minVersion_tip">选择游戏的最低版本,可留空。</string>
<string name="thumbs_up">点赞</string>
<string name="github">GitHub</string>
<string name="dataset_not_exist">DataBaseManifest.json不存在无法加载信息。</string>

View File

@ -27,6 +27,8 @@ data class WebModInfoData(
val screenshots: String? = null,
val tags: String,
val unitNumber: Int,
val updateTime: String
val updateTime: String,
val coinNumber: Int = 0,
val minVersion: String = "未知"
)
}

View File

@ -161,14 +161,14 @@ object ServerConfiguration {
throw NullPointerException("String不能为空")
} else if (string.startsWith("http://") || string.startsWith("https://")) {
//如果说直链
LogCat.d("真实路径组合", "直链" + string)
LogCat.d("getRealLink", "直链 " + string)
string
} else if (string.startsWith(Environment.getExternalStorageDirectory().absolutePath) || string.startsWith(
"/data/"
)
) {
//如果是文件路径
LogCat.d("真实路径组合", "是文件路径" + string)
LogCat.d("getRealLink", "是文件路径 " + string)
string
} else {
//如果开头包含../上级目录
@ -185,7 +185,7 @@ object ServerConfiguration {
"${website}/${string}"
}
}
LogCat.d("真实路径组合", result)
LogCat.d("getRealLink", result)
result
}
}

View File

@ -1104,6 +1104,7 @@ class WebMod private constructor() {
unitNum: Int,
versionName: String,
iconLink: String?,
minVersion: String?,
file: File,
apiCallBack: ApiCallBack<ApiResponse>,
progressListener: ProgressListener? = null, screenshotList: ArrayList<String>? = null
@ -1117,6 +1118,9 @@ class WebMod private constructor() {
.addFormDataPart("versionName", versionName)
.addFormDataPart("unitNumber", unitNum.toString())
.addFormDataPart("file", file.name, file.asRequestBody())
if (minVersion!= null && minVersion.isNotEmpty()) {
builder.addFormDataPart("minVersion", minVersion)
}
if (iconLink != null) {
if (ServerConfiguration.canConvertedToFile(iconLink)) {
val iconFile = File(iconLink)