diff --git a/app/build.gradle b/app/build.gradle
index 9716123..368ed23 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,8 +12,8 @@ android {
applicationId "top.fumiama.base16384"
minSdkVersion 23
targetSdkVersion 30
- versionCode 5
- versionName '1.1.2.1'
+ versionCode 6
+ versionName '1.2'
resConfigs "zh", "en"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -22,7 +22,6 @@ android {
cppFlags ""
}
}
- multiDexEnabled = false
}
/*signingConfigs {
@@ -68,4 +67,4 @@ dependencies {
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
-}
+}
\ No newline at end of file
diff --git a/app/release/app-release.aab b/app/release/app-release.aab
index 928869e..8247267 100644
Binary files a/app/release/app-release.aab and b/app/release/app-release.aab differ
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
index e4729b5..dcde1c4 100644
Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
index e6a0187..6695f3d 100644
--- a/app/release/output-metadata.json
+++ b/app/release/output-metadata.json
@@ -10,8 +10,8 @@
{
"type": "SINGLE",
"filters": [],
- "versionCode": 5,
- "versionName": "1.1.2.1",
+ "versionCode": 6,
+ "versionName": "1.2",
"outputFile": "app-release.apk"
}
]
diff --git a/app/src/main/java/top/fumiama/base16384/MainActivity.kt b/app/src/main/java/top/fumiama/base16384/MainActivity.kt
index a55351c..c1afced 100644
--- a/app/src/main/java/top/fumiama/base16384/MainActivity.kt
+++ b/app/src/main/java/top/fumiama/base16384/MainActivity.kt
@@ -8,6 +8,7 @@ import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
+import android.graphics.Rect
import android.net.Uri
import android.os.Build
import android.os.Bundle
@@ -25,39 +26,16 @@ class MainActivity : Activity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val cm = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
- sv.viewTreeObserver.addOnGlobalLayoutListener {
- val h = sv.getChildAt(0).height
- tti.visibility = if(h > resources.displayMetrics.heightPixels) View.GONE else View.VISIBLE
- }
+ sv.viewTreeObserver.addOnGlobalLayoutListener { setTitleVisibility() }
fab.setOnClickListener { if(checkReadPermission()) pickFile() }
- ben.setOnClickListener {
- ten.text?.let {
- if(it.isNotEmpty()){
- val inputFile = generateCacheFile("input")
- val outputFile = generateCacheFile("output")
- inputFile.writeText(it.toString(), Charsets.UTF_16BE)
- encode(inputFile.absolutePath, outputFile.absolutePath)
- tde.setText(outputFile.readText(Charsets.UTF_16BE))
- copyText(tde, cm)
- }
- }
- }
- bde.setOnClickListener {
- tde.text?.let {
- if(it.isNotEmpty()){
- val inputFile = generateCacheFile("input")
- val outputFile = generateCacheFile("output")
- inputFile.writeText(it.toString(), Charsets.UTF_16BE)
- decode(inputFile.absolutePath, outputFile.absolutePath)
- ten.setText(outputFile.readText(Charsets.UTF_16BE))
- copyText(ten, cm)
- }
- }
- }
+ ben.setOnClickListener { clickButton(true, cm) }
+ bde.setOnClickListener { clickButton(false, cm) }
tti.setOnLongClickListener {
AlertDialog.Builder(this).setTitle(R.string.info).setMessage(R.string.info_content).setIcon(R.mipmap.ic_launcher).show()
true
}
+ setLongPress2Paste(ten, cm)
+ setLongPress2Paste(tde, cm)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -81,19 +59,6 @@ class MainActivity : Activity() {
}
}
- /*private fun packZip(zipf: File, outf: File){
- zipf.parentFile?.let { if(!it.exists()) it.mkdirs() }
- if(zipf.exists()) zipf.delete()
- zipf.createNewFile()
- val zip = ZipOutputStream(CheckedOutputStream(zipf.outputStream(), CRC32()))
- zip.setLevel(9)
- zip.putNextEntry(ZipEntry("output"))
- zip.write(outf.readBytes())
- zip.flush()
- zip.close()
- }*/
-
-
private fun doFromFile(uri: Uri){
val inputFile = generateCacheFile("input")
val outputFile = generateCacheFile("output")
@@ -147,21 +112,6 @@ class MainActivity : Activity() {
startActivityForResult(intent, 2)
}
- /*private fun shareFile(file: File, type: String) {
- if (file.exists()) {
- val share = Intent(Intent.ACTION_SEND)
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- val contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", file)
- share.putExtra(Intent.EXTRA_STREAM, contentUri)
- share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- }else share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file))
- share.type = type //此处可发送多种文件
- share.flags = Intent.FLAG_ACTIVITY_NEW_TASK
- share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- startActivity(Intent.createChooser(share, getString(R.string.share)))
- } else Toast.makeText(this, getString(R.string.read_file_err), Toast.LENGTH_SHORT).show()
- }*/
-
private fun checkReadPermission(): Boolean {
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N && ContextCompat.checkSelfPermission(
this,
@@ -186,12 +136,41 @@ class MainActivity : Activity() {
private fun copyText(t: TextInputEditText, cm: ClipboardManager){
if(t.text?.isNotEmpty() == true) {
- //t.selectAll()
ClipData.newPlainText(getString(R.string.app_name), t.text)?.let { cm.setPrimaryClip(it) }
- Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show()
+ Toast.makeText(this, getString(R.string.copied)+t.text, Toast.LENGTH_SHORT).show()
}
}
+ private fun setLongPress2Paste(t: TextInputEditText, cm: ClipboardManager){
+ t.setOnLongClickListener {
+ if(t.text?.isEmpty() == true) t.setText(cm.primaryClip?.getItemAt(0)?.text)
+ false
+ }
+ }
+
+ private fun clickButton(isEncode: Boolean, cm:ClipboardManager){
+ val tin = if(isEncode)ten else tde
+ val tou = if(isEncode)tde else ten
+ tin.text?.let {
+ if(it.isNotEmpty()){
+ val inputFile = generateCacheFile("input")
+ val outputFile = generateCacheFile("output")
+ inputFile.writeText(it.toString(), Charsets.UTF_16BE)
+ if(isEncode) encode(inputFile.absolutePath, outputFile.absolutePath)
+ else decode(inputFile.absolutePath, outputFile.absolutePath)
+ tou.setText(outputFile.readText(Charsets.UTF_16BE))
+ copyText(tou, cm)
+ }
+ }
+ }
+
+ private fun setTitleVisibility(){
+ val h = sv.getChildAt(0).height
+ val r = Rect()
+ window.decorView.rootView.getWindowVisibleDisplayFrame(r)
+ tti.visibility = if(h > r.bottom) View.GONE else View.VISIBLE
+ }
+
/**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index a0b01f4..a8b36ae 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,10 +4,11 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_gravity="center"
tools:context=".MainActivity">
-
-
+ android:layout_height="wrap_content"
+ android:layout_marginStart="32dp"
+ android:layout_marginEnd="32dp"
+ android:gravity="center"
+ android:orientation="vertical">
-
+
+
+
+
+
-
-
+
+
+
diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..1ac7733
--- /dev/null
+++ b/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index b6a8055..0000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- #F6837A
-
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 4ca5c88..bd5f7c9 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -2,13 +2,9 @@
\ No newline at end of file