diff --git a/app/build.gradle b/app/build.gradle index f67282c..9716123 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,9 +1,8 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-android-extensions' - id 'AndResGuard' -} +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' +//apply plugin: 'AndResGuard' android { compileSdkVersion 30 @@ -13,8 +12,8 @@ android { applicationId "top.fumiama.base16384" minSdkVersion 23 targetSdkVersion 30 - versionCode 1 - versionName "1.0" + versionCode 5 + versionName '1.1.2.1' resConfigs "zh", "en" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -26,25 +25,16 @@ android { multiDexEnabled = false } - signingConfigs { + /*signingConfigs { release { storeFile file('../../../OneDrive/swc/developer/android_key/open_key') storePassword 'fumiama' - keyAlias 'default' + keyAlias 'cert' keyPassword 'fumiama' v1SigningEnabled true v2SigningEnabled true } - } - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.release - } - } + }*/ externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" @@ -59,6 +49,14 @@ android { jvmTarget = '1.8' } ndkVersion '22.0.7026061' + buildTypes { + release { + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + //signingConfig signingConfigs.release + } + } } dependencies { @@ -71,51 +69,3 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } - -andResGuard { - // mappingFile = file("./resource_mapping.txt") - mappingFile = null - use7zip = true - useSign = true - // 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字 - keepRoot = false - // 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小 - fixedResName = "arg" - // 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源 - mergeDuplicatedRes = true - whiteList = [ - // for your icon - "R.drawable.icon", - // for fabric - "R.string.com.crashlytics.*", - // for google-services - "R.string.google_app_id", - "R.string.gcm_defaultSenderId", - "R.string.default_web_client_id", - "R.string.ga_trackingId", - "R.string.firebase_database_url", - "R.string.google_api_key", - "R.string.google_crash_reporting_api_key" - ] - compressFilePattern = [ - "*.png", - "*.jpg", - "*.jpeg", - "*.gif", - ] - sevenzip { - artifact = 'com.tencent.mm:SevenZip:1.2.20' - //path = "/usr/local/bin/7za" - } - - /** - * 可选: 如果不设置则会默认覆盖assemble输出的apk - **/ - // finalApkBackupPath = "${project.rootDir}/final.apk" - - /** - * 可选: 指定v1签名时生成jar文件的摘要算法 - * 默认值为“SHA-1” - **/ - // digestalg = "SHA-256" -} \ No newline at end of file diff --git a/app/release/app-release.aab b/app/release/app-release.aab new file mode 100644 index 0000000..928869e Binary files /dev/null and b/app/release/app-release.aab differ diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..e4729b5 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..e6a0187 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "top.fumiama.base16384", + "variantName": "processReleaseResources", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "versionCode": 5, + "versionName": "1.1.2.1", + "outputFile": "app-release.apk" + } + ] +} \ No newline at end of file diff --git a/app/src/main/java/top/fumiama/base16384/MainActivity.kt b/app/src/main/java/top/fumiama/base16384/MainActivity.kt index 25fc702..a55351c 100644 --- a/app/src/main/java/top/fumiama/base16384/MainActivity.kt +++ b/app/src/main/java/top/fumiama/base16384/MainActivity.kt @@ -2,6 +2,10 @@ package top.fumiama.base16384 import android.Manifest import android.app.Activity +import android.app.AlertDialog +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.net.Uri @@ -11,6 +15,7 @@ import android.view.View import android.widget.Toast import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat +import com.google.android.material.textfield.TextInputEditText import kotlinx.android.synthetic.main.activity_main.* import java.io.File import java.io.FileInputStream @@ -19,6 +24,7 @@ class MainActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { 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 @@ -32,6 +38,7 @@ class MainActivity : Activity() { inputFile.writeText(it.toString(), Charsets.UTF_16BE) encode(inputFile.absolutePath, outputFile.absolutePath) tde.setText(outputFile.readText(Charsets.UTF_16BE)) + copyText(tde, cm) } } } @@ -43,9 +50,14 @@ class MainActivity : Activity() { inputFile.writeText(it.toString(), Charsets.UTF_16BE) decode(inputFile.absolutePath, outputFile.absolutePath) ten.setText(outputFile.readText(Charsets.UTF_16BE)) + copyText(ten, cm) } } } + tti.setOnLongClickListener { + AlertDialog.Builder(this).setTitle(R.string.info).setMessage(R.string.info_content).setIcon(R.mipmap.ic_launcher).show() + true + } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -86,16 +98,19 @@ class MainActivity : Activity() { val inputFile = generateCacheFile("input") val outputFile = generateCacheFile("output") saveFile(inputFile, uri) - val br = inputFile.bufferedReader(Charsets.US_ASCII) - val head1 = br.read() - val head2 = br.read() - val re = if(head1 == 0xFE && head2 == 0xFF) decode(inputFile.absolutePath, outputFile.absolutePath) + val bbf = ByteArray(2) + val br = inputFile.inputStream() + br.read(bbf) + br.close() + val isDecode = bbf[0] == (-2).toByte() && bbf[1] == (-1).toByte() + + val re = if(isDecode) decode(inputFile.absolutePath, outputFile.absolutePath) else encode(inputFile.absolutePath, outputFile.absolutePath) Toast.makeText( this, if(re == 0) { createFile(getString(R.string.output)) - R.string.succeed + if(isDecode) R.string.decode_succeed else R.string.encode_succeed } else R.string.failed, Toast.LENGTH_SHORT ).show() @@ -169,6 +184,14 @@ class MainActivity : Activity() { private fun generateCacheFile(name: String) = File(cacheDir, name) + 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() + } + } + /** * 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/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 8c82db1..de86fd9 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -11,4 +11,9 @@ 成功 失败 输出 + 解码成功 + 编码成功 + 关于 + 作者:源文雨。感谢咲桜动漫社成员的支持。 + 已复制 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 28579a8..751d590 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,10 +4,15 @@ decode Original Text Encoded Text - permission denied + Permission Denied Save Produced File Read File Error! - succeed - failed + Succeed + Failed output + Decode Succeed + Encode Succeed + Info + Author: Fumiama, with precious supports of the members in Sakura Anime Club. + Copied Text \ No newline at end of file diff --git a/build.gradle b/build.gradle index c391794..c409232 100644 --- a/build.gradle +++ b/build.gradle @@ -4,11 +4,13 @@ buildscript { repositories { google() jcenter() + mavenCentral() + maven { url 'https://maven.google.com' } } dependencies { classpath "com.android.tools.build:gradle:4.1.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.20' + //classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.20' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 56f00af..98ee989 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2048m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects