diff --git a/app/build.gradle b/app/build.gradle index 42b5c98..b44dd96 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,83 +3,91 @@ apply plugin: 'kotlin-android' //自定义方法 def releaseTime(){ - return new Date().format("yyyyMMdd",java.util.TimeZone.getTimeZone("UTC")) + return new Date().format("yyyyMMdd",java.util.TimeZone.getTimeZone("UTC")) } android { - compileSdkVersion 30 + compileSdkVersion 30 buildToolsVersion "30.0.3" ndkVersion '23.0.7599858' - ndkPath '/root/android/android-ndk' - - buildFeatures { - dataBinding true - viewBinding true + ndkPath '/root/android/android-ndk' + + buildFeatures { + dataBinding true + viewBinding true } - - defaultConfig { - applicationId "com.ecodemo.silk" - minSdkVersion 21 - targetSdkVersion 30 - versionCode 20 - versionName "1.1.4" - multiDexEnabled true - - externalNativeBuild { - cmake { - cppFlags "" - //arguments "-DANDROID_STL=c++_shared" - abiFilters 'arm64-v8a', 'x86' - } + + defaultConfig { + applicationId "com.ecodemo.silk" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 23 + versionName "1.1.7" + multiDexEnabled true + + externalNativeBuild { + cmake { + cppFlags "" + //arguments "-DANDROID_STL=c++_shared" + abiFilters 'arm64-v8a' + //abiFilters 'armeabi-v7a' } - } + } + } + + lintOptions { + abortOnError false + } - lintOptions { - abortOnError false + buildTypes { + debug{ + minifyEnabled false + zipAlignEnabled false + shrinkResources false + // signingConfig signingConfigs.release } - - buildTypes { - debug{ - minifyEnabled false - zipAlignEnabled false - shrinkResources false - //signingConfig signingConfigs.release - } - release { - minifyEnabled true - multiDexEnabled true - zipAlignEnabled true - //signingConfig signingConfigs.release - //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } + release { + minifyEnabled true + multiDexEnabled true + zipAlignEnabled true + // signingConfig signingConfigs.release + //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + //修改生成的apk名字,格式为 app名_版本号_打包时间_渠道名_release.apk + applicationVariants.all{ variant-> + variant.outputs.all{ + outputFileName= "Silk解码器_${defaultConfig.versionName}_${releaseTime()}.apk" } - - //修改生成的apk名字,格式为 app名_版本号_打包时间_渠道名_release.apk - applicationVariants.all{ variant-> - variant.outputs.all{ - outputFileName= "Silk解码器_${defaultConfig.versionName}_${releaseTime()}.apk" - } + } + + + externalNativeBuild { + cmake { + path "src/main/cpp/CMakeLists.txt" + version "3.19.8" } - - - externalNativeBuild { - cmake { - path "src/main/cpp/CMakeLists.txt" - version "3.19.8" - } + } +} + +repositories { + flatDir { + dirs 'libs' } } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.1' - implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'androidx.documentfile:documentfile:1.0.1' + implementation 'androidx.core:core-ktx:1.3.1' + implementation 'androidx.multidex:multidex:2.0.1' + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'androidx.documentfile:documentfile:1.0.1' + //compile(name:'FFmpegAndroid', ext:'aar') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d2f207d..c472c12 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,12 +2,15 @@ +
Silk解码器
-
Copyright © 2021 Dmeng.All rights reserved.
-


-
Silk Decoder uses the following open source software from the Android Open-Source Project - licensed under the MIT License: +
Copyright © 2022 Dmeng.All rights reserved.
+


+MIT License
+
+Copyright (c) 2022 Ecodemo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.

