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