Skip to content

Commit 1bbf84c

Browse files
committed
release 3.0
1 parent 69bf411 commit 1bbf84c

File tree

11 files changed

+193
-90
lines changed

11 files changed

+193
-90
lines changed

app/build.gradle

+59-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
4+
apply plugin: 'AndResGuard'
45

56
android {
7+
signingConfigs {
8+
config {
9+
keyAlias 'Neuron'
10+
keyPassword KEYSTORE_PASSWORD
11+
storeFile file('../nexus6pcn.jks')
12+
storePassword KEY_PASSWORD
13+
}
14+
}
615
compileSdkVersion 28
716
defaultConfig {
817
applicationId "tech.lincaiqi.PhotoTimeFix"
918
minSdkVersion 19
1019
//noinspection ExpiredTargetSdkVersion
1120
targetSdkVersion 21
12-
versionCode 8
21+
versionCode 9
1322
versionName '3.0'
23+
resConfigs "zh", "zh-rCN"
1424
}
1525
buildTypes {
1626
release {
1727
minifyEnabled true
18-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
1929
shrinkResources true
30+
signingConfig signingConfigs.config
2031
}
2132
}
2233
buildToolsVersion '28.0.3'
@@ -30,8 +41,52 @@ android {
3041

3142
dependencies {
3243
implementation fileTree(include: ['*.jar'], dir: 'libs')
33-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11"
34-
implementation "org.jetbrains.anko:anko-common:0.10.8"
44+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11'
45+
implementation 'org.jetbrains.anko:anko-common:0.10.8'
3546
implementation 'com.android.support:customtabs:28.0.0'
3647
implementation 'com.android.support:design:28.0.0'
3748
}
49+
50+
andResGuard {
51+
// mappingFile = file("./resource_mapping.txt")
52+
mappingFile = null
53+
use7zip = true
54+
useSign = true
55+
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
56+
keepRoot = false
57+
whiteList = [
58+
// for your icon
59+
"R.drawable.icon",
60+
// for fabric
61+
"R.string.com.crashlytics.*",
62+
// for google-services
63+
"R.string.google_app_id",
64+
"R.string.gcm_defaultSenderId",
65+
"R.string.default_web_client_id",
66+
"R.string.ga_trackingId",
67+
"R.string.firebase_database_url",
68+
"R.string.google_api_key",
69+
"R.string.google_crash_reporting_api_key"
70+
]
71+
compressFilePattern = [
72+
"*.png",
73+
"*.jpg",
74+
"*.jpeg",
75+
"*.gif",
76+
]
77+
sevenzip {
78+
artifact = 'com.tencent.mm:SevenZip:1.2.15'
79+
//path = "/usr/local/bin/7za"
80+
}
81+
82+
/**
83+
* 可选: 如果不设置则会默认覆盖assemble输出的apk
84+
**/
85+
// finalApkBackupPath = "${project.rootDir}/final.apk"
86+
87+
/**
88+
* 可选: 指定v1签名时生成jar文件的摘要算法
89+
* 默认值为“SHA-1”
90+
**/
91+
// digestalg = "SHA-256"
92+
}

app/release/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +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":{}}]
1+
[{"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":{}}]

app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
77

88
<application
9-
android:allowBackup="true"
9+
android:allowBackup="false"
1010
android:icon="@drawable/icon"
1111
android:label="@string/app_name"
1212
android:supportsRtl="true"

app/src/main/java/photoTimeFix/CoreK.kt

+67-23
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import android.content.SharedPreferences
88
import android.database.Cursor
99
import android.graphics.Bitmap
1010
import android.graphics.BitmapFactory
11+
import android.media.MediaScannerConnection
1112
import android.net.Uri
1213
import android.provider.MediaStore
1314
import android.support.customtabs.CustomTabsIntent
1415
import android.support.design.widget.AppBarLayout
1516
import android.support.v4.app.Fragment
1617
import android.support.v4.content.ContextCompat
1718
import android.support.v7.app.AlertDialog
19+
import android.util.Log
1820
import android.view.LayoutInflater
1921
import android.view.View
2022
import android.webkit.JavascriptInterface
@@ -24,15 +26,19 @@ import android.widget.Button
2426
import android.widget.ImageView
2527
import android.widget.RadioGroup
2628
import org.jetbrains.anko.longToast
29+
import org.jetbrains.anko.toast
2730
import tech.lincaiqi.PhotoTimeFix.R
2831
import java.io.File
32+
import java.text.SimpleDateFormat
2933
import java.util.*
34+
import java.util.regex.Pattern
3035

3136
class CoreK(private var context: Context) {
3237

33-
fun initFragment(preferences: SharedPreferences, editor: SharedPreferences.Editor, chooseBtn:Button, radioGroup: RadioGroup, fragment: Fragment) {
38+
fun initFragment(preferences: SharedPreferences, editor: SharedPreferences.Editor, chooseBtn: Button, radioGroup: RadioGroup, fragment: Fragment) {
3439
radioGroup.check(preferences.getInt("mode", R.id.radioButton))
3540
chooseBtn.setOnClickListener {
41+
context.longToast("由于系统限制(其实是我懒),请选择文件夹内任意一张图片")
3642
chooseFile(fragment)
3743
}
3844
radioGroup.setOnCheckedChangeListener { _, i ->
@@ -46,11 +52,11 @@ class CoreK(private var context: Context) {
4652
val builder = AlertDialog.Builder(context)
4753
try {
4854
val view = LayoutInflater.from(context).inflate(R.layout.about, null)
49-
val webview: WebView = view.findViewById(R.id.webview)
50-
webview.webViewClient = WebViewClient()
51-
webview.loadUrl("file:///android_asset/about.html")
52-
webview.settings.javaScriptEnabled = true
53-
webview.addJavascriptInterface(this, "openGit")
55+
val webView: WebView = view.findViewById(R.id.webview)
56+
webView.webViewClient = WebViewClient()
57+
webView.loadUrl("file:///android_asset/about.html")
58+
webView.settings.javaScriptEnabled = true
59+
webView.addJavascriptInterface(this, "openGit")
5460
builder.setView(view)
5561
} catch (e: Exception) {
5662
builder.setMessage("加载Webview错误,已停止显示帮助窗口。\n该错误并不影响正常功能运行,且开发者仅在模拟器上遇到过,如果出现此对话框请与开发者联系。")
@@ -88,13 +94,13 @@ class CoreK(private var context: Context) {
8894

8995
}
9096

91-
private fun chooseFile(fragment : Fragment) {
97+
private fun chooseFile(fragment: Fragment) {
9298
val intent = Intent(Intent.ACTION_PICK, null)
9399
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*")
94-
fragment.startActivityForResult(intent,0)
100+
fragment.startActivityForResult(intent, 0)
95101
}
96102

97-
fun resultSolve(requestCode: Int, data: Intent?) : String {
103+
fun resultSolve(requestCode: Int, data: Intent?): String {
98104
try {
99105
return if (requestCode == 0) {
100106
val originalUri = data!!.data
@@ -110,41 +116,79 @@ class CoreK(private var context: Context) {
110116
cursor.close()
111117
path
112118
} else "error"
113-
}else "error"
119+
} else "error"
114120

115-
} catch (e : java.lang.Exception) {
121+
} catch (e: java.lang.Exception) {
116122
e.printStackTrace()
117123
return "error"
118124
}
119125
}
120126

121-
fun updateDate (path : String , activity: Activity) : String {
127+
fun updateDate(path: String, activity: Activity): Array<String?> {
122128
val file = File(path)
123-
val imageView : ImageView = activity.findViewById(R.id.user_bg)
124-
return if (file.exists()&&file.isFile) {
125-
val bm : Bitmap = BitmapFactory.decodeFile(path)
129+
val imageView: ImageView = activity.findViewById(R.id.user_bg)
130+
val returnArray = arrayOfNulls<String>(2)
131+
if (file.exists() && file.isFile) {
132+
val bm: Bitmap = BitmapFactory.decodeFile(path)
126133
imageView.setImageBitmap(bm)
127-
updateAppbar(activity,false)
128-
Date(file.lastModified()).toString()
129-
}
130-
else {
134+
updateAppbar(activity, false)
135+
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
136+
returnArray[0]=sdf.format(Date(file.lastModified()))
137+
var time = file.name
138+
time = Pattern.compile("[^0-9]").matcher(time).replaceAll("").trim { it <= ' ' }
139+
Log.d("date",time)
140+
if (time.contains("20") && time.substring(time.indexOf("20")).length >= 12) {
141+
val targetTime = time.substring(time.indexOf("20"), time.indexOf("20") + 12)
142+
try {
143+
returnArray[1] = sdf.format(SimpleDateFormat("yyyyMMddHHmm", Locale.getDefault()).parse(targetTime))
144+
} catch (e : Exception) {
145+
returnArray[1] = ""
146+
e.printStackTrace()
147+
}
148+
} else {
149+
returnArray[1] = ""
150+
}
151+
} else {
131152
imageView.setImageBitmap(null)
132-
updateAppbar(activity,true)
133-
""
153+
updateAppbar(activity, true)
154+
returnArray[0] = ""
155+
returnArray[1] = ""
134156
}
157+
return returnArray
135158
}
136159

137-
fun updateAppbar (activity: Activity, scrollAble : Boolean) {
160+
fun updateAppbar(activity: Activity, scrollAble: Boolean) {
138161
val mAppBarLayout = activity.findViewById<AppBarLayout>(R.id.app_bars)
139162
val mAppBarChildAt: View = mAppBarLayout.getChildAt(0)
140163
val mAppBarParams: AppBarLayout.LayoutParams = mAppBarChildAt.layoutParams as AppBarLayout.LayoutParams
141164
mAppBarParams.scrollFlags = if (scrollAble) AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
142-
else 0
165+
else 0
143166
mAppBarChildAt.layoutParams = mAppBarParams
144167
/* 作者:Silas_
145168
来源:CSDN
146169
原文:https://blog.csdn.net/qq_31852701/article/details/80859644
147170
版权声明:本文为博主原创文章,转载请附上博文链接! */
148171
}
149172

173+
fun freshMedia(path: String, context: Context) {
174+
val file = File(path)
175+
val paths : Array<String?>
176+
if (!file.exists()) {
177+
context.toast("文件或目录不存在")
178+
return
179+
}
180+
if (file.isFile) {
181+
paths = arrayOf(path)
182+
} else {
183+
val files = file.listFiles()
184+
paths = arrayOfNulls(files.size)
185+
for ((i, f) in files.withIndex()) {
186+
paths[i] = f.absolutePath
187+
}
188+
}
189+
Log.d("path",paths.toString())
190+
MediaScannerConnection.scanFile(context, paths, null) { _, _ -> }
191+
context.toast("完成")
192+
}
193+
150194
}

app/src/main/java/photoTimeFix/Fragment1.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import android.content.Intent
55
import android.content.SharedPreferences
66
import android.os.Bundle
77
import android.os.Environment
8-
import android.support.design.widget.AppBarLayout
9-
import android.support.design.widget.CollapsingToolbarLayout
108
import android.support.v4.app.Fragment
119
import android.util.Log
1210
import android.view.LayoutInflater
@@ -40,22 +38,25 @@ class Fragment1 : Fragment() {
4038
locateText = view.findViewById<EditText>(R.id.locateText)
4139
locateText.setText(preferences.getString("locate", Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera"))
4240
chooseBtn = view.findViewById<Button>(R.id.chooseButton)
43-
radioGroup = view.findViewById<RadioGroup>(R.id.radioGroup)
41+
radioGroup = view.findViewById(R.id.radioGroup)
4442
coreK.initFragment(preferences, editor, chooseBtn, radioGroup, this)
4543
val startBtn = view.findViewById<Button>(R.id.startButton)
4644
startBtn.setOnClickListener {
4745
val startNum: Int = Integer.valueOf(view.findViewById<EditText>(R.id.start).text.toString())
4846
val endNum: Int = Integer.valueOf(view.findViewById<EditText>(R.id.end).text.toString())
4947
val fileString: String = view.findViewById<EditText>(R.id.locateText).text.toString()
5048
val editFormat = view.findViewById<EditText>(R.id.editFormat)
51-
val format: String = if (editFormat.text.toString().equals("")) "yyyyMMddHHmm" else editFormat.text.toString()
49+
val format: String = if (editFormat.text.toString() == "") "yyyyMMddHHmm" else editFormat.text.toString()
5250
val radio: Boolean = radioGroup.checkedRadioButtonId == R.id.radioButton
5351
Log.d("radio", radioGroup.checkedRadioButtonId.toString())
5452
Log.d("radio", R.id.radioButton.toString())
55-
context!!.longToast("由于系统限制(其实是我懒),请选择文件夹内任意一张图片")
56-
core.process(context, startNum, endNum, fileString, radio, activity, format)
53+
core.process(context, startNum, endNum, fileString, radio, activity, format, "")
54+
}
55+
val freshButton = view.findViewById<Button>(R.id.freshButton)
56+
freshButton.setOnClickListener {
57+
val fileString: String = view.findViewById<EditText>(R.id.locateText).text.toString()
58+
coreK.freshMedia(fileString,context!!)
5759
}
58-
5960
return view
6061
}
6162

0 commit comments

Comments
 (0)