+
+
Silk Decoder uses the following open source software from the Android Open-Source Project - licensed under the MIT License:
+
Licensed under the View License:
+ \ No newline at end of file diff --git a/app/src/main/java/com/ecodemo/silk/DecodeAdapter.kt b/app/src/main/java/com/ecodemo/silk/DecodeAdapter.kt index a058825..eee3d23 100644 --- a/app/src/main/java/com/ecodemo/silk/DecodeAdapter.kt +++ b/app/src/main/java/com/ecodemo/silk/DecodeAdapter.kt @@ -35,7 +35,7 @@ class DecodeAdapter(var context_: Context, var dataList: MutableList): Rec holder.date?.text = sdf.format(Date(file.lastModified())) holder.size?.text = MxRecyclerAdapter.getFileSize(file.length().toFloat()) holder.root?.setOnClickListener { - var items = arrayOf("播放"/*,"删除"*/) + var items = arrayOf("播放", "删除") //var path = dataList[holder].getUri().getPath() var dialog_ = AlertDialog.Builder(context) dialog_.setItems(items, DialogInterface.OnClickListener(){_, witch -> @@ -43,8 +43,12 @@ class DecodeAdapter(var context_: Context, var dataList: MutableList): Rec 0 -> { PlayerUtils(context, file) } - 0 -> { - + 1 -> { + file.delete() + if (file.exists()) { + dataList.remove(file) + notifyDataSetChanged() + } } } }) diff --git a/app/src/main/java/com/ecodemo/silk/MainActivity.kt b/app/src/main/java/com/ecodemo/silk/MainActivity.kt index 39e1c0e..a812f37 100644 --- a/app/src/main/java/com/ecodemo/silk/MainActivity.kt +++ b/app/src/main/java/com/ecodemo/silk/MainActivity.kt @@ -20,6 +20,7 @@ import android.widget.Toast import java.util.regex.Pattern import android.content.Intent import android.view.MenuItem +import android.widget.EditText import android.app.AlertDialog import android.os.Environment import android.content.Context @@ -33,82 +34,128 @@ import java.util.concurrent.ExecutorService import android.content.pm.PackageManager import androidx.core.content.ContextCompat import android.preference.PreferenceActivity - class MainActivity: PreferenceActivity() { - - @Suppress("DEPRECATION") - private val app_cache: File = File(Environment.getExternalStorageDirectory(), "Silk解码器") - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - /* 设置状态栏字体色 不然看不清字*/ - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) - } - addPreferencesFromResource(R.xml.main) - - /* 权限申请 */ - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)) { - initPermission() - return - } - - if(!app_cache.exists() && app_cache.isDirectory()) { - app_cache.mkdirs() - } + + @Suppress("DEPRECATION") + private val app_cache: File = File(Environment.getExternalStorageDirectory(), "Silk解码器") + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + /* 设置状态栏字体色 不然看不清字*/ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) } - - //返回授权状态 - override fun onActivityResult(requestCode: Int, resultCode: Int, Data: Intent?) { - super.onActivityResult(requestCode, resultCode, Data) - var uri: Uri? = Data?.getData() - if (requestCode == 0xFC && uri != null) { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){ - if(Environment.isExternalStorageManager()){ - Toast.makeText(this, "存储权限授权成功", Toast.LENGTH_SHORT).show() - } else { - Toast.makeText(this, "你拒绝了授权", Toast.LENGTH_SHORT).show() - java.lang.System.exit(0) - } - } - if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ - Toast.makeText(this, "你拒绝了授权", Toast.LENGTH_SHORT).show() - java.lang.System.exit(0) - } - } - - reload() + addPreferencesFromResource(R.xml.main) + + /* 权限申请 */ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)) { + initPermission() + return + } + + if(!app_cache.exists() && app_cache.isDirectory()) { + app_cache.mkdirs() + } + + findPreference("install_ffmpeg")?.setOnPreferenceClickListener { + /* val view = View.inflate(this, R.layout.install_ffmpeg_dialog, null) + val edit: EditText = view.findViewById(R.id.path) */ + val builder = AlertDialog.Builder(this) + .setTitle("安装 FFmpeg") + .setMessage("由于本应用使用 Android 手机 开发,无法编译 FFmpeg,坐等有缘人协助...") + .setPositiveButton("确定", null) + // .setNeutralButton("取消", null) + builder.create().show() + true + } + + findPreference("author_coolapk")?.setOnPreferenceClickListener { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("coolmarket://u/1512829"))) + } catch (e: Exception) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://www.coolapk.com/u/1512829"))) + } + true + } + + findPreference("app_coolapk")?.setOnPreferenceClickListener { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("coolmarket://apk/com.ecodemo.silk"))) + } catch (e: Exception) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://www.coolapk.com/apk/com.ecodemo.silk"))) + } + true } - fun initPermission() { - AlertDialog.Builder(this) - .setMessage("你正在使用 Silk解码器 App,本软件基于 Silkv3 开源库,我们也很不想让你给予软件 存储权限,由于 Android 6 以上 系统的一些限制 和 本应用的原理,你只能通过给予权限,才能够使用App,否则你将无法使用本 App,我们不会收集和使用你的任何个人信息,本软件无需联网") - .setTitle("警告") - .setPositiveButton("同意", DialogInterface.OnClickListener { _, _-> - if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){ - var intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) - intent.data = Uri.parse("package:" + getPackageName()) - startActivityForResult(intent, 0xFC) - } - if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ - //没有权限则申请权限 - ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),1); - } - } - }).setNeutralButton("取消", DialogInterface.OnClickListener{ _, _ -> - java.lang.System.exit(0) - }).create().show() + findPreference("update_log")?.setOnPreferenceClickListener { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Ecodemo/Silk-Decoder/releases"))) + } catch (e: Exception) { + Toast.makeText(this, "跳转失败:你可能没有安装浏览器", Toast.LENGTH_SHORT).show() + } + true } - /* 重启 Activity */ - fun reload() { - var intent = getIntent() - overridePendingTransition(0, 0) - intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION - finish() - overridePendingTransition(0, 0) - startActivity(intent) - } -} \ No newline at end of file + findPreference("issue")?.setOnPreferenceClickListener { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Ecodemo/Silk-Decoder/issues"))) + } catch (e: Exception) { + Toast.makeText(this, "跳转失败:你可能没有安装浏览器", Toast.LENGTH_SHORT).show() + } + true + } + } + + //返回授权状态 + override fun onActivityResult(requestCode: Int, resultCode: Int, Data: Intent?) { + super.onActivityResult(requestCode, resultCode, Data) + var uri: Uri? = Data?.getData() + if (requestCode == 0xFC && uri != null) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){ + if(Environment.isExternalStorageManager()){ + Toast.makeText(this, "存储权限授权成功", Toast.LENGTH_SHORT).show() + } else { + Toast.makeText(this, "你拒绝了授权", Toast.LENGTH_SHORT).show() + java.lang.System.exit(0) + } + } + if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ + Toast.makeText(this, "你拒绝了授权", Toast.LENGTH_SHORT).show() + java.lang.System.exit(0) + } + } + reload() + } + + fun initPermission() { + AlertDialog.Builder(this) + .setMessage("你正在使用 Silk解码器 App,本软件基于 Silkv3 开源库,我们也很不想让你给予软件 存储权限,由于 Android 6 以上 系统的一些限制 和 本应用的原理,你只能通过给予权限,才能够使用App,否则你将无法使用本 App,我们不会收集和使用你的任何个人信息,本软件无需联网") + .setTitle("警告") + .setPositiveButton("同意", DialogInterface.OnClickListener { _, _-> + if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){ + var intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) + intent.data = Uri.parse("package:" + getPackageName()) + startActivityForResult(intent, 0xFC) + } + if (ContextCompat.checkSelfPermission(this@MainActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ + //没有权限则申请权限 + ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),1); + } + } + }).setNeutralButton("取消", DialogInterface.OnClickListener{ _, _ -> + java.lang.System.exit(0) + }).create().show() + } + + /* 重启 Activity */ + fun reload() { + var intent = getIntent() + overridePendingTransition(0, 0) + intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION + finish() + overridePendingTransition(0, 0) + startActivity(intent) + } +} diff --git a/app/src/main/java/com/ecodemo/silk/MxRecyclerAdapter.kt b/app/src/main/java/com/ecodemo/silk/MxRecyclerAdapter.kt index ccc20ec..bc769f3 100644 --- a/app/src/main/java/com/ecodemo/silk/MxRecyclerAdapter.kt +++ b/app/src/main/java/com/ecodemo/silk/MxRecyclerAdapter.kt @@ -86,7 +86,7 @@ class MxRecyclerAdapter(var context_: Context, var dataList: MutableList @@ -108,12 +108,27 @@ class MxRecyclerAdapter(var context_: Context, var dataList: MutableList { - decoder_to_file(dataList[holder.getAdapterPosition()].getUri(), app_cache, OnDecode { mp3 -> - var msg = Message() - msg.what = 201 - msg.obj = mp3.getAbsolutePath() - handler.sendMessage(msg) - }) + if (File(context.getFilesDir(), "ffmpeg").exists()) { + ffmpeg_decoder(dataList[holder.getAdapterPosition()].getUri(), app_cache, OnDecode { mp3 -> + var msg = Message() + msg.what = 201 + msg.obj = mp3.getAbsolutePath() + handler.sendMessage(msg) + }) + } else { + decoder_to_file(dataList[holder.getAdapterPosition()].getUri(), app_cache, OnDecode { mp3 -> + var msg = Message() + msg.what = 201 + msg.obj = mp3.getAbsolutePath() + handler.sendMessage(msg) + }) + } + } + 2 -> { + var file: DocumentFile = dataList[holder.getAdapterPosition()] + file.delete() + dataList.remove(file) + notifyDataSetChanged() } } }) @@ -135,6 +150,20 @@ class MxRecyclerAdapter(var context_: Context, var dataList: MutableList + when(which) { + 0 -> { + decoder_to_file(source!!, cache!!, de!!) + } + } + }) + dialog_.show() + } + fun decoder(uri: Uri?): File { var cache_dir = context.getCacheDir() var cache_file = File(cache_dir, "cache.slk"); diff --git a/app/src/main/java/com/ecodemo/silk/OtherDecoder.kt b/app/src/main/java/com/ecodemo/silk/OtherDecoder.kt index aa0c5e8..c862739 100644 --- a/app/src/main/java/com/ecodemo/silk/OtherDecoder.kt +++ b/app/src/main/java/com/ecodemo/silk/OtherDecoder.kt @@ -74,7 +74,7 @@ class OtherDecoder : Activity() { } } if(it.what == 999) { - if(list.size == 0) { + if(list.size <= 0) { binding.tisp.text = "啥也没有" binding.tisp.visibility = View.VISIBLE } @@ -245,6 +245,7 @@ class OtherDecoder : Activity() { /* handler.sendEmptyMessage(7) list.sortByDescending({ it.lastModified().toInt() })*/ handler.sendEmptyMessage(6) + handler.sendEmptyMessage(999) break } continue diff --git a/app/src/main/java/com/ecodemo/silk/QQDecoder.kt b/app/src/main/java/com/ecodemo/silk/QQDecoder.kt index 6c8474e..64cc352 100644 --- a/app/src/main/java/com/ecodemo/silk/QQDecoder.kt +++ b/app/src/main/java/com/ecodemo/silk/QQDecoder.kt @@ -243,6 +243,7 @@ class QQDecoder : Activity() { /* handler.sendEmptyMessage(7) list.sortByDescending({ it.lastModified().toInt() })*/ handler.sendEmptyMessage(6) + handler.sendEmptyMessage(999) break } continue diff --git a/app/src/main/res/xml/main.xml b/app/src/main/res/xml/main.xml index b461211..0f12b24 100644 --- a/app/src/main/res/xml/main.xml +++ b/app/src/main/res/xml/main.xml @@ -41,7 +41,14 @@ android:targetClass="com.ecodemo.silk.DecodeFile" /> + + + + + + + + + + + - - diff --git a/build.gradle b/build.gradle index 0f87ee6..f1c50ed 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.build_gradle_version = '4.1.2' + // ext.build_gradle_version = '7.0.4' ext.kotlin_version = "1.4.31" repositories {