Skip to content

Commit

Permalink
release 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryolitia committed Jan 27, 2019
1 parent 69bf411 commit 1bbf84c
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 90 deletions.
63 changes: 59 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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"
}
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -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":{}}]
[{"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":{}}]
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
90 changes: 67 additions & 23 deletions app/src/main/java/photoTimeFix/CoreK.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import android.content.SharedPreferences
import android.database.Cursor
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.media.MediaScannerConnection
import android.net.Uri
import android.provider.MediaStore
import android.support.customtabs.CustomTabsIntent
import android.support.design.widget.AppBarLayout
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.support.v7.app.AlertDialog
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.webkit.JavascriptInterface
Expand All @@ -24,15 +26,19 @@ import android.widget.Button
import android.widget.ImageView
import android.widget.RadioGroup
import org.jetbrains.anko.longToast
import org.jetbrains.anko.toast
import tech.lincaiqi.PhotoTimeFix.R
import java.io.File
import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern

class CoreK(private var context: Context) {

fun initFragment(preferences: SharedPreferences, editor: SharedPreferences.Editor, chooseBtn:Button, radioGroup: RadioGroup, fragment: Fragment) {
fun initFragment(preferences: SharedPreferences, editor: SharedPreferences.Editor, chooseBtn: Button, radioGroup: RadioGroup, fragment: Fragment) {
radioGroup.check(preferences.getInt("mode", R.id.radioButton))
chooseBtn.setOnClickListener {
context.longToast("由于系统限制(其实是我懒),请选择文件夹内任意一张图片")
chooseFile(fragment)
}
radioGroup.setOnCheckedChangeListener { _, i ->
Expand All @@ -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该错误并不影响正常功能运行,且开发者仅在模拟器上遇到过,如果出现此对话框请与开发者联系。")
Expand Down Expand Up @@ -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
Expand All @@ -110,41 +116,79 @@ 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<String?> {
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<String>(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<AppBarLayout>(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
原文:https://blog.csdn.net/qq_31852701/article/details/80859644
版权声明:本文为博主原创文章,转载请附上博文链接! */
}

fun freshMedia(path: String, context: Context) {
val file = File(path)
val paths : Array<String?>
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("完成")
}

}
15 changes: 8 additions & 7 deletions app/src/main/java/photoTimeFix/Fragment1.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,22 +38,25 @@ class Fragment1 : Fragment() {
locateText = view.findViewById<EditText>(R.id.locateText)
locateText.setText(preferences.getString("locate", Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera"))
chooseBtn = view.findViewById<Button>(R.id.chooseButton)
radioGroup = view.findViewById<RadioGroup>(R.id.radioGroup)
radioGroup = view.findViewById(R.id.radioGroup)
coreK.initFragment(preferences, editor, chooseBtn, radioGroup, this)
val startBtn = view.findViewById<Button>(R.id.startButton)
startBtn.setOnClickListener {
val startNum: Int = Integer.valueOf(view.findViewById<EditText>(R.id.start).text.toString())
val endNum: Int = Integer.valueOf(view.findViewById<EditText>(R.id.end).text.toString())
val fileString: String = view.findViewById<EditText>(R.id.locateText).text.toString()
val editFormat = view.findViewById<EditText>(R.id.editFormat)
val format: String = if (editFormat.text.toString().equals("")) "yyyyMMddHHmm" else editFormat.text.toString()
val format: String = if (editFormat.text.toString() == "") "yyyyMMddHHmm" else editFormat.text.toString()
val radio: Boolean = radioGroup.checkedRadioButtonId == R.id.radioButton
Log.d("radio", radioGroup.checkedRadioButtonId.toString())
Log.d("radio", R.id.radioButton.toString())
context!!.longToast("由于系统限制(其实是我懒),请选择文件夹内任意一张图片")
core.process(context, startNum, endNum, fileString, radio, activity, format)
core.process(context, startNum, endNum, fileString, radio, activity, format, "")
}
val freshButton = view.findViewById<Button>(R.id.freshButton)
freshButton.setOnClickListener {
val fileString: String = view.findViewById<EditText>(R.id.locateText).text.toString()
coreK.freshMedia(fileString,context!!)
}

return view
}

Expand Down
Loading

0 comments on commit 1bbf84c

Please sign in to comment.