1
0
mirror of https://github.com/fumiama/android-base16384.git synced 2026-06-08 12:00:29 +08:00
This commit is contained in:
fumiama
2020-12-19 17:10:11 +08:00
parent 2d6fd151b8
commit 537abfa068
6 changed files with 36 additions and 3 deletions

View File

@@ -26,13 +26,29 @@ import java.io.FileInputStream
import java.nio.charset.Charset
class MainActivity : Activity() {
var forceDecode = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val cm = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val pCharsets = PropertiesTools(File(filesDir, "charsets.prop"))
sv.viewTreeObserver.addOnGlobalLayoutListener { setTitleVisibility() }
fab.setOnClickListener { pickFile() }
fab.setOnLongClickListener {
AlertDialog.Builder(this)
.setTitle(R.string.alert)
.setMessage(R.string.force_decode)
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton(android.R.string.ok){ _, _ ->
forceDecode = true
pickFile()
}
.setNegativeButton(android.R.string.cancel){ _, _ ->}
.show()
false
}
ben.setOnClickListener { clickButton(true, cm, pCharsets) }
bde.setOnClickListener { clickButton(false, cm, pCharsets) }
ben.setOnLongClickListener {
@@ -67,7 +83,8 @@ class MainActivity : Activity() {
val br = inputFile.inputStream()
br.read(bbf)
br.close()
val isDecode = bbf[0] == (-2).toByte() && bbf[1] == (-1).toByte()
val isDecode = (bbf[0] == (-2).toByte() && bbf[1] == (-1).toByte()) || forceDecode
if (forceDecode) forceDecode = false
val re = if(isDecode) decode(inputFile.absolutePath, outputFile.absolutePath)
else encode(inputFile.absolutePath, outputFile.absolutePath)

View File

@@ -17,4 +17,6 @@
<string name="info_content">作者:源文雨。感谢咲桜动漫社成员的支持。</string>
<string name="copied">已复制</string>
<string name="select_charset">选择字符集</string>
<string name="alert">提示</string>
<string name="force_decode">执行强制解码?</string>
</resources>

View File

@@ -16,4 +16,6 @@
<string name="info_content">Author: Fumiama, with precious supports from the members in Sakura Anime Club.</string>
<string name="copied">Copied Text</string>
<string name="select_charset">Select Charset</string>
<string name="alert">Alert</string>
<string name="force_decode">Force Decode?</string>
</resources>