mirror of
https://github.com/fumiama/simple-dict-android.git
synced 2026-06-16 16:49:10 +08:00
v3.1.1
1. 自动去重,去错 2. 优化删除步骤 3. 翻页位置指示 4. 向前翻页
This commit is contained in:
@@ -5,15 +5,15 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 31
|
||||||
buildToolsVersion "30.0.2"
|
buildToolsVersion "30.0.2"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "top.fumiama.simpledict"
|
applicationId "top.fumiama.simpledict"
|
||||||
minSdkVersion 26
|
minSdkVersion 26
|
||||||
targetSdkVersion 30
|
targetSdkVersion 31
|
||||||
versionCode 17
|
versionCode 18
|
||||||
versionName '3.0'
|
versionName '3.1.1'
|
||||||
resConfigs "zh", "zh-rCN"
|
resConfigs "zh", "zh-rCN"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
@@ -43,15 +43,15 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.5.0'
|
implementation 'androidx.core:core-ktx:1.7.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
implementation 'androidx.appcompat:appcompat:1.4.0'
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
implementation 'com.lapism:search:2.4.1@aar'
|
implementation 'com.lapism:search:2.4.1@aar'
|
||||||
}
|
}
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.SimpleDict.NoActionBar">
|
android:theme="@style/Theme.SimpleDict.NoActionBar"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
.setNeutralButton("删除") { _, _ ->
|
.setNeutralButton("删除") { _, _ ->
|
||||||
Thread{
|
Thread{
|
||||||
if(dict?.send_del(key) == true) line?.apply {
|
if(dict?.del(key) == true) line?.apply {
|
||||||
val delKey = SpannableString(key)
|
val delKey = SpannableString(key)
|
||||||
val delData = SpannableString(data)
|
val delData = SpannableString(data)
|
||||||
delKey.setSpan(StrikethroughSpan(), 0, key.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
delKey.setSpan(StrikethroughSpan(), 0, key.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
@@ -270,6 +270,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
ta.text = delKey
|
ta.text = delKey
|
||||||
tn.text = delKey
|
tn.text = delKey
|
||||||
tb.text = delData
|
tb.text = delData
|
||||||
|
start--
|
||||||
|
end--
|
||||||
updateSize()
|
updateSize()
|
||||||
}
|
}
|
||||||
else runOnUiThread {
|
else runOnUiThread {
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ class SimpleDict(private val client: Client, private val pwd: String, private va
|
|||||||
dict[k] = data.decodeToString()
|
dict[k] = data.decodeToString()
|
||||||
latestKeys += k
|
latestKeys += k
|
||||||
} else {
|
} else {
|
||||||
send_del(key) // 去错
|
sendel(key) // 去错
|
||||||
}
|
}
|
||||||
} else if(!dict.containsKey(k)){
|
} else if(!dict.containsKey(k)){
|
||||||
dict[k] = data.decodeToString()
|
dict[k] = data.decodeToString()
|
||||||
latestKeys += k
|
latestKeys += k
|
||||||
} else {
|
} else {
|
||||||
send_del(key) // 去重
|
sendel(key) // 去重
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,10 +96,10 @@ class SimpleDict(private val client: Client, private val pwd: String, private va
|
|||||||
fun filterValues(predicate: (String?) -> Boolean) = dict.filterValues(predicate)
|
fun filterValues(predicate: (String?) -> Boolean) = dict.filterValues(predicate)
|
||||||
|
|
||||||
fun fetchDict(doOnLoadFailure: ()->Unit, doOnLoadSuccess: ()->Unit, doCommon: (() -> Unit)? = null) {
|
fun fetchDict(doOnLoadFailure: ()->Unit, doOnLoadSuccess: ()->Unit, doCommon: (() -> Unit)? = null) {
|
||||||
dict = hashMapOf()
|
|
||||||
latestKeys = arrayOf()
|
|
||||||
val noChange = md5File.exists() && dspFile.exists() && !hasNewItem(md5File.readBytes())
|
val noChange = md5File.exists() && dspFile.exists() && !hasNewItem(md5File.readBytes())
|
||||||
val data = if(noChange) dspFile.readBytes() else raw
|
val data = if(noChange) dspFile.readBytes() else raw
|
||||||
|
dict.clear()
|
||||||
|
latestKeys = arrayOf()
|
||||||
if(data == null) doOnLoadFailure()
|
if(data == null) doOnLoadFailure()
|
||||||
else {
|
else {
|
||||||
analyzeDict(data, !noChange)
|
analyzeDict(data, !noChange)
|
||||||
@@ -108,7 +108,7 @@ class SimpleDict(private val client: Client, private val pwd: String, private va
|
|||||||
doCommon?.let { it() }
|
doCommon?.let { it() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun send_del(key: String): Boolean {
|
fun del(key: String): Boolean {
|
||||||
if(spwd == null) return false
|
if(spwd == null) return false
|
||||||
else if(initDict()) {
|
else if(initDict()) {
|
||||||
val delPass = "del$spwd"
|
val delPass = "del$spwd"
|
||||||
@@ -133,7 +133,7 @@ class SimpleDict(private val client: Client, private val pwd: String, private va
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun send_del(key: ByteArray): Boolean {
|
private fun sendel(key: ByteArray): Boolean {
|
||||||
if(spwd == null) return false
|
if(spwd == null) return false
|
||||||
else if(initDict()) {
|
else if(initDict()) {
|
||||||
val delPass = "del$spwd"
|
val delPass = "del$spwd"
|
||||||
@@ -152,7 +152,7 @@ class SimpleDict(private val client: Client, private val pwd: String, private va
|
|||||||
fun set(key: String, value: String): Boolean {
|
fun set(key: String, value: String): Boolean {
|
||||||
//if(spwd == null) return false
|
//if(spwd == null) return false
|
||||||
val contain = dict.containsKey(key)
|
val contain = dict.containsKey(key)
|
||||||
if((contain && send_del(key)) || !contain) {
|
if((contain && sendel(key.toByteArray())) || !contain) {
|
||||||
if(initDict()) {
|
if(initDict()) {
|
||||||
val setPass = "set$spwd"
|
val setPass = "set$spwd"
|
||||||
client.sendMessage(setPass)
|
client.sendMessage(setPass)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.5.20'
|
ext.kotlin_version = '1.5.31'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
classpath 'com.android.tools.build:gradle:4.2.2'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
Reference in New Issue
Block a user