Skip to content

Commit ed5f797

Browse files
Upgrade dependencies, target SDK, JVM version (#56)
* chore: πŸ€– upgrade gradle version * chore: πŸ€– upgrade dep versions * style: πŸ’„ use ktlint format for all files * docs: ✏️ create claude readme * chore: πŸ€– allow composable function naming pattern for ktlint * chore: πŸ€– upgrade jvm to 21 * chore: πŸ€– enable gradle parallel build * docs: ✏️ remove localized ai cli tool document file * ci: 🎑 update ci java version * chore: πŸ€– upgrade packages * style: πŸ’„ format files using ktlint * test: πŸ’ address unsupported robolectric sdk issue
1 parent d57c20c commit ed5f797

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+778
-629
lines changed

β€Ž.editorconfigβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
ktlint_function_naming_ignore_when_annotated_with = Composable

β€Ž.github/workflows/build.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/setup-java@v4
2121
with:
2222
distribution: 'temurin'
23-
java-version: 17
23+
java-version: 21
2424
cache: gradle
2525

2626
- name: Build App

β€Žapp/build.gradle.ktsβ€Ž

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
3+
14
plugins {
25
kotlin("kapt")
36
alias(libs.plugins.android.application)
@@ -11,12 +14,17 @@ plugins {
1114

1215
android {
1316
namespace = "com.rickyhu.hushkeyboard"
14-
compileSdk = 35
17+
compileSdk = 36
18+
19+
compileOptions {
20+
sourceCompatibility = JavaVersion.VERSION_21
21+
targetCompatibility = JavaVersion.VERSION_21
22+
}
1523

1624
defaultConfig {
1725
applicationId = "com.rickyhu.hushkeyboard"
18-
minSdk = 26
19-
targetSdk = 35
26+
minSdk = 29
27+
targetSdk = 36
2028
versionCode = 3
2129
versionName = "0.4.0"
2230

@@ -31,22 +39,15 @@ android {
3139
isMinifyEnabled = false
3240
proguardFiles(
3341
getDefaultProguardFile("proguard-android-optimize.txt"),
34-
"proguard-rules.pro"
42+
"proguard-rules.pro",
3543
)
3644
}
3745
}
38-
compileOptions {
39-
sourceCompatibility = JavaVersion.VERSION_17
40-
targetCompatibility = JavaVersion.VERSION_17
41-
}
42-
kotlinOptions {
43-
jvmTarget = "17"
44-
}
4546
buildFeatures {
4647
compose = true
4748
}
4849
composeOptions {
49-
kotlinCompilerExtensionVersion = "1.4.3"
50+
kotlinCompilerExtensionVersion = "1.5.15"
5051
}
5152
packaging {
5253
resources {
@@ -60,7 +61,15 @@ android {
6061
}
6162
}
6263

63-
tasks.getByPath("preBuild").dependsOn("ktlintFormat")
64+
tasks {
65+
getByPath("preBuild").dependsOn("ktlintFormat")
66+
withType<KotlinJvmCompile>().configureEach {
67+
compilerOptions {
68+
jvmTarget.set(JvmTarget.JVM_21)
69+
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
70+
}
71+
}
72+
}
6473

6574
ktlint {
6675
android.set(true)

β€Žapp/src/main/AndroidManifest.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
android:roundIcon="@mipmap/ic_launcher_round"
1515
android:supportsRtl="true"
1616
android:theme="@style/Theme.HushKeyboard"
17-
tools:targetApi="31">
17+
tools:targetApi="36">
1818
<activity
1919
android:name=".MainActivity"
2020
android:exported="true"

β€Žapp/src/main/java/com/rickyhu/hushkeyboard/MainActivity.ktβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import dagger.hilt.android.AndroidEntryPoint
88

99
@AndroidEntryPoint
1010
class MainActivity : ComponentActivity() {
11-
1211
override fun onCreate(savedInstanceState: Bundle?) {
1312
super.onCreate(savedInstanceState)
1413

β€Žapp/src/main/java/com/rickyhu/hushkeyboard/data/AppSettings.ktβ€Ž

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ data class AppSettings(
88
val wideNotationOption: WideNotationOption = WideNotationOption.WideWithW,
99
val smartDelete: Boolean = true,
1010
val addSpaceAfterNotation: Boolean = true,
11-
val vibrateOnTap: Boolean = true
11+
val vibrateOnTap: Boolean = true,
1212
)
1313

1414
enum class ThemeOption { System, Light, Dark }
1515

1616
enum class WideNotationOption {
17-
WideWithW, WideWithLowercase;
17+
WideWithW,
18+
WideWithLowercase,
19+
;
1820

19-
override fun toString() = when (this) {
20-
WideWithW -> "Use w (Rw)"
21-
WideWithLowercase -> "Use lowercase (r)"
22-
}
21+
override fun toString() =
22+
when (this) {
23+
WideWithW -> "Use w (Rw)"
24+
WideWithLowercase -> "Use lowercase (r)"
25+
}
2326
}
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
package com.rickyhu.hushkeyboard.data
22

33
import androidx.datastore.core.Serializer
4-
import java.io.InputStream
5-
import java.io.OutputStream
64
import kotlinx.serialization.SerializationException
75
import kotlinx.serialization.json.Json
6+
import java.io.InputStream
7+
import java.io.OutputStream
88

99
object AppSettingsSerializer : Serializer<AppSettings> {
1010
override val defaultValue: AppSettings
1111
get() = AppSettings()
1212

13-
override suspend fun readFrom(input: InputStream): AppSettings {
14-
return try {
13+
override suspend fun readFrom(input: InputStream): AppSettings =
14+
try {
1515
Json.decodeFromString(
1616
deserializer = AppSettings.serializer(),
17-
string = input.readBytes().decodeToString()
17+
string = input.readBytes().decodeToString(),
1818
)
1919
} catch (e: SerializationException) {
2020
e.printStackTrace()
2121
defaultValue
2222
}
23-
}
2423

25-
override suspend fun writeTo(t: AppSettings, output: OutputStream) {
24+
override suspend fun writeTo(
25+
t: AppSettings,
26+
output: OutputStream,
27+
) {
2628
output.write(
27-
Json.encodeToString(
28-
serializer = AppSettings.serializer(),
29-
value = t
30-
).encodeToByteArray()
29+
Json
30+
.encodeToString(
31+
serializer = AppSettings.serializer(),
32+
value = t,
33+
).encodeToByteArray(),
3134
)
3235
}
3336
}

β€Žapp/src/main/java/com/rickyhu/hushkeyboard/data/SettingsRepository.ktβ€Ž

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,31 @@ import javax.inject.Inject
77

88
private val Context.dataStore by dataStore("app-settings.json", AppSettingsSerializer)
99

10-
class SettingsRepository @Inject constructor(
11-
@ApplicationContext context: Context
12-
) {
13-
14-
private val dataStore = context.dataStore
15-
val settings = dataStore.data
16-
17-
suspend fun updateThemeOption(themeOption: ThemeOption) {
18-
dataStore.updateData { it.copy(themeOption = themeOption) }
19-
}
20-
21-
suspend fun updateWideNotationOption(wideNotationOption: WideNotationOption) {
22-
dataStore.updateData { it.copy(wideNotationOption = wideNotationOption) }
23-
}
24-
25-
suspend fun updateSmartDelete(smartDelete: Boolean) {
26-
dataStore.updateData { it.copy(smartDelete = smartDelete) }
27-
}
28-
29-
suspend fun updateAddSpaceBetweenNotation(addSpaceBetweenNotation: Boolean) {
30-
dataStore.updateData { it.copy(addSpaceAfterNotation = addSpaceBetweenNotation) }
31-
}
32-
33-
suspend fun updateVibrateOnTap(vibrateOnTap: Boolean) {
34-
dataStore.updateData { it.copy(vibrateOnTap = vibrateOnTap) }
10+
class SettingsRepository
11+
@Inject
12+
constructor(
13+
@ApplicationContext context: Context,
14+
) {
15+
private val dataStore = context.dataStore
16+
val settings = dataStore.data
17+
18+
suspend fun updateThemeOption(themeOption: ThemeOption) {
19+
dataStore.updateData { it.copy(themeOption = themeOption) }
20+
}
21+
22+
suspend fun updateWideNotationOption(wideNotationOption: WideNotationOption) {
23+
dataStore.updateData { it.copy(wideNotationOption = wideNotationOption) }
24+
}
25+
26+
suspend fun updateSmartDelete(smartDelete: Boolean) {
27+
dataStore.updateData { it.copy(smartDelete = smartDelete) }
28+
}
29+
30+
suspend fun updateAddSpaceBetweenNotation(addSpaceBetweenNotation: Boolean) {
31+
dataStore.updateData { it.copy(addSpaceAfterNotation = addSpaceBetweenNotation) }
32+
}
33+
34+
suspend fun updateVibrateOnTap(vibrateOnTap: Boolean) {
35+
dataStore.updateData { it.copy(vibrateOnTap = vibrateOnTap) }
36+
}
3537
}
36-
}

β€Žapp/src/main/java/com/rickyhu/hushkeyboard/home/HomeScreen.ktβ€Ž

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,67 +41,73 @@ import com.rickyhu.hushkeyboard.theme.HushKeyboardTheme
4141
@Composable
4242
fun HomeScreen(
4343
navigateToIntroduction: () -> Unit = {},
44-
navigateToSettings: () -> Unit = {}
44+
navigateToSettings: () -> Unit = {},
4545
) {
4646
var text by remember { mutableStateOf("") }
4747

4848
Scaffold(
4949
content = { paddingValues ->
5050
Column(
51-
modifier = Modifier
52-
.fillMaxSize()
53-
.padding(paddingValues),
51+
modifier =
52+
Modifier
53+
.fillMaxSize()
54+
.padding(paddingValues),
5455
horizontalAlignment = Alignment.CenterHorizontally,
55-
verticalArrangement = Arrangement.Center
56+
verticalArrangement = Arrangement.Center,
5657
) {
5758
Card(
5859
shape = RoundedCornerShape(8.dp),
5960
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
60-
modifier = Modifier
61-
.clip(CircleShape)
62-
.size(200.dp)
63-
.border(BorderStroke(1.dp, Color.Gray), CircleShape)
61+
modifier =
62+
Modifier
63+
.clip(CircleShape)
64+
.size(200.dp)
65+
.border(BorderStroke(1.dp, Color.Gray), CircleShape),
6466
) {
6567
Image(
6668
painter = painterResource(id = R.drawable.app_icon),
67-
contentDescription = "App Icon"
69+
contentDescription = "App Icon",
6870
)
6971
}
7072
Spacer(modifier = Modifier.height(16.dp))
7173
Text(
7274
text = stringResource(R.string.app_name),
7375
style = MaterialTheme.typography.displayMedium,
74-
modifier = Modifier.padding(32.dp)
76+
modifier = Modifier.padding(32.dp),
7577
)
7678
Button(
7779
onClick = navigateToIntroduction,
78-
modifier = Modifier
79-
.fillMaxWidth()
80-
.padding(horizontal = 16.dp, vertical = 8.dp)
80+
modifier =
81+
Modifier
82+
.fillMaxWidth()
83+
.padding(horizontal = 16.dp, vertical = 8.dp),
8184
) {
8285
Text(text = stringResource(R.string.home_setup_keyboard_button))
8386
}
8487
Button(
8588
onClick = navigateToSettings,
86-
modifier = Modifier
87-
.fillMaxWidth()
88-
.padding(horizontal = 16.dp, vertical = 8.dp)
89+
modifier =
90+
Modifier
91+
.fillMaxWidth()
92+
.padding(horizontal = 16.dp, vertical = 8.dp),
8993
) {
9094
Text(text = stringResource(R.string.home_settings_button))
9195
}
9296
OutlinedTextField(
9397
value = text,
9498
onValueChange = { text = it },
9599
label = { Text(text = "Type here") },
96-
keyboardOptions = KeyboardOptions(
97-
keyboardType = KeyboardType.Text
98-
),
99-
modifier = Modifier
100-
.fillMaxWidth()
101-
.padding(16.dp)
100+
keyboardOptions =
101+
KeyboardOptions(
102+
keyboardType = KeyboardType.Text,
103+
),
104+
modifier =
105+
Modifier
106+
.fillMaxWidth()
107+
.padding(16.dp),
102108
)
103109
}
104-
}
110+
},
105111
)
106112
}
107113

0 commit comments

Comments
Β (0)