diff --git a/LibKeyValue/build.gradle b/LibKeyValue/build.gradle index 6e55fca23bed2a7e8c2422c8235fc495b3726a81..0247a4fb7aaeef4747083aa927cf4d5d2c4bc108 100644 --- a/LibKeyValue/build.gradle +++ b/LibKeyValue/build.gradle @@ -5,6 +5,7 @@ plugins { } android { + namespace 'com.mx.keyvalue' compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -18,11 +19,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = JavaVersion.VERSION_17.toString() } } afterEvaluate { @@ -40,5 +41,5 @@ afterEvaluate { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + } \ No newline at end of file diff --git a/LibKeyValue/src/main/java/com/mx/keyvalue/utils/KVUtils.kt b/LibKeyValue/src/main/java/com/mx/keyvalue/utils/KVUtils.kt index 5c54106fc588cda9a78c7121bfcd78c530a0a82c..fb96a8ef84d1939295685ec747063c5148dc9730 100644 --- a/LibKeyValue/src/main/java/com/mx/keyvalue/utils/KVUtils.kt +++ b/LibKeyValue/src/main/java/com/mx/keyvalue/utils/KVUtils.kt @@ -1,12 +1,11 @@ package com.mx.keyvalue.utils -import com.mx.keyvalue.BuildConfig import com.mx.keyvalue.crypt.IKVCrypt import java.security.MessageDigest import java.util.* internal object KVUtils { - private var debug = BuildConfig.DEBUG + private var debug = false fun setDebug(debug: Boolean) { this.debug = debug } diff --git a/README.md b/README.md index 82834e5faaa523e546d44481658d6aef89f6b9e8..fbbe9608a98a524deca2b8245eb69d8eb59b3e8c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![](https://jitpack.io/v/com.gitee.zhangmengxiong/MXKeyValue.svg)](https://jitpack.io/#com.gitee.zhangmengxiong/MXKeyValue) 库引用: 替换1.1.3 为最新版本 ```gradle - implementation 'com.gitee.zhangmengxiong:MXKeyValue:1.1.3' + implementation 'com.gitee.zhangmengxiong:MXKeyValue:1.2.0' ``` ## 使用方法 diff --git a/app/build.gradle b/app/build.gradle index a3a2bef8357aee61d53e2bb445a0745dca49035b..87be8de235661bc0fcad3b42918d90a0b57b5a95 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,10 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -androidExtensions { - experimental = true +plugins { + id 'com.android.application' + id 'kotlin-android' } android { + namespace "com.mx.example" compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "com.mx.example" @@ -17,6 +16,9 @@ android { multiDexEnabled true } + viewBinding { + enabled = true + } buildTypes { release { minifyEnabled false @@ -24,23 +26,22 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '11' + jvmTarget = JavaVersion.VERSION_17.toString() } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.9.0' // Jackson - implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.5' - implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.5' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3' + implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.13.3' implementation project(':LibKeyValue') } \ No newline at end of file diff --git a/app/src/main/java/com/mx/example/app/DelegateTestActivity.kt b/app/src/main/java/com/mx/example/app/DelegateTestActivity.kt index 07cfdf0b082980a51f22765b454af43cbf4068f2..f2269e0c14fc752b351851697d3560f1fa7ad721 100644 --- a/app/src/main/java/com/mx/example/app/DelegateTestActivity.kt +++ b/app/src/main/java/com/mx/example/app/DelegateTestActivity.kt @@ -5,19 +5,25 @@ import androidx.appcompat.app.AppCompatActivity import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.registerKotlinModule -import com.mx.example.R +import com.mx.example.databinding.ActivityDelegateTestBinding import com.mx.example.utils.SPUtils import com.mx.keyvalue.MXKeyValue -import com.mx.keyvalue.delegate.* -import kotlinx.android.synthetic.main.activity_delegate_test.* +import com.mx.keyvalue.delegate.KVBaseDelegate +import com.mx.keyvalue.delegate.KVBoolDelegate +import com.mx.keyvalue.delegate.KVDoubleDelegate +import com.mx.keyvalue.delegate.KVFloatDelegate +import com.mx.keyvalue.delegate.KVIntDelegate +import com.mx.keyvalue.delegate.KVLongDelegate +import com.mx.keyvalue.delegate.KVStringDelegate class DelegateTestActivity : AppCompatActivity() { + private val binding by lazy { ActivityDelegateTestBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_delegate_test) + setContentView(binding.root) - testBtn.setOnClickListener { + binding.testBtn.setOnClickListener { var boolDelegate by KVBoolDelegate(SPUtils.KV, "bool_test", true) println("测试 MXBoolDelegate -> $boolDelegate") boolDelegate = false diff --git a/app/src/main/java/com/mx/example/app/ExpireTestActivity.kt b/app/src/main/java/com/mx/example/app/ExpireTestActivity.kt index 503c47e72a6015babf4af75a44e0b8c5d06f70e2..0ebf50dce94a00003c52ebc4e3a4053f8e40ef98 100644 --- a/app/src/main/java/com/mx/example/app/ExpireTestActivity.kt +++ b/app/src/main/java/com/mx/example/app/ExpireTestActivity.kt @@ -3,18 +3,18 @@ package com.mx.example.app import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity -import com.mx.example.R +import com.mx.example.databinding.ActivityExpireTestBinding import com.mx.example.utils.SPUtils -import kotlinx.android.synthetic.main.activity_expire_test.* import java.util.concurrent.TimeUnit class ExpireTestActivity : AppCompatActivity() { + private val binding by lazy { ActivityExpireTestBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_expire_test) + setContentView(binding.root) - setExpireTxv.setOnClickListener { + binding.setExpireTxv.setOnClickListener { SPUtils.set( "test_expire_key", "1分钟失效:" + System.currentTimeMillis(), @@ -22,10 +22,10 @@ class ExpireTestActivity : AppCompatActivity() { ) Toast.makeText(this, SPUtils.get("test_expire_key", "失效"), Toast.LENGTH_SHORT).show() } - readExpireTxv.setOnClickListener { + binding.readExpireTxv.setOnClickListener { Toast.makeText(this, SPUtils.get("test_expire_key", "失效"), Toast.LENGTH_SHORT).show() } - deleteTxv.setOnClickListener { + binding.deleteTxv.setOnClickListener { SPUtils.delete("test_expire_key") Toast.makeText(this, SPUtils.get("test_expire_key", "失效"), Toast.LENGTH_SHORT).show() } diff --git a/app/src/main/java/com/mx/example/app/MainActivity.kt b/app/src/main/java/com/mx/example/app/MainActivity.kt index 4ae376e2796af18dc5aeebbef54b655243180169..a5d87115a7e524c963055c5747dd1ff6f2bc6b1c 100644 --- a/app/src/main/java/com/mx/example/app/MainActivity.kt +++ b/app/src/main/java/com/mx/example/app/MainActivity.kt @@ -3,21 +3,21 @@ package com.mx.example.app import android.content.Intent import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import com.mx.example.R -import kotlinx.android.synthetic.main.activity_main.* +import com.mx.example.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { + private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - expireTestTxv.setOnClickListener { + setContentView(binding.root) + binding.expireTestTxv.setOnClickListener { startActivity(Intent(this, ExpireTestActivity::class.java)) } - threadTestTxv.setOnClickListener { + binding.threadTestTxv.setOnClickListener { startActivity(Intent(this, MultThreadTestActivity::class.java)) } - delegateTestTxv.setOnClickListener { + binding.delegateTestTxv.setOnClickListener { startActivity(Intent(this, DelegateTestActivity::class.java)) } } diff --git a/app/src/main/java/com/mx/example/app/MultThreadTestActivity.kt b/app/src/main/java/com/mx/example/app/MultThreadTestActivity.kt index 96d1d97454c79bf1129c663f9786b4458eaf2d59..eb4da5556370a919b7aa03892378f28ad05c2217 100644 --- a/app/src/main/java/com/mx/example/app/MultThreadTestActivity.kt +++ b/app/src/main/java/com/mx/example/app/MultThreadTestActivity.kt @@ -2,17 +2,17 @@ package com.mx.example.app import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import com.mx.example.R +import com.mx.example.databinding.ActivityMultThreadTestBinding import com.mx.example.utils.SPUtils -import kotlinx.android.synthetic.main.activity_mult_thread_test.* import kotlin.concurrent.thread import kotlin.random.Random class MultThreadTestActivity : AppCompatActivity() { + private val binding by lazy { ActivityMultThreadTestBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_mult_thread_test) - syncTestTxv.setOnClickListener { + setContentView(binding.root) + binding.syncTestTxv.setOnClickListener { repeat(5) { index -> thread { repeat(100000) { count -> diff --git a/build.gradle b/build.gradle index cafb2c2a6b9131969f86623da42184b222446235..5f9726929947b8f4a5eafbe35c3e809f5d4752e9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,38 +1,20 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext.kotlin_version = "1.7.0" - repositories { - maven { url 'https://maven.aliyun.com/repository/google' } - maven { url 'https://maven.aliyun.com/repository/public' } - maven { url 'https://jitpack.io' } - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } +plugins { + id 'com.android.application' version '8.2.2' apply false + id 'com.android.library' version '8.2.2' apply false + id 'org.jetbrains.kotlin.android' version '1.8.10' apply false } -allprojects { - repositories { - maven { url 'https://maven.aliyun.com/repository/google' } - maven { url 'https://maven.aliyun.com/repository/public' } - maven { url 'https://jitpack.io' } - google() +task clean(type: Delete) { + for (project in allprojects) { + delete project.buildDir } } ext { - compileSdkVersion = 31 - buildToolsVersion = "28.0.3" - - targetSdkVersion = 31 - minSdkVersion = 19 + compileSdkVersion = 33 + targetSdkVersion = 33 + minSdkVersion = 21 versionCode = 1 - versionName = "1.0.7" + versionName = "1.2.0" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db178d5c1e5a73b1cc1b4a677cd7b4c0ab4c9c3e..1a0651d87fba2c0de4059dcd8cf583b25d3cbc76 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jun 25 11:44:57 CST 2022 +#Thu Apr 13 13:24:46 CST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index a614188354df8a26cfc3a8608d5c34da0e3bde76..6255acdadadcf38d95dbf9d6b5115cb92b94bddf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,26 @@ +pluginManagement { + repositories { + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://jitpack.io' } + maven { url "https://mvn.mob.com/android" } + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + repositories { + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/public' } + maven { url 'https://jitpack.io' } + maven { url "https://mvn.mob.com/android" } + google() + mavenCentral() + } +} + rootProject.name = "MXKeyValue" include ':app' include ':LibKeyValue'