Skip to content

Commit

Permalink
[Release] v1.4.6
Browse files Browse the repository at this point in the history
[Changelog]
- System tray support on desktop platform.
- Sound support on desktop platform.
- Synonyms support.
- UX/UI improvements.
  • Loading branch information
Konyaco committed Oct 21, 2022
2 parents 7cc59c4 + f90ba5c commit 730889e
Show file tree
Hide file tree
Showing 25 changed files with 299 additions and 126 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
/common/build/
/android/build/
/desktop/build/
/local.properties
/desktop/cache/
/gradle/.DS_Store
15 changes: 8 additions & 7 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ plugins {
}

android {
compileSdk = 32
compileSdk = 33
defaultConfig {
applicationId = "me.konyaco.collinsdictionary"
minSdk = 21
targetSdk = 32
versionCode = 8
versionName = "1.4.5"
targetSdk = 33
versionCode = 9
versionName = "1.4.6"
}

buildTypes {
Expand Down Expand Up @@ -43,14 +43,15 @@ android {
kotlinOptions {
jvmTarget = "11"
}
namespace = "me.konyaco.collinsdictionary"
}

dependencies {
implementation(project(":common"))
implementation("org.jsoup:jsoup:${rootProject.extra["jsoup_version"]}")
implementation("androidx.core:core-ktx:1.8.0")
implementation("androidx.activity:activity-compose:1.4.0")
implementation("androidx.appcompat:appcompat:1.4.2")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.activity:activity-compose:1.6.0")
implementation("androidx.appcompat:appcompat:1.5.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.konyaco.collinsdictionary">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<application
Expand Down
20 changes: 20 additions & 0 deletions android/src/main/res/drawable/ic_launcher_monochrome.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#FF000000"
android:pathData="M67.8,46.8l-1.8,-0.3v-1.1c0.4,0 0.8,0 1.3,0c2,0 3.9,0 5.9,0.1c4.4,0.3 6.9,3.1 6.9,7.5c-0.1,4.4 -3,7.3 -7.4,7.4c-2.2,0 -4.4,0 -6.7,0v-1c0.3,-0.1 0.7,-0.1 1.1,-0.1c0.6,0 0.8,-0.2 0.8,-0.8c0,-3.7 0,-7.4 0,-11.1C67.9,47.2 67.9,47 67.8,46.8zM70.9,59.2c3.5,0.4 5.5,-1.2 5.9,-4.6c0.1,-1.2 0.1,-2.3 0,-3.4c-0.4,-3.1 -2.1,-4.6 -5.2,-4.5c-0.6,0 -0.7,0.2 -0.7,0.7c0,3.4 0,6.8 0,10.1C70.9,58.1 70.9,58.6 70.9,59.2z"/>
<path
android:fillColor="#FF000000"
android:pathData="M50.6,53.3c0.1,-2.9 0.8,-5.2 3,-6.8c3,-2.2 7.3,-1.6 9.5,1.4c0.4,0.5 0.7,1 0.9,1.6c1.1,2.8 1,5.6 -0.6,8.2c-1.5,2.4 -4.4,3.6 -7.2,3c-2.8,-0.6 -4.9,-2.8 -5.4,-5.8C50.7,54.3 50.6,53.6 50.6,53.3zM61.5,53c-0.1,-1 -0.2,-2.1 -0.4,-3.1c-0.2,-0.7 -0.5,-1.4 -0.8,-2.1c-1.3,-2 -3.9,-2 -5.2,0c-0.9,1.3 -1.1,2.8 -1.2,4.3c-0.1,1.8 0,3.6 0.8,5.3c0.6,1.2 1.4,2.1 2.9,2.1c1.5,0 2.4,-0.8 3,-2.1C61.3,56.1 61.4,54.6 61.5,53L61.5,53z"/>
<path
android:fillColor="#FF000000"
android:pathData="M49,56.4c0,1 0,1.9 0,2.8c0,0.3 -0.2,0.5 -0.4,0.7c-2.8,1.4 -7.3,1.4 -9.8,-1.1c-2.2,-2.2 -2.8,-6.1 -1.6,-9.2c1.2,-2.8 3.9,-4.6 7.3,-4.4c1.3,0.1 2.5,0.5 3.7,0.8c0.4,0.1 0.7,0.4 0.6,0.8l0,0c0,0.9 0,1.8 0,2.8h-1.5c-0.1,-0.7 -0.3,-1.3 -0.4,-2c0,-0.5 -0.4,-0.9 -0.9,-1c-1.9,-0.6 -4,0.3 -5.1,2c-1,1.6 -1.2,3.3 -1.1,5.1c0.1,1.4 0.3,2.8 1.1,4c1.4,2.2 3.9,2.3 5.7,1.6c0.2,-0.1 0.4,-0.3 0.4,-0.6c0.2,-0.5 0.2,-0.9 0.3,-1.4c0,-0.8 0.4,-1 1.1,-0.9C48.6,56.4 48.8,56.4 49,56.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M26.1,45.2h5.4c0.2,0 0.3,0.1 0.3,0.3v14.8c0,0.2 -0.1,0.3 -0.3,0.3h-5.4c-0.2,0 -0.3,-0.1 -0.3,-0.3V45.5C25.9,45.4 26,45.2 26.1,45.2z"
android:strokeAlpha="0.56"
android:fillAlpha="0.56"/>
</vector>
1 change: 1 addition & 0 deletions android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
22 changes: 11 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("com.android.application") version "7.4.0-alpha03" apply false
id("com.android.library") version "7.4.0-alpha03" apply false
kotlin("android") version "1.6.21" apply false
kotlin("multiplatform") version "1.6.21" apply false
id("org.jetbrains.compose") version "1.2.0-alpha01-dev686" apply false
kotlin("plugin.serialization") version "1.6.21" apply false
id("com.android.application") version "7.3.1" apply false
id("com.android.library") version "7.3.1" apply false
kotlin("android") version "1.7.20" apply false
kotlin("multiplatform") version "1.7.20" apply false
id("org.jetbrains.compose") version "1.2.0" apply false
kotlin("plugin.serialization") version "1.7.20" apply false
}

allprojects {
Expand All @@ -13,11 +13,11 @@ allprojects {
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
extra["jsoup_version"] = "1.15.1"
extra["serialization_version"] = "1.3.3"
extra["coroutines_version"] = "1.6.1"
extra["ktor_version"] = "2.0.1"
extra["jsoup_version"] = "1.15.3"
extra["serialization_version"] = "1.4.1"
extra["coroutines_version"] = "1.6.4"
extra["ktor_version"] = "2.1.2"
}

group = "me.konyaco.collinsdictionary"
version = "1.4.5"
version = "1.4.6"
13 changes: 7 additions & 6 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ kotlin {
}
val androidMain by getting {
dependencies {
api("androidx.appcompat:appcompat:1.4.2")
api("androidx.core:core-ktx:1.8.0")
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.9.0")
api("io.ktor:ktor-client-cio:$ktorVersion")
implementation("org.jsoup:jsoup:$jsoupVersion")
}
Expand All @@ -53,12 +53,12 @@ kotlin {
}
name.contains("mac") -> {
implementation("org.openjfx:javafx-base:$javaFxVersion:mac")
implementation("org.openjfx:javafx-graphics:$javaFxVersion:win")
implementation("org.openjfx:javafx-graphics:$javaFxVersion:mac")
implementation("org.openjfx:javafx-media:$javaFxVersion:mac")
}
name.contains("linux") -> {
implementation("org.openjfx:javafx-base:$javaFxVersion:linux")
implementation("org.openjfx:javafx-graphics:$javaFxVersion:win")
implementation("org.openjfx:javafx-graphics:$javaFxVersion:linux")
implementation("org.openjfx:javafx-media:$javaFxVersion:linux")
}
}
Expand All @@ -78,11 +78,12 @@ tasks.withType<Test> {
}

android {
compileSdk = 32
compileSdk = 33
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 32
targetSdk = 33
}
namespace = "me.konyaco.collinsdictionary.common"
}

2 changes: 1 addition & 1 deletion common/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="me.konyaco.collinsdictionary.common" />
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ private class DefinitionParser {
ExampleSentence(
sentence,
null,
null,
emptyList()
null
) // TODO: 2021/7/28 Grammar pattern and sound url.
}

Expand All @@ -234,7 +233,8 @@ private class DefinitionParser {
type = grammarGroup,
definition = Definition(
def = def,
examples = examples
examples = examples,
synonyms = SynonymParser.parse(senseElement)
),
extraDefinitions = emptyList() // TODO: 2021/7/28 Extra definitions.
)
Expand All @@ -243,4 +243,17 @@ private class DefinitionParser {

return definitionEntries
}
}

private object SynonymParser {
fun parse(synonymElement: Element): List<String>? {
val result = mutableListOf<String>()
val thesElement = synonymElement.getElementsByClass("thes").first()
?: return null

thesElement.getElementsByClass("form ref").forEach { //
result.add(it.text())
}
return result
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package me.konyaco.collinsdictionary.ui

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Typography
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import me.konyaco.collinsdictionary.common.R

@Composable
actual fun MyTheme(content: @Composable () -> Unit) {
MaterialTheme(
colors = if (isSystemInDarkTheme()) darkColors else lightColors,
typography = Typography(defaultFontFamily = RobotoFontFamily),
content = content
)
}

actual object MyRes {
actual val Sound: Painter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Repository(
when (localResult) {
is SearchResult.PreciseWord -> emit(Result(Result.Source.LOCAL, localResult))
is SearchResult.Redirect -> emit(Result(Result.Source.LOCAL, localResult))
else -> {
// TODO:
}
}
val remoteResult = onlineDictionary.search(word)
localCacheDictionary.cacheSearchResult(word, remoteResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ data class DefinitionEntry(
@Serializable
data class Definition(
val def: String,
val examples: List<ExampleSentence>
val examples: List<ExampleSentence>,
val synonyms: List<String>?
)

@Serializable
data class ExampleSentence(
val sentence: String,
val grammarPattern: String?,
val soundUrl: String?,
val synonyms: List<String>?
val soundUrl: String?
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.konyaco.collinsdictionary.service

import kotlinx.serialization.SerializationException
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand All @@ -21,7 +22,12 @@ class LocalCacheDictionary(private val localStorage: LocalStorage) : CollinsDict

override suspend fun getDefinition(word: String): Word? {
val text = localStorage.getDefinition(word) ?: return null
return json.decodeFromString<Word>(text)
return try {
json.decodeFromString<Word>(text)
} catch (e: SerializationException) {
localStorage.deleteDefinition(word)
null
}
}

fun cacheSearchResult(word: String, searchResult: SearchResult) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.konyaco.collinsdictionary.ui

import androidx.compose.animation.*
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
Expand Down Expand Up @@ -74,12 +75,12 @@ fun App(
ProvideSoundPlayer {
ProvideLocalScreenSize {
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
val padding = when (LocalScreenSize.current) {
val padding by animateDpAsState(when (LocalScreenSize.current) {
ScreenSize.PHONE -> 16.dp
ScreenSize.TABLET -> 24.dp
ScreenSize.LAPTOP -> 48.dp
ScreenSize.DESKTOP -> 48.dp
}
})

Column(
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.konyaco.collinsdictionary.ui

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Typography
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -46,7 +48,13 @@ internal val darkColors = darkColors(
)

@Composable
expect fun MyTheme(content: @Composable () -> Unit)
fun MyTheme(darkMode: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
MaterialTheme(
colors = if (darkMode) darkColors else lightColors,
typography = Typography(defaultFontFamily = RobotoFontFamily),
content = content
)
}

expect object MyRes {
val Sound: Painter
Expand Down
Loading

0 comments on commit 730889e

Please sign in to comment.