Commit 1736226e by pye52

Merge branch 'develop' into test

parents a31bb7f8 e5889123
...@@ -58,6 +58,10 @@ android { ...@@ -58,6 +58,10 @@ android {
} }
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} }
dependencies { dependencies {
...@@ -68,13 +72,13 @@ dependencies { ...@@ -68,13 +72,13 @@ dependencies {
implementation "org.java-websocket:Java-WebSocket:1.4.0" implementation "org.java-websocket:Java-WebSocket:1.4.0"
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.github.salomonbrys.kotson:kotson:2.5.0' implementation 'com.github.salomonbrys.kotson:kotson:2.5.0'
implementation 'com.blankj:utilcode:1.25.9' implementation 'com.blankj:utilcode:1.26.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.1' implementation 'com.squareup.okhttp3:okhttp:3.12.10'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.12.10'
implementation 'com.squareup.retrofit2:retrofit:2.6.2' implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0' implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.6.0' implementation 'com.squareup.retrofit2:converter-scalars:2.7.1'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.13'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
} }
package com.bgycc.smartcanteen package com.bgycc.smartcanteen
import android.Manifest
import android.app.ActivityManager import android.app.ActivityManager
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
...@@ -10,18 +9,20 @@ import com.bgycc.smartcanteen.helper.TTSHelper ...@@ -10,18 +9,20 @@ import com.bgycc.smartcanteen.helper.TTSHelper
import com.bgycc.smartcanteen.helper.TimerHelper import com.bgycc.smartcanteen.helper.TimerHelper
import com.bgycc.smartcanteen.helper.WifiHelpler import com.bgycc.smartcanteen.helper.WifiHelpler
import com.bgycc.smartcanteen.manager.NetworkManager import com.bgycc.smartcanteen.manager.NetworkManager
import com.bgycc.smartcanteen.util.LogUtil
import com.bgycc.smartcanteen.module.Device import com.bgycc.smartcanteen.module.Device
import com.bgycc.smartcanteen.util.LogUtil
import com.blankj.utilcode.constant.PermissionConstants import com.blankj.utilcode.constant.PermissionConstants
import com.blankj.utilcode.util.CrashUtils
import com.blankj.utilcode.util.LogUtils import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.PermissionUtils import com.blankj.utilcode.util.PermissionUtils
import java.lang.Exception import java.io.File
import kotlin.system.exitProcess import kotlin.system.exitProcess
class App : Application() { class App : Application() {
companion object { companion object {
private lateinit var sDefault: App private lateinit var sDefault: App
private const val LOG_DIR = "log"
private val sInstances = HashMap<String, App>() private val sInstances = HashMap<String, App>()
private var sVersionName = "0.0.0" private var sVersionName = "0.0.0"
private var sVersionCode = 0 private var sVersionCode = 0
...@@ -96,7 +97,12 @@ class App : Application() { ...@@ -96,7 +97,12 @@ class App : Application() {
private fun initLog() { private fun initLog() {
LogUtil.setEnable(BuildConfig.DEBUG) LogUtil.setEnable(BuildConfig.DEBUG)
val config = LogUtils.getConfig() val logDir: String = applicationContext.filesDir.absolutePath + File.separator + LOG_DIR
config.saveDays = 7 CrashUtils.init(logDir)
LogUtils.getConfig()
.setDir(logDir)
.setLog2FileSwitch(true)
.setBorderSwitch(false)
.saveDays = 7
} }
} }
\ No newline at end of file
...@@ -46,7 +46,7 @@ object LogAction : Action(ActionEnum.LOG_PULL.name) { ...@@ -46,7 +46,7 @@ object LogAction : Action(ActionEnum.LOG_PULL.name) {
val logZipFile = File(PathUtils.getExternalAppCachePath(), "upload/log.zip") val logZipFile = File(PathUtils.getExternalAppCachePath(), "upload/log.zip")
val logUploadDir = File(PathUtils.getExternalAppCachePath(), "upload/log") val logUploadDir = File(PathUtils.getExternalAppCachePath(), "upload/log")
FileUtils.delete(logZipFile) FileUtils.delete(logZipFile)
FileUtils.deleteDir(logUploadDir) FileUtils.delete(logUploadDir)
logUploadDir.mkdirs() logUploadDir.mkdirs()
val logDir = when (type) { val logDir = when (type) {
...@@ -56,11 +56,11 @@ object LogAction : Action(ActionEnum.LOG_PULL.name) { ...@@ -56,11 +56,11 @@ object LogAction : Action(ActionEnum.LOG_PULL.name) {
FileUtils.listFilesInDir(logDir)?.forEach { FileUtils.listFilesInDir(logDir)?.forEach {
val date = Date(it.lastModified()) val date = Date(it.lastModified())
if (date >= startTime && date <= endTime) { if (date >= startTime && date <= endTime) {
FileUtils.copyFile(it, File(logUploadDir, it.name)) FileUtils.copy(it, File(logUploadDir, it.name))
} }
} }
ZipUtils.zipFile(logUploadDir, logZipFile) ZipUtils.zipFile(logUploadDir, logZipFile)
FileUtils.deleteDir(logUploadDir) FileUtils.delete(logUploadDir)
MainHttpClient.uploadLog(logZipFile, "$type${formatSrc.format(startTime)}${formatSrc.format(endTime)}${App.getDeviceSN()}.zip") MainHttpClient.uploadLog(logZipFile, "$type${formatSrc.format(startTime)}${formatSrc.format(endTime)}${App.getDeviceSN()}.zip")
} catch (e: Exception) {} } catch (e: Exception) {}
state = State.INITED state = State.INITED
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
buildscript { buildscript {
ext.kotlin_version = '1.3.61' ext.kotlin_version = '1.3.61'
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/google' } jcenter()
maven { url 'https://maven.aliyun.com/repository/jcenter' } google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
...@@ -17,8 +17,8 @@ buildscript { ...@@ -17,8 +17,8 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
maven { url 'https://maven.aliyun.com/repository/google' } jcenter()
maven { url 'https://maven.aliyun.com/repository/jcenter' } google()
} }
} }
......
...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment