1
0
mirror of https://github.com/fumiama/simple-dict-android.git synced 2026-06-05 00:30:24 +08:00
This commit is contained in:
fumiama
2021-02-18 00:27:11 +08:00
parent 85428c591c
commit c82f715f55
8 changed files with 41 additions and 30 deletions

View File

@@ -13,8 +13,8 @@ android {
applicationId "top.fumiama.simpledict"
minSdkVersion 26
targetSdkVersion 30
versionCode 3
versionName '1.1.1'
versionCode 4
versionName '1.2'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -54,7 +54,6 @@ android {
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
@@ -82,7 +81,6 @@ andResGuard {
// it's always better to remove duplicated resource from repo
mergeDuplicatedRes = true
whiteList = [
"R.drawable.load",
// your icon
"R.drawable.icon",
// for fabric
@@ -94,14 +92,9 @@ andResGuard {
"R.string.ga_trackingId",
"R.string.firebase_database_url",
"R.string.google_api_key",
"R.string.google_crash_reporting_api_key",
"R.font.*"
"R.string.google_crash_reporting_api_key"
]
compressFilePattern = [
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
"resources.arsc"
]
sevenzip {

View File

@@ -57,27 +57,27 @@ class Client(val ip: String, val port: Int) {
}
}
fun receiveRawMessage()= try {
fun receiveRawMessage() : ByteArray {
var re = byteArrayOf()
try {
if (isConnect) {
Log.d("MyC", "开始接收服务端信息")
val inMessage = ByteArray(1024) //设置接受缓冲,避免接受数据过长占用过多内存
val a = din?.read(inMessage) //a存储返回消息的长度
if (a == null || a <= -1) null
else {
Log.d("MyC", "reply length:$a")
inMessage.copyOf(a)
}
} else {
Log.d("MyC", "no connect to receive message")
null
}
val inMessage = ByteArray(4096) //设置接受缓冲,避免接受数据过长占用过多内存
var a: Int
do {
a = din?.read(inMessage)?:0 //a存储返回消息的长度
Log.d("MyC", "reply length:$a: ${inMessage.decodeToString()}")
re += inMessage.copyOf(a)
} while (a == 4096)
} else Log.d("MyC", "no connect to receive message")
} catch (e: IOException) {
Log.d("MyC", "receive message failed")
e.printStackTrace()
null
}
return re
}
fun receiveMessage() = receiveRawMessage()?.decodeToString()
fun receiveMessage() = receiveRawMessage().decodeToString()
/**
* 关闭连接

View File

@@ -6,13 +6,13 @@ import java.lang.Thread.sleep
class SimpleDict(private val client: Client, private val pwd: String) { //must run in thread
private var dict = HashMap<String, String?>()
val keys get() = dict.keys
val values get() = dict.values
//val values get() = dict.values
//val size get() = dict.size
private val raw: ByteArray?
private val raw: ByteArray
get() {
initDict()
client.sendMessage("cat")
sleep(233)
sleep(2333)
val re = client.receiveRawMessage()
closeDict()
return re
@@ -47,7 +47,7 @@ class SimpleDict(private val client: Client, private val pwd: String) { //must
fun fetchDict() {
val dictBlock = ByteArray(128)
raw?.inputStream()?.let {
raw.inputStream().let {
var c = '1'
while (!it.read().toChar().isDigit()) Log.d("MySD", "Skip banner.")
while (c.isDigit()) {

View File

@@ -18,6 +18,7 @@
android:layout_height="match_parent"
app:contentScrim="?attr/colorSurface"
app:layout_scrollFlags="scroll"
app:toolbarId="@+id/toolbar">
<com.lapism.search.widget.MaterialSearchView

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"

View File

@@ -10,7 +10,7 @@
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

Binary file not shown.

View File

@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "top.fumiama.simpledict",
"variantName": "processWinreleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 4,
"versionName": "1.2",
"outputFile": "app-winrelease.apk"
}
]
}