From 31654a28d88ef6fc7189f2765e3c5c14f4c8c2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Wed, 16 Nov 2022 06:28:57 +0100 Subject: [PATCH 1/6] load test resources --- data/network/build.gradle.kts | 13 +++++++ .../androiddev/common/ResourceLoader.kt | 14 +++++++ .../androiddev/common/ResourceLoader.kt | 12 ++++++ .../common/network/MastodonApiTests.kt | 8 ++-- .../androiddev/common/ResourceLoader.kt | 14 +++++++ .../androiddev/common/ResourceLoader.kt | 37 +++++++++++++++++++ 6 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt create mode 100644 data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt create mode 100644 data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt create mode 100644 data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt diff --git a/data/network/build.gradle.kts b/data/network/build.gradle.kts index 45e1a8da..19d24a80 100644 --- a/data/network/build.gradle.kts +++ b/data/network/build.gradle.kts @@ -108,6 +108,19 @@ kotlin { implementation(libs.org.jetbrains.kotlin.test.junit) } } + val iosX64Test by getting + val iosArm64Test by getting + val iosSimulatorArm64Test by getting + val iosTest by creating { + dependsOn(getByName("commonTest")) + + iosX64Test.dependsOn(this) + iosArm64Test.dependsOn(this) + iosSimulatorArm64Test.dependsOn(this) + dependencies { + implementation(libs.org.jetbrains.kotlinx.coroutines.test) + } + } named("commonTest") { dependencies { implementation(kotlin("test")) diff --git a/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt new file mode 100644 index 00000000..08aa7d6b --- /dev/null +++ b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -0,0 +1,14 @@ +/* + * This file is part of MastodonX. + * + * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + */ +package social.androiddev.common + +actual fun readBinaryResource(resourceName: String): ByteArray { + return ClassLoader.getSystemResourceAsStream(resourceName)!!.readBytes() +} diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt new file mode 100644 index 00000000..45633688 --- /dev/null +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -0,0 +1,12 @@ +/* + * This file is part of MastodonX. + * + * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + */ +package social.androiddev.common + +expect fun readBinaryResource(resourceName: String): ByteArray diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt index 577fb572..eb5439b7 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt @@ -28,19 +28,17 @@ import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue +import social.androiddev.common.readBinaryResource @OptIn(ExperimentalCoroutinesApi::class) class MastodonApiTests { - // TODO: fix loading json from resources @Test - @Ignore fun `Instance request should fail with invalid response`() = runTest { // given - // val content: String = javaClass.classLoader.getResource("response_instance_invalid.json").readText() - val content: String = "" + val byteArray: ByteArray = readBinaryResource("response_instance_invalid.json") val mastodonApi = MastodonApiImpl( httpClient = createMockClient( - statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = content) + statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(content = byteArray) ) ) diff --git a/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt new file mode 100644 index 00000000..08aa7d6b --- /dev/null +++ b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -0,0 +1,14 @@ +/* + * This file is part of MastodonX. + * + * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + */ +package social.androiddev.common + +actual fun readBinaryResource(resourceName: String): ByteArray { + return ClassLoader.getSystemResourceAsStream(resourceName)!!.readBytes() +} diff --git a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt new file mode 100644 index 00000000..f2c50c1f --- /dev/null +++ b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -0,0 +1,37 @@ +/* + * This file is part of MastodonX. + * + * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + */ +package social.androiddev.common + +import kotlinx.cinterop.addressOf +import kotlinx.cinterop.usePinned +import platform.Foundation.NSBundle +import platform.Foundation.NSData +import platform.Foundation.dataWithContentsOfFile +import platform.posix.memcpy + +actual fun readBinaryResource(resourceName: String): ByteArray { + // split based on "." and "/". We want to strip the leading ./ and + // split the extension + val pathParts = resourceName.split("[.|/]".toRegex()) + // pathParts looks like + // [, , test_case_input_one, bin] + val path = NSBundle.mainBundle + .pathForResource("resources/${pathParts[2]}", pathParts[3]) + val data = NSData.dataWithContentsOfFile(path!!) + return data!!.toByteArray() +} + +internal fun NSData.toByteArray(): ByteArray { + return ByteArray(length.toInt()).apply { + usePinned { + memcpy(it.addressOf(0), bytes, length) + } + } +} From 2b5df54faaede87f9a8c1bffb635f7cf70f2509a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Thu, 17 Nov 2022 10:21:51 +0100 Subject: [PATCH 2/6] use absolute path for resources --- .../social/androiddev/common/ResourceLoader.kt | 6 ++++-- .../androiddev/common/network/MastodonApiImpl.kt | 3 +++ .../social/androiddev/common/ResourceLoader.kt | 7 ++++++- .../androiddev/common/network/MastodonApiTests.kt | 15 ++++++++------- .../common/network/model/AccountTests.kt | 7 +++---- .../common/network/model/ContextTests.kt | 7 +++---- .../common/network/model/ConversationTests.kt | 7 +++---- .../common/network/model/NotificationTests.kt | 7 +++---- .../common/network/model/StatusTests.kt | 7 +++---- .../social/androiddev/common/ResourceLoader.kt | 6 ++++-- .../social/androiddev/common/ResourceLoader.kt | 4 ++-- 11 files changed, 42 insertions(+), 34 deletions(-) diff --git a/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt index 08aa7d6b..7b7f0b9d 100644 --- a/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -9,6 +9,8 @@ */ package social.androiddev.common -actual fun readBinaryResource(resourceName: String): ByteArray { - return ClassLoader.getSystemResourceAsStream(resourceName)!!.readBytes() +import java.io.File + +actual fun readBinaryResource(resourcePath: String): ByteArray { + return File(resourcePath).readBytes() } diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt index 8771cd2f..163683c7 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt @@ -13,6 +13,7 @@ import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.plugins.ResponseException import io.ktor.client.request.get +import io.ktor.serialization.JsonConvertException import kotlinx.serialization.SerializationException import social.androiddev.common.network.model.Instance @@ -31,6 +32,8 @@ class MastodonApiImpl( ) } catch (exception: SerializationException) { Result.failure(exception = exception) + } catch (exception: JsonConvertException) { + Result.failure(exception = exception) } catch (exception: ResponseException) { Result.failure(exception = exception) } diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt index 45633688..ab36f34a 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -9,4 +9,9 @@ */ package social.androiddev.common -expect fun readBinaryResource(resourceName: String): ByteArray +/** + * the resourcePath is based on the module + * + * e.g.: "src/commonTest/resources/resource_name.json" + */ +expect fun readBinaryResource(resourcePath: String): ByteArray diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt index eb5439b7..aa90e9b1 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt @@ -19,6 +19,7 @@ import io.ktor.http.HttpStatusCode import io.ktor.http.headersOf import io.ktor.serialization.kotlinx.json.json import io.ktor.utils.io.ByteReadChannel +import io.ktor.utils.io.charsets.Charsets import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json @@ -35,10 +36,12 @@ class MastodonApiTests { @Test fun `Instance request should fail with invalid response`() = runTest { // given - val byteArray: ByteArray = readBinaryResource("response_instance_invalid.json") + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_instance_invalid.json") + println(byteArray.decodeToString()) + val mastodonApi = MastodonApiImpl( httpClient = createMockClient( - statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(content = byteArray) + statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = byteArray.decodeToString()) ) ) @@ -50,17 +53,15 @@ class MastodonApiTests { assertNull(actual = result.getOrNull()?.uri) } - // TODO: fix loading json from resources @Test - @Ignore fun `Instance request should succeed with required field response`() = runTest { // given - // val content: String = javaClass.classLoader.getResource("response_instance_valid.json").readText() - val content: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_instance_valid.json") + println(byteArray.decodeToString()) val mastodonApi = MastodonApiImpl( httpClient = createMockClient( - statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = content) + statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = byteArray.decodeToString()) ) ) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt index d601f34e..0c2c5f96 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt @@ -14,15 +14,14 @@ import kotlinx.serialization.json.Json import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals +import social.androiddev.common.readBinaryResource class AccountTests { - // TODO: fix loading json from resources - @Ignore @Test fun `deserialize required fields should succeed`() { // given - // val json: String = javaClass.classLoader.getResource("response_account_required.json").readText() - val json: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_account_required.json") + val json: String = byteArray.decodeToString() // when val account = Json.decodeFromString(json) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt index 38b727d4..131364c5 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt @@ -15,15 +15,14 @@ import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +import social.androiddev.common.readBinaryResource class ContextTests { - // TODO: fix loading json from resources - @Ignore @Test fun `deserialize required fields should succeed`() { // given - // val json: String = javaClass.classLoader.getResource("response_context_required.json").readText() - val json: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_context_required.json") + val json: String = byteArray.decodeToString() // when val context = Json.decodeFromString(json) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt index b89dfbe3..d8268776 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt @@ -15,15 +15,14 @@ import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +import social.androiddev.common.readBinaryResource class ConversationTests { - // TODO: fix loading json from resources - @Ignore @Test fun `deserialize required fields should succeed`() { // given - // val json: String = javaClass.classLoader.getResource("response_conversation_required.json").readText() - val json: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_conversation_required.json") + val json: String = byteArray.decodeToString() // when val conversation = Json.decodeFromString(json) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt index 2cea0270..332248f3 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt @@ -15,15 +15,14 @@ import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +import social.androiddev.common.readBinaryResource class NotificationTests { - // TODO: fix loading json from resources - @Ignore @Test fun `deserialize required fields should succeed`() { // given - // val json: String = javaClass.classLoader.getResource("response_notification_required.json").readText() - val json: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_notification_required.json") + val json: String = byteArray.decodeToString() // when val notification = Json.decodeFromString(json) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt index d50f0e77..96c37ff4 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt @@ -15,15 +15,14 @@ import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull +import social.androiddev.common.readBinaryResource class StatusTests { - // TODO: fix loading json from resources - @Ignore @Test fun `deserialize required fields should succeed`() { // given - // val json: String = javaClass.classLoader.getResource("response_status_required.json").readText() - val json: String = "" + val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_status_required.json") + val json: String = byteArray.decodeToString() // when val status = Json.decodeFromString(json) diff --git a/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt index 08aa7d6b..7b7f0b9d 100644 --- a/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -9,6 +9,8 @@ */ package social.androiddev.common -actual fun readBinaryResource(resourceName: String): ByteArray { - return ClassLoader.getSystemResourceAsStream(resourceName)!!.readBytes() +import java.io.File + +actual fun readBinaryResource(resourcePath: String): ByteArray { + return File(resourcePath).readBytes() } diff --git a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt index f2c50c1f..851ccf96 100644 --- a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -16,10 +16,10 @@ import platform.Foundation.NSData import platform.Foundation.dataWithContentsOfFile import platform.posix.memcpy -actual fun readBinaryResource(resourceName: String): ByteArray { +actual fun readBinaryResource(resourcePath: String): ByteArray { // split based on "." and "/". We want to strip the leading ./ and // split the extension - val pathParts = resourceName.split("[.|/]".toRegex()) + val pathParts = resourcePath.split("[.|/]".toRegex()) // pathParts looks like // [, , test_case_input_one, bin] val path = NSBundle.mainBundle From 48bd797ac7a980049fce3938ee77870b0baba1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Thu, 17 Nov 2022 10:38:54 +0100 Subject: [PATCH 3/6] adjust imports --- .../social/androiddev/common/network/MastodonApiTests.kt | 4 +--- .../social/androiddev/common/network/model/AccountTests.kt | 3 +-- .../social/androiddev/common/network/model/ContextTests.kt | 3 +-- .../androiddev/common/network/model/ConversationTests.kt | 3 +-- .../androiddev/common/network/model/NotificationTests.kt | 3 +-- .../social/androiddev/common/network/model/StatusTests.kt | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt index aa90e9b1..11ffb504 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt @@ -19,17 +19,15 @@ import io.ktor.http.HttpStatusCode import io.ktor.http.headersOf import io.ktor.serialization.kotlinx.json.json import io.ktor.utils.io.ByteReadChannel -import io.ktor.utils.io.charsets.Charsets import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue -import social.androiddev.common.readBinaryResource @OptIn(ExperimentalCoroutinesApi::class) class MastodonApiTests { diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt index 0c2c5f96..f2d77d90 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt @@ -11,10 +11,9 @@ package social.androiddev.common.network.model import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertEquals -import social.androiddev.common.readBinaryResource class AccountTests { @Test diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt index 131364c5..46a4a9ba 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt @@ -11,11 +11,10 @@ package social.androiddev.common.network.model import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull -import social.androiddev.common.readBinaryResource class ContextTests { @Test diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt index d8268776..c4b53db7 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt @@ -11,11 +11,10 @@ package social.androiddev.common.network.model import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull -import social.androiddev.common.readBinaryResource class ConversationTests { @Test diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt index 332248f3..af250305 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt @@ -11,11 +11,10 @@ package social.androiddev.common.network.model import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull -import social.androiddev.common.readBinaryResource class NotificationTests { @Test diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt index 96c37ff4..ab6a89e4 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt @@ -11,11 +11,10 @@ package social.androiddev.common.network.model import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import kotlin.test.Ignore +import social.androiddev.common.readBinaryResource import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull -import social.androiddev.common.readBinaryResource class StatusTests { @Test From 2a23782f615c3049495f181755a56d5ca1a227c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Thu, 17 Nov 2022 11:16:37 +0100 Subject: [PATCH 4/6] use absolute path for iOS as well --- .../social/androiddev/common/ResourceLoader.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt index 851ccf96..3afce1b0 100644 --- a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -13,19 +13,17 @@ import kotlinx.cinterop.addressOf import kotlinx.cinterop.usePinned import platform.Foundation.NSBundle import platform.Foundation.NSData +import platform.Foundation.NSUTF8StringEncoding import platform.Foundation.dataWithContentsOfFile import platform.posix.memcpy actual fun readBinaryResource(resourcePath: String): ByteArray { - // split based on "." and "/". We want to strip the leading ./ and - // split the extension - val pathParts = resourcePath.split("[.|/]".toRegex()) - // pathParts looks like - // [, , test_case_input_one, bin] - val path = NSBundle.mainBundle - .pathForResource("resources/${pathParts[2]}", pathParts[3]) - val data = NSData.dataWithContentsOfFile(path!!) - return data!!.toByteArray() + val path = resourcePath.substringBeforeLast(".") + val fileType = resourcePath.substringAfterLast(".") + + val absolutePath = NSBundle.mainBundle.pathForResource(path, fileType) + + return NSData.dataWithContentsOfFile(absolutePath!!, NSUTF8StringEncoding, null)!!.toByteArray() } internal fun NSData.toByteArray(): ByteArray { From d5df1e57ffa789128f314d12b9519b4b8424b78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Stu=CC=88rmer?= Date: Thu, 17 Nov 2022 11:41:16 +0100 Subject: [PATCH 5/6] print path in CI --- .../iosTest/kotlin/social/androiddev/common/ResourceLoader.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt index 3afce1b0..87e47d9e 100644 --- a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -20,8 +20,10 @@ import platform.posix.memcpy actual fun readBinaryResource(resourcePath: String): ByteArray { val path = resourcePath.substringBeforeLast(".") val fileType = resourcePath.substringAfterLast(".") + println("resourcePath=$resourcePath, path=$path, fileType=$fileType") val absolutePath = NSBundle.mainBundle.pathForResource(path, fileType) + println("absolutePath=$absolutePath") return NSData.dataWithContentsOfFile(absolutePath!!, NSUTF8StringEncoding, null)!!.toByteArray() } From 3df07ac5533dc58ca46246e6adeeeef1b1c68d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20St=C3=BCrmer?= Date: Tue, 6 Dec 2022 06:46:55 +0100 Subject: [PATCH 6/6] solve conflicts --- .githooks/pre-commit | 18 + .github/CODEOWNERS | 2 +- CONTRIBUTING.md | 63 ++-- LICENSE.md | 4 +- README.md | 44 ++- app-android/build.gradle.kts | 20 +- app-android/src/main/AndroidManifest.xml | 3 +- .../social/androiddev/dodo/DodoApplication.kt | 28 ++ .../social/androiddev/dodo/MainActivity.kt | 39 +++ .../androiddev/dodo/di/AndroidAppModule.kt | 18 + .../androiddev/mastodon/MainActivity.kt | 34 -- app-android/src/main/res/values/strings.xml | 5 +- app-desktop/build.gradle.kts | 19 +- .../kotlin/social/androiddev/desktop/Main.kt | 35 +- .../convention-plugins/build.gradle.kts | 16 + .../androiddev/plugins/CodeQualityPlugin.kt | 21 ++ build-logic/settings.gradle.kts | 16 + build.gradle.kts | 9 - copyright.kt | 9 - copyright.txt | 9 + data/network/build.gradle.kts | 12 +- .../common/network/AndroidPlatform.kt | 8 +- .../common/network/AndroidUrlStream.kt | 8 +- .../androiddev/common/ResourceLoader.kt | 8 +- .../androiddev/common/network/MastodonApi.kt | 46 ++- .../common/network/MastodonApiImpl.kt | 41 --- .../common/network/MastodonApiKtor.kt | 86 +++++ .../androiddev/common/network/Platform.kt | 8 +- .../androiddev/common/network/UrlStream.kt | 8 +- .../common/network/di/NetworkModule.kt | 42 +++ .../common/network/model/Account.kt | 8 +- .../common/network/model/Activity.kt | 8 +- .../common/network/model/Announcement.kt | 8 +- .../network/model/AnnouncementReaction.kt | 8 +- .../common/network/model/Application.kt | 30 +- .../common/network/model/Attachment.kt | 8 +- .../androiddev/common/network/model/Card.kt | 8 +- .../common/network/model/Context.kt | 8 +- .../common/network/model/Conversation.kt | 8 +- .../androiddev/common/network/model/Emoji.kt | 8 +- .../androiddev/common/network/model/Error.kt | 8 +- .../common/network/model/FeaturedTag.kt | 8 +- .../androiddev/common/network/model/Field.kt | 8 +- .../androiddev/common/network/model/Filter.kt | 8 +- .../common/network/model/History.kt | 8 +- .../common/network/model/IdentityProof.kt | 8 +- .../common/network/model/Instance.kt | 8 +- .../androiddev/common/network/model/Marker.kt | 8 +- .../common/network/model/Mention.kt | 8 +- .../common/network/model/Notification.kt | 8 +- .../androiddev/common/network/model/Poll.kt | 8 +- .../common/network/model/Preferences.kt | 8 +- .../common/network/model/PushSubscription.kt | 8 +- .../androiddev/common/network/model/Source.kt | 8 +- .../androiddev/common/network/model/Status.kt | 8 +- .../androiddev/common/network/model/Tag.kt | 8 +- .../common/network/model/UserList.kt | 8 +- .../common/network/util/RunCatching.kt | 78 +++++ .../androiddev/common/ResourceLoader.kt | 8 +- .../common/network/MastodonApiTests.kt | 283 ++++++++++++++-- .../common/network/model/AccountTests.kt | 8 +- .../common/network/model/ActivityTests.kt | 8 +- .../model/AnnouncementReactionTests.kt | 8 +- .../common/network/model/AnnouncementTests.kt | 8 +- .../common/network/model/ApplicationTests.kt | 17 +- .../common/network/model/AttachmentTests.kt | 8 +- .../common/network/model/CardTests.kt | 8 +- .../common/network/model/ContextTests.kt | 8 +- .../common/network/model/ConversationTests.kt | 8 +- .../common/network/model/EmojiTests.kt | 8 +- .../common/network/model/ErrorTests.kt | 8 +- .../common/network/model/FeatureTests.kt | 8 +- .../common/network/model/FilterTests.kt | 8 +- .../common/network/model/HistoryTests.kt | 8 +- .../network/model/IdentityProofTests.kt | 8 +- .../common/network/model/MarkerTests.kt | 8 +- .../common/network/model/MentionTests.kt | 8 +- .../common/network/model/NotificationTests.kt | 8 +- .../common/network/model/PollTests.kt | 8 +- .../common/network/model/PreferencesTests.kt | 8 +- .../network/model/PushSubscriptionTests.kt | 8 +- .../common/network/model/StatusTests.kt | 8 +- .../common/network/model/TagTests.kt | 8 +- .../common/network/model/UserListTests.kt | 8 +- .../resources/response_context_required.json | 6 +- .../response_conversation_required.json | 3 +- .../resources/response_instance_invalid.json | 1 - .../response_notification_required.json | 3 +- .../resources/response_status_required.json | 3 +- .../androiddev/common/network/Platform.kt | 8 +- .../androiddev/common/network/UrlStream.kt | 8 +- .../androiddev/common/ResourceLoader.kt | 8 +- .../androiddev/common/network/Platform.kt | 8 +- .../androiddev/common/network/UrlStream.kt | 8 +- .../androiddev/common/ResourceLoader.kt | 8 +- data/persistence/build.gradle.kts | 48 ++- .../common/persistence/DatabaseDriver.kt | 20 ++ .../common/persistence/DatabaseDriver.kt | 19 ++ .../common/persistence/DatabaseDriver.kt | 14 + .../AuthenticationDatabaseWrapper.kt | 16 + .../persistence/authentication/Application.sq | 14 + .../common/persistence/DatabaseDriver.kt | 14 + .../AuthenticationDatabaseTests.kt | 40 +++ .../common/persistence/DatabaseDriver.kt | 19 ++ .../common/persistence/DatabaseDriver.kt | 19 ++ .../androiddev/common/persistence/.gitkeep | 0 .../common/persistence/DatabaseDriver.kt | 17 + .../common/persistence/DatabaseDriver.kt | 17 + data/repository/build.gradle.kts | 102 ++++++ .../src/androidMain/AndroidManifest.xml | 2 + .../androiddev/common/repository}/.gitkeep | 0 .../AuthenticationRepositoryImpl.kt | 43 +++ .../common/repository/di/RepositoryModule.kt | 29 ++ .../androiddev/common/repository}/.gitkeep | 0 .../androiddev/common/repository}/.gitkeep | 0 di/build.gradle.kts | 76 +++++ di/src/androidMain/AndroidManifest.xml | 2 + .../social/androiddev/common/Platform.kt | 14 + .../social/androiddev/common/Platform.kt | 14 + .../social/androiddev/common/di/AppModule.kt | 22 ++ .../androiddev/common/di/PlatformModule.kt | 22 ++ .../social/androiddev/common/Platform.kt | 15 + .../social/androiddev/common/Platform.kt | 17 + domain/authentication/build.gradle.kts | 65 ++++ .../src/androidMain/AndroidManifest.xml | 2 + .../repository/AuthenticationRepository.kt | 21 ++ .../usecase/AuthenticateClient.kt | 31 ++ domain/timeline/build.gradle.kts | 20 +- .../domain/timeline/model/Account.kt | 8 +- .../domain/timeline/model/Status.kt | 8 +- .../domain/timeline/model/Visibility.kt | 8 +- gradle/libs.versions.toml | 13 +- settings.gradle.kts | 27 +- ui/common/build.gradle.kts | 14 +- .../androiddev/common/utils/ImageLoading.kt | 8 +- .../common/composables/UserAvatar.kt | 12 +- .../composables/buttons/MastodonButton.kt | 24 +- .../buttons/MastodonOutlinedButton.kt | 24 +- .../composables/buttons/MastodonTextButton.kt | 24 +- .../composables/text/MastodonTextField.kt | 309 ++++++++++++++++++ .../common/network/NetworkMonitor.kt | 16 - .../{MastodonColors.kt => DodoColors.kt} | 8 +- .../androiddev/common/theme/DodoTheme.kt | 29 ++ ...astodonTypography.kt => DodoTypography.kt} | 10 +- .../androiddev/common/theme/MastodonTheme.kt | 29 -- .../androiddev/common/utils/AsyncImage.kt | 23 +- .../androiddev/common/utils/ImageLoading.kt | 8 +- .../androiddev/common/utils/ImageLoading.kt | 8 +- ui/{welcome => root}/build.gradle.kts | 16 +- .../src/androidMain/AndroidManifest.xml | 0 .../root/composables/RootContent.kt | 100 ++++++ .../root/composables/SplashContent.kt | 65 ++++ .../root/navigation/DefaultRootComponent.kt | 107 ++++++ .../root/navigation/DefaultSplashComponent.kt | 27 ++ .../root/navigation/RootComponent.kt | 43 +++ .../root/navigation/SplashComponent.kt | 26 ++ ui/signed-in/build.gradle.kts | 72 ++++ .../src/androidMain/AndroidManifest.xml | 2 + .../composables/SignedInRootContent.kt | 63 ++++ .../DefaultSignedInRootComponent.kt | 73 +++++ .../navigation/SignedInRootComponent.kt | 32 ++ ui/signed-out/build.gradle.kts | 71 ++++ .../src/androidMain/AndroidManifest.xml | 2 + .../signedout/composables/LandingContent.kt} | 81 +++-- .../composables/SelectServerContent.kt | 85 +++++ .../composables/SignedOutRootContent.kt | 60 ++++ .../navigation/DefaultLandingComponent.kt | 22 ++ .../DefaultSelectServerComponent.kt | 22 ++ .../DefaultSignedOutRootComponent.kt | 86 +++++ .../signedout/navigation/LandingComponent.kt | 21 ++ .../navigation/SelectServerComponent.kt | 18 + .../navigation/SignedOutRootComponent.kt | 33 ++ ui/timeline/build.gradle.kts | 10 +- .../androiddev/timeline/HorizontalSpacer.kt | 8 +- .../androiddev/timeline/TimelineCard.kt | 14 +- .../{TimelineScreen.kt => TimelineContent.kt} | 33 +- .../social/androiddev/timeline/TootContent.kt | 14 +- .../androiddev/timeline/TootContentHeader.kt | 14 +- .../androiddev/timeline/VerticalSpacer.kt | 8 +- .../navigation/DefaultTimelineComponent.kt | 16 + .../timeline/navigation/TimelineComponent.kt | 15 + 181 files changed, 3434 insertions(+), 740 deletions(-) create mode 100755 .githooks/pre-commit create mode 100644 app-android/src/main/kotlin/social/androiddev/dodo/DodoApplication.kt create mode 100644 app-android/src/main/kotlin/social/androiddev/dodo/MainActivity.kt create mode 100644 app-android/src/main/kotlin/social/androiddev/dodo/di/AndroidAppModule.kt delete mode 100644 app-android/src/main/kotlin/social/androiddev/mastodon/MainActivity.kt create mode 100644 build-logic/convention-plugins/build.gradle.kts create mode 100644 build-logic/convention-plugins/src/main/kotlin/social/androiddev/plugins/CodeQualityPlugin.kt create mode 100644 build-logic/settings.gradle.kts delete mode 100644 copyright.kt create mode 100644 copyright.txt delete mode 100644 data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt create mode 100644 data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiKtor.kt create mode 100644 data/network/src/commonMain/kotlin/social/androiddev/common/network/di/NetworkModule.kt create mode 100644 data/network/src/commonMain/kotlin/social/androiddev/common/network/util/RunCatching.kt delete mode 100644 data/network/src/commonTest/resources/response_instance_invalid.json create mode 100644 data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/androidTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseWrapper.kt create mode 100644 data/persistence/src/commonMain/sqldelight/social/androiddev/common/persistence/authentication/Application.sq create mode 100644 data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseTests.kt create mode 100644 data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/desktopTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt delete mode 100644 data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/.gitkeep create mode 100644 data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/persistence/src/iosTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt create mode 100644 data/repository/build.gradle.kts create mode 100644 data/repository/src/androidMain/AndroidManifest.xml rename data/{persistence/src/androidMain/kotlin/social/androiddev/common/persistence => repository/src/androidMain/kotlin/social/androiddev/common/repository}/.gitkeep (100%) create mode 100644 data/repository/src/commonMain/kotlin/social/androiddev/common/repository/AuthenticationRepositoryImpl.kt create mode 100644 data/repository/src/commonMain/kotlin/social/androiddev/common/repository/di/RepositoryModule.kt rename data/{persistence/src/commonMain/kotlin/social/androiddev/common/persistence => repository/src/desktopMain/kotlin/social/androiddev/common/repository}/.gitkeep (100%) rename data/{persistence/src/desktopMain/kotlin/social/androiddev/common/persistence => repository/src/iosMain/kotlin/social/androiddev/common/repository}/.gitkeep (100%) create mode 100644 di/build.gradle.kts create mode 100644 di/src/androidMain/AndroidManifest.xml create mode 100644 di/src/androidMain/kotlin/social/androiddev/common/Platform.kt create mode 100644 di/src/commonMain/kotlin/social/androiddev/common/Platform.kt create mode 100644 di/src/commonMain/kotlin/social/androiddev/common/di/AppModule.kt create mode 100644 di/src/commonMain/kotlin/social/androiddev/common/di/PlatformModule.kt create mode 100644 di/src/desktopMain/kotlin/social/androiddev/common/Platform.kt create mode 100644 di/src/iosMain/kotlin/social/androiddev/common/Platform.kt create mode 100644 domain/authentication/build.gradle.kts create mode 100644 domain/authentication/src/androidMain/AndroidManifest.xml create mode 100644 domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/repository/AuthenticationRepository.kt create mode 100644 domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/AuthenticateClient.kt create mode 100644 ui/common/src/commonMain/kotlin/social/androiddev/common/composables/text/MastodonTextField.kt delete mode 100644 ui/common/src/commonMain/kotlin/social/androiddev/common/network/NetworkMonitor.kt rename ui/common/src/commonMain/kotlin/social/androiddev/common/theme/{MastodonColors.kt => DodoColors.kt} (58%) create mode 100644 ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTheme.kt rename ui/common/src/commonMain/kotlin/social/androiddev/common/theme/{MastodonTypography.kt => DodoTypography.kt} (87%) delete mode 100644 ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTheme.kt rename ui/{welcome => root}/build.gradle.kts (84%) rename ui/{welcome => root}/src/androidMain/AndroidManifest.xml (100%) create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/composables/RootContent.kt create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/composables/SplashContent.kt create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultRootComponent.kt create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultSplashComponent.kt create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/RootComponent.kt create mode 100644 ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/SplashComponent.kt create mode 100644 ui/signed-in/build.gradle.kts create mode 100644 ui/signed-in/src/androidMain/AndroidManifest.xml create mode 100644 ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/composables/SignedInRootContent.kt create mode 100644 ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/DefaultSignedInRootComponent.kt create mode 100644 ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/SignedInRootComponent.kt create mode 100644 ui/signed-out/build.gradle.kts create mode 100644 ui/signed-out/src/androidMain/AndroidManifest.xml rename ui/{welcome/src/commonMain/kotlin/social/androiddev/welcome/composables/WelcomeScreen.kt => signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/LandingContent.kt} (64%) create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SelectServerContent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SignedOutRootContent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultLandingComponent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSelectServerComponent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSignedOutRootComponent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/LandingComponent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SelectServerComponent.kt create mode 100644 ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SignedOutRootComponent.kt rename ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/{TimelineScreen.kt => TimelineContent.kt} (52%) create mode 100644 ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/DefaultTimelineComponent.kt create mode 100644 ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineComponent.kt diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..7bd42925 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,18 @@ +#!/bin/sh +# +# hook script to verify code formatting and runs tests for all modules +# also it will try to format code and add missing license headers to every kotlin file. + +echo "***** Run code formatting and tests ******" +git stash -q --keep-index + +./gradlew spotlessApply +./gradlew check + +status=$? + +git stash pop -q + +echo "***** Done with code formatting and tests ******" + +exit $status diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c9ce4580..0cb4d471 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,5 +3,5 @@ # https://github.blog/2017-07-06-introducing-code-owners/ # Add a fallback to default owners -* @thebino +* @thebino @crocsandcoffee diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea3e37a9..04e04958 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,15 @@ -# Welcome to MastodonCompose +# Welcome to Dodo for Mastodon[^temporary] +[^temporary]: This is just the working title for now. -This is a free and open project and lives from contributions of the community. +This is a free and open Mastodon client and lives from contributions of the community. There are many ways to contribute: * 📣 Spread the project or its apps to the world * ✍️ Writing tutorials and blog posts - * 📝 Create or update [the documentation](https://github.com/AndroidDev-social/MastodonCompose/wiki) - * 🐛 Submit [bug reports](https://github.com/AndroidDev-social/MastodonCompose/issues) - * 💡 Adding ideas and feature requests to [Discussions](https://github.com/AndroidDev-social/MastodonCompose/discussions) + * 📝 Create or update [the documentation](https://github.com/AndroidDev-social/DodoForMastodon/wiki) + * 🐛 Submit [bug reports](https://github.com/AndroidDev-social/DodoForMastodon/issues) + * 💡 Adding ideas and feature requests to [Discussions](https://github.com/AndroidDev-social/DodoForMastodon/discussions) * 👩‍🎨 Create designs or UX flows * 🧑‍💻 Contribute code or review PRs @@ -50,11 +51,12 @@ When you're happy with your changes, create Atomic commits on a **new feature br Atomic commits will make it easier to track down regressions. Also, it enables the ability to cherry-pick or revert a change if needed. -1. Fork it (https://github.com/AndroidDev-social/MastodonCompose/fork) -2. Create a new feature branch (`git checkout -b feature/fooBar`) -3. Commit your changes (`git commit -am 'Add some fooBar'`) -4. Push to the branch (`git push origin feature/fooBar`) -5. Create a new Pull Request +1. Fork it (https://github.com/AndroidDev-social/DodoForMastodon/fork) +2. Install pre-commit hooks (`git config core.hooksPath .githooks`) +3. Create a new feature branch (`git checkout -b feature/fooBar`) +4. Commit your changes (`git commit -am 'Add some fooBar'`) +5. Push to the branch (`git push origin feature/fooBar`) +6. Create a new Pull Request @@ -62,19 +64,19 @@ Atomic commits will make it easier to track down regressions. Also, it enables t > If you find a security vulnerability, do NOT open an issue. Email [webmaster@stuermer-benjamin.de] instead. -1. Open the [issues tab](https://github.com/AndroidDev-social/MastodonCompose/issues) on github -2. Click on [New issue](https://github.com/AndroidDev-social/MastodonCompose/issues/new/choose) +1. Open the [issues tab](https://github.com/AndroidDev-social/DodoForMastodon/issues) on github +2. Click on [New issue](https://github.com/AndroidDev-social/DodoForMastodon/issues/new/choose) 3. Choose the bug report 🐛 template and fill out all required fields ## 💡 How to suggest a feature or enhancement -Check [open issues](https://github.com/AndroidDev-social/MastodonCompose/issues) and [ongoing discussions](https://github.com/AndroidDev-social/MastodonCompose/discussions) for a list of proposed features. +Check [open issues](https://github.com/AndroidDev-social/DodoForMastodon/issues) and [ongoing discussions](https://github.com/AndroidDev-social/MastodonCompose/discussions) for a list of proposed features. -If your suggestion can not be found already, see if it is already covered by our [Roadmap](https://github.com/AndroidDev-social/MastodonCompose#roadmap). +If your suggestion can not be found already, see if it is already covered by our [Roadmap](https://github.com/AndroidDev-social/DodoForMastodon#roadmap). -Otherwise, start a new [Discussion](https://github.com/AndroidDev-social/MastodonCompose/discussions) and see what other users and contributors think. +Otherwise, start a new [Discussion](https://github.com/AndroidDev-social/DodoForMastodon/discussions) and see what other users and contributors think. @@ -100,7 +102,7 @@ Underneath it is using these frameworks: ## 🗄️ Structure -The project is structured in **features and layers** +The project is structured in **layers with tree-structured feature modules** ```mermaid flowchart TD @@ -112,37 +114,52 @@ flowchart TD desktop --> ui ios --> ui - ui-welcome --> domain-welcome ui-timeline --> domain-timeline + select-server --> domain-authentication subgraph ui + ui-root + ui-signedIn + ui-signedOut ui-timeline - ui-settings - ui-messages + ui-profile ui-notifications - ui-search + landing + select-server + oauth/sign-up/log-in end + ui-root --> ui-signedIn + ui-root --> ui-signedOut + ui-signedOut --> landing + ui-signedOut --> select-server + ui-signedOut --> oauth/sign-up/log-in + ui-signedIn --> ui-timeline + ui-signedIn --> ui-profile + ui-signedIn --> ui-notifications + subgraph domain domain-timeline - domain-welcome + domain-authentication end domain --> data subgraph data + data-repository data-network data-persistence end - data-network --> data-persistence[fa:fa-database data-persistence] + data-repository <--> data-network + data-repository <--> data-persistence[fa:fa-database data-persistence] data-network <--> Y[fa:fa-cloud MastodonAPI] ``` -### 💻 Build +## 💻 Build To build the different apps, checkout the repository and run one of the following commands on your local machine diff --git a/LICENSE.md b/LICENSE.md index bbb3d6f8..1f24e1f7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -630,7 +630,7 @@ attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - MastodonX is a multiplatform client for the Fediverse, built by + Dodo is a multiplatform client for the Fediverse, built by multiple people from the Fediverse. Copyright (C) 2022 Androiddev.social Developers @@ -653,7 +653,7 @@ mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - MastodonX Copyright (C) 2022 Androiddev.social Developers + Dodo Copyright (C) 2022 Androiddev.social Developers This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index bc6ab758..d00d913c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -# MastodonX -[![CC-BY license](https://img.shields.io/badge/License-CC--BY-blue.svg)](https://creativecommons.org/licenses/by-nd/4.0) -![CI](https://github.com/AndroidDev-social/MastodonCompose/actions/workflows/continuous-delivery-pipeline.yml/badge.svg) +# Dodo +[![GNU GPL-3.0](https://img.shields.io/github/license/thebino/MastodonCompose)](https://img.shields.io/github/license/thebino/MastodonCompose) +![CI](https://github.com/AndroidDev-social/DodoForMastodon/actions/workflows/continuous-delivery-pipeline.yml/badge.svg) A multiplatform Mastodon client written in [Kotlin](kotlinlang.org) for the amazing [androiddev.social](https://androiddev.social) community and everyone else who enjoys #Fediverse -[F-Droid] -[Google Play] -[Apple Appstore] +[Join our Slack](https://join.slack.com/t/androiddev-social/shared_invite/zt-1jchjo9kz-_Q_I02QWeenpya10Is6trQ) --- @@ -14,40 +12,38 @@ A multiplatform Mastodon client written in [Kotlin](kotlinlang.org) for the amaz The app is not published nor ready for use. Later on it will probably just be installed from any of the available sources. +[F-Droid] +[Google Play] +[Apple Appstore] + ## Contribution +This is a free and open project and lives from contributions of the community. + See our [Contribution Guidelines](CONTRIBUTING.md) -## MVP Roadmap -Building an MVP with base functionality for Desktop and Android +## MVP + +A MVP (Minimum viable product) is a similified version of a product with only some base funcionality. This is often used to prove a concept or set the baseline of a project. -Progress of MVP can be found [here](https://github.com/AndroidDev-social/MastodonCompose/milestones) +### Roadmap - * Sign up + * *Sign up* a new account * Select an instance [joinmastodon servers](https://joinmastodon.org/de/servers) - * Sign in with credentials + * *Sign in* with credentials * Browse *local* timeline * Create a Toot! * Log out -## MVP contributions - -Before tons of developers pour in to start contributing, it would be nice to get the codebase into a stable working condition with some sort of consistent architecture and design. In order to do this it would be more optimal to limit the # of devs working on each task under the MVP roadmap. Each task can be picked up by a single dev who does the full end-to-end functionality. Or, 2-3 devs can split up the work by having one person pick up the data/api layer, one on android and one on desktop. This small group can act like it's own "sprint team" and collaborate closely to split up the work and coordinate efforts to avoid duplicating effort. Since only one person can be assigned an issue, that person can be the feature "lead" and the other 1-2 devs can add a comment to the issue as the other contributors. - -## Non-MVP contributions +Check out [the Progress](https://github.com/AndroidDev-social/DodoForMastodon/milestones) -There is plenty of [other issues to work on outside of MVP](https://github.com/AndroidDev-social/MastodonCompose/issues) and these can be started by any contributor. Please assign the issue to yourself for visibility. -Alternatively, there can be contributions made that aren't code related. -- Innovative ideas for possible features that don't exist in other existing clients that [require discussion here](https://github.com/AndroidDev-social/MastodonCompose/discussions/categories/ideas) -- General question, gotchas and other discussions [here](https://github.com/AndroidDev-social/MastodonCompose/discussions/categories/general) -- Create new Issues/Features for post MVP. (e.g. Material You support, animations, V2 functionality, migrations, etc) ## License -MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along with MastodonX. If not, see . +You should have received a copy of the GNU General Public License along with Dodo. If not, see . diff --git a/app-android/build.gradle.kts b/app-android/build.gradle.kts index ac7132dd..501a582d 100644 --- a/app-android/build.gradle.kts +++ b/app-android/build.gradle.kts @@ -2,15 +2,8 @@ plugins { id("com.android.application") kotlin("android") id("org.jetbrains.compose") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("kotlin-parcelize") + id("social.androiddev.code-quality") } val targetSDKVersion: Int by rootProject.extra @@ -18,7 +11,7 @@ val minSDKVersion: Int by rootProject.extra val compileSDKVersion: Int by rootProject.extra android { - namespace = "social.androiddev.mastodon" + namespace = "social.androiddev.dodo" compileSdk = compileSDKVersion defaultConfig { @@ -39,10 +32,15 @@ android { } dependencies { - implementation(projects.ui.welcome) + implementation(projects.ui.root) implementation(projects.ui.common) implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.androidx.activity.compose) implementation(libs.androidx.compose.foundation) + implementation(projects.di) + implementation(libs.io.insert.koin.core) + implementation(libs.io.insert.koin.android) + implementation(libs.com.arkivanov.decompose) + implementation(libs.com.arkivanov.decompose.extensions.compose.jetbrains) } diff --git a/app-android/src/main/AndroidManifest.xml b/app-android/src/main/AndroidManifest.xml index b71a7ccc..801ec138 100644 --- a/app-android/src/main/AndroidManifest.xml +++ b/app-android/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + android:name="social.androiddev.dodo.MainActivity"> diff --git a/app-android/src/main/kotlin/social/androiddev/dodo/DodoApplication.kt b/app-android/src/main/kotlin/social/androiddev/dodo/DodoApplication.kt new file mode 100644 index 00000000..d25449c0 --- /dev/null +++ b/app-android/src/main/kotlin/social/androiddev/dodo/DodoApplication.kt @@ -0,0 +1,28 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.dodo + +import android.app.Application +import org.koin.android.ext.koin.androidContext +import org.koin.android.ext.koin.androidLogger +import org.koin.core.context.startKoin +import social.androiddev.common.di.appModule +import social.androiddev.dodo.di.androidModule + +class DodoApplication : Application() { + override fun onCreate() { + super.onCreate() + startKoin { + androidContext(this@DodoApplication) + androidLogger() + modules(appModule() + androidModule) + } + } +} diff --git a/app-android/src/main/kotlin/social/androiddev/dodo/MainActivity.kt b/app-android/src/main/kotlin/social/androiddev/dodo/MainActivity.kt new file mode 100644 index 00000000..fecd1f51 --- /dev/null +++ b/app-android/src/main/kotlin/social/androiddev/dodo/MainActivity.kt @@ -0,0 +1,39 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.dodo + +import android.os.Bundle +import androidx.activity.compose.setContent +import androidx.appcompat.app.AppCompatActivity +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.defaultComponentContext +import social.androiddev.common.theme.DodoTheme +import social.androiddev.root.composables.RootContent +import social.androiddev.root.navigation.DefaultRootComponent + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Create the root component before starting Compose + val root = DefaultRootComponent(componentContext = defaultComponentContext()) + + setContent { + DodoTheme { + RootContent( + component = root, + modifier = Modifier.fillMaxSize(), + ) + } + } + } +} diff --git a/app-android/src/main/kotlin/social/androiddev/dodo/di/AndroidAppModule.kt b/app-android/src/main/kotlin/social/androiddev/dodo/di/AndroidAppModule.kt new file mode 100644 index 00000000..558d7e91 --- /dev/null +++ b/app-android/src/main/kotlin/social/androiddev/dodo/di/AndroidAppModule.kt @@ -0,0 +1,18 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.dodo.di + +import org.koin.dsl.module + +/** + * The Dodo Android app Koin module holding koin definitions + * specific to the android app + */ +val androidModule = module { } diff --git a/app-android/src/main/kotlin/social/androiddev/mastodon/MainActivity.kt b/app-android/src/main/kotlin/social/androiddev/mastodon/MainActivity.kt deleted file mode 100644 index ff6ced98..00000000 --- a/app-android/src/main/kotlin/social/androiddev/mastodon/MainActivity.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of MastodonX. - * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . - */ -package social.androiddev.mastodon - -import WelcomeScreen -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Modifier -import social.androiddev.common.theme.MastodonTheme - -class MainActivity : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - MastodonTheme { - WelcomeScreen( - modifier = Modifier.fillMaxSize(), - navigateToSignUp = {}, - navigateToLogin = {}, - ) - } - } - } -} diff --git a/app-android/src/main/res/values/strings.xml b/app-android/src/main/res/values/strings.xml index d1c05b26..b44bd85a 100644 --- a/app-android/src/main/res/values/strings.xml +++ b/app-android/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ - MastodonCompose - \ No newline at end of file + Dodo + Dodo for Mastodon + diff --git a/app-desktop/build.gradle.kts b/app-desktop/build.gradle.kts index d812caea..9275c19e 100644 --- a/app-desktop/build.gradle.kts +++ b/app-desktop/build.gradle.kts @@ -3,15 +3,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) id("org.jetbrains.compose") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") } kotlin { @@ -23,9 +15,10 @@ kotlin { named("jvmMain") { dependencies { implementation(compose.desktop.currentOs) - implementation(projects.ui.timeline) + implementation(projects.ui.root) implementation(projects.ui.common) - implementation(projects.ui.welcome) + implementation(libs.com.arkivanov.decompose) + implementation(libs.com.arkivanov.decompose.extensions.compose.jetbrains) } } } @@ -37,13 +30,13 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "MastodonCompose" + packageName = "Dodo" packageVersion = "1.0.0" modules("java.sql") windows { - menuGroup = "Mastodon Compose" + menuGroup = "Dodo" // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html upgradeUuid = "ccfe9aed-16ce-42e3-9fd9-92720794b2c2" } diff --git a/app-desktop/src/jvmMain/kotlin/social/androiddev/desktop/Main.kt b/app-desktop/src/jvmMain/kotlin/social/androiddev/desktop/Main.kt index d87c414b..1b3e9c84 100644 --- a/app-desktop/src/jvmMain/kotlin/social/androiddev/desktop/Main.kt +++ b/app-desktop/src/jvmMain/kotlin/social/androiddev/desktop/Main.kt @@ -1,36 +1,49 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.desktop -import WelcomeScreen import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import androidx.compose.ui.window.rememberWindowState -import social.androiddev.common.theme.MastodonTheme +import com.arkivanov.decompose.DefaultComponentContext +import com.arkivanov.decompose.extensions.compose.jetbrains.lifecycle.LifecycleController +import com.arkivanov.essenty.lifecycle.LifecycleRegistry +import social.androiddev.common.theme.DodoTheme +import social.androiddev.root.composables.RootContent +import social.androiddev.root.navigation.DefaultRootComponent fun main() { + + val lifecycle = LifecycleRegistry() + // Create the root component before starting Compose + val root = DefaultRootComponent( + componentContext = DefaultComponentContext(lifecycle) + ) + application { val windowState = rememberWindowState() + // Bind the registry to the lifecycle of the window + LifecycleController(lifecycle, windowState) + Window( onCloseRequest = ::exitApplication, state = windowState, - title = "MastodonX" + title = "Dodo" ) { - MastodonTheme { - WelcomeScreen( + DodoTheme { + RootContent( + component = root, modifier = Modifier.fillMaxSize(), - navigateToSignUp = {}, - navigateToLogin = {}, ) } } diff --git a/build-logic/convention-plugins/build.gradle.kts b/build-logic/convention-plugins/build.gradle.kts new file mode 100644 index 00000000..573a9deb --- /dev/null +++ b/build-logic/convention-plugins/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + `kotlin-dsl` +} + +gradlePlugin { + plugins { + register("CodeQuality") { + id = "social.androiddev.code-quality" + implementationClass = "social.androiddev.plugins.CodeQualityPlugin" + } + } +} + +dependencies { + implementation(libs.com.diffplug.spotless.gradle.plugin) +} \ No newline at end of file diff --git a/build-logic/convention-plugins/src/main/kotlin/social/androiddev/plugins/CodeQualityPlugin.kt b/build-logic/convention-plugins/src/main/kotlin/social/androiddev/plugins/CodeQualityPlugin.kt new file mode 100644 index 00000000..c45451ed --- /dev/null +++ b/build-logic/convention-plugins/src/main/kotlin/social/androiddev/plugins/CodeQualityPlugin.kt @@ -0,0 +1,21 @@ +package social.androiddev.plugins + +import com.diffplug.gradle.spotless.SpotlessExtension +import com.diffplug.gradle.spotless.SpotlessPlugin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import java.io.File + +class CodeQualityPlugin : Plugin { + override fun apply(target: Project) = with(target) { + pluginManager.apply(SpotlessPlugin::class.java) + extensions.configure { + kotlin { + target("src/*/kotlin/**/*.kt") + ktlint("0.43.2") + licenseHeaderFile(File(rootDir, "copyright.txt")) + } + } + } +} \ No newline at end of file diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..9737411f --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,16 @@ +rootProject.name = "build-logic" + +dependencyResolutionManagement { + repositories { + google() + gradlePluginPortal() + mavenCentral() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} + +include(":convention-plugins") \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ff2121f1..a8154125 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,15 +18,6 @@ buildscript { } } -allprojects { - repositories { - google() - mavenCentral() - mavenLocal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - } -} - // Workaround for: // // The Kotlin source set androidAndroidTestRelease was configured but not added to any diff --git a/copyright.kt b/copyright.kt deleted file mode 100644 index 1260be97..00000000 --- a/copyright.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * This file is part of MastodonX. - * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . - */ diff --git a/copyright.txt b/copyright.txt new file mode 100644 index 00000000..890a8da7 --- /dev/null +++ b/copyright.txt @@ -0,0 +1,9 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ diff --git a/data/network/build.gradle.kts b/data/network/build.gradle.kts index 19d24a80..50218472 100644 --- a/data/network/build.gradle.kts +++ b/data/network/build.gradle.kts @@ -2,15 +2,7 @@ plugins { id("kotlin-multiplatform") id("com.android.library") kotlin("plugin.serialization") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") } val targetSDKVersion: Int by rootProject.extra @@ -55,6 +47,7 @@ kotlin { implementation(libs.io.ktor.serialization.kotlinx.json) implementation(libs.io.ktor.client.content.negotiation) implementation(libs.org.jetbrains.kotlinx.serialization.json) + implementation(libs.io.insert.koin.core) } } @@ -128,6 +121,7 @@ kotlin { implementation(libs.org.jetbrains.kotlin.test.common) implementation(libs.org.jetbrains.kotlin.test.annotations.common) implementation(libs.org.jetbrains.kotlinx.coroutines.test) + implementation(libs.io.insert.koin.test) } } } diff --git a/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidPlatform.kt b/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidPlatform.kt index 4486699d..d33c1437 100644 --- a/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidPlatform.kt +++ b/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidPlatform.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidUrlStream.kt b/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidUrlStream.kt index ebe87f7e..06f1e4be 100644 --- a/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidUrlStream.kt +++ b/data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidUrlStream.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt index 7b7f0b9d..4399503a 100644 --- a/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/androidTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApi.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApi.kt index d227f9b2..11bee556 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApi.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApi.kt @@ -1,21 +1,57 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network +import social.androiddev.common.network.model.Application import social.androiddev.common.network.model.Instance +import social.androiddev.common.network.model.NewOauthApplication interface MastodonApi { + + /** + * Register client applications that can be used to obtain OAuth tokens. + * + * @see https://docs.joinmastodon.org/methods/apps/#create-an-application + * + * @param clientName A name for your application + * @param redirectUris Where the user should be redirected after authorization. + * To display the authorization code to the user instead of redirecting to a web page, + * use urn:ietf:wg:oauth:2.0:oob in this parameter. + * @param scopes Space separated list of scopes. If none is provided, defaults to read. + * @param website An optional URL to the homepage of your app + * + * @return Application with `client_id` and `client_secret` + */ + suspend fun createApplication( + domain: String, + clientName: String, + redirectUris: String, + scopes: String, + website: String?, + ): Result + /** - * Fetch information about the server + * Confirm that the app’s OAuth2 credentials work. + * + * @see https://docs.joinmastodon.org/methods/apps/#verify_credentials + * + * @return an `application` if a valid token was provides in the authorization header + */ + suspend fun verifyApplication(): Result + + /** + * Fetch general information about the server * * @see https://docs.joinmastodon.org/methods/instance/ + * + * @return an instance entity */ suspend fun getInstance(domain: String? = null): Result } diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt deleted file mode 100644 index 163683c7..00000000 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiImpl.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of MastodonX. - * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . - */ -package social.androiddev.common.network - -import io.ktor.client.HttpClient -import io.ktor.client.call.body -import io.ktor.client.plugins.ResponseException -import io.ktor.client.request.get -import io.ktor.serialization.JsonConvertException -import kotlinx.serialization.SerializationException -import social.androiddev.common.network.model.Instance - -class MastodonApiImpl( - private val httpClient: HttpClient, - -) : MastodonApi { - override suspend fun getInstance(domain: String?): Result { - return try { - Result.success( - httpClient.get("/api/v1/instance") { - domain?.let { - headers.append("domain", domain) - } - }.body() - ) - } catch (exception: SerializationException) { - Result.failure(exception = exception) - } catch (exception: JsonConvertException) { - Result.failure(exception = exception) - } catch (exception: ResponseException) { - Result.failure(exception = exception) - } - } -} diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiKtor.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiKtor.kt new file mode 100644 index 00000000..507b1111 --- /dev/null +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/MastodonApiKtor.kt @@ -0,0 +1,86 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.network + +import io.ktor.client.HttpClient +import io.ktor.client.call.body +import io.ktor.client.plugins.ResponseException +import io.ktor.client.request.forms.formData +import io.ktor.client.request.get +import io.ktor.client.request.headers +import io.ktor.client.request.post +import io.ktor.http.HttpHeaders +import io.ktor.http.URLProtocol +import io.ktor.http.path +import io.ktor.serialization.JsonConvertException +import kotlinx.serialization.SerializationException +import social.androiddev.common.network.model.Application +import social.androiddev.common.network.model.Instance +import social.androiddev.common.network.model.NewOauthApplication +import social.androiddev.common.network.util.runCatchingIgnoreCancelled + +internal class MastodonApiKtor( + private val httpClient: HttpClient, +) : MastodonApi { + + override suspend fun createApplication( + domain: String, + clientName: String, + redirectUris: String, + scopes: String, + website: String? + ): Result { + return runCatchingIgnoreCancelled { + httpClient.post { + url { + protocol = URLProtocol.HTTPS + host = domain + path("/api/v1/apps") + } + formData { + append("client_name", clientName) + append("redirect_uris", redirectUris) + append("scopes", scopes) + if (website != null) { + append("website", website) + } + } + }.body() + } + } + + override suspend fun verifyApplication(): Result { + return runCatchingIgnoreCancelled { + httpClient.get("/api/v1/apps/verify_credentials") { + headers { + append(HttpHeaders.Authorization, "testAuthorization") + } + }.body() + } + } + + override suspend fun getInstance(domain: String?): Result { + return try { + Result.success( + httpClient.get("/api/v1/instance") { + domain?.let { + headers.append("domain", domain) + } + }.body() + ) + } catch (exception: SerializationException) { + Result.failure(exception = exception) + } catch (exception: JsonConvertException) { + Result.failure(exception = exception) + } catch (exception: ResponseException) { + Result.failure(exception = exception) + } + } +} diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/Platform.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/Platform.kt index 4c6e0781..d6d88ee4 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/Platform.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/Platform.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/UrlStream.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/UrlStream.kt index c814009b..c5aceb00 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/UrlStream.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/UrlStream.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/di/NetworkModule.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/di/NetworkModule.kt new file mode 100644 index 00000000..95ddbb4e --- /dev/null +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/di/NetworkModule.kt @@ -0,0 +1,42 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.network.di + +import io.ktor.client.HttpClient +import io.ktor.client.plugins.defaultRequest +import io.ktor.http.URLProtocol +import org.koin.core.module.Module +import org.koin.core.module.dsl.singleOf +import org.koin.dsl.module +import social.androiddev.common.network.MastodonApi +import social.androiddev.common.network.MastodonApiKtor + +/** + * Koin module containing all koin/bean definitions for + * network/api related classes + */ +val networkModule: Module = module { + + singleOf { + HttpClient { + defaultRequest { + url { + protocol = URLProtocol.HTTPS + } + } + } + } + + single { + MastodonApiKtor( + httpClient = get(), + ) + } +} diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Account.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Account.kt index b690439a..2c1882f2 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Account.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Account.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Activity.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Activity.kt index 15b6f355..92dd38ac 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Activity.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Activity.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Announcement.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Announcement.kt index 4f5b565e..981a89b8 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Announcement.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Announcement.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AnnouncementReaction.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AnnouncementReaction.kt index 93186e48..9de8d270 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AnnouncementReaction.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AnnouncementReaction.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Application.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Application.kt index 6d3acf47..88eeb2cc 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Application.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Application.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model @@ -17,13 +17,23 @@ import kotlinx.serialization.Serializable */ @Serializable data class Application( - // required attributes - @SerialName("name") val name: String, + val name: String, + @SerialName("vapid_key") val vapidKey: String, + // optional attributes - @SerialName("website") val website: String? = null, - @SerialName("vapid_key") val vapidKey: String? = null, + val website: String? = null, +) + +@Serializable +data class NewOauthApplication( + val id: String, + val name: String, + @SerialName("vapid_key") val vapidKey: String, // client attributes - @SerialName("client_id") val clientId: String? = null, - @SerialName("client_secret") val clientSecret: String? = null + @SerialName("client_id") val clientId: String, + @SerialName("client_secret") val clientSecret: String, + + // optional attributes + val website: String? = null, ) diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Attachment.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Attachment.kt index 8730ffbc..d349ba0b 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Attachment.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Attachment.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Card.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Card.kt index 2cc77794..f6e26c2e 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Card.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Card.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Context.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Context.kt index 7a58cfde..9c7fd69f 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Context.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Context.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Conversation.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Conversation.kt index 76325f88..2b9beb4a 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Conversation.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Conversation.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Emoji.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Emoji.kt index a4e2a61d..5acc7de2 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Emoji.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Emoji.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Error.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Error.kt index a8f1c6cc..31d242a6 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Error.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Error.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/FeaturedTag.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/FeaturedTag.kt index f3496167..fefbe216 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/FeaturedTag.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/FeaturedTag.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Field.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Field.kt index 41adeb5c..25e34b05 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Field.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Field.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Filter.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Filter.kt index 9ef35d69..c0020fd9 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Filter.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Filter.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/History.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/History.kt index b60fa0c3..5ad5d4d1 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/History.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/History.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/IdentityProof.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/IdentityProof.kt index a6642542..76a236eb 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/IdentityProof.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/IdentityProof.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Instance.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Instance.kt index 534aaf53..2ee1bfe6 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Instance.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Instance.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Marker.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Marker.kt index f294e265..22e323f1 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Marker.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Marker.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Mention.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Mention.kt index 8e2401bb..e5e2e1d1 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Mention.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Mention.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Notification.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Notification.kt index 15ee445b..359c0873 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Notification.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Notification.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Poll.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Poll.kt index e72abeeb..5150f12d 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Poll.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Poll.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Preferences.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Preferences.kt index 337ab638..208f9f0e 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Preferences.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Preferences.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/PushSubscription.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/PushSubscription.kt index 3c37ab4c..757377f2 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/PushSubscription.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/PushSubscription.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Source.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Source.kt index 081a87da..7a9dd256 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Source.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Source.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt index 31e8b136..d2bed412 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Tag.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Tag.kt index 378a66c2..0aa8cf78 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Tag.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Tag.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/UserList.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/UserList.kt index 8ce42e2a..43f3490e 100644 --- a/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/UserList.kt +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/model/UserList.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonMain/kotlin/social/androiddev/common/network/util/RunCatching.kt b/data/network/src/commonMain/kotlin/social/androiddev/common/network/util/RunCatching.kt new file mode 100644 index 00000000..f7c4d9bb --- /dev/null +++ b/data/network/src/commonMain/kotlin/social/androiddev/common/network/util/RunCatching.kt @@ -0,0 +1,78 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.network.util + +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.TimeoutCancellationException + +/** + * Executes [block] and returns the [Result]. If an error occurs then [block] will be + * retried a maximum of [maxRetry] times. Caution - this should typically be used only on + * worker/background threads. + */ +inline fun runCatchingRetry(maxRetry: Int, block: () -> T): Result { + var result: Result + var retryCount = 0 + do { + result = runCatching(block) + retryCount++ + } while (result.isFailure && retryCount <= maxRetry) + return result +} + +/** + * Executes [block] and unwraps the [Result]. If a failure occurs then [default] will be returned. + */ +inline fun runOrDefault(block: () -> T, default: (Throwable) -> T): T = + runCatching(block).fold( + onSuccess = { it }, + onFailure = default, + ) + +/** + * Executes [block] and returns a [Result]. All exceptions thrown are + * returned as a [Result.Failure] except a [kotlinx.coroutines.CancellationException] + * which will be rethrown. + * + * See [Throwable.isCancellation] for more info. + */ +inline fun runCatchingIgnoreCancelled(block: () -> T): Result = runCatching(block) + .onFailure { error -> + if (error.isCancellation()) { + throw error + } + } + +/** + * Executes [block] and returns the [Result]. If an error occurs then [block] will be + * retried a maximum of [maxRetry] times. Caution - this should typically be used only on + * worker/background threads. This is slightly different from [runCatchingRetry] in that + * a [CancellationException] will not be caught and will be rethrown. + * + * See [Throwable.isCancellation] for more info. + */ +inline fun runCatchingRetryIgnoreCanceled(maxRetry: Int, block: () -> T): Result { + var result: Result + var retryCount = 0 + do { + result = runCatchingIgnoreCancelled(block) + retryCount++ + } while (result.isFailure && retryCount <= maxRetry) + return result +} + +/** + * Extension on a [Throwable] that returns true if it is of type [CancellationException]. Typically, + * this type of Exception should _not_ be caught and should be bubbled up. Coroutines internally + * uses [CancellationException] for cancelling of work, and they are ignored by all handlers by default. + * + * @See https://kotlinlang.org/docs/exception-handling.html#cancellation-and-exceptions + */ +fun Throwable.isCancellation() = this is CancellationException && this !is TimeoutCancellationException diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt index ab36f34a..1513d27c 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt index 11ffb504..455abb09 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/MastodonApiTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network @@ -22,53 +22,134 @@ import io.ktor.utils.io.ByteReadChannel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import social.androiddev.common.readBinaryResource import kotlin.test.Test -import kotlin.test.assertFalse +import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue @OptIn(ExperimentalCoroutinesApi::class) class MastodonApiTests { + /** + * @see https://docs.joinmastodon.org/methods/apps/#200-ok + */ @Test - fun `Instance request should fail with invalid response`() = runTest { + fun `create a new application with valid response should succeed`() = runTest { // given - val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_instance_invalid.json") - println(byteArray.decodeToString()) + val content: String = validApplicationCreation - val mastodonApi = MastodonApiImpl( + val mastodonApi: MastodonApi = MastodonApiKtor( httpClient = createMockClient( - statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = byteArray.decodeToString()) + statusCode = HttpStatusCode.Unauthorized, + content = ByteReadChannel(text = content) ) ) // when - val result = mastodonApi.getInstance("") + val result = mastodonApi.createApplication( + domain = "androiddev.social", + clientName = "Dodo", + redirectUris = "https://androiddev.social/oauth", + scopes = "read", + website = "https://androiddev.social" + ) // then - assertFalse(actual = result.isSuccess) - assertNull(actual = result.getOrNull()?.uri) + assertTrue(actual = result.isSuccess) + assertNotNull(actual = result.getOrNull()) + assertEquals(actual = result.getOrNull()?.id, expected = "563419") + assertEquals(actual = result.getOrNull()?.name, expected = "test app") + assertEquals(actual = result.getOrNull()?.vapidKey, expected = "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=") + + assertEquals(expected = "TWhM-tNSuncnqN7DBJmoyeLnk6K3iJJ71KKXxgL1hPM", actual = result.getOrNull()?.clientId) + assertEquals(expected = "ZEaFUFmF0umgBX1qKJDjaU99Q31lDkOU8NutzTOoliw", actual = result.getOrNull()?.clientSecret) + assertEquals(expected = "https://androiddev.social", actual = result.getOrNull()?.website) } + /** + * @see https://docs.joinmastodon.org/methods/apps/#422-unprocessable-entity + */ @Test - fun `Instance request should succeed with required field response`() = runTest { + fun `create a new application with missing parameter should fail`() = runTest { // given - val byteArray: ByteArray = readBinaryResource("src/commonTest/resources/response_instance_valid.json") - println(byteArray.decodeToString()) + val content = """"error": "Validation failed: Redirect URI must be an absolute URI."""" + val mastodonApi = MastodonApiKtor( + httpClient = createMockClient( + statusCode = HttpStatusCode.UnprocessableEntity, content = ByteReadChannel(text = content) + ) + ) + + // when + val result = mastodonApi.createApplication( + domain = "androiddev.social", + clientName = "Dodo", + redirectUris = "https://androiddev.social/oauth", + scopes = "read", + website = "https://androiddev.social" + ) + + // then + assertTrue(actual = result.isFailure) + assertNull(actual = result.getOrNull()) + } - val mastodonApi = MastodonApiImpl( + /** + * @see https://docs.joinmastodon.org/methods/apps/#200-ok-1 + */ + @Test + fun `verify oauth credentials for new application should succeed`() = runTest { + // given + val content: String = applicationVerificationValid + val mastodonApi = MastodonApiKtor( httpClient = createMockClient( - statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = byteArray.decodeToString()) + statusCode = HttpStatusCode.OK, content = ByteReadChannel(text = content) ) ) // when - val result = mastodonApi.getInstance("") + val result = mastodonApi.verifyApplication() + + // then + assertTrue(actual = result.isSuccess) + } + + /** + * @see https://docs.joinmastodon.org/methods/apps/#401-unauthorized + */ + @Test + fun `verify oauth credentials for new application with invalid token should fail`() = runTest { + // given + val content: String = applicationVerificationFailed + val mastodonApi = MastodonApiKtor( + httpClient = createMockClient( + statusCode = HttpStatusCode.Unauthorized, content = ByteReadChannel(text = content) + ) + ) + + // when + val result = mastodonApi.verifyApplication() + + // then + assertTrue(actual = result.isFailure) + } + + /** + * @see https://docs.joinmastodon.org/methods/instance/#200-ok + */ + @Test + fun `view server information should succeed`() = runTest { + val content: String = serverInformationValid + val mastodonApi = MastodonApiKtor( + httpClient = createMockClient( + statusCode = HttpStatusCode.OK, content = ByteReadChannel(text = content) + ) + ) + + // when + val result = mastodonApi.getInstance("androiddev.social") // then assertTrue(actual = result.isSuccess) - assertNotNull(actual = result.getOrNull()?.uri) } private fun createMockClient( @@ -78,7 +159,9 @@ class MastodonApiTests { return HttpClient( MockEngine { respond( - content = content, status = statusCode, headers = headersOf(HttpHeaders.ContentType, "application/json") + content = content, + status = statusCode, + headers = headersOf(HttpHeaders.ContentType, "application/json") ) } ) { @@ -94,4 +177,160 @@ class MastodonApiTests { } } } + + private val validInstanceResponse = """ + { + "uri": "mastodon.social", + "title": "Mastodon", + "description": "Server run by the main developers of the project \"🐘\" It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!", + "short_description": "Server run by the main developers of the project \"🐘\" It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!", + "email": "staff@mastodon.social", + "version": "3.0.1", + "languages": + [ + "en" + ], + "registrations": true, + "approval_required": false, + "invites_enabled": true, + "urls": + { + "streaming_api": "wss://mastodon.social" + }, + "stats": + { + "user_count": 415526, + "status_count": 17085754, + "domain_count": 11834 + }, + "user_count": 415526, + "thumbnail": "https://files.mastodon.social/site_uploads/files/000/000/001/original/vlcsnap-2018-08-27-16h43m11s127.png", + "contact_account": + { + "id": "1", + "username": "Gargron", + "acct": "Gargron", + "display_name": "Eugen", + "locked": false, + "bot": false, + "created_at": "2016-03-16T14:34:26.392Z", + "note": "

Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.

", + "url": "https://mastodon.social/@Gargron", + "avatar": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg", + "avatar_static": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg", + "header": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png", + "header_static": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png", + "followers_count": 317112, + "following_count": 453, + "statuses_count": 60903, + "last_status_at": "2019-11-26T21:14:44.522Z", + "emojis": [], + "discoverable": false, + "fields": + [ + { + "name": "Patreon", + "value": "https://www.patreon.com/mastodonhttps://zeonfederated.com It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!", + "short_description": "Server run by the main developers of the project \"🐘\" It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!", + "email": "staff@mastodon.social", + "version": "3.0.1", + "languages": + [ + "en" + ], + "registrations": true, + "approval_required": false, + "invites_enabled": true, + "urls": + { + "streaming_api": "wss://mastodon.social" + }, + "stats": + { + "user_count": 415526, + "status_count": 17085754, + "domain_count": 11834 + }, + "user_count": 415526, + + "thumbnail": "https://files.mastodon.social/site_uploads/files/000/000/001/original/vlcsnap-2018-08-27-16h43m11s127.png", + "contact_account": + { + "id": "1", + "username": "Gargron", + "acct": "Gargron", + "display_name": "Eugen", + "locked": false, + "bot": false, + "created_at": "2016-03-16T14:34:26.392Z", + "note": "

Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.

", + "url": "https://mastodon.social/@Gargron", + "avatar": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg", + "avatar_static": "https://files.mastodon.social/accounts/avatars/000/000/001/original/d96d39a0abb45b92.jpg", + "header": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png", + "header_static": "https://files.mastodon.social/accounts/headers/000/000/001/original/c91b871f294ea63e.png", + "followers_count": 317112, + "following_count": 453, + "statuses_count": 60903, + "last_status_at": "2019-11-26T21:14:44.522Z", + "emojis": [], + "discoverable": false, + "fields": + [ + { + "name": "Patreon", + "value": "
https://www.patreon.com/mastodonhttps://zeonfederated.com. + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ActivityTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ActivityTests.kt index f1f34651..d679f581 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ActivityTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ActivityTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementReactionTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementReactionTests.kt index 3bb1d7a8..aa580561 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementReactionTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementReactionTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementTests.kt index dc91abaa..047c4114 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AnnouncementTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ApplicationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ApplicationTests.kt index 72ba05b9..aacb1063 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ApplicationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ApplicationTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model @@ -21,20 +21,23 @@ class ApplicationTests { // given val json = """ { + "id": "123", "name": "test app", + "client_id": "bgorLrj8s1CeX_QghuI5NhVsestPXkTyyCBuaSCeYj4", + "client_secret": "lNmvmMA8_deuGdQOsuZ_dqE7zxQOoociwfTlHB-L1C0", "website": null, "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" } """.trimIndent() // when - val application = Json.decodeFromString(json) + val application = Json.decodeFromString(json) // then assertEquals(expected = "test app", actual = application.name) assertNull(actual = application.website) assertEquals(expected = "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=", actual = application.vapidKey) - assertNull(actual = application.clientId) - assertNull(actual = application.clientSecret) + assertEquals(expected = "bgorLrj8s1CeX_QghuI5NhVsestPXkTyyCBuaSCeYj4", actual = application.clientId) + assertEquals(expected = "lNmvmMA8_deuGdQOsuZ_dqE7zxQOoociwfTlHB-L1C0", actual = application.clientSecret) } } diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AttachmentTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AttachmentTests.kt index 7968272f..fd649f51 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AttachmentTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AttachmentTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/CardTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/CardTests.kt index deddc523..f75bee07 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/CardTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/CardTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt index 46a4a9ba..b94dce22 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt index c4b53db7..dbd29fdf 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/EmojiTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/EmojiTests.kt index 3f7d7315..cf9150ac 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/EmojiTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/EmojiTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ErrorTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ErrorTests.kt index bf6a4648..176c494e 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ErrorTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ErrorTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FeatureTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FeatureTests.kt index e2fe4b6e..5621f89e 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FeatureTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FeatureTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FilterTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FilterTests.kt index baf99135..ffb2957b 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FilterTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FilterTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/HistoryTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/HistoryTests.kt index cdd8f1c2..a65d7d15 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/HistoryTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/HistoryTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/IdentityProofTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/IdentityProofTests.kt index 6b93a695..648fdb2e 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/IdentityProofTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/IdentityProofTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MarkerTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MarkerTests.kt index b46bbf53..b12ef926 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MarkerTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MarkerTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MentionTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MentionTests.kt index f3d8b0db..3d98ad55 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MentionTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/MentionTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt index af250305..4360644b 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PollTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PollTests.kt index 8034b45d..0b3c4a48 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PollTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PollTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PreferencesTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PreferencesTests.kt index 0e5bec4a..8c545619 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PreferencesTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PreferencesTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PushSubscriptionTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PushSubscriptionTests.kt index 347019b5..715af212 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PushSubscriptionTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PushSubscriptionTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt index ab6a89e4..78b4b92e 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/TagTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/TagTests.kt index 33229ab3..c14b8d3c 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/TagTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/TagTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/UserListTests.kt b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/UserListTests.kt index 331cf8dc..e4a87db5 100644 --- a/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/UserListTests.kt +++ b/data/network/src/commonTest/kotlin/social/androiddev/common/network/model/UserListTests.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network.model diff --git a/data/network/src/commonTest/resources/response_context_required.json b/data/network/src/commonTest/resources/response_context_required.json index 9920d577..41f3bfca 100644 --- a/data/network/src/commonTest/resources/response_context_required.json +++ b/data/network/src/commonTest/resources/response_context_required.json @@ -24,7 +24,8 @@ "application": { "name": "Web", - "website": null + "website": null, + "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" }, "account": { @@ -114,7 +115,8 @@ "application": { "name": "Web", - "website": null + "website": null, + "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" }, "account": { diff --git a/data/network/src/commonTest/resources/response_conversation_required.json b/data/network/src/commonTest/resources/response_conversation_required.json index 37cf4697..449a05ec 100644 --- a/data/network/src/commonTest/resources/response_conversation_required.json +++ b/data/network/src/commonTest/resources/response_conversation_required.json @@ -92,7 +92,8 @@ "application": { "name": "Web", - "website": null + "website": null, + "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" }, "account": { diff --git a/data/network/src/commonTest/resources/response_instance_invalid.json b/data/network/src/commonTest/resources/response_instance_invalid.json deleted file mode 100644 index e9aa9ce7..00000000 --- a/data/network/src/commonTest/resources/response_instance_invalid.json +++ /dev/null @@ -1 +0,0 @@ -{"error":"Access denied. Please check your credentials."} \ No newline at end of file diff --git a/data/network/src/commonTest/resources/response_notification_required.json b/data/network/src/commonTest/resources/response_notification_required.json index f389f9a5..fbd8592c 100644 --- a/data/network/src/commonTest/resources/response_notification_required.json +++ b/data/network/src/commonTest/resources/response_notification_required.json @@ -91,7 +91,8 @@ "application": { "name": "Web", - "website": null + "website": null, + "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" }, "account": { diff --git a/data/network/src/commonTest/resources/response_status_required.json b/data/network/src/commonTest/resources/response_status_required.json index be736b8f..e02ada3c 100644 --- a/data/network/src/commonTest/resources/response_status_required.json +++ b/data/network/src/commonTest/resources/response_status_required.json @@ -21,7 +21,8 @@ "application": { "name": "Web", - "website": null + "website": null, + "vapid_key": "BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=" }, "account": { diff --git a/data/network/src/desktopMain/kotlin/social/androiddev/common/network/Platform.kt b/data/network/src/desktopMain/kotlin/social/androiddev/common/network/Platform.kt index be9df885..e43b87d9 100644 --- a/data/network/src/desktopMain/kotlin/social/androiddev/common/network/Platform.kt +++ b/data/network/src/desktopMain/kotlin/social/androiddev/common/network/Platform.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/desktopMain/kotlin/social/androiddev/common/network/UrlStream.kt b/data/network/src/desktopMain/kotlin/social/androiddev/common/network/UrlStream.kt index ebe87f7e..06f1e4be 100644 --- a/data/network/src/desktopMain/kotlin/social/androiddev/common/network/UrlStream.kt +++ b/data/network/src/desktopMain/kotlin/social/androiddev/common/network/UrlStream.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt index 7b7f0b9d..4399503a 100644 --- a/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/desktopTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common diff --git a/data/network/src/iosMain/kotlin/social/androiddev/common/network/Platform.kt b/data/network/src/iosMain/kotlin/social/androiddev/common/network/Platform.kt index 1c03f5f9..0bf2ad8c 100644 --- a/data/network/src/iosMain/kotlin/social/androiddev/common/network/Platform.kt +++ b/data/network/src/iosMain/kotlin/social/androiddev/common/network/Platform.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/iosMain/kotlin/social/androiddev/common/network/UrlStream.kt b/data/network/src/iosMain/kotlin/social/androiddev/common/network/UrlStream.kt index b8586f9c..1b0c5f32 100644 --- a/data/network/src/iosMain/kotlin/social/androiddev/common/network/UrlStream.kt +++ b/data/network/src/iosMain/kotlin/social/androiddev/common/network/UrlStream.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.network diff --git a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt index 87e47d9e..70fdaf4d 100644 --- a/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt +++ b/data/network/src/iosTest/kotlin/social/androiddev/common/ResourceLoader.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common diff --git a/data/persistence/build.gradle.kts b/data/persistence/build.gradle.kts index 7f3afe18..30b3fc05 100644 --- a/data/persistence/build.gradle.kts +++ b/data/persistence/build.gradle.kts @@ -1,15 +1,15 @@ plugins { id("kotlin-multiplatform") id("com.android.library") -// id("com.squareup.sqldelight") - id("com.diffplug.spotless") version "6.11.0" + id("com.squareup.sqldelight") + id("social.androiddev.code-quality") } -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) + +sqldelight { + database("AuthenticationDatabase") { + packageName = "social.androiddev.common.persistence" + sourceFolders = listOf("sqldelight") } } @@ -90,10 +90,44 @@ kotlin { // testing + named("androidTest") { + dependencies { + implementation(kotlin("test")) + implementation(libs.org.jetbrains.kotlin.test.junit) + implementation(libs.com.squareup.sqldelight.android.driver) + implementation(libs.com.squareup.sqldelight.sqlite.driver) + implementation(libs.org.xerial.sqlite.jdbc) + } + } + named("desktopTest") { + dependencies { + implementation(kotlin("test")) + implementation(libs.org.jetbrains.kotlin.test.junit) + implementation(libs.com.squareup.sqldelight.sqlite.driver) + implementation(libs.org.xerial.sqlite.jdbc) + } + } + val iosX64Test by getting + val iosArm64Test by getting + val iosSimulatorArm64Test by getting + val iosTest by creating { + dependsOn(getByName("commonTest")) + + iosX64Test.dependsOn(this) + iosArm64Test.dependsOn(this) + iosSimulatorArm64Test.dependsOn(this) + dependencies { + implementation(libs.org.jetbrains.kotlinx.coroutines.test) + implementation(libs.com.squareup.sqldelight.native.driver) + } + } named("commonTest") { dependencies { + implementation(kotlin("test")) implementation(libs.org.jetbrains.kotlin.test.common) implementation(libs.org.jetbrains.kotlin.test.annotations.common) + implementation(libs.org.jetbrains.kotlinx.coroutines.test) + implementation(libs.org.xerial.sqlite.jdbc) } } } diff --git a/data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..4f13ecdb --- /dev/null +++ b/data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,20 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver + +actual suspend fun provideDatabaseDriver(schema: SqlDriver.Schema): SqlDriver { + // TODO: replace with AndroidSqliteDriver and inject context + return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> + schema.create(driver = driver) + } +} diff --git a/data/persistence/src/androidTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/androidTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..d2510383 --- /dev/null +++ b/data/persistence/src/androidTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,19 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver + +actual suspend fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { + return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> + schema.create(driver = driver) + } +} diff --git a/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..81c5eda6 --- /dev/null +++ b/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,14 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver + +expect suspend fun provideDatabaseDriver(schema: SqlDriver.Schema): SqlDriver diff --git a/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseWrapper.kt b/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseWrapper.kt new file mode 100644 index 00000000..323e8e87 --- /dev/null +++ b/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseWrapper.kt @@ -0,0 +1,16 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence.authentication + +import social.androiddev.common.persistence.AuthenticationDatabase + +class AuthenticationDatabaseWrapper( + private val instance: AuthenticationDatabase +) diff --git a/data/persistence/src/commonMain/sqldelight/social/androiddev/common/persistence/authentication/Application.sq b/data/persistence/src/commonMain/sqldelight/social/androiddev/common/persistence/authentication/Application.sq new file mode 100644 index 00000000..ac0d1e24 --- /dev/null +++ b/data/persistence/src/commonMain/sqldelight/social/androiddev/common/persistence/authentication/Application.sq @@ -0,0 +1,14 @@ +CREATE TABLE Application ( + instance Text NOT NULL PRIMARY KEY, + client_id Text NOT NULL, + client_secret TEXT NOT NULL +); + +insertApplication: +INSERT OR REPLACE INTO Application(instance, client_id, client_secret)VALUES(?,?,?); + +selectAll: +SELECT * FROM Application; + +deleteAll: +DELETE FROM Application; diff --git a/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..4a187779 --- /dev/null +++ b/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,14 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver + +expect suspend fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver diff --git a/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseTests.kt b/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseTests.kt new file mode 100644 index 00000000..ece6349b --- /dev/null +++ b/data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseTests.kt @@ -0,0 +1,40 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence.authentication + +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import social.androiddev.common.persistence.AuthenticationDatabase +import social.androiddev.common.persistence.provideTestSqlDriver +import kotlin.test.Test +import kotlin.test.assertEquals + +@OptIn(ExperimentalCoroutinesApi::class) +internal class AuthenticationDatabaseTests { + + @Test + fun `insert application into clean database should contain one entry`() = runTest { + // given + val driver = provideTestSqlDriver(AuthenticationDatabase.Schema) + val database = AuthenticationDatabase(driver = driver) + + // when + database.applicationQueries.deleteAll() + database.applicationQueries.insertApplication( + instance = "androiddev.social", + client_id = "test_client_id", + client_secret = "test_client_secret" + ) + + // then + val list = database.applicationQueries.selectAll().executeAsList() + assertEquals(expected = 1, list.size) + } +} diff --git a/data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..2283a37d --- /dev/null +++ b/data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,19 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver + +actual suspend fun provideDatabaseDriver(schema: SqlDriver.Schema): SqlDriver { + return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> + schema.create(driver = driver) + } +} diff --git a/data/persistence/src/desktopTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/desktopTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..d2510383 --- /dev/null +++ b/data/persistence/src/desktopTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,19 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver + +actual suspend fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { + return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> + schema.create(driver = driver) + } +} diff --git a/data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/.gitkeep b/data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..42d58e0e --- /dev/null +++ b/data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,17 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.drivers.native.NativeSqliteDriver + +actual suspend fun provideDatabaseDriver(schema: SqlDriver.Schema): SqlDriver { + return NativeSqliteDriver(schema = schema, name = "authentication.db") +} diff --git a/data/persistence/src/iosTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt b/data/persistence/src/iosTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt new file mode 100644 index 00000000..1dac76a9 --- /dev/null +++ b/data/persistence/src/iosTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt @@ -0,0 +1,17 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.persistence + +import com.squareup.sqldelight.db.SqlDriver +import com.squareup.sqldelight.drivers.native.NativeSqliteDriver + +actual suspend fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { + return NativeSqliteDriver(schema = schema, name = "authentication.db") +} diff --git a/data/repository/build.gradle.kts b/data/repository/build.gradle.kts new file mode 100644 index 00000000..f94055fb --- /dev/null +++ b/data/repository/build.gradle.kts @@ -0,0 +1,102 @@ +plugins { + id("kotlin-multiplatform") + id("com.android.library") + kotlin("plugin.serialization") + id("social.androiddev.code-quality") +} + + +val targetSDKVersion: Int by rootProject.extra +val minSDKVersion: Int by rootProject.extra +val compileSDKVersion: Int by rootProject.extra + +android { + namespace = "social.androiddev.common.repository" + compileSdk = compileSDKVersion + + defaultConfig { + minSdk = minSDKVersion + targetSdk = targetSDKVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} + +kotlin { + jvm("desktop") + android() + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + // shared + val commonMain by getting { + dependencies { + implementation(projects.data.network) + implementation(projects.domain.authentication) + implementation(libs.io.insert.koin.core) + } + } + + + // android + getByName("androidMain") { + dependsOn(commonMain) + dependencies {} + } + + + // desktop + getByName("desktopMain") { + dependencies {} + } + + + // iOS + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + val iosMain by creating { + dependsOn(getByName("commonMain")) + + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) + + dependencies {} + } + + // testing + named("androidTest") { + dependencies { + implementation(kotlin("test")) + implementation(libs.org.jetbrains.kotlin.test.junit) + } + } + named("desktopTest") { + dependencies { + implementation(kotlin("test")) + implementation(libs.org.jetbrains.kotlin.test.junit) + } + } + named("commonTest") { + dependencies { + implementation(kotlin("test")) + implementation(libs.org.jetbrains.kotlin.test.common) + implementation(libs.org.jetbrains.kotlin.test.annotations.common) + implementation(libs.org.jetbrains.kotlinx.coroutines.test) + } + } + } +} \ No newline at end of file diff --git a/data/repository/src/androidMain/AndroidManifest.xml b/data/repository/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000..4fb03756 --- /dev/null +++ b/data/repository/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/.gitkeep b/data/repository/src/androidMain/kotlin/social/androiddev/common/repository/.gitkeep similarity index 100% rename from data/persistence/src/androidMain/kotlin/social/androiddev/common/persistence/.gitkeep rename to data/repository/src/androidMain/kotlin/social/androiddev/common/repository/.gitkeep diff --git a/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/AuthenticationRepositoryImpl.kt b/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/AuthenticationRepositoryImpl.kt new file mode 100644 index 00000000..e3762985 --- /dev/null +++ b/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/AuthenticationRepositoryImpl.kt @@ -0,0 +1,43 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.repository + +import social.androiddev.common.network.MastodonApi +import social.androiddev.domain.authentication.repository.AuthenticationRepository + +internal class AuthenticationRepositoryImpl( + private val mastodonApi: MastodonApi +) : AuthenticationRepository { + + override suspend fun createApplicationClient( + domain: String, + clientName: String, + redirectUris: String, + scopes: String, + website: String? + ): Boolean { + val application = mastodonApi.createApplication( + domain = domain, + clientName = clientName, + redirectUris = redirectUris, + scopes = scopes, + website = website + ).getOrNull() + + return if (application == null) { + false + } else { + // TODO store in cache for later use + val clientId = application.clientId + val clientSecret = application.clientSecret + true + } + } +} diff --git a/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/di/RepositoryModule.kt b/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/di/RepositoryModule.kt new file mode 100644 index 00000000..4b9bae26 --- /dev/null +++ b/data/repository/src/commonMain/kotlin/social/androiddev/common/repository/di/RepositoryModule.kt @@ -0,0 +1,29 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.repository.di + +import org.koin.core.module.Module +import org.koin.dsl.module +import social.androiddev.common.repository.AuthenticationRepositoryImpl +import social.androiddev.domain.authentication.repository.AuthenticationRepository + +/** + * Koin module containing all koin/bean definitions for + * all repositories. Repositories encapsulate different data sources + * and are typically injected into ViewModels or UseCases. + */ +val repositoryModule: Module = module { + + factory { + AuthenticationRepositoryImpl( + mastodonApi = get(), + ) + } +} diff --git a/data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/.gitkeep b/data/repository/src/desktopMain/kotlin/social/androiddev/common/repository/.gitkeep similarity index 100% rename from data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/.gitkeep rename to data/repository/src/desktopMain/kotlin/social/androiddev/common/repository/.gitkeep diff --git a/data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/.gitkeep b/data/repository/src/iosMain/kotlin/social/androiddev/common/repository/.gitkeep similarity index 100% rename from data/persistence/src/desktopMain/kotlin/social/androiddev/common/persistence/.gitkeep rename to data/repository/src/iosMain/kotlin/social/androiddev/common/repository/.gitkeep diff --git a/di/build.gradle.kts b/di/build.gradle.kts new file mode 100644 index 00000000..a92e4ab9 --- /dev/null +++ b/di/build.gradle.kts @@ -0,0 +1,76 @@ +plugins { + id("kotlin-multiplatform") + id("com.android.library") + id("social.androiddev.code-quality") +} + +val targetSDKVersion: Int by rootProject.extra +val minSDKVersion: Int by rootProject.extra +val compileSDKVersion: Int by rootProject.extra + +android { + namespace = "social.androiddev.di" + compileSdk = compileSDKVersion + + defaultConfig { + minSdk = minSDKVersion + targetSdk = targetSDKVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} + +kotlin { + jvm("desktop") + android() + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + named("commonMain") { + dependencies { + implementation(projects.data.network) + implementation(projects.data.persistence) + implementation(projects.data.repository) + implementation(libs.io.insert.koin.core) + } + } + + named("androidMain") { + dependencies {} + } + + named("desktopMain") { + dependencies {} + } + + // iOS + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + val iosMain by creating { + dependsOn(getByName("commonMain")) + + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) + + dependencies {} + } + } + + tasks.withType { + kotlinOptions.jvmTarget = "11" + } +} diff --git a/di/src/androidMain/AndroidManifest.xml b/di/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000..4fb03756 --- /dev/null +++ b/di/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/di/src/androidMain/kotlin/social/androiddev/common/Platform.kt b/di/src/androidMain/kotlin/social/androiddev/common/Platform.kt new file mode 100644 index 00000000..a6ef7508 --- /dev/null +++ b/di/src/androidMain/kotlin/social/androiddev/common/Platform.kt @@ -0,0 +1,14 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common + +actual class Platform actual constructor() { + actual val name: String = "Android ${android.os.Build.VERSION.SDK_INT}" +} diff --git a/di/src/commonMain/kotlin/social/androiddev/common/Platform.kt b/di/src/commonMain/kotlin/social/androiddev/common/Platform.kt new file mode 100644 index 00000000..2dd2bcd2 --- /dev/null +++ b/di/src/commonMain/kotlin/social/androiddev/common/Platform.kt @@ -0,0 +1,14 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common + +expect class Platform() { + val name: String +} diff --git a/di/src/commonMain/kotlin/social/androiddev/common/di/AppModule.kt b/di/src/commonMain/kotlin/social/androiddev/common/di/AppModule.kt new file mode 100644 index 00000000..a9053579 --- /dev/null +++ b/di/src/commonMain/kotlin/social/androiddev/common/di/AppModule.kt @@ -0,0 +1,22 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.di + +import social.androiddev.common.network.di.networkModule +import social.androiddev.common.repository.di.repositoryModule + +/** + * Base Koin module shared across all apps (android, iOS, Desktop) + */ +fun appModule() = listOf( + platformModule, + networkModule, + repositoryModule, +) diff --git a/di/src/commonMain/kotlin/social/androiddev/common/di/PlatformModule.kt b/di/src/commonMain/kotlin/social/androiddev/common/di/PlatformModule.kt new file mode 100644 index 00000000..23f7e3a9 --- /dev/null +++ b/di/src/commonMain/kotlin/social/androiddev/common/di/PlatformModule.kt @@ -0,0 +1,22 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.di + +import org.koin.core.module.dsl.singleOf +import org.koin.dsl.module +import social.androiddev.common.Platform + +/** + * Platform specific Koin module. All build targets must + * fulfill any platform required koin definitions specified. + */ +val platformModule = module { + singleOf(::Platform) +} diff --git a/di/src/desktopMain/kotlin/social/androiddev/common/Platform.kt b/di/src/desktopMain/kotlin/social/androiddev/common/Platform.kt new file mode 100644 index 00000000..952e5870 --- /dev/null +++ b/di/src/desktopMain/kotlin/social/androiddev/common/Platform.kt @@ -0,0 +1,15 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common + +actual class Platform actual constructor() { + actual val name: String + get() = "Desktop" +} diff --git a/di/src/iosMain/kotlin/social/androiddev/common/Platform.kt b/di/src/iosMain/kotlin/social/androiddev/common/Platform.kt new file mode 100644 index 00000000..f4941277 --- /dev/null +++ b/di/src/iosMain/kotlin/social/androiddev/common/Platform.kt @@ -0,0 +1,17 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common + +import platform.UIKit.UIDevice + +actual class Platform actual constructor() { + actual val name: String = + UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion +} diff --git a/domain/authentication/build.gradle.kts b/domain/authentication/build.gradle.kts new file mode 100644 index 00000000..d160195b --- /dev/null +++ b/domain/authentication/build.gradle.kts @@ -0,0 +1,65 @@ +plugins { + id("kotlin-multiplatform") + id("com.android.library") + id("social.androiddev.code-quality") +} + +val targetSDKVersion: Int by rootProject.extra +val minSDKVersion: Int by rootProject.extra +val compileSDKVersion: Int by rootProject.extra + +android { + namespace = "social.androiddev.domain.authentication" + compileSdk = compileSDKVersion + + defaultConfig { + minSdk = minSDKVersion + targetSdk = targetSDKVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} + +kotlin { + jvm("desktop") + android() + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + // shared + val commonMain by getting { + dependencies {} + } + + // android + getByName("androidMain") { + dependsOn(commonMain) + dependencies {} + } + + // desktop + getByName("desktopMain") { + dependencies {} + } + + // testing + named("commonTest") { + dependencies { + implementation(libs.org.jetbrains.kotlin.test.common) + implementation(libs.org.jetbrains.kotlin.test.annotations.common) + } + } + } +} \ No newline at end of file diff --git a/domain/authentication/src/androidMain/AndroidManifest.xml b/domain/authentication/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000..4fb03756 --- /dev/null +++ b/domain/authentication/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/repository/AuthenticationRepository.kt b/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/repository/AuthenticationRepository.kt new file mode 100644 index 00000000..f5d9b993 --- /dev/null +++ b/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/repository/AuthenticationRepository.kt @@ -0,0 +1,21 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.domain.authentication.repository + +interface AuthenticationRepository { + + suspend fun createApplicationClient( + domain: String, + clientName: String, + redirectUris: String, + scopes: String, + website: String? + ): Boolean +} diff --git a/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/AuthenticateClient.kt b/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/AuthenticateClient.kt new file mode 100644 index 00000000..a1202ee1 --- /dev/null +++ b/domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/AuthenticateClient.kt @@ -0,0 +1,31 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.domain.authentication.usecase + +import social.androiddev.domain.authentication.repository.AuthenticationRepository + +class AuthenticateClient( + private val authenticationRepository: AuthenticationRepository, +) { + + suspend operator fun invoke( + domain: String, + clientName: String, + redirectURIs: String, + scopes: String = "read write follow push", + website: String? = null, + ): Boolean = authenticationRepository.createApplicationClient( + domain = domain, + clientName = clientName, + redirectUris = redirectURIs, + scopes = scopes, + website = website + ) +} diff --git a/domain/timeline/build.gradle.kts b/domain/timeline/build.gradle.kts index 1d4d426d..9d49fb8a 100644 --- a/domain/timeline/build.gradle.kts +++ b/domain/timeline/build.gradle.kts @@ -1,15 +1,7 @@ plugins { id("kotlin-multiplatform") id("com.android.library") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") } val targetSDKVersion: Int by rootProject.extra @@ -46,24 +38,20 @@ kotlin { // shared val commonMain by getting { - dependencies { - implementation(projects.data.network) - } + dependencies {} } // android getByName("androidMain") { dependsOn(commonMain) - dependencies { - } + dependencies {} } // desktop getByName("desktopMain") { - dependencies { - } + dependencies {} } // testing named("commonTest") { diff --git a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Account.kt b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Account.kt index 13b6a338..4c16262d 100644 --- a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Account.kt +++ b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Account.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.domain.timeline.model diff --git a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Status.kt b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Status.kt index f0aead13..9c2938b0 100644 --- a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Status.kt +++ b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Status.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.domain.timeline.model diff --git a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Visibility.kt b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Visibility.kt index 21f63911..72049fa5 100644 --- a/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Visibility.kt +++ b/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Visibility.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.domain.timeline.model diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1fb1dffc..e7e3b5b3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,6 +5,7 @@ org-jetbrains-kotlin = "1.7.20" org-jetbrains-kotlinx-coroutines = "1.6.4" com-android-tools-build = "7.2.2" com-squareup-sqldelight = "1.5.3" +com-diffplug-spotless = "6.11.0" # libraries io-ktor = "2.1.3" com-google-truth = "1.1.3" @@ -13,7 +14,9 @@ androidx-core = "1.3.1" androidx-appcompat = "1.5.1" androidx-activity = "1.6.1" androidx-compose-foundation = "1.2.1" -com-arkivanov-decompose = "1.0.0-alpha-05" +com-arkivanov-decompose = "1.0.0-alpha-07" +org-xerial = "3.8.10.2" +io-insert-koin = "3.2.0" [libraries] @@ -23,6 +26,7 @@ org-jetbrains-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gra com-android-tools-build-gradle = { module = "com.android.tools.build:gradle", version.ref = "com-android-tools-build" } org-jetbrains-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "org-jetbrains-kotlin" } com-squareup-sqldelight-gradle-plugin = { module = "com.squareup.sqldelight:gradle-plugin", version.ref = "com-squareup-sqldelight" } +com-diffplug-spotless-gradle-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "com-diffplug-spotless" } # libraries io-ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "io-ktor" } @@ -33,8 +37,11 @@ io-ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-neg io-ktor-client-mock-jvm = { module = "io.ktor:ktor-client-mock-jvm", version.ref = "io-ktor" } io-ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "io-ktor" } io-ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "io-ktor" } +io-insert-koin-core = { module = "io.insert-koin:koin-core", version.ref = "io-insert-koin" } +io-insert-koin-test = { module = "io.insert-koin:koin-test", version.ref = "io-insert-koin" } +io-insert-koin-android = { module = "io.insert-koin:koin-android", version.ref = "io-insert-koin" } -org-jetbrains-kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "org-jetbrains-kotlinx-coroutines"} +org-jetbrains-kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "org-jetbrains-kotlinx-coroutines" } org-jetbrains-kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "org-jetbrains-kotlinx" } org-jetbrains-kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "org-jetbrains-kotlin" } @@ -44,6 +51,7 @@ org-jetbrains-kotlin-test-annotations-common = { module = "org.jetbrains.kotlin: com-squareup-sqldelight-android-driver = { module = "com.squareup.sqldelight:android-driver", version.ref = "com-squareup-sqldelight" } com-squareup-sqldelight-native-driver = { module = "com.squareup.sqldelight:native-driver", version.ref = "com-squareup-sqldelight" } com-squareup-sqldelight-sqlite-driver = { module = "com.squareup.sqldelight:sqlite-driver", version.ref = "com-squareup-sqldelight" } +org-xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "org-xerial" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } @@ -52,5 +60,6 @@ androidx-compose-foundation = { module = "androidx.compose.foundation:foundation com-arkivanov-decompose = { module = "com.arkivanov.decompose:decompose", version.ref = "com-arkivanov-decompose" } com-arkivanov-decompose-extensions-compose-jetbrains = { module = "com.arkivanov.decompose:extensions-compose-jetbrains", version.ref = "com-arkivanov-decompose" } +com-arkivanov-decompose-extensions-compose-jetpack = { module = "com.arkivanov.decompose:extensions-compose-jetpack", version.ref = "com-arkivanov-decompose" } [plugins] diff --git a/settings.gradle.kts b/settings.gradle.kts index f04213c1..3d213f0c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,21 +1,44 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -rootProject.name="MastodonCompose" +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + includeBuild("build-logic") +} +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + mavenLocal() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + } +} + +rootProject.name="DodoForMastodon" + +include(":di") include(":app-android") include(":app-desktop") //include(":app-iOS") include(":ui:timeline") -include(":ui:welcome") //include(":ui:messages") //include(":ui:notifications") //include(":ui:search") //include(":ui:settings") include(":ui:common") +include(":ui:root") +include(":ui:signed-in") +include(":ui:signed-out") include(":domain:timeline") +include(":domain:authentication") //include(":data-timeline") include(":data:persistence") include(":data:network") +include(":data:repository") diff --git a/ui/common/build.gradle.kts b/ui/common/build.gradle.kts index 98cec28c..22a1dc66 100644 --- a/ui/common/build.gradle.kts +++ b/ui/common/build.gradle.kts @@ -2,14 +2,8 @@ plugins { id("kotlin-multiplatform") id("org.jetbrains.compose") id("com.android.library") - id("com.diffplug.spotless") version "6.11.0" -} -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") + id("kotlin-parcelize") } val targetSDKVersion: Int by rootProject.extra @@ -49,8 +43,8 @@ kotlin { implementation(compose.runtime) implementation(compose.foundation) implementation(compose.material) - implementation(libs.com.arkivanov.decompose) - implementation(libs.com.arkivanov.decompose.extensions.compose.jetbrains) + api(libs.com.arkivanov.decompose) + api(libs.com.arkivanov.decompose.extensions.compose.jetbrains) } } diff --git a/ui/common/src/androidMain/kotlin/social/androiddev/common/utils/ImageLoading.kt b/ui/common/src/androidMain/kotlin/social/androiddev/common/utils/ImageLoading.kt index b13e83b5..c80b9b68 100644 --- a/ui/common/src/androidMain/kotlin/social/androiddev/common/utils/ImageLoading.kt +++ b/ui/common/src/androidMain/kotlin/social/androiddev/common/utils/ImageLoading.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.utils diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/UserAvatar.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/UserAvatar.kt index 750e892d..d3511707 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/UserAvatar.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/UserAvatar.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.composables @@ -16,7 +16,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.unit.dp -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme import social.androiddev.common.utils.AsyncImage import social.androiddev.common.utils.loadImageIntoPainter @@ -38,7 +38,7 @@ fun UserAvatar( // @Preview @Composable private fun UserPreview() { - MastodonTheme { + DodoTheme { UserAvatar(url = "https://media.mastodon.cloud/accounts/avatars/000/018/251/original/e78973b0b821c7e3.jpg") } } diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonButton.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonButton.kt index d14fd8fa..1c3fdb1f 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonButton.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonButton.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.composables.buttons @@ -31,10 +31,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.unit.dp -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme @Composable -fun MastodonButton( +fun DodoButton( text: String, modifier: Modifier = Modifier, enabled: Boolean = true, @@ -122,10 +122,10 @@ private class DefaultButtonColors( // @Preview @Composable private fun PreviewButtonLight() { - MastodonTheme( + DodoTheme( useDarkTheme = false, ) { - MastodonButton( + DodoButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} @@ -138,7 +138,7 @@ private fun PreviewButtonLight() { // @Preview @Composable private fun PreviewButtonDark() { - MastodonTheme( + DodoTheme( useDarkTheme = true, ) { Surface { @@ -150,19 +150,19 @@ private fun PreviewButtonDark() { horizontalAlignment = Alignment.CenterHorizontally, ) { - MastodonButton( + DodoButton( modifier = Modifier.fillMaxWidth(), text = "This is a long button", onClick = {} ) - MastodonButton( + DodoButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} ) - MastodonButton( + DodoButton( modifier = Modifier.wrapContentSize(), text = "Disabled", onClick = {} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonOutlinedButton.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonOutlinedButton.kt index e617ccaa..dca893cc 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonOutlinedButton.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonOutlinedButton.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.composables.buttons @@ -29,10 +29,10 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme @Composable -fun MastodonOutlinedButton( +fun DodoOutlinedButton( text: String, modifier: Modifier = Modifier, enabled: Boolean = true, @@ -118,10 +118,10 @@ private class DefaultOutlineButtonColors( // @Preview @Composable private fun PreviewOutlineButtonLight() { - MastodonTheme( + DodoTheme( useDarkTheme = false, ) { - MastodonOutlinedButton( + DodoOutlinedButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} @@ -134,7 +134,7 @@ private fun PreviewOutlineButtonLight() { // @Preview @Composable private fun PreviewOutlineButtonDark() { - MastodonTheme( + DodoTheme( useDarkTheme = true, ) { Surface { @@ -146,19 +146,19 @@ private fun PreviewOutlineButtonDark() { horizontalAlignment = Alignment.CenterHorizontally, ) { - MastodonOutlinedButton( + DodoOutlinedButton( modifier = Modifier.fillMaxWidth(), text = "This is a long button", onClick = {} ) - MastodonOutlinedButton( + DodoOutlinedButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} ) - MastodonOutlinedButton( + DodoOutlinedButton( modifier = Modifier.wrapContentSize(), text = "Disabled", onClick = {} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonTextButton.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonTextButton.kt index 7ff4505b..952c9547 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonTextButton.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/buttons/MastodonTextButton.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.composables.buttons @@ -28,10 +28,10 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme @Composable -fun MastodonTextButton( +fun DodoTextButton( text: String, modifier: Modifier = Modifier, enabled: Boolean = true, @@ -116,10 +116,10 @@ private class DefaultTextButtonColors( // @Preview @Composable private fun PreviewTextButtonLight() { - MastodonTheme( + DodoTheme( useDarkTheme = false, ) { - MastodonTextButton( + DodoTextButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} @@ -132,7 +132,7 @@ private fun PreviewTextButtonLight() { // @Preview @Composable private fun PreviewTextButtonDark() { - MastodonTheme( + DodoTheme( useDarkTheme = true, ) { Column( @@ -143,19 +143,19 @@ private fun PreviewTextButtonDark() { horizontalAlignment = Alignment.CenterHorizontally, ) { - MastodonTextButton( + DodoTextButton( modifier = Modifier.fillMaxWidth(), text = "This is a long button", onClick = {} ) - MastodonTextButton( + DodoTextButton( modifier = Modifier.wrapContentSize(), text = "Action", onClick = {} ) - MastodonTextButton( + DodoTextButton( modifier = Modifier.wrapContentSize(), text = "Disabled", onClick = {} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/text/MastodonTextField.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/text/MastodonTextField.kt new file mode 100644 index 00000000..97d59f8e --- /dev/null +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/composables/text/MastodonTextField.kt @@ -0,0 +1,309 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.composables.text + +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.tween +import androidx.compose.foundation.interaction.InteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.ZeroCornerSize +import androidx.compose.material.ContentAlpha +import androidx.compose.material.LocalContentAlpha +import androidx.compose.material.LocalContentColor +import androidx.compose.material.LocalTextStyle +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface +import androidx.compose.material.TextField +import androidx.compose.material.TextFieldColors +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.State +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import social.androiddev.common.theme.DodoTheme + +@Composable +fun DodoTextField( + value: String, + onValueChange: (String) -> Unit, + modifier: Modifier = Modifier, + enabled: Boolean = true, + isError: Boolean = false, + singleLine: Boolean = false, + maxLines: Int = Int.MAX_VALUE, + label: @Composable (() -> Unit)? = null, + placeholder: @Composable (() -> Unit)? = null, + leadingIcon: @Composable (() -> Unit)? = null, + trailingIcon: @Composable (() -> Unit)? = null, + colors: TextFieldColors = textFieldColors(), +) { + TextField( + value = value, + onValueChange = onValueChange, + modifier = modifier, + enabled = enabled, + readOnly = false, + textStyle = LocalTextStyle.current, + label = label, + placeholder = placeholder, + leadingIcon = leadingIcon, + trailingIcon = trailingIcon, + isError = isError, + singleLine = singleLine, + maxLines = maxLines, + shape = MaterialTheme.shapes.small.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize), + colors = colors, + ) +} + +/** + * Creates a [TextFieldColors] that represents the default input text, background and content + * (including label, placeholder, leading and trailing icons) colors used in a [TextField]. + */ +@Composable +private fun textFieldColors( + textColor: Color = LocalContentColor.current.copy(LocalContentAlpha.current), + disabledTextColor: Color = textColor.copy(ContentAlpha.disabled), + backgroundColor: Color = MaterialTheme.colors.onSurface.copy(alpha = TextFieldDefaults.BackgroundOpacity), + cursorColor: Color = MaterialTheme.colors.primary, + errorCursorColor: Color = MaterialTheme.colors.error, + focusedIndicatorColor: Color = + MaterialTheme.colors.primary.copy(alpha = ContentAlpha.high), + unfocusedIndicatorColor: Color = + MaterialTheme.colors.onSurface.copy(alpha = TextFieldDefaults.UnfocusedIndicatorLineOpacity), + disabledIndicatorColor: Color = unfocusedIndicatorColor.copy(alpha = ContentAlpha.disabled), + errorIndicatorColor: Color = MaterialTheme.colors.error, + leadingIconColor: Color = + MaterialTheme.colors.onSurface.copy(alpha = TextFieldDefaults.IconOpacity), + disabledLeadingIconColor: Color = leadingIconColor.copy(alpha = ContentAlpha.disabled), + errorLeadingIconColor: Color = leadingIconColor, + trailingIconColor: Color = + MaterialTheme.colors.onSurface.copy(alpha = TextFieldDefaults.IconOpacity), + disabledTrailingIconColor: Color = trailingIconColor.copy(alpha = ContentAlpha.disabled), + errorTrailingIconColor: Color = MaterialTheme.colors.error, + focusedLabelColor: Color = MaterialTheme.colors.primary.copy(alpha = ContentAlpha.high), + unfocusedLabelColor: Color = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium), + disabledLabelColor: Color = unfocusedLabelColor.copy(ContentAlpha.disabled), + errorLabelColor: Color = MaterialTheme.colors.error, + placeholderColor: Color = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium), + disabledPlaceholderColor: Color = placeholderColor.copy(ContentAlpha.disabled) +): TextFieldColors = DefaultTextFieldColors( + textColor = textColor, + disabledTextColor = disabledTextColor, + cursorColor = cursorColor, + errorCursorColor = errorCursorColor, + focusedIndicatorColor = focusedIndicatorColor, + unfocusedIndicatorColor = unfocusedIndicatorColor, + errorIndicatorColor = errorIndicatorColor, + disabledIndicatorColor = disabledIndicatorColor, + leadingIconColor = leadingIconColor, + disabledLeadingIconColor = disabledLeadingIconColor, + errorLeadingIconColor = errorLeadingIconColor, + trailingIconColor = trailingIconColor, + disabledTrailingIconColor = disabledTrailingIconColor, + errorTrailingIconColor = errorTrailingIconColor, + backgroundColor = backgroundColor, + focusedLabelColor = focusedLabelColor, + unfocusedLabelColor = unfocusedLabelColor, + disabledLabelColor = disabledLabelColor, + errorLabelColor = errorLabelColor, + placeholderColor = placeholderColor, + disabledPlaceholderColor = disabledPlaceholderColor +) + +@Immutable +private class DefaultTextFieldColors( + private val textColor: Color, + private val disabledTextColor: Color, + private val cursorColor: Color, + private val errorCursorColor: Color, + private val focusedIndicatorColor: Color, + private val unfocusedIndicatorColor: Color, + private val errorIndicatorColor: Color, + private val disabledIndicatorColor: Color, + private val leadingIconColor: Color, + private val disabledLeadingIconColor: Color, + private val errorLeadingIconColor: Color, + private val trailingIconColor: Color, + private val disabledTrailingIconColor: Color, + private val errorTrailingIconColor: Color, + private val backgroundColor: Color, + private val focusedLabelColor: Color, + private val unfocusedLabelColor: Color, + private val disabledLabelColor: Color, + private val errorLabelColor: Color, + private val placeholderColor: Color, + private val disabledPlaceholderColor: Color +) : TextFieldColors { + + @Composable + override fun leadingIconColor(enabled: Boolean, isError: Boolean): State { + return rememberUpdatedState( + when { + !enabled -> disabledLeadingIconColor + isError -> errorLeadingIconColor + else -> leadingIconColor + } + ) + } + + @Composable + override fun trailingIconColor(enabled: Boolean, isError: Boolean): State { + return rememberUpdatedState( + when { + !enabled -> disabledTrailingIconColor + isError -> errorTrailingIconColor + else -> trailingIconColor + } + ) + } + + @Composable + override fun indicatorColor( + enabled: Boolean, + isError: Boolean, + interactionSource: InteractionSource + ): State { + val focused by interactionSource.collectIsFocusedAsState() + + val targetValue = when { + !enabled -> disabledIndicatorColor + isError -> errorIndicatorColor + focused -> focusedIndicatorColor + else -> unfocusedIndicatorColor + } + return if (enabled) { + animateColorAsState(targetValue, tween(durationMillis = AnimationDuration)) + } else { + rememberUpdatedState(targetValue) + } + } + + @Composable + override fun backgroundColor(enabled: Boolean): State { + return rememberUpdatedState(backgroundColor) + } + + @Composable + override fun placeholderColor(enabled: Boolean): State { + return rememberUpdatedState(if (enabled) placeholderColor else disabledPlaceholderColor) + } + + @Composable + override fun labelColor( + enabled: Boolean, + error: Boolean, + interactionSource: InteractionSource + ): State { + val focused by interactionSource.collectIsFocusedAsState() + + val targetValue = when { + !enabled -> disabledLabelColor + error -> errorLabelColor + focused -> focusedLabelColor + else -> unfocusedLabelColor + } + return rememberUpdatedState(targetValue) + } + + @Composable + override fun textColor(enabled: Boolean): State { + return rememberUpdatedState(if (enabled) textColor else disabledTextColor) + } + + @Composable + override fun cursorColor(isError: Boolean): State { + return rememberUpdatedState(if (isError) errorCursorColor else cursorColor) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as DefaultTextFieldColors + + if (textColor != other.textColor) return false + if (disabledTextColor != other.disabledTextColor) return false + if (cursorColor != other.cursorColor) return false + if (errorCursorColor != other.errorCursorColor) return false + if (focusedIndicatorColor != other.focusedIndicatorColor) return false + if (unfocusedIndicatorColor != other.unfocusedIndicatorColor) return false + if (errorIndicatorColor != other.errorIndicatorColor) return false + if (disabledIndicatorColor != other.disabledIndicatorColor) return false + if (leadingIconColor != other.leadingIconColor) return false + if (disabledLeadingIconColor != other.disabledLeadingIconColor) return false + if (errorLeadingIconColor != other.errorLeadingIconColor) return false + if (trailingIconColor != other.trailingIconColor) return false + if (disabledTrailingIconColor != other.disabledTrailingIconColor) return false + if (errorTrailingIconColor != other.errorTrailingIconColor) return false + if (backgroundColor != other.backgroundColor) return false + if (focusedLabelColor != other.focusedLabelColor) return false + if (unfocusedLabelColor != other.unfocusedLabelColor) return false + if (disabledLabelColor != other.disabledLabelColor) return false + if (errorLabelColor != other.errorLabelColor) return false + if (placeholderColor != other.placeholderColor) return false + if (disabledPlaceholderColor != other.disabledPlaceholderColor) return false + + return true + } + + override fun hashCode(): Int { + var result = textColor.hashCode() + result = 31 * result + disabledTextColor.hashCode() + result = 31 * result + cursorColor.hashCode() + result = 31 * result + errorCursorColor.hashCode() + result = 31 * result + focusedIndicatorColor.hashCode() + result = 31 * result + unfocusedIndicatorColor.hashCode() + result = 31 * result + errorIndicatorColor.hashCode() + result = 31 * result + disabledIndicatorColor.hashCode() + result = 31 * result + leadingIconColor.hashCode() + result = 31 * result + disabledLeadingIconColor.hashCode() + result = 31 * result + errorLeadingIconColor.hashCode() + result = 31 * result + trailingIconColor.hashCode() + result = 31 * result + disabledTrailingIconColor.hashCode() + result = 31 * result + errorTrailingIconColor.hashCode() + result = 31 * result + backgroundColor.hashCode() + result = 31 * result + focusedLabelColor.hashCode() + result = 31 * result + unfocusedLabelColor.hashCode() + result = 31 * result + disabledLabelColor.hashCode() + result = 31 * result + errorLabelColor.hashCode() + result = 31 * result + placeholderColor.hashCode() + result = 31 * result + disabledPlaceholderColor.hashCode() + return result + } +} + +private const val AnimationDuration = 150 + +// @androidx.compose.desktop.ui.tooling.preview.Preview +@Composable +fun PreviewTextField() { + DodoTheme { + Surface { + var text by remember { mutableStateOf("Hello World") } + DodoTextField( + value = text, + onValueChange = { text = it }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp), + ) + } + } +} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/network/NetworkMonitor.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/network/NetworkMonitor.kt deleted file mode 100644 index a01c18f7..00000000 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/network/NetworkMonitor.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * This file is part of MastodonX. - * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . - */ -package social.androiddev.common.network - -import kotlinx.coroutines.flow.Flow - -interface NetworkMonitor { - val isOnline: Flow -} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonColors.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoColors.kt similarity index 58% rename from ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonColors.kt rename to ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoColors.kt index 6f88c63c..37df71b8 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonColors.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoColors.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.theme diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTheme.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTheme.kt new file mode 100644 index 00000000..616ad8f5 --- /dev/null +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTheme.kt @@ -0,0 +1,29 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.common.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.Composable + +@Composable +fun DodoTheme( + useDarkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable() () -> Unit +) { + MaterialTheme( + colors = if (useDarkTheme) { + darkColors + } else { + lightColors + }, + typography = DodoTypography, content = content + ) +} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTypography.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTypography.kt similarity index 87% rename from ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTypography.kt rename to ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTypography.kt index 9cb7fb0d..2b7d113a 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTypography.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTypography.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.theme @@ -24,7 +24,7 @@ import androidx.compose.ui.unit.sp * The type scale is a combination of thirteen styles that are supported by the type system. * It contains reusable categories of text, each with an intended application and meaning. */ -val MastodonTypography = Typography( +val DodoTypography = Typography( /** the default FontFamily to be used for TextStyles below */ defaultFontFamily = FontFamily.Default, diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTheme.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTheme.kt deleted file mode 100644 index 350ae346..00000000 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/theme/MastodonTheme.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of MastodonX. - * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . - */ -package social.androiddev.common.theme - -import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.runtime.Composable - -@Composable -fun MastodonTheme( - useDarkTheme: Boolean = isSystemInDarkTheme(), - content: @Composable() () -> Unit -) { - MaterialTheme( - colors = if (useDarkTheme) { - darkColors - } else { - lightColors - }, - typography = MastodonTypography, content = content - ) -} diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/AsyncImage.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/AsyncImage.kt index e2320f71..b6950d3a 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/AsyncImage.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/AsyncImage.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.utils @@ -20,7 +20,7 @@ import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import java.io.IOException +import social.androiddev.common.network.util.runCatchingIgnoreCancelled /** * Use this helper until we switch to a image loading library which supports multiplatform @@ -36,12 +36,15 @@ fun AsyncImage( ) { val image: T? by produceState(null) { value = withContext(Dispatchers.IO) { - try { + runCatchingIgnoreCancelled { load() - } catch (e: IOException) { - e.printStackTrace() - null - } + }.fold( + onSuccess = { it }, + onFailure = { t -> + t.printStackTrace() + null + } + ) } } diff --git a/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/ImageLoading.kt b/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/ImageLoading.kt index 58cc6b06..c1ee8b03 100644 --- a/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/ImageLoading.kt +++ b/ui/common/src/commonMain/kotlin/social/androiddev/common/utils/ImageLoading.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.utils diff --git a/ui/common/src/desktopMain/kotlin/social/androiddev/common/utils/ImageLoading.kt b/ui/common/src/desktopMain/kotlin/social/androiddev/common/utils/ImageLoading.kt index 4ac45051..5deb02af 100644 --- a/ui/common/src/desktopMain/kotlin/social/androiddev/common/utils/ImageLoading.kt +++ b/ui/common/src/desktopMain/kotlin/social/androiddev/common/utils/ImageLoading.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.common.utils diff --git a/ui/welcome/build.gradle.kts b/ui/root/build.gradle.kts similarity index 84% rename from ui/welcome/build.gradle.kts rename to ui/root/build.gradle.kts index 45a7c2fe..9606c49e 100644 --- a/ui/welcome/build.gradle.kts +++ b/ui/root/build.gradle.kts @@ -2,15 +2,8 @@ plugins { id("kotlin-multiplatform") id("org.jetbrains.compose") id("com.android.library") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") + id("kotlin-parcelize") } val targetSDKVersion: Int by rootProject.extra @@ -19,7 +12,7 @@ val compileSDKVersion: Int by rootProject.extra android { - namespace = "social.androiddev.ui.welcome" + namespace = "social.androiddev.ui.root" compileSdk = compileSDKVersion @@ -48,8 +41,9 @@ kotlin { sourceSets { val commonMain by getting { dependencies { -// implementation(project(":domain:welcome")) implementation(projects.ui.common) + implementation(projects.ui.signedIn) + implementation(projects.ui.signedOut) implementation(compose.runtime) implementation(compose.foundation) implementation(compose.material) diff --git a/ui/welcome/src/androidMain/AndroidManifest.xml b/ui/root/src/androidMain/AndroidManifest.xml similarity index 100% rename from ui/welcome/src/androidMain/AndroidManifest.xml rename to ui/root/src/androidMain/AndroidManifest.xml diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/RootContent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/RootContent.kt new file mode 100644 index 00000000..0054c24f --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/RootContent.kt @@ -0,0 +1,100 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.composables + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.ExperimentalDecomposeApi +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children +import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import social.androiddev.root.navigation.RootComponent +import social.androiddev.root.navigation.SplashComponent +import social.androiddev.signedin.composables.SignedInRootContent +import social.androiddev.signedin.navigation.SignedInRootComponent +import social.androiddev.signedout.composables.SignedOutRootContent +import social.androiddev.signedout.navigation.SignedOutRootComponent + +/** + * App root composable that delegates business logic + * and decompose navigation to [RootComponent] + */ +@OptIn(ExperimentalDecomposeApi::class) +@Composable +fun RootContent( + component: RootComponent, + modifier: Modifier = Modifier, +) { + val childStack by component.childStack.subscribeAsState() + + Box( + modifier = modifier, + contentAlignment = Alignment.Center, + ) { + + Children( + stack = childStack, + modifier = Modifier.fillMaxSize(), + ) { createdChild -> + when (val child = createdChild.instance) { + is RootComponent.Child.Splash -> { + SplashScreen( + component = child.component, + ) + } + + is RootComponent.Child.SignedIn -> { + SignedInRoot( + component = child.component, + ) + } + + is RootComponent.Child.SignedOut -> { + SignedOutRoot( + component = child.component, + ) + } + } + } + } +} + +@Composable +private fun SignedOutRoot( + component: SignedOutRootComponent, +) { + SignedOutRootContent( + modifier = Modifier.fillMaxSize(), + component = component, + ) +} + +@Composable +private fun SignedInRoot( + component: SignedInRootComponent, +) { + SignedInRootContent( + modifier = Modifier.fillMaxSize(), + component = component, + ) +} + +@Composable +private fun SplashScreen( + component: SplashComponent, +) { + SplashContent( + modifier = Modifier.fillMaxSize(), + component = component, + ) +} diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/SplashContent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/SplashContent.kt new file mode 100644 index 00000000..19df6721 --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/composables/SplashContent.kt @@ -0,0 +1,65 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.composables + +import androidx.compose.foundation.layout.Box +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import social.androiddev.root.navigation.SplashComponent + +/** + * Stateful SplashScreen composable using [SplashComponent] for + * decompose navigation and business logic. + */ +@Composable +fun SplashContent( + modifier: Modifier, + component: SplashComponent, +) { + SplashContent( + modifier = modifier, + navigateToWelcome = { + component.navigateToLanding() + }, + navigateToTimeline = { + component.navigateToTimeline() + }, + ) +} + +/** + * Stateless composable for rendering a simple Splash Screen + * upon app launch. + */ +@Composable +fun SplashContent( + modifier: Modifier, + navigateToTimeline: () -> Unit, + navigateToWelcome: () -> Unit, +) { + Box( + modifier = modifier, + contentAlignment = Alignment.Center, + ) { + Text("Loading") + + LaunchedEffect(Unit) { + // TODO: Hook up to a DI ViewModel + if (true) { + navigateToWelcome() + } else { + navigateToTimeline() + } + } + } +} diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultRootComponent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultRootComponent.kt new file mode 100644 index 00000000..0a14617a --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultRootComponent.kt @@ -0,0 +1,107 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.navigation + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.childStack +import com.arkivanov.decompose.router.stack.replaceCurrent +import com.arkivanov.decompose.value.Value +import com.arkivanov.essenty.parcelable.Parcelable +import com.arkivanov.essenty.parcelable.Parcelize +import social.androiddev.signedin.navigation.DefaultSignedInRootComponent +import social.androiddev.signedout.navigation.DefaultSignedOutRootComponent + +/** + * Default impl of the [RootComponent] that manages the navigation stack for the + * 3 main "scopes". Loading/Splash screen, Logged out flow, and Logged in flow. + * See [Config] and [RootComponent.Child] for more details. + */ +class DefaultRootComponent( + componentContext: ComponentContext, + deepLink: RootComponent.DeepLink = RootComponent.DeepLink.None, +) : RootComponent, ComponentContext by componentContext { + + // StackNavigation accepts navigation commands and forwards them to all subscribed observers. + private val navigation = StackNavigation() + + // ChildStack is a simple data class that stores a stack of components and their configurations. + private val stack: Value> = childStack( + source = navigation, + initialStack = { getInitialStack(deepLink) }, + handleBackButton = true, // Pop the back stack on back button press + childFactory = ::createChild, + ) + + override val childStack: Value> = stack + + private fun createChild(config: Config, componentContext: ComponentContext): RootComponent.Child = + when (config) { + Config.Splash -> RootComponent.Child.Splash(createSplashComponent(componentContext)) + Config.SignedIn -> RootComponent.Child.SignedIn(createSignedInComponent(componentContext)) + Config.SignedOut -> RootComponent.Child.SignedOut(createSignedOutComponent(componentContext)) + } + + private fun createSignedOutComponent( + componentContext: ComponentContext, + ) = DefaultSignedOutRootComponent( + componentContext = componentContext, + ) + + private fun createSignedInComponent( + componentContext: ComponentContext, + ) = DefaultSignedInRootComponent( + componentContext = componentContext, + ) + + private fun createSplashComponent( + componentContext: ComponentContext, + ) = DefaultSplashComponent( + componentContext = componentContext, + navigateToTimelineInternal = { + navigation.replaceCurrent(Config.SignedIn) + }, + navigateToLandingInternal = { + navigation.replaceCurrent(Config.SignedOut) + }, + ) + + private fun getInitialStack( + deepLink: RootComponent.DeepLink, + ): List = + when (deepLink) { + is RootComponent.DeepLink.None -> listOf(Config.Splash) + } + + /** + * Supported configurations for all children in this root. + * A "configuration" represents a child component + * and contains all it's arguments. + * These configurations are persisted and restored on events like + * configuration changes, process death etc... + * + * All Configurations must: + * 1) Be immutable + * 2) Implement `equals()` and `hashCode()` + * 3) Implement Parcelable + */ + private sealed interface Config : Parcelable { + + @Parcelize + object SignedIn : Config + + @Parcelize + object SignedOut : Config + + @Parcelize + object Splash : Config + } +} diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultSplashComponent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultSplashComponent.kt new file mode 100644 index 00000000..3f95ebb7 --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/DefaultSplashComponent.kt @@ -0,0 +1,27 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.navigation + +import com.arkivanov.decompose.ComponentContext + +class DefaultSplashComponent( + private val componentContext: ComponentContext, + private val navigateToLandingInternal: () -> Unit, + private val navigateToTimelineInternal: () -> Unit, +) : SplashComponent, ComponentContext by componentContext { + + override fun navigateToTimeline() { + navigateToTimelineInternal() + } + + override fun navigateToLanding() { + navigateToLandingInternal() + } +} diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/RootComponent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/RootComponent.kt new file mode 100644 index 00000000..147d5ad5 --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/RootComponent.kt @@ -0,0 +1,43 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.navigation + +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.Value +import social.androiddev.signedin.navigation.SignedInRootComponent +import social.androiddev.signedout.navigation.SignedOutRootComponent + +/** + * The base component describing all business logic needed for the root entry point + */ +interface RootComponent { + + // Store a stack of components and their configurations in this root graph + val childStack: Value> + + /** + * Supported "Child"s in this navigation stack. These are created from a configuration that + * contains any arguments for this particular child in the navigation stack. + */ + sealed class Child { + data class Splash(val component: SplashComponent) : Child() + + data class SignedOut(val component: SignedOutRootComponent) : Child() + + data class SignedIn(val component: SignedInRootComponent) : Child() + } + + /** + * Supported deep links for this root graph + */ + sealed interface DeepLink { + object None : DeepLink + } +} diff --git a/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/SplashComponent.kt b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/SplashComponent.kt new file mode 100644 index 00000000..7fc4c233 --- /dev/null +++ b/ui/root/src/commonMain/kotlin/social/androiddev/root/navigation/SplashComponent.kt @@ -0,0 +1,26 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.root.navigation + +/** + * The base component describing all business logic needed for the splash screen + */ +interface SplashComponent { + + /** + * Callback invoked when the logged-in user should be taken to the timeline screen + */ + fun navigateToTimeline() + + /** + * Callback invoked when the logged-out user should be taken to the landing screen + */ + fun navigateToLanding() +} diff --git a/ui/signed-in/build.gradle.kts b/ui/signed-in/build.gradle.kts new file mode 100644 index 00000000..1adbce0a --- /dev/null +++ b/ui/signed-in/build.gradle.kts @@ -0,0 +1,72 @@ +plugins { + id("kotlin-multiplatform") + id("org.jetbrains.compose") + id("com.android.library") + id("social.androiddev.code-quality") + id("kotlin-parcelize") +} + +val targetSDKVersion: Int by rootProject.extra +val minSDKVersion: Int by rootProject.extra +val compileSDKVersion: Int by rootProject.extra + +android { + + namespace = "social.androiddev.ui.signed_in" + + compileSdk = compileSDKVersion + + defaultConfig { + minSdk = minSDKVersion + targetSdk = targetSDKVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} + +kotlin { + jvm("desktop") + android() + + sourceSets { + val commonMain by getting { + dependencies { + implementation(projects.ui.common) + implementation(projects.ui.timeline) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) + } + } + + named("androidMain") { + dependencies { + // Workaround for https://github.com/JetBrains/compose-jb/issues/2340 + implementation(libs.androidx.compose.foundation) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.core.ktx) + } + } + + named("desktopMain") { + dependencies { +// dependsOn(commonMain) + implementation(compose.desktop.common) + } + } + } + + tasks.withType { + kotlinOptions.jvmTarget = "11" + } +} diff --git a/ui/signed-in/src/androidMain/AndroidManifest.xml b/ui/signed-in/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000..10728cc7 --- /dev/null +++ b/ui/signed-in/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/composables/SignedInRootContent.kt b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/composables/SignedInRootContent.kt new file mode 100644 index 00000000..69b6aa69 --- /dev/null +++ b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/composables/SignedInRootContent.kt @@ -0,0 +1,63 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedin.composables + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children +import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import social.androiddev.signedin.navigation.SignedInRootComponent +import social.androiddev.timeline.TimelineContent +import social.androiddev.timeline.navigation.TimelineComponent + +/** + * The root composable for when the user launches the app and is + * currently signed in. + * Business logic and decompose navigation is delegated to [SignedInRootComponent]. + */ +@Composable +fun SignedInRootContent( + component: SignedInRootComponent, + modifier: Modifier = Modifier, +) { + val childStack by component.childStack.subscribeAsState() + + // TODO Add bottom navigation + Box( + modifier = modifier, + contentAlignment = Alignment.Center + ) { + + Children( + stack = childStack, + modifier = Modifier.fillMaxSize() + ) { createdChild -> + when (val child = createdChild.instance) { + is SignedInRootComponent.Child.Timeline -> { + TimelineTab(child.component) + } + } + } + } +} + +@Composable +private fun TimelineTab( + component: TimelineComponent +) { + TimelineContent( + component = component, + modifier = Modifier.fillMaxSize(), + ) +} diff --git a/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/DefaultSignedInRootComponent.kt b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/DefaultSignedInRootComponent.kt new file mode 100644 index 00000000..2978e449 --- /dev/null +++ b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/DefaultSignedInRootComponent.kt @@ -0,0 +1,73 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedin.navigation + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.childStack +import com.arkivanov.decompose.value.Value +import com.arkivanov.essenty.parcelable.Parcelable +import com.arkivanov.essenty.parcelable.Parcelize +import social.androiddev.timeline.navigation.DefaultTimelineComponent + +/** + * Default impl of the [SignedInRootComponent] that manages the navigation stack for the + * main tabbed "scopes". Timeline, Profile, and Notifications etc. + * See [Config] and [SignedInRootComponent.Child] for more details. + */ +class DefaultSignedInRootComponent( + private val componentContext: ComponentContext +) : SignedInRootComponent, ComponentContext by componentContext { + + // StackNavigation accepts navigation commands and forwards them to all subscribed observers. + private val navigation = StackNavigation() + + // ChildStack is a simple data class that stores a stack of components and their configurations. + private val stack: Value> = childStack( + source = navigation, + initialStack = { listOf(Config.Timeline) }, + handleBackButton = true, // Pop the back stack on back button press + childFactory = ::createChild + ) + + override val childStack: Value> = stack + + private fun createChild(config: Config, componentContext: ComponentContext): SignedInRootComponent.Child = + when (config) { + Config.Timeline -> { + SignedInRootComponent.Child.Timeline(createTimelineComponent(componentContext)) + } + } + + private fun createTimelineComponent( + componentContext: ComponentContext, + ) = DefaultTimelineComponent( + componentContext = componentContext + ) + + /** + * Supported configurations for all children in this root. + * A "configuration" represents a child component + * and contains all it's arguments. + * These configurations are persisted and restored on events like + * configuration changes, process death etc... + * + * All Configurations must: + * 1) Be immutable + * 2) Implement `equals()` and `hashCode()` + * 3) Implement Parcelable + */ + private sealed interface Config : Parcelable { + + @Parcelize + object Timeline : Config + } +} diff --git a/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/SignedInRootComponent.kt b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/SignedInRootComponent.kt new file mode 100644 index 00000000..af718401 --- /dev/null +++ b/ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/SignedInRootComponent.kt @@ -0,0 +1,32 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedin.navigation + +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.Value +import social.androiddev.timeline.navigation.TimelineComponent + +/** + * The base component describing all business logic needed for the signed-in root entry point + */ +interface SignedInRootComponent { + + // Store a stack of components and their configurations in this root graph + val childStack: Value> + + /** + * Supported "Child"s in this navigation stack. These are created from a configuration that + * contains any arguments for this particular child in the navigation stack. + */ + sealed class Child { + + data class Timeline(val component: TimelineComponent) : Child() + } +} diff --git a/ui/signed-out/build.gradle.kts b/ui/signed-out/build.gradle.kts new file mode 100644 index 00000000..bb28b1c1 --- /dev/null +++ b/ui/signed-out/build.gradle.kts @@ -0,0 +1,71 @@ +plugins { + id("kotlin-multiplatform") + id("org.jetbrains.compose") + id("com.android.library") + id("social.androiddev.code-quality") + id("kotlin-parcelize") +} + +val targetSDKVersion: Int by rootProject.extra +val minSDKVersion: Int by rootProject.extra +val compileSDKVersion: Int by rootProject.extra + +android { + + namespace = "social.androiddev.ui.signed_out" + + compileSdk = compileSDKVersion + + defaultConfig { + minSdk = minSDKVersion + targetSdk = targetSDKVersion + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + sourceSets { + named("main") { + manifest.srcFile("src/androidMain/AndroidManifest.xml") + res.srcDirs("src/androidMain/res") + } + } +} + +kotlin { + jvm("desktop") + android() + + sourceSets { + val commonMain by getting { + dependencies { + implementation(projects.ui.common) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) + } + } + + named("androidMain") { + dependencies { + // Workaround for https://github.com/JetBrains/compose-jb/issues/2340 + implementation(libs.androidx.compose.foundation) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.core.ktx) + } + } + + named("desktopMain") { + dependencies { +// dependsOn(commonMain) + implementation(compose.desktop.common) + } + } + } + + tasks.withType { + kotlinOptions.jvmTarget = "11" + } +} diff --git a/ui/signed-out/src/androidMain/AndroidManifest.xml b/ui/signed-out/src/androidMain/AndroidManifest.xml new file mode 100644 index 00000000..10728cc7 --- /dev/null +++ b/ui/signed-out/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ui/welcome/src/commonMain/kotlin/social/androiddev/welcome/composables/WelcomeScreen.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/LandingContent.kt similarity index 64% rename from ui/welcome/src/commonMain/kotlin/social/androiddev/welcome/composables/WelcomeScreen.kt rename to ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/LandingContent.kt index e7177e2a..5518d37b 100644 --- a/ui/welcome/src/commonMain/kotlin/social/androiddev/welcome/composables/WelcomeScreen.kt +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/LandingContent.kt @@ -1,12 +1,14 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ +package social.androiddev.signedout.composables + import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -32,21 +34,47 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import social.androiddev.common.composables.buttons.MastodonButton -import social.androiddev.common.composables.buttons.MastodonOutlinedButton +import social.androiddev.common.composables.buttons.DodoButton import social.androiddev.common.theme.Blue -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme import social.androiddev.common.utils.AsyncImage import social.androiddev.common.utils.loadImageIntoPainter +import social.androiddev.signedout.navigation.LandingComponent +/** + * Landing view that delegates business logic to [LandingContent] + */ @Composable -fun WelcomeScreen( +fun LandingContent( + component: LandingComponent, modifier: Modifier = Modifier, - navigateToLogin: () -> Unit, - navigateToSignUp: () -> Unit, appIcon: @Composable () -> Unit = { AsyncImage( - load = { loadImageIntoPainter(url = "https://via.placeholder.com/200x200/6FA4DE/010041?text=MastodonX") }, + load = { loadImageIntoPainter(url = "https://via.placeholder.com/200x200/6FA4DE/010041?text=Dodo") }, + painterFor = { remember { it } }, + contentDescription = "App Logo", + modifier = Modifier + .padding(horizontal = 48.dp) + .size(240.dp) + .clip(CircleShape), + contentScale = ContentScale.Crop, + ) + }, +) { + LandingContent( + modifier = modifier, + onGetStartedClicked = component::onGetStartedClicked, + appIcon = appIcon, + ) +} + +@Composable +fun LandingContent( + modifier: Modifier = Modifier, + onGetStartedClicked: () -> Unit, + appIcon: @Composable () -> Unit = { + AsyncImage( + load = { loadImageIntoPainter(url = "https://via.placeholder.com/200x200/6FA4DE/010041?text=Dodo") }, painterFor = { remember { it } }, contentDescription = "App Logo", modifier = Modifier @@ -91,11 +119,11 @@ fun WelcomeScreen( } Text( - text = "MastodonX", + text = "Dodo", style = MaterialTheme.typography.h3, textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, - modifier = Modifier.padding(horizontal = 24.dp) + modifier = Modifier.padding(horizontal = 24.dp), ) Spacer(Modifier.height(12.dp)) @@ -105,27 +133,17 @@ fun WelcomeScreen( style = MaterialTheme.typography.h6, textAlign = TextAlign.Center, fontWeight = FontWeight.SemiBold, - modifier = Modifier.padding(horizontal = 24.dp) + modifier = Modifier.padding(horizontal = 24.dp), ) Spacer(Modifier.height(42.dp)) - MastodonButton( - modifier = Modifier - .widthIn(min = 240.dp) - .padding(horizontal = 24.dp), - onClick = navigateToLogin, - text = "Log In" - ) - - Spacer(Modifier.height(8.dp)) - - MastodonOutlinedButton( + DodoButton( modifier = Modifier .widthIn(min = 240.dp) .padding(horizontal = 24.dp), - onClick = navigateToSignUp, - text = "Sign Up" + onClick = onGetStartedClicked, + text = "Get Started", ) } } @@ -133,11 +151,10 @@ fun WelcomeScreen( // @Preview @Composable -private fun PreviewWelcomeScreen() { - MastodonTheme(true) { - WelcomeScreen( - navigateToLogin = {}, - navigateToSignUp = {}, +private fun PreviewLandingContent() { + DodoTheme(true) { + LandingContent( + onGetStartedClicked = {}, ) } } diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SelectServerContent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SelectServerContent.kt new file mode 100644 index 00000000..0ebd008c --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SelectServerContent.kt @@ -0,0 +1,85 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.composables + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import social.androiddev.common.composables.buttons.DodoButton +import social.androiddev.common.composables.text.DodoTextField +import social.androiddev.common.theme.DodoTheme +import social.androiddev.signedout.navigation.SelectServerComponent + +/** + * Select Server view that delegates business/navigation logic to [SelectServerComponent] + * for when a user wants to select their mastodon domain/server + */ +@Composable +fun SelectServerContent( + modifier: Modifier, + component: SelectServerComponent, +) { + SelectServerContent( + modifier = modifier, + onServerSelected = component::onServerSelected, + ) +} + +@Composable +fun SelectServerContent( + modifier: Modifier, + onServerSelected: (String) -> Unit, +) { + + var server by rememberSaveable { mutableStateOf("") } + Column( + modifier = modifier, + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + + DodoTextField( + value = server, + onValueChange = { v -> + server = v + }, + ) + + Spacer(Modifier.height(24.dp)) + + DodoButton( + text = "Select", + onClick = { + onServerSelected(server) + }, + ) + } +} + +// @Preview +@Composable +private fun PreviewLandingContent() { + DodoTheme(true) { + SelectServerContent( + modifier = Modifier.fillMaxSize(), + onServerSelected = {}, + ) + } +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SignedOutRootContent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SignedOutRootContent.kt new file mode 100644 index 00000000..cac4cf1f --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/composables/SignedOutRootContent.kt @@ -0,0 +1,60 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.composables + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children +import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState +import social.androiddev.signedout.navigation.SignedOutRootComponent + +/** + * The root composable for when the user launches the app and is + * currently signed out. + * Business logic and decompose navigation is delegated to [SignedOutRootComponent]. + */ +@Composable +fun SignedOutRootContent( + component: SignedOutRootComponent, + modifier: Modifier = Modifier, +) { + val childStack by component.childStack.subscribeAsState() + + Box( + modifier = modifier, + contentAlignment = Alignment.Center, + ) { + + Children( + stack = childStack, + modifier = Modifier.fillMaxSize(), + ) { createdChild -> + when (val child = createdChild.instance) { + is SignedOutRootComponent.Child.Landing -> { + LandingContent( + modifier = Modifier.fillMaxSize(), + component = child.component, + ) + } + + is SignedOutRootComponent.Child.SelectServer -> { + SelectServerContent( + modifier = Modifier.fillMaxSize(), + component = child.component, + ) + } + } + } + } +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultLandingComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultLandingComponent.kt new file mode 100644 index 00000000..c4d3946b --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultLandingComponent.kt @@ -0,0 +1,22 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +import com.arkivanov.decompose.ComponentContext + +class DefaultLandingComponent( + private val componentContext: ComponentContext, + private val onGetStartedClickedInternal: () -> Unit, +) : LandingComponent, ComponentContext by componentContext { + + override fun onGetStartedClicked() { + onGetStartedClickedInternal() + } +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSelectServerComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSelectServerComponent.kt new file mode 100644 index 00000000..3308c5d3 --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSelectServerComponent.kt @@ -0,0 +1,22 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +import com.arkivanov.decompose.ComponentContext + +class DefaultSelectServerComponent( + private val componentContext: ComponentContext, + private val launchOAuth: (server: String) -> Unit, +) : SelectServerComponent, ComponentContext by componentContext { + + override fun onServerSelected(server: String) { + launchOAuth(server) + } +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSignedOutRootComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSignedOutRootComponent.kt new file mode 100644 index 00000000..3071ce23 --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/DefaultSignedOutRootComponent.kt @@ -0,0 +1,86 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.router.stack.StackNavigation +import com.arkivanov.decompose.router.stack.childStack +import com.arkivanov.decompose.router.stack.push +import com.arkivanov.decompose.value.Value +import com.arkivanov.essenty.parcelable.Parcelable +import com.arkivanov.essenty.parcelable.Parcelize + +class DefaultSignedOutRootComponent( + componentContext: ComponentContext +) : SignedOutRootComponent, ComponentContext by componentContext { + + // StackNavigation accepts navigation commands and forwards them to all subscribed observers. + private val navigation = StackNavigation() + + // ChildStack is a simple data class that stores a stack of components and their configurations. + private val stack: Value> = childStack( + source = navigation, + initialStack = { listOf(Config.Landing) }, + handleBackButton = true, // Pop the back stack on back button press + childFactory = ::createChild + ) + + override val childStack: Value> = stack + + private fun createChild(config: Config, componentContext: ComponentContext): SignedOutRootComponent.Child = + when (config) { + Config.Landing -> { + SignedOutRootComponent.Child.Landing(createLandingComponent(componentContext)) + } + Config.SelectServer -> { + SignedOutRootComponent.Child.SelectServer(createSelectServerComponent(componentContext)) + } + } + + private fun createLandingComponent( + componentContext: ComponentContext + ) = DefaultLandingComponent( + componentContext = componentContext, + onGetStartedClickedInternal = { + navigation.push(Config.SelectServer) + } + ) + + private fun createSelectServerComponent( + componentContext: ComponentContext + ) = DefaultSelectServerComponent( + componentContext = componentContext, + launchOAuth = { server -> + // TODO: Launch WebView with selected server + } + ) + + /** + * Supported configurations for all children in this root. + * A "configuration" represents a child component + * and contains all it's arguments. + * These configurations are persisted and restored on events like + * configuration changes, process death etc... + * + * All Configurations must: + * 1) Be immutable + * 2) Implement `equals()` and `hashCode()` + * 3) Implement Parcelable + */ + private sealed interface Config : Parcelable { + + @Parcelize + object Landing : Config + + @Parcelize + object SelectServer : Config + } +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/LandingComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/LandingComponent.kt new file mode 100644 index 00000000..09c49fcc --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/LandingComponent.kt @@ -0,0 +1,21 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +/** + * The base component describing all business logic needed for the welcome screen + */ +interface LandingComponent { + + /** + * Callback invoked when user clicks the "Get Started" button in the Welcome Screen + */ + fun onGetStartedClicked() +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SelectServerComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SelectServerComponent.kt new file mode 100644 index 00000000..72ba025a --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SelectServerComponent.kt @@ -0,0 +1,18 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +/** + * The base component describing all business logic needed for the select server screen + */ +interface SelectServerComponent { + + fun onServerSelected(server: String) +} diff --git a/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SignedOutRootComponent.kt b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SignedOutRootComponent.kt new file mode 100644 index 00000000..03736785 --- /dev/null +++ b/ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/navigation/SignedOutRootComponent.kt @@ -0,0 +1,33 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.signedout.navigation + +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.Value + +/** + * The base component describing all business logic needed for the signed-out root entry point + */ +interface SignedOutRootComponent { + + // Store a stack of components and their configurations in this root graph + val childStack: Value> + + /** + * Supported "Child"s in this navigation stack. These are created from a configuration that + * contains any arguments for this particular child in the navigation stack. + */ + sealed class Child { + + data class Landing(val component: LandingComponent) : Child() + + data class SelectServer(val component: SelectServerComponent) : Child() + } +} diff --git a/ui/timeline/build.gradle.kts b/ui/timeline/build.gradle.kts index a0f6e74c..1403adf8 100644 --- a/ui/timeline/build.gradle.kts +++ b/ui/timeline/build.gradle.kts @@ -2,15 +2,7 @@ plugins { id("kotlin-multiplatform") id("org.jetbrains.compose") id("com.android.library") - id("com.diffplug.spotless") version "6.11.0" -} - -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - ktlint("0.43.2") - licenseHeaderFile(rootProject.file("copyright.kt")) - } + id("social.androiddev.code-quality") } val targetSDKVersion: Int by rootProject.extra diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/HorizontalSpacer.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/HorizontalSpacer.kt index 8fba620b..8aaa05e9 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/HorizontalSpacer.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/HorizontalSpacer.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineCard.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineCard.kt index 655702c6..5e71b122 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineCard.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineCard.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline @@ -29,7 +29,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import social.androiddev.common.composables.UserAvatar -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme /** * Stateful @@ -133,7 +133,7 @@ val dummyFeedItem = FeedItemState( // @Preview @Composable private fun PreviewFeedCardLight() { - MastodonTheme(useDarkTheme = false) { + DodoTheme(useDarkTheme = false) { Box(Modifier.padding(12.dp)) { TimelineCard( state = dummyFeedItem, @@ -146,7 +146,7 @@ private fun PreviewFeedCardLight() { // @Preview @Composable private fun PreviewFeedCardDark() { - MastodonTheme(useDarkTheme = true) { + DodoTheme(useDarkTheme = true) { Box(Modifier.padding(12.dp)) { TimelineCard( state = dummyFeedItem, diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineScreen.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineContent.kt similarity index 52% rename from ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineScreen.kt rename to ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineContent.kt index f474adc6..1789c2d7 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineScreen.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TimelineContent.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline @@ -20,10 +20,27 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme +import social.androiddev.timeline.navigation.TimelineComponent + +/** + * Timeline view that delegates business/navigation logic to [TimelineComponent] + * for when a user wants to view their Timeline + */ +@Composable +fun TimelineContent( + component: TimelineComponent, + modifier: Modifier = Modifier, +) { + // TODO: Hook up to View Model for fetching timeline items + TimelineContent( + items = emptyList(), + modifier = modifier, + ) +} @Composable -fun TimelineScreen( +fun TimelineContent( items: List, modifier: Modifier = Modifier, ) { @@ -49,7 +66,7 @@ fun TimelineScreen( // @Preview @Composable private fun TimelinePreview() { - MastodonTheme { - TimelineScreen(listOf(dummyFeedItem)) + DodoTheme { + TimelineContent(listOf(dummyFeedItem)) } } diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContent.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContent.kt index 764d37a4..8add20da 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContent.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContent.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline @@ -18,7 +18,7 @@ import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme @Composable fun TootContent( @@ -56,7 +56,7 @@ fun TootContent( // @Preview @Composable private fun PreviewTootContentLight() { - MastodonTheme(useDarkTheme = false) { + DodoTheme(useDarkTheme = false) { Surface { TootContent( modifier = Modifier @@ -76,7 +76,7 @@ private fun PreviewTootContentLight() { // @Preview @Composable private fun PreviewTootContentDark() { - MastodonTheme(useDarkTheme = true) { + DodoTheme(useDarkTheme = true) { Surface { TootContent( modifier = Modifier diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContentHeader.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContentHeader.kt index ba83581d..db4ff38e 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContentHeader.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContentHeader.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline @@ -20,7 +20,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight -import social.androiddev.common.theme.MastodonTheme +import social.androiddev.common.theme.DodoTheme @Composable fun TootContentHeader( @@ -57,7 +57,7 @@ fun TootContentHeader( // @Preview @Composable private fun PreviewLight() { - MastodonTheme(useDarkTheme = false) { + DodoTheme(useDarkTheme = false) { Surface { TootContentHeader( modifier = Modifier.fillMaxWidth().wrapContentHeight(), @@ -72,7 +72,7 @@ private fun PreviewLight() { // @Preview @Composable private fun PreviewDark() { - MastodonTheme(useDarkTheme = true) { + DodoTheme(useDarkTheme = true) { Surface { TootContentHeader( modifier = Modifier.fillMaxWidth().wrapContentHeight(), diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/VerticalSpacer.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/VerticalSpacer.kt index 16fc16cc..cf40318d 100644 --- a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/VerticalSpacer.kt +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/VerticalSpacer.kt @@ -1,11 +1,11 @@ /* - * This file is part of MastodonX. + * This file is part of Dodo. * - * MastodonX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * MastodonX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with MastodonX. If not, see . + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . */ package social.androiddev.timeline diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/DefaultTimelineComponent.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/DefaultTimelineComponent.kt new file mode 100644 index 00000000..e60ed20b --- /dev/null +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/DefaultTimelineComponent.kt @@ -0,0 +1,16 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.timeline.navigation + +import com.arkivanov.decompose.ComponentContext + +class DefaultTimelineComponent( + private val componentContext: ComponentContext, +) : TimelineComponent diff --git a/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineComponent.kt b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineComponent.kt new file mode 100644 index 00000000..35236f68 --- /dev/null +++ b/ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineComponent.kt @@ -0,0 +1,15 @@ +/* + * This file is part of Dodo. + * + * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Dodo. If not, see . + */ +package social.androiddev.timeline.navigation + +/** + * The base component describing all business logic needed for the timeline view + */ +interface TimelineComponent