diff --git a/app/build.gradle b/app/build.gradle
index 8077964..64c58e4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,22 +1,33 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
+apply plugin: 'AndResGuard'
android {
+ signingConfigs {
+ config {
+ keyAlias 'Neuron'
+ keyPassword KEYSTORE_PASSWORD
+ storeFile file('../nexus6pcn.jks')
+ storePassword KEY_PASSWORD
+ }
+ }
compileSdkVersion 28
defaultConfig {
applicationId "tech.lincaiqi.PhotoTimeFix"
minSdkVersion 19
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 21
- versionCode 8
+ versionCode 9
versionName '3.0'
+ resConfigs "zh", "zh-rCN"
}
buildTypes {
release {
minifyEnabled true
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
shrinkResources true
+ signingConfig signingConfigs.config
}
}
buildToolsVersion '28.0.3'
@@ -30,8 +41,52 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11"
- implementation "org.jetbrains.anko:anko-common:0.10.8"
+ implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11'
+ implementation 'org.jetbrains.anko:anko-common:0.10.8'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
+
+andResGuard {
+ // mappingFile = file("./resource_mapping.txt")
+ mappingFile = null
+ use7zip = true
+ useSign = true
+ // 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
+ keepRoot = false
+ 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.15'
+ //path = "/usr/local/bin/7za"
+ }
+
+ /**
+ * 可选: 如果不设置则会默认覆盖assemble输出的apk
+ **/
+ // finalApkBackupPath = "${project.rootDir}/final.apk"
+
+ /**
+ * 可选: 指定v1签名时生成jar文件的摘要算法
+ * 默认值为“SHA-1”
+ **/
+ // digestalg = "SHA-256"
+}
diff --git a/app/release/output.json b/app/release/output.json
index b8aa86b..4cd96aa 100644
--- a/app/release/output.json
+++ b/app/release/output.json
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5ff0211..bd7b791 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,7 +6,7 @@
@@ -46,11 +52,11 @@ class CoreK(private var context: Context) {
val builder = AlertDialog.Builder(context)
try {
val view = LayoutInflater.from(context).inflate(R.layout.about, null)
- val webview: WebView = view.findViewById(R.id.webview)
- webview.webViewClient = WebViewClient()
- webview.loadUrl("file:///android_asset/about.html")
- webview.settings.javaScriptEnabled = true
- webview.addJavascriptInterface(this, "openGit")
+ val webView: WebView = view.findViewById(R.id.webview)
+ webView.webViewClient = WebViewClient()
+ webView.loadUrl("file:///android_asset/about.html")
+ webView.settings.javaScriptEnabled = true
+ webView.addJavascriptInterface(this, "openGit")
builder.setView(view)
} catch (e: Exception) {
builder.setMessage("加载Webview错误,已停止显示帮助窗口。\n该错误并不影响正常功能运行,且开发者仅在模拟器上遇到过,如果出现此对话框请与开发者联系。")
@@ -88,13 +94,13 @@ class CoreK(private var context: Context) {
}
- private fun chooseFile(fragment : Fragment) {
+ private fun chooseFile(fragment: Fragment) {
val intent = Intent(Intent.ACTION_PICK, null)
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*")
- fragment.startActivityForResult(intent,0)
+ fragment.startActivityForResult(intent, 0)
}
- fun resultSolve(requestCode: Int, data: Intent?) : String {
+ fun resultSolve(requestCode: Int, data: Intent?): String {
try {
return if (requestCode == 0) {
val originalUri = data!!.data
@@ -110,36 +116,53 @@ class CoreK(private var context: Context) {
cursor.close()
path
} else "error"
- }else "error"
+ } else "error"
- } catch (e : java.lang.Exception) {
+ } catch (e: java.lang.Exception) {
e.printStackTrace()
return "error"
}
}
- fun updateDate (path : String , activity: Activity) : String {
+ fun updateDate(path: String, activity: Activity): Array {
val file = File(path)
- val imageView : ImageView = activity.findViewById(R.id.user_bg)
- return if (file.exists()&&file.isFile) {
- val bm : Bitmap = BitmapFactory.decodeFile(path)
+ val imageView: ImageView = activity.findViewById(R.id.user_bg)
+ val returnArray = arrayOfNulls(2)
+ if (file.exists() && file.isFile) {
+ val bm: Bitmap = BitmapFactory.decodeFile(path)
imageView.setImageBitmap(bm)
- updateAppbar(activity,false)
- Date(file.lastModified()).toString()
- }
- else {
+ updateAppbar(activity, false)
+ val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
+ returnArray[0]=sdf.format(Date(file.lastModified()))
+ var time = file.name
+ time = Pattern.compile("[^0-9]").matcher(time).replaceAll("").trim { it <= ' ' }
+ Log.d("date",time)
+ if (time.contains("20") && time.substring(time.indexOf("20")).length >= 12) {
+ val targetTime = time.substring(time.indexOf("20"), time.indexOf("20") + 12)
+ try {
+ returnArray[1] = sdf.format(SimpleDateFormat("yyyyMMddHHmm", Locale.getDefault()).parse(targetTime))
+ } catch (e : Exception) {
+ returnArray[1] = ""
+ e.printStackTrace()
+ }
+ } else {
+ returnArray[1] = ""
+ }
+ } else {
imageView.setImageBitmap(null)
- updateAppbar(activity,true)
- ""
+ updateAppbar(activity, true)
+ returnArray[0] = ""
+ returnArray[1] = ""
}
+ return returnArray
}
- fun updateAppbar (activity: Activity, scrollAble : Boolean) {
+ fun updateAppbar(activity: Activity, scrollAble: Boolean) {
val mAppBarLayout = activity.findViewById(R.id.app_bars)
val mAppBarChildAt: View = mAppBarLayout.getChildAt(0)
val mAppBarParams: AppBarLayout.LayoutParams = mAppBarChildAt.layoutParams as AppBarLayout.LayoutParams
mAppBarParams.scrollFlags = if (scrollAble) AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
- else 0
+ else 0
mAppBarChildAt.layoutParams = mAppBarParams
/* 作者:Silas_
来源:CSDN
@@ -147,4 +170,25 @@ class CoreK(private var context: Context) {
版权声明:本文为博主原创文章,转载请附上博文链接! */
}
+ fun freshMedia(path: String, context: Context) {
+ val file = File(path)
+ val paths : Array
+ if (!file.exists()) {
+ context.toast("文件或目录不存在")
+ return
+ }
+ if (file.isFile) {
+ paths = arrayOf(path)
+ } else {
+ val files = file.listFiles()
+ paths = arrayOfNulls(files.size)
+ for ((i, f) in files.withIndex()) {
+ paths[i] = f.absolutePath
+ }
+ }
+ Log.d("path",paths.toString())
+ MediaScannerConnection.scanFile(context, paths, null) { _, _ -> }
+ context.toast("完成")
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/photoTimeFix/Fragment1.kt b/app/src/main/java/photoTimeFix/Fragment1.kt
index f054991..d332c8c 100644
--- a/app/src/main/java/photoTimeFix/Fragment1.kt
+++ b/app/src/main/java/photoTimeFix/Fragment1.kt
@@ -5,8 +5,6 @@ import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Environment
-import android.support.design.widget.AppBarLayout
-import android.support.design.widget.CollapsingToolbarLayout
import android.support.v4.app.Fragment
import android.util.Log
import android.view.LayoutInflater
@@ -40,7 +38,7 @@ class Fragment1 : Fragment() {
locateText = view.findViewById(R.id.locateText)
locateText.setText(preferences.getString("locate", Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera"))
chooseBtn = view.findViewById