Skip to content

Commit 4721f01

Browse files
authored
Update Kotlin & NDK version (#771)
* Address breaking changes in Kotlin WpApiClient constructor Also addresses the warnings about KoinContext no longer being required. * Update Kotlin version to 2.1.21 * Update NDK version to `28.1.13356709` * Update android-targetSdk to 36 * Update Docker ndk version
1 parent 6ad6a37 commit 4721f01

File tree

8 files changed

+68
-68
lines changed

8 files changed

+68
-68
lines changed

native/kotlin/api/android/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ android {
2020
// to be manually installed: https://developer.android.com/build/releases/gradle-plugin#compatibility
2121
// Note that if the project's AGP version is not up to date, we need to find the correct release
2222
// notes from the list: https://developer.android.com/build/releases/past-releases (on the left side)
23+
//
24+
// TODO: The comment above is temporarily incorrect, as we are using a specific NDK version to
25+
// test the 16kb page size changes. When we update AGP to a version that is packaged with NDK
26+
// version above `28`, we should remove this.
27+
ndkVersion = "28.1.13356709"
2328

2429
defaultConfig {
2530
minSdk = libs.versions.android.minSdk.get().toInt()
@@ -112,4 +117,4 @@ project.afterEvaluate {
112117
}
113118
}
114119
}
115-
}
120+
}

native/kotlin/example/composeApp/src/androidMain/kotlin/rs/wordpress/example/ui/welcome/WelcomeActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import rs.wordpress.api.kotlin.WpLoginClient
1313
import rs.wordpress.example.shared.App
1414
import rs.wordpress.example.shared.repository.AuthenticationRepository
1515
import androidx.core.net.toUri
16+
import rs.wordpress.api.kotlin.toURL
1617
import uniffi.wp_api.AutoDiscoveryAttemptSuccess
1718

