mirror of
https://github.com/fumiama/android-base16384.git
synced 2026-06-11 13:30:27 +08:00
v1.2
This commit is contained in:
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId "top.fumiama.base16384"
|
applicationId "top.fumiama.base16384"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 5
|
versionCode 6
|
||||||
versionName '1.1.2.1'
|
versionName '1.2'
|
||||||
resConfigs "zh", "en"
|
resConfigs "zh", "en"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
@@ -22,7 +22,6 @@ android {
|
|||||||
cppFlags ""
|
cppFlags ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
multiDexEnabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*signingConfigs {
|
/*signingConfigs {
|
||||||
@@ -68,4 +67,4 @@ dependencies {
|
|||||||
testImplementation 'junit:junit:4.13.1'
|
testImplementation 'junit:junit:4.13.1'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import android.content.ClipboardManager
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.graphics.Rect
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -25,39 +26,16 @@ class MainActivity : Activity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
val cm = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val cm = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
sv.viewTreeObserver.addOnGlobalLayoutListener {
|
sv.viewTreeObserver.addOnGlobalLayoutListener { setTitleVisibility() }
|
||||||
val h = sv.getChildAt(0).height
|
|
||||||
tti.visibility = if(h > resources.displayMetrics.heightPixels) View.GONE else View.VISIBLE
|
|
||||||
}
|
|
||||||
fab.setOnClickListener { if(checkReadPermission()) pickFile() }
|
fab.setOnClickListener { if(checkReadPermission()) pickFile() }
|
||||||
ben.setOnClickListener {
|
ben.setOnClickListener { clickButton(true, cm) }
|
||||||
ten.text?.let {
|
bde.setOnClickListener { clickButton(false, cm) }
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tti.setOnLongClickListener {
|
tti.setOnLongClickListener {
|
||||||
AlertDialog.Builder(this).setTitle(R.string.info).setMessage(R.string.info_content).setIcon(R.mipmap.ic_launcher).show()
|
AlertDialog.Builder(this).setTitle(R.string.info).setMessage(R.string.info_content).setIcon(R.mipmap.ic_launcher).show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
setLongPress2Paste(ten, cm)
|
||||||
|
setLongPress2Paste(tde, cm)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
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){
|
private fun doFromFile(uri: Uri){
|
||||||
val inputFile = generateCacheFile("input")
|
val inputFile = generateCacheFile("input")
|
||||||
val outputFile = generateCacheFile("output")
|
val outputFile = generateCacheFile("output")
|
||||||
@@ -147,21 +112,6 @@ class MainActivity : Activity() {
|
|||||||
startActivityForResult(intent, 2)
|
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 {
|
private fun checkReadPermission(): Boolean {
|
||||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N && ContextCompat.checkSelfPermission(
|
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N && ContextCompat.checkSelfPermission(
|
||||||
this,
|
this,
|
||||||
@@ -186,12 +136,41 @@ class MainActivity : Activity() {
|
|||||||
|
|
||||||
private fun copyText(t: TextInputEditText, cm: ClipboardManager){
|
private fun copyText(t: TextInputEditText, cm: ClipboardManager){
|
||||||
if(t.text?.isNotEmpty() == true) {
|
if(t.text?.isNotEmpty() == true) {
|
||||||
//t.selectAll()
|
|
||||||
ClipData.newPlainText(getString(R.string.app_name), t.text)?.let { cm.setPrimaryClip(it) }
|
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,
|
* A native method that is implemented by the 'native-lib' native library,
|
||||||
* which is packaged with this application.
|
* which is packaged with this application.
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<ScrollView
|
||||||
android:id="@+id/constraintLayout2"
|
android:id="@+id/sv"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
@@ -15,61 +16,51 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<ScrollView
|
<LinearLayout
|
||||||
android:id="@+id/sv"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_marginStart="32dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_marginEnd="32dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:gravity="center"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/stxt"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/ten"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/text_original" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/ben"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="32dp"
|
android:text="@string/encode" />
|
||||||
android:layout_marginEnd="32dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/stxt"
|
android:id="@+id/dtxt"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/tde"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/ten"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/text_original" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/ben"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/encode" />
|
android:hint="@string/text_encoded" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<Button
|
||||||
android:id="@+id/dtxt"
|
android:id="@+id/bde"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/decode" />
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
</LinearLayout>
|
||||||
android:id="@+id/tde"
|
</ScrollView>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/text_encoded" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/bde"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/decode" />
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tti"
|
android:id="@+id/tti"
|
||||||
@@ -79,7 +70,7 @@
|
|||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
android:textColor="?attr/colorOnSurface"
|
android:textColor="?attr/colorOnSurface"
|
||||||
android:textSize="36sp"
|
android:textSize="36sp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/constraintLayout2"
|
app:layout_constraintBottom_toTopOf="@+id/sv"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|||||||
9
app/src/main/res/values-night/styles.xml
Normal file
9
app/src/main/res/values-night/styles.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:fitsSystemWindows">true</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<color name="colorAccent">#F6837A</color>
|
|
||||||
</resources>
|
|
||||||
@@ -2,13 +2,9 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="android:colorAccent">@color/colorAccent</item>
|
|
||||||
<item name="colorPrimarySurface">@color/colorAccent</item>
|
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
<item name="android:windowTranslucentStatus">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
<item name="android:fitsSystemWindows">false</item>
|
<item name="android:fitsSystemWindows">true</item>
|
||||||
<item name="windowActionBar">false</item>
|
|
||||||
<item name="windowNoTitle">true</item>
|
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user