修复第一次运行助手时,没有游戏目录,没权限无法创建模组的问题。
This commit is contained in:
parent
a2c721dd1d
commit
ef95908cd4
|
@ -12,6 +12,7 @@ import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import com.coldmint.rust.pro.databinding.ActivityCreateModBinding
|
import com.coldmint.rust.pro.databinding.ActivityCreateModBinding
|
||||||
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -113,6 +114,10 @@ class CreateModActivity : BaseActivity<ActivityCreateModBinding>() {
|
||||||
stringBuilder.append("\nminVersion: ")
|
stringBuilder.append("\nminVersion: ")
|
||||||
stringBuilder.append(minVersion)
|
stringBuilder.append(minVersion)
|
||||||
}
|
}
|
||||||
|
GlobalMethod.requestStoragePermissions(this@CreateModActivity) {
|
||||||
|
if (!it) {
|
||||||
|
return@requestStoragePermissions
|
||||||
|
}
|
||||||
val mod_directory =
|
val mod_directory =
|
||||||
File(Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/units/" + name)
|
File(Environment.getExternalStorageDirectory().absolutePath + "/rustedWarfare/units/" + name)
|
||||||
if (mod_directory.exists()) {
|
if (mod_directory.exists()) {
|
||||||
|
@ -123,19 +128,15 @@ class CreateModActivity : BaseActivity<ActivityCreateModBinding>() {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (mod_directory.mkdirs()) {
|
if (mod_directory.mkdirs()) {
|
||||||
try {
|
|
||||||
val fileWriter = FileWriter(mod_directory.absolutePath + "/mod-info.txt")
|
val fileWriter = FileWriter(mod_directory.absolutePath + "/mod-info.txt")
|
||||||
fileWriter.write(stringBuilder.toString())
|
fileWriter.write(stringBuilder.toString())
|
||||||
fileWriter.close()
|
fileWriter.close()
|
||||||
setResult(RESULT_OK)
|
setResult(RESULT_OK)
|
||||||
finish()
|
finish()
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this@CreateModActivity, "你的手机拒绝创建目录", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user