1819
class WelcomeActivity : ComponentActivity() {
@@ -60,8 +61,8 @@ class WelcomeActivity : ComponentActivity() {
6061
val discoverySuccess = apiDiscoverySuccess
6162
?: throw IllegalStateException("Api discovery has to be successful before authentication")
6263
authRepository.addAuthenticatedSite(
63-
discoverySuccess.parsedSiteUrl,
64-
discoverySuccess.apiRootUrl,
64+
discoverySuccess.parsedSiteUrl.toURL(),
65+
discoverySuccess.apiRootUrl.toURL(),
6566
username,
6667
password
6768
)

native/kotlin/example/composeApp/src/commonMain/kotlin/rs/wordpress/example/shared/App.kt

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
55
import androidx.navigation.compose.NavHost
66
import androidx.navigation.compose.composable
77
import androidx.navigation.compose.rememberNavController
8-
import org.koin.compose.KoinContext
98
import org.koin.compose.koinInject
109
import rs.wordpress.example.shared.ui.login.LoginScreen
1110
import rs.wordpress.example.shared.ui.plugins.PluginListScreen
@@ -17,49 +16,47 @@ import rs.wordpress.example.shared.ui.welcome.WelcomeScreen
1716

1817
@Composable
1918
fun App(authenticationEnabled: Boolean, authenticateSite: (String) -> Unit) {
20-
KoinContext {
21-
val userListViewModel = koinInject<UserListViewModel>()
22-
val pluginListViewModel = koinInject<PluginListViewModel>()
23-
val navController = rememberNavController()
19+
val userListViewModel = koinInject<UserListViewModel>()
20+
val pluginListViewModel = koinInject<PluginListViewModel>()
21+
val navController = rememberNavController()
2422

25-
MaterialTheme {
26-
NavHost(navController, startDestination = "welcome") {
27-
composable("welcome") {
28-
WelcomeScreen(
29-
authenticationEnabled,
30-
onLoginClicked = {
31-
navController.navigate("login")
32-
},
33-
onSiteClicked = { authenticatedSite ->
34-
userListViewModel.setAuthenticatedSite(authenticatedSite)
35-
pluginListViewModel.setAuthenticatedSite(authenticatedSite)
36-
navController.navigate("site")
37-
}
38-
)
39-
}
40-
composable("login") {
41-
if (authenticationEnabled) {
42-
LoginScreen(authenticateSite)
43-
} else {
44-
throw IllegalStateException("Authentication is disabled")
23+
MaterialTheme {
24+
NavHost(navController, startDestination = "welcome") {
25+
composable("welcome") {
26+
WelcomeScreen(
27+
authenticationEnabled,
28+
onLoginClicked = {
29+
navController.navigate("login")
30+
},
31+
onSiteClicked = { authenticatedSite ->
32+
userListViewModel.setAuthenticatedSite(authenticatedSite)
33+
pluginListViewModel.setAuthenticatedSite(authenticatedSite)
34+
navController.navigate("site")
4535
}
36+
)
37+
}
38+
composable("login") {
39+
if (authenticationEnabled) {
40+
LoginScreen(authenticateSite)
41+
} else {
42+
throw IllegalStateException("Authentication is disabled")
4643
}
47-
composable("site") {
48-
SiteScreen(
49-
onUsersClicked = {
50-
navController.navigate("users")
51-
},
52-
onPluginsClicked = {
53-
navController.navigate("plugins")
54-
}
55-
)
56-
}
57-
composable("users") {
58-
UserListScreen()
59-
}
60-
composable("plugins") {
61-
PluginListScreen()
62-
}
44+
}
45+
composable("site") {
46+
SiteScreen(
47+
onUsersClicked = {
48+
navController.navigate("users")
49+
},
50+
onPluginsClicked = {
51+
navController.navigate("plugins")
52+
}
53+
)
54+
}
55+
composable("users") {
56+
UserListScreen()
57+
}
58+
composable("plugins") {
59+
PluginListScreen()
6360
}
6461
}
6562
}

native/kotlin/example/composeApp/src/commonMain/kotlin/rs/wordpress/example/shared/ui/plugins/PluginListViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PluginListViewModel(private val authRepository: AuthenticationRepository)
1616
apiClient = null
1717
authRepository.authenticationForSite(authenticatedSite)?.let {
1818
apiClient = WpApiClient(
19-
apiRootUrl = authenticatedSite.apiRootUrl,
19+
wpOrgSiteApiRootUrl = authenticatedSite.apiRootUrl,
2020
authProvider = WpAuthenticationProvider.staticWithAuth(it)
2121
)
2222
}

native/kotlin/example/composeApp/src/commonMain/kotlin/rs/wordpress/example/shared/ui/users/UserListViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class UserListViewModel(private val authRepository: AuthenticationRepository) {
1616
apiClient = null
1717
authRepository.authenticationForSite(authenticatedSite)?.let {
1818
apiClient = WpApiClient(
19-
apiRootUrl = authenticatedSite.apiRootUrl,
19+
wpOrgSiteApiRootUrl = authenticatedSite.apiRootUrl,
2020
authProvider = WpAuthenticationProvider.staticWithAuth(it)
2121
)
2222
}

native/kotlin/example/composeApp/src/commonMain/kotlin/rs/wordpress/example/shared/ui/welcome/WelcomeScreen.kt

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import androidx.compose.material.Text
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.ui.Alignment
1313
import androidx.compose.ui.Modifier
14-
import org.koin.compose.KoinContext
1514
import org.koin.compose.koinInject
1615
import rs.wordpress.example.shared.domain.AuthenticatedSite
1716

@@ -22,27 +21,25 @@ fun WelcomeScreen(
2221
onLoginClicked: () -> Unit,
2322
onSiteClicked: (AuthenticatedSite) -> Unit
2423
) {
25-
KoinContext{
26-
val welcomeViewModel = koinInject<WelcomeViewModel>()
24+
val welcomeViewModel = koinInject<WelcomeViewModel>()
2725

28-
MaterialTheme {
29-
Column(
30-
horizontalAlignment = Alignment.CenterHorizontally,
31-
verticalArrangement = Arrangement.Center,
32-
modifier = Modifier.fillMaxSize(),
33-
) {
34-
if (authenticationEnabled) {
35-
Column {
36-
Button(onClick = onLoginClicked) {
37-
Text("Add new site")
38-
}
26+
MaterialTheme {
27+
Column(
28+
horizontalAlignment = Alignment.CenterHorizontally,
29+
verticalArrangement = Arrangement.Center,
30+
modifier = Modifier.fillMaxSize(),
31+
) {
32+
if (authenticationEnabled) {
33+
Column {
34+
Button(onClick = onLoginClicked) {
35+
Text("Add new site")
3936
}
4037
}
41-
LazyColumn {
42-
items(welcomeViewModel.getSiteList()) { site ->
43-
Button(onClick = { onSiteClicked(site) }) {
44-
Text(site.name)
45-
}
38+
}
39+
LazyColumn {
40+
items(welcomeViewModel.getSiteList()) { site ->
41+
Button(onClick = { onSiteClicked(site) }) {
42+
Text(site.name)
4643
}
4744
}
4845
}

native/kotlin/gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
agp = "8.8.1"
33
android-compileSdk = "36"
44
android-minSdk = "24"
5-
android-targetSdk = "34"
5+
android-targetSdk = "36"
66
androidx-activityCompose = "1.10.1"
77
androidx-core-ktx = "1.16.0"
88
androidx-material3 = "1.3.2"
@@ -13,7 +13,7 @@ detekt-plugin = "1.23.8"
1313
jna = "5.17.0"
1414
junit = "4.13.2"
1515
koin = "4.1.0"
16-
kotlin = "2.0.21"
16+
kotlin = "2.1.21"
1717
kotlinx-coroutines = "1.10.2"
1818
kotlinx-serialization-json = "1.6.3"
1919
landscapist = "2.5.0"

wordpress.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ENV PATH="//usr/lib/android-sdk/cmdline-tools/latest/bin:${PATH}"
3333
RUN yes | sdkmanager --licenses
3434

3535
RUN sdkmanager --install \
36-
"ndk;27.0.12077973"
36+
"ndk;28.1.13356709"
3737

3838
# Cache Gradle 8.7
3939
RUN mkdir gradle-cache-tmp \

0 commit comments

Comments
 (0)