├── .githooks ├── pre-commit └── pre-push ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.yaml │ └── feature_request.yml ├── pull_request_template.md └── workflows │ └── continuous-delivery-pipeline.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── app-android ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ ├── kotlin │ └── social │ │ └── androiddev │ │ └── dodo │ │ ├── DodoApplication.kt │ │ ├── MainActivity.kt │ │ └── di │ │ └── AndroidAppModule.kt │ └── res │ ├── drawable │ └── ic_launcher_foreground.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ └── values │ ├── ic_launcher_background.xml │ └── strings.xml ├── app-desktop ├── build.gradle.kts └── src │ └── jvmMain │ └── kotlin │ └── social │ └── androiddev │ └── desktop │ └── Main.kt ├── app-ios └── .gitkeep ├── build-logic ├── convention-plugins │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ ├── social.androiddev.android.common.gradle.kts │ │ ├── social.androiddev.codequality.gradle.kts │ │ ├── social.androiddev.library.common.gradle.kts │ │ ├── social.androiddev.library.gradle.kts │ │ └── social.androiddev.library.ui.gradle.kts └── settings.gradle.kts ├── build.gradle.kts ├── config └── detekt │ └── detekt.yml ├── copyright.txt ├── data ├── network │ ├── build.gradle.kts │ └── src │ │ ├── androidMain │ │ ├── AndroidManifest.xml │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── network │ │ │ ├── AndroidPlatform.kt │ │ │ └── AndroidUrlStream.kt │ │ ├── commonMain │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── network │ │ │ ├── MastodonApi.kt │ │ │ ├── MastodonApiKtor.kt │ │ │ ├── Platform.kt │ │ │ ├── UrlStream.kt │ │ │ ├── di │ │ │ └── NetworkModule.kt │ │ │ ├── model │ │ │ ├── Account.kt │ │ │ ├── Activity.kt │ │ │ ├── Announcement.kt │ │ │ ├── AnnouncementReaction.kt │ │ │ ├── Application.kt │ │ │ ├── Attachment.kt │ │ │ ├── AvailableInstance.kt │ │ │ ├── Card.kt │ │ │ ├── Context.kt │ │ │ ├── Conversation.kt │ │ │ ├── Emoji.kt │ │ │ ├── Error.kt │ │ │ ├── FeaturedTag.kt │ │ │ ├── Field.kt │ │ │ ├── Filter.kt │ │ │ ├── History.kt │ │ │ ├── IdentityProof.kt │ │ │ ├── Instance.kt │ │ │ ├── Marker.kt │ │ │ ├── Mention.kt │ │ │ ├── Notification.kt │ │ │ ├── Poll.kt │ │ │ ├── Preferences.kt │ │ │ ├── PushSubscription.kt │ │ │ ├── Source.kt │ │ │ ├── Status.kt │ │ │ ├── Tag.kt │ │ │ ├── Token.kt │ │ │ ├── UserList.kt │ │ │ └── request │ │ │ │ ├── CreateAccessTokenBody.kt │ │ │ │ └── CreateApplicationBody.kt │ │ │ └── util │ │ │ └── RunCatching.kt │ │ ├── commonTest │ │ ├── kotlin │ │ │ └── social │ │ │ │ └── androiddev │ │ │ │ └── common │ │ │ │ └── network │ │ │ │ ├── MastodonApiTests.kt │ │ │ │ ├── fixtures │ │ │ │ └── TestFixtures.kt │ │ │ │ └── model │ │ │ │ ├── AccountTests.kt │ │ │ │ ├── ActivityTests.kt │ │ │ │ ├── AnnouncementReactionTests.kt │ │ │ │ ├── AnnouncementTests.kt │ │ │ │ ├── ApplicationTests.kt │ │ │ │ ├── AttachmentTests.kt │ │ │ │ ├── CardTests.kt │ │ │ │ ├── ContextTests.kt │ │ │ │ ├── ConversationTests.kt │ │ │ │ ├── EmojiTests.kt │ │ │ │ ├── ErrorTests.kt │ │ │ │ ├── FeatureTests.kt │ │ │ │ ├── FilterTests.kt │ │ │ │ ├── HistoryTests.kt │ │ │ │ ├── IdentityProofTests.kt │ │ │ │ ├── MarkerTests.kt │ │ │ │ ├── MentionTests.kt │ │ │ │ ├── NotificationTests.kt │ │ │ │ ├── PollTests.kt │ │ │ │ ├── PreferencesTests.kt │ │ │ │ ├── PushSubscriptionTests.kt │ │ │ │ ├── StatusTests.kt │ │ │ │ ├── TagTests.kt │ │ │ │ └── UserListTests.kt │ │ └── resources │ │ │ ├── response_account_required.json │ │ │ ├── response_context_required.json │ │ │ ├── response_conversation_required.json │ │ │ ├── response_instance_valid.json │ │ │ ├── response_notification_required.json │ │ │ └── response_status_required.json │ │ ├── desktopMain │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── network │ │ │ ├── DesktopPlatform.kt │ │ │ └── UrlStream.kt │ │ └── iosMain │ │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── network │ │ ├── IOSPlatform.kt │ │ └── UrlStream.kt ├── persistence │ ├── build.gradle.kts │ └── src │ │ ├── androidAndroidTest │ │ └── aidl │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── AndroidTestSqlDriver.kt │ │ ├── androidMain │ │ ├── AndroidManifest.xml │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── di │ │ │ └── AndroidPersistenceModule.kt │ │ ├── androidTest │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── AndroidTestDatabaseDriver.kt │ │ ├── commonMain │ │ ├── kotlin │ │ │ └── social │ │ │ │ └── androiddev │ │ │ │ └── common │ │ │ │ └── persistence │ │ │ │ ├── authentication │ │ │ │ └── AuthenticationDatabaseWrapper.kt │ │ │ │ ├── di │ │ │ │ └── PersistenceModule.kt │ │ │ │ └── localstorage │ │ │ │ ├── DodoAuthStorage.kt │ │ │ │ └── DodoAuthStorageImpl.kt │ │ ├── sqldelight │ │ │ └── social │ │ │ │ └── androiddev │ │ │ │ └── common │ │ │ │ └── persistence │ │ │ │ └── authentication │ │ │ │ └── Application.sq │ │ └── sqldelightTimeline │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── timeline │ │ │ ├── ConflictResolution.sq │ │ │ └── Timeline.sq │ │ ├── commonTest │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ ├── DatabaseDriver.kt │ │ │ └── authentication │ │ │ └── AuthenticationDatabaseTests.kt │ │ ├── desktopMain │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── di │ │ │ └── DesktopPersistenceModule.kt │ │ ├── desktopTest │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── DesktopTestDatabaseDriver.kt │ │ ├── iosMain │ │ └── kotlin │ │ │ └── social │ │ │ └── androiddev │ │ │ └── common │ │ │ └── persistence │ │ │ └── di │ │ │ └── IOSPersistenceModule.kt │ │ └── iosTest │ │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── persistence │ │ └── IOSTestDatabaseDriver.kt └── repository │ ├── build.gradle.kts │ └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── repository │ │ └── .gitkeep │ ├── commonMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── repository │ │ ├── AuthenticationRepositoryImpl.kt │ │ ├── di │ │ └── RepositoryModule.kt │ │ └── timeline │ │ ├── ModelMappers.kt │ │ ├── RealHomeTimelineRepository.kt │ │ ├── TimelineFetcher.kt │ │ ├── TimelineRepoModule.kt │ │ └── TimelineSourceOfTruth.kt │ ├── commonTest │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── repository │ │ └── timeline │ │ ├── AuthenticationRepositoryTest.kt │ │ ├── RealHomeTimelineRepositoryTest.kt │ │ ├── TimelineFetcherKtTest.kt │ │ └── fixtures │ │ └── TestFixtures.kt │ ├── desktopMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── repository │ │ └── .gitkeep │ └── iosMain │ └── kotlin │ └── social │ └── androiddev │ └── common │ └── repository │ └── .gitkeep ├── di ├── build.gradle.kts └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── Platform.kt │ ├── commonMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ ├── Platform.kt │ │ └── di │ │ ├── AppModule.kt │ │ └── PlatformModule.kt │ ├── desktopMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── Platform.kt │ └── iosMain │ └── kotlin │ └── social │ └── androiddev │ └── common │ └── Platform.kt ├── domain ├── authentication │ ├── build.gradle.kts │ └── src │ │ ├── androidMain │ │ └── AndroidManifest.xml │ │ └── commonMain │ │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── domain │ │ └── authentication │ │ ├── di │ │ └── DomainAuthenticationModule.kt │ │ ├── model │ │ ├── ApplicationOAuthToken.kt │ │ ├── AuthStatus.kt │ │ └── NewAppOAuthToken.kt │ │ ├── repository │ │ └── AuthenticationRepository.kt │ │ └── usecase │ │ ├── AuthenticateClient.kt │ │ ├── CreateAccessToken.kt │ │ ├── GetAuthStatus.kt │ │ ├── GetSelectedApplicationOAuthToken.kt │ │ └── LogoutFromCurrentServer.kt └── timeline │ ├── build.gradle.kts │ └── src │ ├── androidMain │ └── AndroidManifest.xml │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── domain │ └── timeline │ ├── HomeTimelineRepository.kt │ ├── model │ ├── Account.kt │ ├── StatusLocal.kt │ └── Visibility.kt │ └── usecase │ └── .gitkeep ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── kotlin-utils ├── build.gradle.kts └── src │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── kotlinutils │ └── NullUnless.kt ├── logging ├── build.gradle.kts └── src │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── common │ └── logging │ ├── DodoLogger.kt │ └── LoggingModule.kt ├── settings.gradle.kts └── ui ├── common ├── build.gradle.kts └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ └── utils │ │ └── ImageLoading.kt │ ├── commonMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── common │ │ ├── composables │ │ ├── UserAvatar.kt │ │ ├── buttons │ │ │ ├── MastodonButton.kt │ │ │ ├── MastodonOutlinedButton.kt │ │ │ └── MastodonTextButton.kt │ │ └── text │ │ │ └── MastodonTextField.kt │ │ ├── decompose │ │ ├── CoroutineScopeExt.kt │ │ └── LifecycleOwnerExt.kt │ │ ├── theme │ │ ├── DodoColors.kt │ │ ├── DodoTheme.kt │ │ └── DodoTypography.kt │ │ └── utils │ │ ├── AsyncImage.kt │ │ └── ImageLoading.kt │ └── desktopMain │ └── kotlin │ └── social │ └── androiddev │ └── common │ └── utils │ └── ImageLoading.kt ├── desktop-webview ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── social │ └── androiddev │ └── ui │ └── desktop │ └── webview │ ├── JFXWebView.kt │ └── WebView.kt ├── messages └── src │ ├── main │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── messages │ │ └── .gitkeep │ └── test │ └── kotlin │ └── social │ └── androiddev │ └── messages │ └── .gitkeep ├── notifications └── src │ ├── main │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── notifications │ │ └── .gitkeep │ └── test │ └── kotlin │ └── social │ └── androiddev │ └── notifications │ └── .gitkeep ├── root ├── build.gradle.kts └── src │ ├── androidMain │ └── AndroidManifest.xml │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── root │ ├── root │ ├── DefaultRootComponent.kt │ ├── RootComponent.kt │ ├── RootComponentViewModel.kt │ ├── RootContent.kt │ └── UiAuthStatus.kt │ └── splash │ ├── DefaultSplashComponent.kt │ ├── SplashComponent.kt │ └── SplashContent.kt ├── search └── src │ ├── main │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── search │ │ └── .gitkeep │ └── test │ └── kotlin │ └── social │ └── androiddev │ └── search │ └── .gitkeep ├── settings ├── build.gradle.kts └── src │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── settings │ ├── RealSettingsComponent.kt │ ├── SettingsComponent.kt │ └── SettingsContent.kt ├── signed-in ├── build.gradle.kts └── src │ ├── androidMain │ └── AndroidManifest.xml │ └── commonMain │ └── kotlin │ └── social │ └── androiddev │ └── signedin │ ├── composables │ └── SignedInRootContent.kt │ └── navigation │ ├── DefaultSignedInRootComponent.kt │ ├── NavHeaderSettings.kt │ └── SignedInRootComponent.kt ├── signed-out ├── build.gradle.kts └── src │ ├── androidMain │ ├── AndroidManifest.xml │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── signedout │ │ ├── selectserver │ │ └── AndroidRedirectScheme.kt │ │ └── signin │ │ └── SignInWebView.kt │ ├── commonMain │ └── kotlin │ │ └── social │ │ └── androiddev │ │ └── signedout │ │ ├── landing │ │ ├── DefaultLandingComponent.kt │ │ ├── LandingComponent.kt │ │ └── LandingContent.kt │ │ ├── root │ │ ├── DefaultSignedOutRootComponent.kt │ │ ├── SignedOutRootComponent.kt │ │ └── SignedOutRootContent.kt │ │ ├── selectserver │ │ ├── DefaultSelectServerComponent.kt │ │ ├── RedirectScheme.kt │ │ ├── SelectServerComponent.kt │ │ ├── SelectServerContent.kt │ │ └── SelectServerViewModel.kt │ │ ├── signin │ │ ├── DefaultSignInComponent.kt │ │ ├── SignInComponent.kt │ │ ├── SignInContent.kt │ │ ├── SignInViewModel.kt │ │ └── SignInWebView.kt │ │ └── util │ │ └── StringExt.kt │ └── desktopMain │ └── kotlin │ └── social │ └── androiddev │ └── signedout │ ├── selectserver │ └── DesktopRedirectScheme.kt │ └── signin │ └── SignInWebView.kt └── timeline ├── build.gradle.kts └── src ├── androidMain └── AndroidManifest.xml └── commonMain └── kotlin └── social └── androiddev └── timeline ├── HorizontalSpacer.kt ├── TimelineCard.kt ├── TimelineContent.kt ├── TootContent.kt ├── TootContentHeader.kt ├── VerticalSpacer.kt └── navigation ├── DefaultTimelineComponent.kt ├── TimelineComponent.kt └── TimelineViewModel.kt /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # hook script to format code and add missing license headers to every kotlin file. 4 | 5 | echo "***** Run code formatting ******" 6 | git stash -q --keep-index 7 | 8 | ./gradlew spotlessApply 9 | 10 | status=$? 11 | 12 | git stash pop -q 13 | 14 | echo "***** Done with code formatting ******" 15 | 16 | exit $status 17 | -------------------------------------------------------------------------------- /.githooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # hook script to verify code formatting and runs tests for all modules 4 | 5 | echo "***** Run verifying and tests ******" 6 | 7 | ./gradlew check 8 | 9 | status=$? 10 | 11 | echo "***** Done with verifying and tests ******" 12 | 13 | exit $status 14 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file helps to identify who should be responsible for reviewing specific files of a project. 2 | # 3 | # https://github.blog/2017-07-06-introducing-code-owners/ 4 | 5 | # Add a fallback to default owners 6 | * @thebino @crocsandcoffee 7 | 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yaml: -------------------------------------------------------------------------------- 1 | name: 🐛Bug Report 2 | description: File a bug report here 3 | title: "[BUG]: " 4 | labels: ["bug"] 5 | assignees: ["thebino"] 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | Thanks for taking the time to fill out this bug report 🤗 11 | Make sure there aren't any open/closed issues for this topic 😃 12 | 13 | - type: textarea 14 | id: bug-description 15 | attributes: 16 | label: Description of the bug 17 | description: Give us a brief description of what happened and what should have happened 18 | validations: 19 | required: true 20 | 21 | - type: textarea 22 | id: steps-to-reproduce 23 | attributes: 24 | label: Steps To Reproduce 25 | description: Steps to reproduce the behavior. 26 | placeholder: | 27 | 1. Go to '...' 28 | 2. Click on '...' 29 | 3. Scroll down to '...' 30 | 4. See error 31 | validations: 32 | required: true 33 | - type: textarea 34 | id: additional-information 35 | attributes: 36 | label: Additional Information 37 | description: | 38 | Provide any additional information such as logs, screenshots, likes, scenarios in which the bug occurs so that it facilitates resolving the issue. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: ✨Feature Request 2 | description: Request a new feature or enhancement 3 | labels: ["enhancement"] 4 | title: "[FEAT]: " 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Please make sure this feature request hasn't been already submitted by someone by looking through other open/closed issues 10 | 11 | - type: textarea 12 | id: description 13 | attributes: 14 | label: Description 15 | description: Give us a brief description of the feature or enhancement you would like 16 | validations: 17 | required: true 18 | 19 | - type: textarea 20 | id: additional-information 21 | attributes: 22 | label: Additional Information 23 | description: Give us some additional information on the feature request like proposed solutions, links, screenshots, etc. 24 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## 📑 What does this PR do? 2 | 3 | 4 | 5 | # ✅ Checklist 6 | 7 | - [ ] My pull request adheres to the code style of this project 8 | - [ ] My code requires changes to the documentation 9 | - [ ] I have updated the documentation as required 10 | - [ ] All the tests have passed 11 | 12 | ## 🧪 How can this PR been tested? 13 | 14 | 15 | ## 🧾 Tasks Remaining: (List of tasks remaining to be implemented) 16 | 17 | - What is remaining to be implemented in this PR? Mention a list of them 18 | 19 | 20 | ## 🖼️ Screenshots (if applicable): 21 | -------------------------------------------------------------------------------- /.github/workflows/continuous-delivery-pipeline.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Delivery Pipeline 2 | # This is responsible for the whole delivery pipeline (build, integrate, test and release) 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | - development 9 | pull_request: 10 | types: [opened, synchronize, reopened, edited] 11 | 12 | jobs: 13 | 14 | build: 15 | strategy: 16 | matrix: 17 | config: [ 18 | { target: android, os: ubuntu-latest, tasks: "testDebugUnitTest testReleaseUnitTest :app-android:test", continueOnError: false }, 19 | { target: ios, os: macos-12, tasks: "iosX64Test iosSimulatorArm64Test", continueOnError: false }, 20 | { target: desktop, os: windows-latest, tasks: "desktopTest :app-desktop:test", continueOnError: false }, 21 | ] 22 | runs-on: ${{ matrix.config.os }} 23 | name: Build ${{ matrix.config.target }} 24 | 25 | steps: 26 | - name: Checkout repository 27 | uses: actions/checkout@v3 28 | 29 | - name: Set up JDK 11 30 | uses: actions/setup-java@v3 31 | with: 32 | java-version: 11 33 | distribution: temurin 34 | cache: gradle 35 | 36 | - uses: maxim-lobanov/setup-xcode@v1 37 | if: ${{ matrix.config.target == 'ios' }} 38 | with: 39 | xcode-version: latest-stable 40 | 41 | - name: Build all 42 | run: | 43 | ./gradlew --console=plain build --stacktrace 44 | 45 | unit_tests: 46 | runs-on: ubuntu-latest 47 | timeout-minutes: 30 48 | 49 | steps: 50 | - name: Checkout repository 51 | uses: actions/checkout@v3 52 | 53 | - name: Set up JDK 11 54 | uses: actions/setup-java@v3 55 | with: 56 | java-version: 11 57 | distribution: temurin 58 | cache: 'gradle' 59 | 60 | - name: Run tests 61 | run: | 62 | ./gradlew --console=plain test --stacktrace 63 | 64 | - name: Upload test reports 65 | if: always() 66 | uses: actions/upload-artifact@v2 67 | with: 68 | name: tests 69 | path: ./**/build/reports/tests 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Mac files 6 | .DS_Store 7 | 8 | # files for the dex VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # generated files 15 | bin/ 16 | gen/ 17 | 18 | # Ignore gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | proguard-project.txt 28 | 29 | # Eclipse files 30 | .project 31 | .classpath 32 | .settings/ 33 | 34 | # Android Studio/IDEA 35 | *.iml 36 | .idea 37 | /captures 38 | 39 | ## Do not ignore project settings 40 | !.idea/codeInsightSettings.xml 41 | !.idea/codeStyles/ 42 | !.idea/copyright/ 43 | !.idea/dataSources.xml 44 | !.idea/detekt.xml 45 | !.idea/encodings.xml 46 | !.idea/externalDependencies.xml 47 | !.idea/fileTemplates/ 48 | !.idea/icon.png 49 | !.idea/inspectionProfiles/ 50 | !.idea/runConfigurations/ 51 | !.idea/scopes/ 52 | !.idea/vcs.xml 53 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | 11 | ## [0.0.1] - 2022-11-07 12 | ### Added 13 | - First project setup 14 | 15 | 16 | [Unreleased]: https://github.com/thebino/MastodonCompose/compare/v0.0.1...HEAD 17 | [0.0.1]: https://github.com/thebino/MastodonCompose/releases/tag/v0.0.1 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dodo 2 | [![GNU GPL-3.0](https://img.shields.io/github/license/thebino/MastodonCompose)](https://img.shields.io/github/license/thebino/MastodonCompose) 3 | ![CI](https://github.com/AndroidDev-social/DodoForMastodon/actions/workflows/continuous-delivery-pipeline.yml/badge.svg) 4 | 5 | A multiplatform Mastodon client written in [Kotlin](kotlinlang.org) for the amazing [androiddev.social](https://androiddev.social) community and everyone else who enjoys #Fediverse 6 | 7 | [Join our Slack](https://join.slack.com/t/androiddev-social/shared_invite/zt-1jchjo9kz-_Q_I02QWeenpya10Is6trQ) 8 | 9 | --- 10 | 11 | ## Getting started 12 | 13 | The app is not published nor ready for use. Later on it will probably just be installed from any of the available sources. 14 | 15 | [F-Droid] 16 | [Google Play] 17 | [Apple Appstore] 18 | 19 | 20 | ## Contribution 21 | 22 | This is a free and open project and lives from contributions of the community. 23 | 24 | See our [Contribution Guidelines](CONTRIBUTING.md) 25 | 26 | 27 | ## MVP 28 | 29 | 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. 30 | 31 | ### Roadmap 32 | 33 | * *Sign up* a new account 34 | * Select an instance [joinmastodon servers](https://joinmastodon.org/de/servers) 35 | * *Sign in* with credentials 36 | * Browse *local* timeline 37 | * Create a Toot! 38 | * Log out 39 | 40 | Check out [the Progress](https://github.com/AndroidDev-social/DodoForMastodon/milestones) 41 | 42 | 43 | ## License 44 | 45 | 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. 46 | 47 | 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. 48 | 49 | You should have received a copy of the GNU General Public License along with Dodo. If not, see . 50 | -------------------------------------------------------------------------------- /app-android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("social.androiddev.android.common") 4 | kotlin("android") 5 | id("org.jetbrains.compose") 6 | id("kotlin-parcelize") 7 | } 8 | 9 | android { 10 | namespace = "social.androiddev.dodo" 11 | 12 | defaultConfig { 13 | versionCode = 1 14 | versionName = "1.0" 15 | } 16 | } 17 | 18 | dependencies { 19 | implementation(projects.ui.root) 20 | implementation(projects.ui.common) 21 | implementation(libs.androidx.core.ktx) 22 | implementation(libs.androidx.appcompat) 23 | implementation(libs.androidx.activity.compose) 24 | implementation(libs.androidx.compose.foundation) 25 | implementation(projects.di) 26 | implementation(libs.io.insert.koin.core) 27 | implementation(libs.io.insert.koin.android) 28 | implementation(libs.com.arkivanov.decompose) 29 | implementation(libs.com.arkivanov.decompose.extensions.compose.jetbrains) 30 | } 31 | -------------------------------------------------------------------------------- /app-android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app-android/src/main/kotlin/social/androiddev/dodo/DodoApplication.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.dodo 14 | 15 | import android.app.Application 16 | import org.koin.android.ext.koin.androidContext 17 | import org.koin.android.ext.koin.androidLogger 18 | import org.koin.core.context.startKoin 19 | import social.androiddev.common.di.appModule 20 | import social.androiddev.dodo.di.androidModule 21 | 22 | class DodoApplication : Application() { 23 | override fun onCreate() { 24 | super.onCreate() 25 | startKoin { 26 | androidContext(this@DodoApplication) 27 | androidLogger() 28 | modules(appModule() + androidModule) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app-android/src/main/kotlin/social/androiddev/dodo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.dodo 14 | 15 | import android.os.Bundle 16 | import androidx.activity.compose.setContent 17 | import androidx.appcompat.app.AppCompatActivity 18 | import androidx.compose.foundation.layout.fillMaxSize 19 | import androidx.compose.ui.Modifier 20 | import com.arkivanov.decompose.defaultComponentContext 21 | import kotlinx.coroutines.Dispatchers 22 | import social.androiddev.common.theme.DodoTheme 23 | import social.androiddev.root.root.DefaultRootComponent 24 | import social.androiddev.root.root.RootContent 25 | 26 | class MainActivity : AppCompatActivity() { 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | 31 | // Create the root component before starting Compose 32 | val root = DefaultRootComponent( 33 | componentContext = defaultComponentContext(), 34 | mainContext = Dispatchers.Main, 35 | ) 36 | 37 | setContent { 38 | DodoTheme { 39 | RootContent( 40 | component = root, 41 | modifier = Modifier.fillMaxSize(), 42 | ) 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app-android/src/main/kotlin/social/androiddev/dodo/di/AndroidAppModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.dodo.di 14 | 15 | import org.koin.dsl.module 16 | 17 | /** 18 | * The Dodo Android app Koin module holding koin definitions 19 | * specific to the android app 20 | */ 21 | val androidModule = module { } 22 | -------------------------------------------------------------------------------- /app-android/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app-android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app-android/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3C3F41 4 | -------------------------------------------------------------------------------- /app-android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Dodo 3 | Dodo for Mastodon 4 | 5 | -------------------------------------------------------------------------------- /app-desktop/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat 2 | 3 | plugins { 4 | id("social.androiddev.codequality") 5 | kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) 6 | id("org.jetbrains.compose") 7 | } 8 | 9 | kotlin { 10 | jvm { 11 | withJava() 12 | } 13 | 14 | sourceSets { 15 | named("jvmMain") { 16 | dependencies { 17 | implementation(compose.desktop.currentOs) 18 | implementation(projects.ui.root) 19 | implementation(projects.di) 20 | implementation(projects.ui.common) 21 | implementation(libs.com.arkivanov.decompose) 22 | implementation(libs.com.arkivanov.decompose.extensions.compose.jetbrains) 23 | implementation(libs.io.insert.koin.core) 24 | implementation(libs.kotlinx.coroutines.javafx) 25 | implementation(libs.kotlinx.coroutines.core) 26 | } 27 | } 28 | } 29 | } 30 | 31 | compose.desktop { 32 | application { 33 | mainClass = "social.androiddev.desktop.MainKt" 34 | 35 | nativeDistributions { 36 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) 37 | packageName = "Dodo" 38 | packageVersion = "1.0.0" 39 | 40 | modules("java.sql") 41 | 42 | windows { 43 | menuGroup = "Dodo" 44 | // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html 45 | upgradeUuid = "ccfe9aed-16ce-42e3-9fd9-92720794b2c2" 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app-ios/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/app-ios/.gitkeep -------------------------------------------------------------------------------- /build-logic/convention-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation(libs.com.diffplug.spotless.gradle.plugin) 7 | implementation(libs.org.jetbrains.kotlin.gradle.plugin) 8 | implementation(libs.org.jetbrains.compose.gradle.plugin) 9 | implementation(libs.com.android.tools.build.gradle) 10 | // hack to access version catalogue https://github.com/gradle/gradle/issues/15383 11 | implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) 12 | } -------------------------------------------------------------------------------- /build-logic/convention-plugins/src/main/kotlin/social.androiddev.android.common.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convention plugin to apply android configuration that's common across both library and app 3 | * modules. 4 | */ 5 | plugins { 6 | id("social.androiddev.codequality") 7 | } 8 | 9 | android { 10 | compileSdk = 33 11 | 12 | defaultConfig { 13 | minSdk = 24 14 | } 15 | 16 | // targetSdk is in a different interface for library and application projects 17 | when (this) { 18 | is com.android.build.api.dsl.ApplicationBaseFlavor -> { 19 | targetSdk = 33 20 | } 21 | 22 | is com.android.build.api.dsl.LibraryBaseFlavor -> { 23 | targetSdk = 33 24 | } 25 | } 26 | 27 | compileOptions { 28 | sourceCompatibility = JavaVersion.VERSION_11 29 | targetCompatibility = JavaVersion.VERSION_11 30 | } 31 | } 32 | 33 | fun Project.android(configure: com.android.build.api.dsl.CommonExtension<*, *, *, *>.() -> Unit) { 34 | extensions.configure("android", configure) 35 | } 36 | -------------------------------------------------------------------------------- /build-logic/convention-plugins/src/main/kotlin/social.androiddev.codequality.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convention plugin to apply various code-quality tools. Since this should be included in every 3 | * module, it's applied automatically by other convention plugins, but can be applied directly for 4 | * any module that doesn't use any. 5 | */ 6 | plugins { 7 | id("com.diffplug.spotless") 8 | } 9 | 10 | spotless { 11 | kotlin { 12 | target("src/*/kotlin/**/*.kt") 13 | ktlint("0.43.2") 14 | licenseHeaderFile(File(rootDir, "copyright.txt")) 15 | } 16 | } -------------------------------------------------------------------------------- /build-logic/convention-plugins/src/main/kotlin/social.androiddev.library.common.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convention plugin to apply common configurations for library modules. Instead of depending on 3 | * this directly you should depend on `social.androiddev.library` or `social.androiddev.library.ui`. 4 | */ 5 | plugins { 6 | id("org.jetbrains.kotlin.multiplatform") 7 | id("com.android.library") 8 | id("social.androiddev.android.common") 9 | } 10 | 11 | android { 12 | sourceSets { 13 | named("main") { 14 | manifest.srcFile("src/androidMain/AndroidManifest.xml") 15 | res.srcDirs("src/androidMain/res") 16 | } 17 | } 18 | } 19 | 20 | // Workaround for: 21 | // 22 | // The Kotlin source set androidAndroidTestRelease was configured but not added to any 23 | // Kotlin compilation. You can add a source set to a target's compilation by connecting it 24 | // with the compilation's default source set using 'dependsOn'. 25 | // See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets 26 | // 27 | // Remove log pollution until Android support in KMP improves. 28 | // 29 | afterEvaluate { 30 | project.extensions.findByType()?.let { ext -> 31 | ext.sourceSets.removeAll { sourceSet -> 32 | setOf( 33 | "androidAndroidTestRelease", 34 | "androidTestFixtures", 35 | "androidTestFixturesDebug", 36 | "androidTestFixturesRelease", 37 | ).contains(sourceSet.name) 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /build-logic/convention-plugins/src/main/kotlin/social.androiddev.library.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convention plugin for non-ui library modules. 3 | */ 4 | plugins { 5 | id("social.androiddev.library.common") 6 | } 7 | 8 | val libs = the() 9 | 10 | kotlin { 11 | jvm("desktop") 12 | android() 13 | ios() 14 | 15 | sourceSets { 16 | // shared 17 | val commonMain by getting 18 | 19 | val androidMain by getting { 20 | dependsOn(commonMain) 21 | } 22 | 23 | // testing 24 | val commonTest by getting { 25 | dependencies { 26 | implementation(kotlin("test")) 27 | implementation(libs.org.jetbrains.kotlin.test.common) 28 | implementation(libs.org.jetbrains.kotlin.test.annotations.common) 29 | } 30 | } 31 | val androidTest by getting { 32 | dependencies { 33 | implementation(kotlin("test")) 34 | implementation(libs.org.jetbrains.kotlin.test.junit) 35 | } 36 | } 37 | val desktopTest by getting { 38 | dependencies { 39 | implementation(kotlin("test")) 40 | implementation(libs.org.jetbrains.kotlin.test.junit) 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /build-logic/convention-plugins/src/main/kotlin/social.androiddev.library.ui.gradle.kts: -------------------------------------------------------------------------------- 1 | /** 2 | * Convention plugin for ui library modules. Includes compose dependencies. Currently does not 3 | * support iOS. 4 | */ 5 | plugins { 6 | id("social.androiddev.library.common") 7 | id("org.jetbrains.compose") 8 | } 9 | 10 | val libs = the() 11 | 12 | kotlin { 13 | jvm("desktop") 14 | android() 15 | 16 | sourceSets { 17 | // shared 18 | val commonMain by getting { 19 | dependencies { 20 | implementation(compose.runtime) 21 | implementation(compose.foundation) 22 | implementation(compose.material) 23 | } 24 | } 25 | 26 | // android 27 | val androidMain by getting { 28 | dependencies { 29 | implementation(libs.androidx.core.ktx) 30 | // Workaround for https://github.com/JetBrains/compose-jb/issues/2340 31 | implementation(libs.androidx.compose.foundation) 32 | } 33 | } 34 | 35 | // desktop 36 | val desktopMain by getting { 37 | dependencies { 38 | implementation(compose.desktop.common) 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "build-logic" 2 | 3 | dependencyResolutionManagement { 4 | repositories { 5 | gradlePluginPortal() 6 | mavenCentral() 7 | google() 8 | } 9 | versionCatalogs { 10 | create("libs") { 11 | from(files("../gradle/libs.versions.toml")) 12 | } 13 | } 14 | } 15 | 16 | include(":convention-plugins") -------------------------------------------------------------------------------- /copyright.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | -------------------------------------------------------------------------------- /data/network/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidPlatform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | class AndroidPlatform : Platform { 16 | override val name: String = "Android" 17 | override val version: String = "0.1.0" 18 | override val build: String = "1" 19 | } 20 | 21 | actual fun getPlatform(): Platform = AndroidPlatform() 22 | -------------------------------------------------------------------------------- /data/network/src/androidMain/kotlin/social/androiddev/common/network/AndroidUrlStream.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | import io.ktor.client.HttpClient 16 | import io.ktor.client.call.body 17 | import io.ktor.client.engine.cio.CIO 18 | import io.ktor.client.request.get 19 | import java.io.ByteArrayInputStream 20 | 21 | actual suspend fun urlStream(url: String): ByteArray = HttpClient(CIO).use { 22 | ByteArrayInputStream(it.get(url).body()).readBytes() 23 | } 24 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | interface Platform { 16 | val name: String 17 | val version: String 18 | val build: String 19 | } 20 | 21 | expect fun getPlatform(): Platform 22 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/UrlStream.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | expect suspend fun urlStream(url: String): ByteArray 16 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Activity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/activity/ 20 | */ 21 | @Serializable 22 | data class Activity( 23 | @SerialName("week") val week: String, 24 | @SerialName("statuses") val statuses: String, 25 | @SerialName("logins") val logins: String, 26 | @SerialName("registrations") val registrations: String, 27 | ) 28 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Announcement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/announcement/ 20 | */ 21 | @Serializable 22 | data class Announcement( 23 | // Base attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("text") val text: String, 26 | @SerialName("published") val published: Boolean, 27 | @SerialName("all_day") val allDay: Boolean, 28 | @SerialName("created_at") val createdAt: String, 29 | @SerialName("updated_at") val updatedAt: String, 30 | @SerialName("read") val read: Boolean, 31 | @SerialName("reactions") val reactions: List, 32 | 33 | // Optional attributes 34 | @SerialName("scheduled_at") val scheduledAt: String? = null, 35 | @SerialName("starts_at") val startsAt: String? = null, 36 | @SerialName("ends_at") val endsAt: String? = null, 37 | ) 38 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AnnouncementReaction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/announcementreaction/ 20 | */ 21 | @Serializable 22 | data class AnnouncementReaction( 23 | // base attributes 24 | @SerialName("name") val name: String, 25 | @SerialName("count") val count: Int, 26 | @SerialName("me") val me: Boolean, 27 | 28 | // custom emoji attributes 29 | @SerialName("url") val url: String? = null, 30 | @SerialName("static_url") val staticUrl: String? = null, 31 | ) 32 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Application.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/application/ 20 | */ 21 | @Serializable 22 | data class Application( 23 | val name: String, 24 | @SerialName("vapid_key") val vapidKey: String? = null, 25 | 26 | // optional attributes 27 | val website: String? = null, 28 | ) 29 | 30 | @Serializable 31 | data class NewOauthApplication( 32 | val id: String, 33 | val name: String, 34 | @SerialName("vapid_key") val vapidKey: String, 35 | 36 | // client attributes 37 | @SerialName("client_id") val clientId: String, 38 | @SerialName("client_secret") val clientSecret: String, 39 | 40 | // optional attributes 41 | val website: String? = null, 42 | ) 43 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/AvailableInstance.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | @Serializable 19 | data class AvailableInstance( 20 | val domain: String, 21 | val version: String, 22 | val description: String, 23 | val languages: List, 24 | val region: String, 25 | val categories: List, 26 | @SerialName("proxied_thumbnail") val thumbnail: String, 27 | @SerialName("total_users") val totalUsers: Int, 28 | @SerialName("last_week_users") val lastWeekUsers: Int, 29 | @SerialName("approval_required") val approvalRequired: Boolean, 30 | val language: String, 31 | val category: String, 32 | ) 33 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Card.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/card/ 20 | */ 21 | @Serializable 22 | data class Card( 23 | // base attributes 24 | @SerialName("url") val url: String, 25 | @SerialName("title") val title: String, 26 | @SerialName("description") val description: String, 27 | @SerialName("type") val type: CardType, 28 | 29 | // optional attributes 30 | @SerialName("author_name") val authorName: String? = null, 31 | @SerialName("author_url") val authorUrl: String? = null, 32 | @SerialName("provider_name") val providerName: String? = null, 33 | @SerialName("provider_url") val providerUrl: String? = null, 34 | @SerialName("html") val html: String? = null, 35 | @SerialName("width") val width: Int? = null, 36 | @SerialName("height") val height: Int? = null, 37 | @SerialName("image") val image: String? = null, 38 | @SerialName("embed_url") val embedUrl: String? = null, 39 | @SerialName("blurhash") val blurhash: String? = null, 40 | ) 41 | 42 | @Serializable 43 | enum class CardType { 44 | link, 45 | photo, 46 | video, 47 | rich, 48 | } 49 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Context.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/context/ 20 | */ 21 | @Serializable 22 | data class Context( 23 | // required attributes 24 | @SerialName("ancestors") val ancestors: List, 25 | @SerialName("descendants") val descendants: List, 26 | ) 27 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Conversation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/conversation/ 20 | */ 21 | @Serializable 22 | data class Conversation( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("accounts") val accounts: List, 26 | @SerialName("unread") val unread: Boolean, 27 | 28 | // optional attributes 29 | @SerialName("last_status") val lastStatus: Status, 30 | ) 31 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Emoji.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/emoji/ 20 | */ 21 | @Serializable 22 | data class Emoji( 23 | // required attributes 24 | @SerialName("shortcode") val shortcode: String, 25 | @SerialName("url") val url: String, 26 | @SerialName("static_url") val staticUrl: String, 27 | @SerialName("visible_in_picker") val visibleInPicker: Boolean, 28 | 29 | // optional attributes 30 | @SerialName("category") val category: String? = null 31 | ) 32 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Error.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/error/ 20 | */ 21 | @Serializable 22 | data class Error( 23 | // required attributes 24 | @SerialName("error") val error: String, 25 | 26 | // optional attributes 27 | @SerialName("error_description") val errorDescription: String? = null, 28 | ) 29 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/FeaturedTag.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/featuredtag/ 20 | */ 21 | @Serializable 22 | data class FeaturedTag( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("name") val name: String, 26 | @SerialName("url") val url: String, 27 | @SerialName("statuses_count") val statusesCount: Int, 28 | @SerialName("last_status_at") val lastStatusAt: String, 29 | 30 | // optional attributes 31 | @SerialName("history") val history: List? = null, 32 | ) 33 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Field.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/field/ 20 | */ 21 | @Serializable 22 | data class Field( 23 | @SerialName("name") val name: String, 24 | @SerialName("value") val value: String, 25 | @SerialName("verified_at") val verifiedAt: String? = null 26 | ) 27 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Filter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/filter/ 20 | */ 21 | @Serializable 22 | data class Filter( 23 | @SerialName("id") val id: String, 24 | @SerialName("phrase") val phrase: String, 25 | @SerialName("context") val context: List, 26 | @SerialName("expires_at") val expiresAt: String, 27 | @SerialName("irreversible") val irreversible: Boolean, 28 | @SerialName("whole_word") val wholeWord: Boolean, 29 | 30 | ) 31 | 32 | enum class FilterContext { 33 | home, notifications, public, thread 34 | } 35 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/History.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/history/ 20 | */ 21 | @Serializable 22 | data class History( 23 | // required attributes 24 | @SerialName("day") val day: String, 25 | @SerialName("uses") val uses: String, 26 | @SerialName("accounts") val accounts: String, 27 | ) 28 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/IdentityProof.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/identityproof/ 20 | */ 21 | @Serializable 22 | data class IdentityProof( 23 | // required attributes 24 | @SerialName("provider") val provider: String, 25 | @SerialName("provider_username") val providerUsername: String, 26 | @SerialName("profile_url") val profileUrl: String, 27 | @SerialName("proof_url") val proofUrl: String, 28 | @SerialName("updated_at") val updatedAt: String, 29 | ) 30 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Instance.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/instance/ 20 | */ 21 | @Serializable 22 | data class Instance( 23 | @SerialName("uri") val uri: String, 24 | @SerialName("title") val title: String, 25 | @SerialName("description") val description: String, 26 | @SerialName("short_description") val shortDescription: String, 27 | @SerialName("email") val email: String, 28 | @SerialName("version") val version: String, 29 | @SerialName("languages") val languages: List, 30 | @SerialName("registrations") val registrations: Boolean, 31 | @SerialName("approval_required") val approvalRequired: Boolean, 32 | @SerialName("invites_enabled") val invitesEnabled: Boolean, 33 | @SerialName("urls") val urls: Map, 34 | @SerialName("stats") val stats: Map, 35 | @SerialName("thumbnail") val thumbnail: String?, 36 | @SerialName("contact_account") val contactAccount: Account, 37 | ) 38 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Marker.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/marker/ 20 | */ 21 | @Serializable 22 | data class Marker( 23 | // required attributes 24 | @SerialName("home") val home: MarkerHash, 25 | @SerialName("notifications") val uses: MarkerHash, 26 | ) 27 | 28 | @Serializable 29 | data class MarkerHash( 30 | @SerialName("last_read_id") val lastReadId: String, 31 | @SerialName("updated_at") val updatedAt: String, 32 | @SerialName("version") val version: Int, 33 | ) 34 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Mention.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/mention/ 20 | */ 21 | @Serializable 22 | data class Mention( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("username") val username: String, 26 | @SerialName("acct") val acct: String, 27 | @SerialName("url") val url: String, 28 | ) 29 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Notification.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/notification/ 20 | */ 21 | @Serializable 22 | data class Notification( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("type") val type: NotificationType, 26 | @SerialName("created_at") val createdAt: String, 27 | @SerialName("account") val account: Account, 28 | 29 | // optional attributes 30 | @SerialName("status") val status: Status, 31 | ) 32 | 33 | enum class NotificationType { 34 | follow, follow_request, mention, reblog, favourite, poll, status 35 | } 36 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Poll.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/poll/ 20 | */ 21 | @Serializable 22 | data class Poll( 23 | @SerialName("id") val id: String, 24 | @SerialName("expires_at") val expiresAt: String, 25 | @SerialName("expired") val expired: Boolean, 26 | @SerialName("multiple") val multiple: Boolean, 27 | @SerialName("votes_count") val votesCount: Int? = null, 28 | @SerialName("voters_count") val votersCount: Int? = null, 29 | @SerialName("voted") val voted: Boolean? = null, 30 | @SerialName("own_votes") val ownVotes: List? = null, 31 | @SerialName("options") val options: List? = null, 32 | @SerialName("emojis") val emojis: List? = null, 33 | ) 34 | 35 | @Serializable 36 | data class PollHash( 37 | val title: String, 38 | @SerialName("votes_count") val votesCount: Int, 39 | ) 40 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Preferences.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/preferences/ 20 | */ 21 | @Serializable 22 | data class Preferences( 23 | // required attributes 24 | @SerialName("posting:default:visibility") val postingVisibility: PostingVisibility, 25 | @SerialName("posting:default:sensitive") val postingSensitive: Boolean, 26 | @SerialName("posting:default:language") val postingLanguage: String? = null, 27 | @SerialName("reading:expand:media") val readingMedia: ReadingMedia, 28 | @SerialName("reading:expand:spoilers") val readingSpoilers: Boolean, 29 | 30 | // optional attributes 31 | @SerialName("history") val history: List? = null, 32 | ) 33 | 34 | enum class PostingVisibility { 35 | public, unlisted, private, direct 36 | } 37 | 38 | enum class ReadingMedia { 39 | default, show_all, hide_all 40 | } 41 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/PushSubscription.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/pushsubscription/ 20 | */ 21 | @Serializable 22 | data class PushSubscription( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("endpoint") val endpoint: String, 26 | @SerialName("server_key") val serverKey: String, 27 | @SerialName("alerts") val alerts: Alerts, 28 | ) 29 | 30 | @Serializable 31 | data class Alerts( 32 | val follow: Boolean, 33 | val favourite: Boolean, 34 | val mention: Boolean, 35 | val reblog: Boolean, 36 | val poll: Boolean, 37 | ) 38 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Source.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/source/ 20 | */ 21 | @Serializable 22 | data class Source( 23 | // base attributes 24 | @SerialName("note") val note: String, 25 | @SerialName("fields") val fields: List, 26 | 27 | // optional attributes 28 | @SerialName("privacy") val privacy: Privacy, 29 | @SerialName("sensitive") val sensitive: Boolean, 30 | @SerialName("language") val language: String, 31 | @SerialName("follow_requests_count") val followRequestsCount: Int, 32 | ) 33 | 34 | enum class Privacy { public, unlisted, private, direct } 35 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Tag.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/tag/ 20 | */ 21 | @Serializable 22 | data class Tag( 23 | // required attributes 24 | @SerialName("name") val name: String, 25 | @SerialName("url") val url: String, 26 | 27 | // optional attributes 28 | @SerialName("history") val history: List? = emptyList(), 29 | ) 30 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Token.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | @Serializable 19 | data class Token( 20 | val scope: String, 21 | @SerialName("access_token") val accessToken: String, 22 | @SerialName("token_type") val tokenType: String, 23 | // Not needed for now 24 | // @SerialName("created_at") val createdAt: Date, 25 | ) 26 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/UserList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | /** 19 | * https://docs.joinmastodon.org/entities/list/ 20 | */ 21 | @Serializable 22 | data class UserList( 23 | // required attributes 24 | @SerialName("id") val id: String, 25 | @SerialName("title") val title: String, 26 | @SerialName("replies_policy") val repliesPolicy: RepliesPolicy, 27 | ) 28 | 29 | enum class RepliesPolicy { followed, list, none } 30 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/request/CreateAccessTokenBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model.request 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | @Serializable 19 | internal data class CreateAccessTokenBody( 20 | val scope: String, 21 | val code: String, 22 | @SerialName("client_id") val clientId: String, 23 | @SerialName("client_secret") val clientSecret: String, 24 | @SerialName("redirect_uri") val redirectUri: String, 25 | @SerialName("grant_type") val grantType: String, 26 | ) 27 | -------------------------------------------------------------------------------- /data/network/src/commonMain/kotlin/social/androiddev/common/network/model/request/CreateApplicationBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model.request 14 | 15 | import kotlinx.serialization.SerialName 16 | import kotlinx.serialization.Serializable 17 | 18 | @Serializable 19 | internal data class CreateApplicationBody( 20 | val scopes: String, 21 | @SerialName("client_name") val clientName: String, 22 | @SerialName("redirect_uris") val redirectUris: String, 23 | ) 24 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/AccountTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Ignore 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | 21 | class AccountTests { 22 | // TODO: fix loading json from resources 23 | @Ignore 24 | @Test 25 | fun `deserialize required fields should succeed`() { 26 | // given 27 | // val json: String = javaClass.classLoader.getResource("response_account_required.json").readText() 28 | val json: String = "" 29 | 30 | // when 31 | val account = Json.decodeFromString(json) 32 | 33 | // then 34 | 35 | assertEquals(expected = "23634", actual = account.id) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ActivityTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | 20 | class ActivityTests { 21 | @Test 22 | fun `deserialize required fields should succeed`() { 23 | // given 24 | val json = """ 25 | { 26 | "week": "1574640000", 27 | "statuses": "37125", 28 | "logins": "14239", 29 | "registrations": "542" 30 | } 31 | """.trimIndent() 32 | 33 | // when 34 | val activity = Json.decodeFromString(json) 35 | 36 | // then 37 | assertEquals(expected = "1574640000", actual = activity.week) 38 | assertEquals(expected = "37125", actual = activity.statuses) 39 | assertEquals(expected = "14239", actual = activity.logins) 40 | assertEquals(expected = "542", actual = activity.registrations) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ContextTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Ignore 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | import kotlin.test.assertNotNull 21 | 22 | class ContextTests { 23 | // TODO: fix loading json from resources 24 | @Ignore 25 | @Test 26 | fun `deserialize required fields should succeed`() { 27 | // given 28 | // val json: String = javaClass.classLoader.getResource("response_context_required.json").readText() 29 | val json: String = "" 30 | 31 | // when 32 | val context = Json.decodeFromString(json) 33 | 34 | // then 35 | assertNotNull(actual = context) 36 | assertNotNull(actual = context.ancestors) 37 | assertEquals(expected = 1, actual = context.ancestors.size) 38 | assertNotNull(actual = context.descendants) 39 | assertEquals(expected = 1, actual = context.descendants.size) 40 | 41 | val firstAncestor = context.ancestors[0] 42 | assertEquals(expected = "103270115826048975", actual = firstAncestor.id) 43 | 44 | val firstDescendants = context.descendants[0] 45 | assertEquals(expected = "103270115826048975", actual = firstDescendants.id) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ConversationTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Ignore 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | import kotlin.test.assertNotNull 21 | 22 | class ConversationTests { 23 | // TODO: fix loading json from resources 24 | @Ignore 25 | @Test 26 | fun `deserialize required fields should succeed`() { 27 | // given 28 | // val json: String = javaClass.classLoader.getResource("response_conversation_required.json").readText() 29 | val json: String = "" 30 | 31 | // when 32 | val conversation = Json.decodeFromString(json) 33 | 34 | // then 35 | assertNotNull(actual = conversation) 36 | assertEquals(expected = "418450", actual = conversation.id) 37 | assertNotNull(actual = conversation.accounts) 38 | assertEquals(expected = 1, actual = conversation.accounts.size) 39 | assertEquals(expected = true, actual = conversation.unread) 40 | assertNotNull(actual = conversation.lastStatus) 41 | assertEquals(expected = "103270115826048975", actual = conversation.lastStatus.id) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/ErrorTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | 20 | class ErrorTests { 21 | @Test 22 | fun `deserialize video card should succeed`() { 23 | // given 24 | val json = """ 25 | { 26 | "error": "invalid_grant", 27 | "error_description": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client." 28 | } 29 | """.trimIndent() 30 | 31 | // when 32 | val error = Json.decodeFromString(json) 33 | 34 | // then 35 | assertEquals(expected = "invalid_grant", actual = error.error) 36 | assertEquals( 37 | expected = "The provided authorization grant is invalid, expired, " + 38 | "revoked, does not match the redirection URI used " + 39 | "in the authorization request, or was issued to another client.", 40 | actual = error.errorDescription 41 | ) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/FeatureTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | 20 | class FeatureTests { 21 | @Test 22 | fun `deserialize required fields should succeed`() { 23 | // given 24 | val json = """ 25 | { 26 | "id": "627", 27 | "name": "nowplaying", 28 | "url": "", 29 | "statuses_count": 36, 30 | "last_status_at": "2019-11-15T07:14:43.524Z" 31 | } 32 | """.trimIndent() 33 | 34 | // when 35 | val featuredTag = Json.decodeFromString(json) 36 | 37 | // then 38 | assertEquals(expected = "627", actual = featuredTag.id) 39 | assertEquals(expected = "nowplaying", actual = featuredTag.name) 40 | assertEquals(expected = 36, actual = featuredTag.statusesCount) 41 | assertEquals(expected = "2019-11-15T07:14:43.524Z", actual = featuredTag.lastStatusAt) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/HistoryTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | 20 | class HistoryTests { 21 | @Test 22 | fun `deserialize required fields should succeed`() { 23 | // given 24 | val json = """ 25 | { 26 | "day": "1574553600", 27 | "uses": "200", 28 | "accounts": "31" 29 | } 30 | """.trimIndent() 31 | 32 | // when 33 | val history = Json.decodeFromString(json) 34 | 35 | // then 36 | assertEquals(expected = "1574553600", actual = history.day) 37 | assertEquals(expected = "200", actual = history.uses) 38 | assertEquals(expected = "31", actual = history.accounts) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/NotificationTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Ignore 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | import kotlin.test.assertNotNull 21 | 22 | class NotificationTests { 23 | // TODO: fix loading json from resources 24 | @Ignore 25 | @Test 26 | fun `deserialize required fields should succeed`() { 27 | // given 28 | // val json: String = javaClass.classLoader.getResource("response_notification_required.json").readText() 29 | val json: String = "" 30 | 31 | // when 32 | val notification = Json.decodeFromString(json) 33 | 34 | // then 35 | assertNotNull(actual = notification) 36 | assertEquals(expected = "34975861", actual = notification.id) 37 | assertEquals(expected = NotificationType.mention, actual = notification.type) 38 | assertEquals(expected = "2019-11-23T07:49:02.064Z", actual = notification.createdAt) 39 | assertNotNull(actual = notification.account) 40 | assertEquals(expected = "23634", actual = notification.account.id) 41 | assertNotNull(actual = notification.status) 42 | assertEquals(expected = "103270115826048975", actual = notification.status.id) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/PreferencesTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | import kotlin.test.assertNull 20 | 21 | class PreferencesTests { 22 | @Test 23 | fun `deserialize required fields should succeed`() { 24 | // given 25 | val json = """ 26 | { 27 | "posting:default:visibility": "public", 28 | "posting:default:sensitive": false, 29 | "posting:default:language": null, 30 | "reading:expand:media": "default", 31 | "reading:expand:spoilers": false 32 | } 33 | """.trimIndent() 34 | 35 | // when 36 | val preferences = Json.decodeFromString(json) 37 | 38 | // then 39 | assertEquals(expected = PostingVisibility.public, actual = preferences.postingVisibility) 40 | assertEquals(expected = false, actual = preferences.postingSensitive) 41 | assertNull(actual = preferences.postingLanguage) 42 | assertEquals(expected = ReadingMedia.default, actual = preferences.readingMedia) 43 | assertEquals(expected = false, actual = preferences.readingSpoilers) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/StatusTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Ignore 18 | import kotlin.test.Test 19 | import kotlin.test.assertEquals 20 | import kotlin.test.assertNotNull 21 | 22 | class StatusTests { 23 | // TODO: fix loading json from resources 24 | @Ignore 25 | @Test 26 | fun `deserialize required fields should succeed`() { 27 | // given 28 | // val json: String = javaClass.classLoader.getResource("response_status_required.json").readText() 29 | val json: String = "" 30 | 31 | // when 32 | val status = Json.decodeFromString(json) 33 | 34 | // then 35 | assertNotNull(actual = status) 36 | assertEquals(expected = "103270115826048975", actual = status.id) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /data/network/src/commonTest/kotlin/social/androiddev/common/network/model/UserListTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network.model 14 | 15 | import kotlinx.serialization.decodeFromString 16 | import kotlinx.serialization.json.Json 17 | import kotlin.test.Test 18 | import kotlin.test.assertEquals 19 | 20 | class UserListTests { 21 | @Test 22 | fun `deserialize required fields should succeed`() { 23 | // given 24 | val json = """ 25 | { 26 | "id": "12249", 27 | "title": "Friends", 28 | "replies_policy": "list" 29 | } 30 | """.trimIndent() 31 | 32 | // when 33 | val userList = Json.decodeFromString(json) 34 | 35 | // then 36 | assertEquals(expected = "12249", actual = userList.id) 37 | assertEquals(expected = "Friends", actual = userList.title) 38 | assertEquals(expected = RepliesPolicy.list, actual = userList.repliesPolicy) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /data/network/src/desktopMain/kotlin/social/androiddev/common/network/DesktopPlatform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | class DesktopPlatform : Platform { 16 | override val name: String = "Desktop" 17 | override val version: String = "0.1.0" 18 | override val build: String = "1" 19 | } 20 | 21 | actual fun getPlatform(): Platform = DesktopPlatform() 22 | -------------------------------------------------------------------------------- /data/network/src/desktopMain/kotlin/social/androiddev/common/network/UrlStream.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | import io.ktor.client.HttpClient 16 | import io.ktor.client.call.body 17 | import io.ktor.client.engine.cio.CIO 18 | import io.ktor.client.request.get 19 | import java.io.ByteArrayInputStream 20 | 21 | actual suspend fun urlStream(url: String): ByteArray = HttpClient(CIO).use { 22 | ByteArrayInputStream(it.get(url).body()).readBytes() 23 | } 24 | -------------------------------------------------------------------------------- /data/network/src/iosMain/kotlin/social/androiddev/common/network/IOSPlatform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | import platform.UIKit.UIDevice 16 | 17 | class IOSPlatform : Platform { 18 | override val name: String = UIDevice.currentDevice.systemName() 19 | override val version: String = UIDevice.currentDevice.systemVersion 20 | override val build: String = "1" 21 | } 22 | 23 | actual fun getPlatform(): Platform = IOSPlatform() 24 | -------------------------------------------------------------------------------- /data/network/src/iosMain/kotlin/social/androiddev/common/network/UrlStream.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.network 14 | 15 | import io.ktor.client.HttpClient 16 | import io.ktor.client.call.body 17 | import io.ktor.client.request.get 18 | import io.ktor.utils.io.core.use 19 | 20 | actual suspend fun urlStream(url: String): ByteArray = HttpClient().use { 21 | it.get(urlString = url).body() 22 | } 23 | -------------------------------------------------------------------------------- /data/persistence/src/androidAndroidTest/aidl/social/androiddev/common/persistence/AndroidTestSqlDriver.kt: -------------------------------------------------------------------------------- 1 | package social.androiddev.common.persistence 2 | 3 | import com.squareup.sqldelight.db.SqlDriver 4 | import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver 5 | 6 | actual fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { 7 | return JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY).also { driver -> 8 | schema.create(driver = driver) 9 | } 10 | } -------------------------------------------------------------------------------- /data/persistence/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /data/persistence/src/androidTest/kotlin/social/androiddev/common/persistence/AndroidTestDatabaseDriver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence 14 | 15 | import com.squareup.sqldelight.db.SqlDriver 16 | import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver 17 | 18 | actual fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { 19 | return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> 20 | schema.create(driver = driver) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/authentication/AuthenticationDatabaseWrapper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence.authentication 14 | 15 | import social.androiddev.common.persistence.AuthenticationDatabase 16 | 17 | @Suppress("UnusedPrivateMember") 18 | class AuthenticationDatabaseWrapper( 19 | private val instance: AuthenticationDatabase 20 | ) 21 | -------------------------------------------------------------------------------- /data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/di/PersistenceModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence.di 14 | 15 | import org.koin.core.module.Module 16 | 17 | /** 18 | * Expect a platform specific Koin module containing all 19 | * bean definitions for persistent storage related classes 20 | */ 21 | expect val persistenceModule: Module 22 | 23 | internal const val AUTH_DB_NAME = "authentication.db" 24 | internal const val FEED_DB_NAME = "feed.db" 25 | internal const val AUTH_SETTINGS_NAME = "DodoAuthSettings" 26 | -------------------------------------------------------------------------------- /data/persistence/src/commonMain/kotlin/social/androiddev/common/persistence/localstorage/DodoAuthStorage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence.localstorage 14 | 15 | import kotlinx.coroutines.flow.Flow 16 | 17 | /** 18 | * Contract for key => value storage for any authentication related data 19 | */ 20 | interface DodoAuthStorage { 21 | 22 | /** 23 | * The current domain/server the user is logged into. 24 | * This is used to query the right account info since 25 | * the user can have multiple accounts 26 | */ 27 | var currentDomain: String? 28 | 29 | /** 30 | * List of servers that user has access to 31 | */ 32 | val authorizedServersFlow: Flow> 33 | 34 | /** 35 | * Save the @param token keyed by @param server 36 | */ 37 | suspend fun saveAccessToken(server: String, token: String) 38 | 39 | /** 40 | * Get the Access token for @param server 41 | */ 42 | fun getAccessToken(server: String): String? 43 | 44 | /** 45 | * Remove stored access token for selected @param server 46 | */ 47 | fun clearAccessToken(server: String) 48 | } 49 | -------------------------------------------------------------------------------- /data/persistence/src/commonMain/sqldelight/social/androiddev/common/persistence/authentication/Application.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS Application ( 2 | instance Text NOT NULL PRIMARY KEY, 3 | client_id Text NOT NULL, 4 | client_secret TEXT NOT NULL, 5 | redirect_uri TEXT NOT NULL 6 | ); 7 | 8 | insertApplication: 9 | INSERT OR REPLACE INTO Application 10 | VALUES ?; 11 | 12 | selectAll: 13 | SELECT * FROM Application; 14 | 15 | deleteAll: 16 | DELETE FROM Application; 17 | 18 | selectByServer: 19 | SELECT * 20 | FROM Application 21 | WHERE instance = ?; 22 | -------------------------------------------------------------------------------- /data/persistence/src/commonMain/sqldelightTimeline/social/androiddev/common/timeline/ConflictResolution.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS failedWrite ( 2 | key TEXT NOT NULL PRIMARY KEY, 3 | datetime INTEGER AS Long 4 | ); 5 | 6 | get: 7 | SELECT * 8 | FROM failedWrite 9 | WHERE key = ?; 10 | 11 | upsert: 12 | INSERT OR REPLACE INTO failedWrite VALUES ?; 13 | 14 | delete: 15 | DELETE FROM failedWrite 16 | WHERE key = ?; 17 | 18 | deleteAll: 19 | DELETE FROM failedWrite; -------------------------------------------------------------------------------- /data/persistence/src/commonMain/sqldelightTimeline/social/androiddev/common/timeline/Timeline.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS StatusDB ( 2 | type TEXT NOT NULL, 3 | remoteId Text NOT NULL PRIMARY KEY, 4 | uri Text NOT NULL, 5 | createdAt Text NOT NULL, 6 | content Text NOT NULL, 7 | accountId Text, 8 | visibility Text NOT NULL, 9 | sensitive INTEGER AS Boolean DEFAULT 0, 10 | spoilerText Text NOT NULL, 11 | avatarUrl Text NOT NULL, 12 | accountAddress Text NOT NULL, 13 | applicationName Text NOT NULL, 14 | userName Text NOT NULL, 15 | repliesCount INTEGER, 16 | favouritesCount INTEGER, 17 | reblogsCount INTEGER 18 | ); 19 | 20 | insertFeedItem: 21 | INSERT OR REPLACE INTO StatusDB 22 | VALUES ?; 23 | 24 | selectHomeItems: 25 | SELECT * FROM StatusDB 26 | WHERE type = "HOME" 27 | ORDER BY createdAt; 28 | 29 | deleteAll: 30 | DELETE FROM StatusDB; 31 | -------------------------------------------------------------------------------- /data/persistence/src/commonTest/kotlin/social/androiddev/common/persistence/DatabaseDriver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence 14 | 15 | import com.squareup.sqldelight.db.SqlDriver 16 | 17 | expect fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver 18 | -------------------------------------------------------------------------------- /data/persistence/src/desktopTest/kotlin/social/androiddev/common/persistence/DesktopTestDatabaseDriver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence 14 | 15 | import com.squareup.sqldelight.db.SqlDriver 16 | import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver 17 | 18 | actual fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { 19 | return JdbcSqliteDriver(url = JdbcSqliteDriver.IN_MEMORY).also { driver -> 20 | schema.create(driver = driver) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /data/persistence/src/iosMain/kotlin/social/androiddev/common/persistence/di/IOSPersistenceModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence.di 14 | 15 | import com.russhwolf.settings.NSUserDefaultsSettings 16 | import com.squareup.sqldelight.drivers.native.NativeSqliteDriver 17 | import kotlinx.serialization.json.Json 18 | import org.koin.core.module.Module 19 | import org.koin.dsl.module 20 | import social.androiddev.common.persistence.AuthenticationDatabase 21 | import social.androiddev.common.persistence.localstorage.DodoAuthStorage 22 | import social.androiddev.common.persistence.localstorage.DodoAuthStorageImpl 23 | 24 | /** 25 | * Koin DI module for all iOS specific persistence dependencies 26 | */ 27 | actual val persistenceModule: Module = module { 28 | single { 29 | DodoAuthStorageImpl( 30 | settings = NSUserDefaultsSettings 31 | .Factory() 32 | .create(AUTH_SETTINGS_NAME), 33 | json = Json { 34 | ignoreUnknownKeys = true 35 | encodeDefaults = false 36 | } 37 | ) 38 | } 39 | 40 | single { 41 | val driver = NativeSqliteDriver(schema = AuthenticationDatabase.Schema, name = AUTH_DB_NAME) 42 | AuthenticationDatabase(driver) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /data/persistence/src/iosTest/kotlin/social/androiddev/common/persistence/IOSTestDatabaseDriver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.persistence 14 | 15 | import co.touchlab.sqliter.DatabaseConfiguration 16 | import com.squareup.sqldelight.db.SqlDriver 17 | import com.squareup.sqldelight.drivers.native.NativeSqliteDriver 18 | import com.squareup.sqldelight.drivers.native.wrapConnection 19 | 20 | actual fun provideTestSqlDriver(schema: SqlDriver.Schema): SqlDriver { 21 | return NativeSqliteDriver( 22 | DatabaseConfiguration( 23 | name = "authentication.db", 24 | version = schema.version, 25 | create = { connection -> 26 | wrapConnection(connection) { schema.create(it) } 27 | }, 28 | upgrade = { connection, oldVersion, newVersion -> 29 | wrapConnection(connection) { schema.migrate(it, oldVersion, newVersion) } 30 | }, 31 | inMemory = true 32 | ) 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /data/repository/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | kotlin("plugin.serialization") 4 | } 5 | 6 | android { 7 | namespace = "social.androiddev.common.repository" 8 | } 9 | 10 | kotlin { 11 | sourceSets { 12 | // shared 13 | val commonMain by getting { 14 | dependencies { 15 | implementation(projects.data.network) 16 | implementation(projects.data.persistence) 17 | implementation(projects.domain.authentication) 18 | implementation(projects.domain.timeline) 19 | implementation(libs.io.insert.koin.core) 20 | implementation(libs.kotlinx.coroutines.core) 21 | implementation(libs.com.squareup.sqldelight.coroutines.extensions) 22 | //TODO remove as api dependency once we can stop dependening on StoreResponse in UI 23 | api(libs.store) 24 | implementation(libs.com.squareup.sqldelight.coroutines.extensions) 25 | } 26 | } 27 | // testing 28 | val androidTest by getting { 29 | dependencies { 30 | implementation(kotlin("test")) 31 | implementation(libs.org.jetbrains.kotlin.test.junit) 32 | } 33 | } 34 | val androidMain by getting { 35 | dependencies { 36 | api(libs.org.jetbrains.kotlinx.atomicfu) 37 | } 38 | } 39 | val desktopTest by getting { 40 | dependencies { 41 | implementation(kotlin("test")) 42 | implementation(libs.org.jetbrains.kotlin.test.junit) 43 | } 44 | } 45 | val commonTest by getting { 46 | dependencies { 47 | implementation(kotlin("test")) 48 | implementation(libs.org.jetbrains.kotlin.test.common) 49 | implementation(libs.org.jetbrains.kotlin.test.annotations.common) 50 | implementation(libs.org.jetbrains.kotlinx.coroutines.test) 51 | implementation(libs.app.cash.turbine) 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /data/repository/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /data/repository/src/androidMain/kotlin/social/androiddev/common/repository/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/data/repository/src/androidMain/kotlin/social/androiddev/common/repository/.gitkeep -------------------------------------------------------------------------------- /data/repository/src/commonMain/kotlin/social/androiddev/common/repository/di/RepositoryModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.repository.di 14 | 15 | import kotlinx.coroutines.Dispatchers 16 | import org.koin.core.module.Module 17 | import org.koin.dsl.module 18 | import social.androiddev.common.repository.AuthenticationRepositoryImpl 19 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 20 | 21 | /** 22 | * Koin module containing all koin/bean definitions for 23 | * all repositories. Repositories encapsulate different data sources 24 | * and are typically injected into ViewModels or UseCases. 25 | */ 26 | val repositoryModule: Module = module { 27 | 28 | single { 29 | AuthenticationRepositoryImpl( 30 | mastodonApi = get(), 31 | database = get(), 32 | settings = get(), 33 | ioCoroutineContext = Dispatchers.Default 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/RealHomeTimelineRepository.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.repository.timeline 14 | 15 | import kotlinx.coroutines.flow.Flow 16 | import kotlinx.coroutines.flow.distinctUntilChanged 17 | import org.mobilenativefoundation.store.store5.Store 18 | import org.mobilenativefoundation.store.store5.StoreRequest 19 | import org.mobilenativefoundation.store.store5.StoreResponse 20 | import social.androiddev.domain.timeline.FeedType 21 | import social.androiddev.domain.timeline.HomeTimelineRepository 22 | import social.androiddev.domain.timeline.model.StatusLocal 23 | 24 | class RealHomeTimelineRepository( 25 | private val store: Store> 26 | ) : HomeTimelineRepository { 27 | /** 28 | * returns a flow of home feed items from a database 29 | * anytime table rows are created/updated will return a new list of timeline items 30 | * on first return will also call network fetcher to get 31 | * latest from network and update local storage with it] 32 | */ 33 | override fun read( 34 | feedType: FeedType, 35 | refresh: Boolean 36 | ): Flow>> { 37 | return store.stream(StoreRequest.cached(key = feedType, refresh = true)) 38 | .distinctUntilChanged() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/TimelineFetcher.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.repository.timeline 14 | 15 | import org.mobilenativefoundation.store.store5.Fetcher 16 | import social.androiddev.common.network.MastodonApi 17 | import social.androiddev.common.persistence.localstorage.DodoAuthStorage 18 | import social.androiddev.common.timeline.StatusDB 19 | import social.androiddev.domain.timeline.FeedType 20 | /** 21 | * Wrapper for [MastodonApi.getHomeFeed] while also getting an auth token from storage 22 | * and mapping result to list of [StatusDB] 23 | */ 24 | fun MastodonApi.timelineFetcher(authStorage: DodoAuthStorage): Fetcher> = 25 | Fetcher.of { key: FeedType -> 26 | when (key) { 27 | is FeedType.Home -> { 28 | getHomeFeed( 29 | authStorage.currentDomain!!, 30 | authStorage.getAccessToken(authStorage.currentDomain!!)!! 31 | ) 32 | .getOrThrow() 33 | .map { it.statusDB() } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /data/repository/src/desktopMain/kotlin/social/androiddev/common/repository/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/data/repository/src/desktopMain/kotlin/social/androiddev/common/repository/.gitkeep -------------------------------------------------------------------------------- /data/repository/src/iosMain/kotlin/social/androiddev/common/repository/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/data/repository/src/iosMain/kotlin/social/androiddev/common/repository/.gitkeep -------------------------------------------------------------------------------- /di/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.di" 7 | } 8 | 9 | kotlin { 10 | sourceSets { 11 | val commonMain by getting { 12 | dependencies { 13 | implementation(projects.data.network) 14 | implementation(projects.data.persistence) 15 | implementation(projects.data.repository) 16 | implementation(projects.logging) 17 | implementation(projects.domain.authentication) 18 | implementation(libs.io.insert.koin.core) 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /di/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /di/src/androidMain/kotlin/social/androiddev/common/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common 14 | 15 | actual class Platform actual constructor() { 16 | actual val name: String = "Android ${android.os.Build.VERSION.SDK_INT}" 17 | } 18 | -------------------------------------------------------------------------------- /di/src/commonMain/kotlin/social/androiddev/common/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common 14 | 15 | expect class Platform() { 16 | val name: String 17 | } 18 | -------------------------------------------------------------------------------- /di/src/commonMain/kotlin/social/androiddev/common/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.di 14 | 15 | import social.androiddev.common.network.di.networkModule 16 | import social.androiddev.common.persistence.di.persistenceModule 17 | import social.androiddev.common.repository.di.repositoryModule 18 | import social.androiddev.common.repository.timeline.timelineRepoModule 19 | import social.androiddev.domain.authentication.di.domainAuthModule 20 | 21 | /** 22 | * Base Koin module shared across all apps (android, iOS, Desktop) 23 | */ 24 | fun appModule() = listOf( 25 | platformModule, 26 | networkModule, 27 | persistenceModule, 28 | domainAuthModule, 29 | repositoryModule, 30 | timelineRepoModule 31 | ) 32 | -------------------------------------------------------------------------------- /di/src/commonMain/kotlin/social/androiddev/common/di/PlatformModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.di 14 | 15 | import org.koin.core.module.dsl.singleOf 16 | import org.koin.dsl.module 17 | import social.androiddev.common.Platform 18 | 19 | /** 20 | * Platform specific Koin module. All build targets must 21 | * fulfill any platform required koin definitions specified. 22 | */ 23 | val platformModule = module { 24 | singleOf(::Platform) 25 | } 26 | -------------------------------------------------------------------------------- /di/src/desktopMain/kotlin/social/androiddev/common/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common 14 | 15 | actual class Platform actual constructor() { 16 | actual val name: String 17 | get() = "Desktop" 18 | } 19 | -------------------------------------------------------------------------------- /di/src/iosMain/kotlin/social/androiddev/common/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common 14 | 15 | import platform.UIKit.UIDevice 16 | 17 | actual class Platform actual constructor() { 18 | actual val name: String = 19 | UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion 20 | } 21 | -------------------------------------------------------------------------------- /domain/authentication/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.domain.authentication" 7 | } 8 | 9 | kotlin { 10 | sourceSets { 11 | // shared 12 | val commonMain by getting { 13 | dependencies { 14 | implementation(libs.io.insert.koin.core) 15 | implementation(libs.kotlinx.coroutines.core) 16 | } 17 | } 18 | 19 | val commonTest by getting { 20 | dependencies { 21 | implementation(libs.org.jetbrains.kotlin.test.common) 22 | implementation(libs.org.jetbrains.kotlin.test.annotations.common) 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /domain/authentication/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/di/DomainAuthenticationModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.di 14 | 15 | import org.koin.core.module.Module 16 | import org.koin.dsl.module 17 | import social.androiddev.domain.authentication.usecase.AuthenticateClient 18 | import social.androiddev.domain.authentication.usecase.CreateAccessToken 19 | import social.androiddev.domain.authentication.usecase.GetAuthStatus 20 | import social.androiddev.domain.authentication.usecase.GetSelectedApplicationOAuthToken 21 | import social.androiddev.domain.authentication.usecase.LogoutFromCurrentServer 22 | 23 | /** 24 | * Koin module containing all koin/bean definitions for 25 | * domain related classes for authentication 26 | */ 27 | val domainAuthModule: Module = module { 28 | 29 | factory { 30 | AuthenticateClient( 31 | authenticationRepository = get(), 32 | ) 33 | } 34 | 35 | factory { 36 | GetSelectedApplicationOAuthToken( 37 | authenticationRepository = get(), 38 | ) 39 | } 40 | 41 | factory { 42 | CreateAccessToken( 43 | authenticationRepository = get(), 44 | ) 45 | } 46 | 47 | factory { 48 | GetAuthStatus( 49 | authenticationRepository = get() 50 | ) 51 | } 52 | 53 | factory { 54 | LogoutFromCurrentServer( 55 | authenticationRepository = get() 56 | ) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/model/ApplicationOAuthToken.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.model 14 | 15 | data class ApplicationOAuthToken( 16 | val server: String, 17 | val clientId: String, 18 | val clientSecret: String, 19 | val redirectUri: String, 20 | ) 21 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/model/AuthStatus.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.model 14 | 15 | /** 16 | * Represents the authentication status of user to Mastodon servers 17 | */ 18 | sealed class AuthStatus { 19 | /** 20 | * Authenticated to at least one server 21 | */ 22 | object Authorized : AuthStatus() 23 | 24 | /** 25 | * User logged out or never signed in before 26 | */ 27 | object Unauthorized : AuthStatus() 28 | } 29 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/model/NewAppOAuthToken.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.model 14 | 15 | data class NewAppOAuthToken( 16 | val clientId: String, 17 | val clientSecret: String, 18 | val redirectUri: String, 19 | ) 20 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/repository/AuthenticationRepository.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.repository 14 | 15 | import kotlinx.coroutines.flow.Flow 16 | import social.androiddev.domain.authentication.model.ApplicationOAuthToken 17 | import social.androiddev.domain.authentication.model.NewAppOAuthToken 18 | 19 | interface AuthenticationRepository { 20 | 21 | suspend fun createApplicationClient( 22 | domain: String, 23 | clientName: String, 24 | redirectUris: String, 25 | scopes: String, 26 | website: String?, 27 | ): NewAppOAuthToken? 28 | 29 | suspend fun saveApplication( 30 | token: NewAppOAuthToken, 31 | domain: String, 32 | ) 33 | 34 | suspend fun createAccessToken( 35 | authCode: String, 36 | server: String, 37 | scope: String, 38 | grantType: String, 39 | ): String? 40 | 41 | suspend fun saveAccessToken(server: String, token: String) 42 | 43 | val selectedServer: String? 44 | 45 | suspend fun getApplicationOAuthToken(server: String): ApplicationOAuthToken? 46 | 47 | fun isAccessTokenPresent(): Flow 48 | 49 | fun removeAccessToken(server: String) 50 | } 51 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/AuthenticateClient.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.usecase 14 | 15 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 16 | 17 | class AuthenticateClient( 18 | private val authenticationRepository: AuthenticationRepository, 19 | ) { 20 | 21 | suspend operator fun invoke( 22 | domain: String, 23 | clientName: String, 24 | redirectURIs: String, 25 | scopes: String, 26 | website: String? = null, 27 | ): Boolean { 28 | val oAuthToken = authenticationRepository.createApplicationClient( 29 | domain = domain, 30 | clientName = clientName, 31 | redirectUris = redirectURIs, 32 | scopes = scopes, 33 | website = website, 34 | ) 35 | 36 | return if (oAuthToken != null) { 37 | authenticationRepository.saveApplication( 38 | token = oAuthToken, 39 | domain = domain, 40 | ) 41 | true 42 | } else { 43 | false 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/CreateAccessToken.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.usecase 14 | 15 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 16 | 17 | class CreateAccessToken( 18 | private val authenticationRepository: AuthenticationRepository 19 | ) { 20 | 21 | suspend operator fun invoke(authCode: String, server: String): Boolean { 22 | val token = authenticationRepository.createAccessToken( 23 | server = server, 24 | authCode = authCode, 25 | scope = "read write follow push", 26 | grantType = "authorization_code", 27 | ) 28 | 29 | return if (token != null) { 30 | authenticationRepository.saveAccessToken(server = server, token = token) 31 | true 32 | } else { 33 | false 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/GetAuthStatus.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.usecase 14 | 15 | import kotlinx.coroutines.flow.Flow 16 | import kotlinx.coroutines.flow.map 17 | import social.androiddev.domain.authentication.model.AuthStatus 18 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 19 | 20 | class GetAuthStatus(private val authenticationRepository: AuthenticationRepository) { 21 | operator fun invoke(): Flow = 22 | authenticationRepository.isAccessTokenPresent().map { hasAccessToken -> 23 | if (hasAccessToken) { 24 | AuthStatus.Authorized 25 | } else { 26 | AuthStatus.Unauthorized 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/GetSelectedApplicationOAuthToken.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.usecase 14 | 15 | import social.androiddev.domain.authentication.model.ApplicationOAuthToken 16 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 17 | 18 | class GetSelectedApplicationOAuthToken( 19 | private val authenticationRepository: AuthenticationRepository 20 | ) { 21 | suspend operator fun invoke(): ApplicationOAuthToken { 22 | val server = requireNotNull(authenticationRepository.selectedServer) { 23 | "Selected Server must not be null" 24 | } 25 | 26 | val token = requireNotNull(authenticationRepository.getApplicationOAuthToken(server)) { 27 | "OAuth Token must not be null" 28 | } 29 | 30 | return token 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /domain/authentication/src/commonMain/kotlin/social/androiddev/domain/authentication/usecase/LogoutFromCurrentServer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.authentication.usecase 14 | 15 | import social.androiddev.domain.authentication.repository.AuthenticationRepository 16 | 17 | class LogoutFromCurrentServer(private val authenticationRepository: AuthenticationRepository) { 18 | operator fun invoke() { 19 | val server = authenticationRepository.selectedServer 20 | if (server != null) { 21 | authenticationRepository.removeAccessToken(server) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /domain/timeline/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.domain.timeline" 7 | } 8 | 9 | kotlin { 10 | jvm("desktop") 11 | android() 12 | iosX64() 13 | iosArm64() 14 | 15 | sourceSets { 16 | // shared 17 | 18 | val commonMain by getting { 19 | dependencies { 20 | api(libs.store) 21 | implementation(libs.kotlinx.coroutines.core) 22 | } 23 | } 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /domain/timeline/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/HomeTimelineRepository.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.timeline 14 | 15 | import kotlinx.coroutines.flow.Flow 16 | import org.mobilenativefoundation.store.store5.StoreResponse 17 | import social.androiddev.domain.timeline.model.StatusLocal 18 | 19 | interface HomeTimelineRepository { 20 | fun read( 21 | feedType: FeedType, 22 | refresh: Boolean = false 23 | ): Flow>> 24 | } 25 | 26 | sealed class FeedType(val type: String) { 27 | object Home : FeedType("HOME") 28 | } 29 | -------------------------------------------------------------------------------- /domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Account.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.timeline.model 14 | 15 | data class Account( 16 | val id: String, 17 | val username: String, 18 | val acct: String, 19 | val avatar: String, 20 | ) 21 | -------------------------------------------------------------------------------- /domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/StatusLocal.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.timeline.model 14 | 15 | import social.androiddev.domain.timeline.FeedType 16 | 17 | data class StatusLocal( 18 | val remoteId: String, 19 | val feedType: FeedType, 20 | val createdAt: String, 21 | val repliesCount: Long = 0, 22 | val reblogsCount: Long = 0, 23 | val favoritesCount: Long = 0, 24 | val content: String, 25 | val account: Account? = null, 26 | val sensitive: Boolean = false, 27 | val spoilerText: String? = null, 28 | val visibility: String, 29 | val avatarUrl: String = "", 30 | val accountAddress: String = "", 31 | val userName: String 32 | ) 33 | -------------------------------------------------------------------------------- /domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/Visibility.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.domain.timeline.model 14 | 15 | enum class Visibility { 16 | PUBLIC, UNLISTED, PRIVATE, DIRECT 17 | } 18 | -------------------------------------------------------------------------------- /domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/usecase/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/usecase/.gitkeep -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # Documentation: https://docs.gradle.org/current/userguide/build_environment.html 3 | 4 | # Gradle will reuse task outputs from any previous build 5 | org.gradle.caching=true 6 | 7 | # Enabled configuration injection feature 8 | org.gradle.configureondemand=true 9 | 10 | # use of rich output format (colors and font variants) 11 | org.gradle.console=rich 12 | 13 | # Specifies the JVM arguments used for the daemon process. 14 | org.gradle.jvmargs=-Xmx7168m -XX:MaxMetaspaceSize=2g 15 | 16 | # Gradle will fork up to org.gradle.workers.max JVMs to execute projects in parallel. 17 | org.gradle.parallel=true 18 | # Default is number of CPU processors. 19 | # org.gradle.workers.max= 20 | 21 | # log all warnings 22 | org.gradle.warning.mode=all 23 | 24 | # Print the welcome message once 25 | org.gradle.welcome=never 26 | 27 | # use the appropriate AndroidX library instead of a Support Library 28 | android.useAndroidX=true 29 | 30 | # Automatically convert third-party libraries to use AndroidX by rewriting their binaries 31 | android.enableJetifier=false 32 | 33 | # Kotlin code style for this project: "official" or "obsolete": 34 | kotlin.code.style=official 35 | 36 | # suprress AGP warning 37 | android.suppressUnsupportedCompileSdk=33 38 | 39 | # suppress Kotlin Multiplatform Projects are an "Alpha feature" warning 40 | kotlin.mpp.stability.nowarn=true 41 | 42 | # suppress warning about not building iOS targets on linux 43 | kotlin.native.ignoreDisabledTargets=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /kotlin-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.kotlinutils" 7 | } 8 | -------------------------------------------------------------------------------- /kotlin-utils/src/commonMain/kotlin/social/androiddev/kotlinutils/NullUnless.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.kotlinutils 14 | 15 | import kotlin.contracts.ExperimentalContracts 16 | import kotlin.contracts.InvocationKind 17 | import kotlin.contracts.contract 18 | 19 | /** 20 | * Only return the result of [block] if [expression] is true, otherwise always returns null 21 | */ 22 | @OptIn(ExperimentalContracts::class) 23 | inline fun nullUnless(expression: Boolean, block: () -> T): T? { 24 | contract { 25 | returnsNotNull() implies (expression) 26 | callsInPlace(block, InvocationKind.AT_MOST_ONCE) 27 | } 28 | return if (!expression) { 29 | null 30 | } else { 31 | block() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /logging/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.logging" 7 | } 8 | 9 | kotlin { 10 | sourceSets { 11 | val commonMain by getting { 12 | dependencies { 13 | implementation(libs.io.github.aakira.napier) 14 | implementation(libs.io.insert.koin.core) 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /logging/src/commonMain/kotlin/social/androiddev/common/logging/LoggingModule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.logging 14 | 15 | import io.github.aakira.napier.DebugAntilog 16 | import io.github.aakira.napier.Napier 17 | import org.koin.dsl.module 18 | 19 | val loggingModule = module { 20 | // todo: provide different antilog for release 21 | Napier.base(DebugAntilog()) 22 | } 23 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 2 | 3 | pluginManagement { 4 | repositories { 5 | gradlePluginPortal() 6 | mavenCentral() 7 | google() 8 | } 9 | includeBuild("build-logic") 10 | } 11 | 12 | dependencyResolutionManagement { 13 | repositories { 14 | mavenCentral() 15 | google() 16 | mavenLocal() 17 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") 18 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots") 19 | } 20 | } 21 | 22 | rootProject.name = "DodoForMastodon" 23 | 24 | include(":di") 25 | include(":logging") 26 | include(":app-android") 27 | include(":app-desktop") 28 | 29 | include(":ui:timeline") 30 | include(":ui:common") 31 | include(":ui:root") 32 | include(":ui:signed-in") 33 | include(":ui:signed-out") 34 | include(":ui:desktop-webview") 35 | include(":ui:settings") 36 | 37 | include(":domain:timeline") 38 | include(":domain:authentication") 39 | 40 | include(":data:persistence") 41 | include(":data:network") 42 | include(":data:repository") 43 | 44 | include(":kotlin-utils") -------------------------------------------------------------------------------- /ui/common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | id("kotlin-parcelize") 4 | } 5 | 6 | android { 7 | namespace = "social.androiddev.common" 8 | } 9 | 10 | kotlin { 11 | sourceSets { 12 | val commonMain by getting { 13 | dependencies { 14 | implementation(projects.data.network) 15 | implementation(projects.logging) 16 | api(libs.com.arkivanov.decompose) 17 | api(libs.com.arkivanov.decompose.extensions.compose.jetbrains) 18 | api(libs.kotlinx.collections.immutable) 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ui/common/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ui/common/src/androidMain/kotlin/social/androiddev/common/utils/ImageLoading.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.utils 14 | 15 | import android.graphics.Bitmap 16 | import android.graphics.BitmapFactory 17 | import androidx.compose.ui.graphics.asImageBitmap 18 | import androidx.compose.ui.graphics.painter.BitmapPainter 19 | import androidx.compose.ui.graphics.painter.Painter 20 | import social.androiddev.common.network.urlStream 21 | 22 | actual suspend fun loadImageIntoPainter(url: String): Painter { 23 | val byteArray: ByteArray = urlStream(url) 24 | val bitmap: Bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size) 25 | 26 | return BitmapPainter(bitmap.asImageBitmap()) 27 | } 28 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/composables/UserAvatar.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.composables 14 | 15 | import androidx.compose.foundation.layout.width 16 | import androidx.compose.foundation.shape.RoundedCornerShape 17 | import androidx.compose.runtime.Composable 18 | import androidx.compose.runtime.remember 19 | import androidx.compose.ui.Modifier 20 | import androidx.compose.ui.draw.clip 21 | import androidx.compose.ui.unit.dp 22 | import social.androiddev.common.theme.DodoTheme 23 | import social.androiddev.common.utils.AsyncImage 24 | import social.androiddev.common.utils.loadImageIntoPainter 25 | 26 | @Composable 27 | fun UserAvatar( 28 | url: String, 29 | modifier: Modifier = Modifier 30 | ) { 31 | AsyncImage( 32 | load = { loadImageIntoPainter(url = url) }, 33 | painterFor = { remember { it } }, 34 | contentDescription = "User avatar", 35 | modifier = modifier.width(48.dp).clip(RoundedCornerShape(5.dp)) 36 | ) 37 | } 38 | 39 | // skip preview to work with multiplatform 40 | // https://github.com/JetBrains/compose-jb/issues/1603 41 | // @Preview 42 | @Composable 43 | private fun UserPreview() { 44 | DodoTheme { 45 | UserAvatar(url = "https://media.mastodon.cloud/accounts/avatars/000/018/251/original/e78973b0b821c7e3.jpg") 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/decompose/CoroutineScopeExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.decompose 14 | 15 | import com.arkivanov.essenty.lifecycle.Lifecycle 16 | import com.arkivanov.essenty.lifecycle.doOnDestroy 17 | import kotlinx.coroutines.CoroutineScope 18 | import kotlinx.coroutines.cancel 19 | import kotlin.coroutines.CoroutineContext 20 | 21 | /** 22 | * Create a lifecycle aware [CoroutineScope] using a [CoroutineContext] and Decompose [Lifecycle]. 23 | * The [CoroutineScope] will properly cancel any running work when the lifecycle of the 24 | * component is destroyed. 25 | */ 26 | fun CoroutineScope(context: CoroutineContext, lifecycle: Lifecycle): CoroutineScope { 27 | val scope = CoroutineScope(context) 28 | lifecycle.doOnDestroy(scope::cancel) 29 | return scope 30 | } 31 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/decompose/LifecycleOwnerExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.decompose 14 | 15 | import com.arkivanov.essenty.lifecycle.LifecycleOwner 16 | import kotlinx.coroutines.CoroutineScope 17 | import kotlin.coroutines.CoroutineContext 18 | 19 | /** 20 | * Create a lifecycle aware [CoroutineScope] from a Decompose [LifecycleOwner]. 21 | */ 22 | fun LifecycleOwner.coroutineScope(context: CoroutineContext): CoroutineScope = 23 | CoroutineScope(context, lifecycle) 24 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoColors.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.theme 14 | 15 | import androidx.compose.material.darkColors 16 | import androidx.compose.material.lightColors 17 | import androidx.compose.ui.graphics.Color 18 | 19 | val Blue = Color(0xFF4772F5) 20 | val LightBlue = Color(0xff8EC8F0) 21 | val DarkGrey = Color(0xFF1E202A) 22 | val LightGrey = Color(0xFFBABBBE) 23 | val Green = Color(0xff69f0ae) 24 | 25 | val darkColors = 26 | darkColors( 27 | primary = Blue, 28 | onPrimary = Color.White, 29 | secondary = Green, 30 | onSecondary = LightBlue, 31 | surface = DarkGrey, 32 | onSurface = Color.White 33 | ) 34 | 35 | val lightColors = lightColors( 36 | primary = Blue, 37 | onPrimary = Color.White, 38 | secondary = Green, 39 | onSecondary = LightBlue, 40 | surface = DarkGrey, 41 | onSurface = Color.White 42 | ) 43 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/theme/DodoTheme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.theme 14 | 15 | import androidx.compose.foundation.isSystemInDarkTheme 16 | import androidx.compose.material.MaterialTheme 17 | import androidx.compose.runtime.Composable 18 | 19 | @Composable 20 | fun DodoTheme( 21 | useDarkTheme: Boolean = isSystemInDarkTheme(), 22 | content: @Composable () -> Unit 23 | ) { 24 | MaterialTheme( 25 | colors = if (useDarkTheme) { 26 | darkColors 27 | } else { 28 | lightColors 29 | }, 30 | typography = DodoTypography, 31 | content = content 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /ui/common/src/commonMain/kotlin/social/androiddev/common/utils/ImageLoading.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.utils 14 | 15 | import androidx.compose.ui.graphics.painter.Painter 16 | 17 | /** 18 | * load image from given url as inputStream and put it into a bitmap painter 19 | */ 20 | expect suspend fun loadImageIntoPainter(url: String): Painter 21 | -------------------------------------------------------------------------------- /ui/common/src/desktopMain/kotlin/social/androiddev/common/utils/ImageLoading.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.common.utils 14 | 15 | import androidx.compose.ui.graphics.ImageBitmap 16 | import androidx.compose.ui.graphics.painter.BitmapPainter 17 | import androidx.compose.ui.graphics.painter.Painter 18 | import androidx.compose.ui.res.loadImageBitmap 19 | import social.androiddev.common.network.urlStream 20 | import java.io.ByteArrayInputStream 21 | 22 | actual suspend fun loadImageIntoPainter(url: String): Painter { 23 | val inputStream: ByteArrayInputStream = urlStream(url).inputStream() 24 | val imageBitmap: ImageBitmap = loadImageBitmap(inputStream = inputStream) 25 | 26 | return BitmapPainter(imageBitmap) 27 | } 28 | -------------------------------------------------------------------------------- /ui/desktop-webview/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | id("org.jetbrains.compose") 4 | id("social.androiddev.codequality") 5 | id("org.openjfx.javafxplugin") version "0.0.13" 6 | } 7 | 8 | dependencies { 9 | implementation(compose.desktop.common) 10 | } 11 | 12 | javafx { 13 | version = "19" 14 | modules( 15 | "javafx.base", 16 | "javafx.controls", 17 | "javafx.graphics", 18 | "javafx.swing", 19 | "javafx.web", 20 | "javafx.media" 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /ui/desktop-webview/src/main/kotlin/social/androiddev/ui/desktop/webview/JFXWebView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.ui.desktop.webview 14 | 15 | import javafx.application.Platform 16 | import javafx.embed.swing.JFXPanel 17 | import javafx.scene.Scene 18 | import javafx.scene.paint.Color 19 | import javafx.scene.web.WebView 20 | 21 | internal class JFXWebView( 22 | private val url: String, 23 | private val onUrlOfCurrentPageChanged: (newUrl: String) -> Unit, 24 | ) : JFXPanel() { 25 | init { 26 | // FIXME : I added this line to avoid the following behavior: 27 | // If the user goes back and then restarts the webview the initialization is not done 28 | // may be because of Decompose navigation.pop() ?? 29 | Platform.setImplicitExit(false) 30 | 31 | Platform.runLater(::initialiseJavaFXScene) 32 | } 33 | 34 | private fun initialiseJavaFXScene() { 35 | val webView = WebView() 36 | webView.pageFill = Color.TRANSPARENT 37 | webView.engine.locationProperty().addListener { observable, _, _ -> 38 | onUrlOfCurrentPageChanged(observable.value) 39 | } 40 | 41 | val scene = Scene(webView, Color.TRANSPARENT) 42 | setScene(scene) 43 | 44 | webView.engine.load(url) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ui/desktop-webview/src/main/kotlin/social/androiddev/ui/desktop/webview/WebView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.ui.desktop.webview 14 | 15 | import androidx.compose.material.MaterialTheme 16 | import androidx.compose.runtime.Composable 17 | import androidx.compose.ui.Modifier 18 | import androidx.compose.ui.awt.SwingPanel 19 | 20 | @Composable 21 | fun JFXWebView( 22 | url: String, 23 | shouldCancelLoadingUrl: (url: String) -> Boolean, 24 | modifier: Modifier = Modifier 25 | ) { 26 | SwingPanel( 27 | background = MaterialTheme.colors.surface, 28 | factory = { 29 | JFXWebView( 30 | url = url, 31 | onUrlOfCurrentPageChanged = { url -> 32 | shouldCancelLoadingUrl(url) 33 | }, 34 | ) 35 | }, 36 | modifier = modifier, 37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /ui/messages/src/main/kotlin/social/androiddev/messages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/messages/src/main/kotlin/social/androiddev/messages/.gitkeep -------------------------------------------------------------------------------- /ui/messages/src/test/kotlin/social/androiddev/messages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/messages/src/test/kotlin/social/androiddev/messages/.gitkeep -------------------------------------------------------------------------------- /ui/notifications/src/main/kotlin/social/androiddev/notifications/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/notifications/src/main/kotlin/social/androiddev/notifications/.gitkeep -------------------------------------------------------------------------------- /ui/notifications/src/test/kotlin/social/androiddev/notifications/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/notifications/src/test/kotlin/social/androiddev/notifications/.gitkeep -------------------------------------------------------------------------------- /ui/root/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | id("kotlin-parcelize") 4 | } 5 | 6 | android { 7 | namespace = "social.androiddev.ui.root" 8 | } 9 | 10 | kotlin { 11 | sourceSets { 12 | val commonMain by getting { 13 | dependencies { 14 | implementation(projects.ui.common) 15 | implementation(projects.ui.signedIn) 16 | implementation(projects.ui.signedOut) 17 | implementation(projects.domain.authentication) 18 | implementation(compose.runtime) 19 | implementation(compose.foundation) 20 | implementation(compose.material) 21 | implementation(libs.io.insert.koin.core) 22 | } 23 | } 24 | 25 | val androidMain by getting { 26 | dependencies { 27 | implementation(libs.androidx.appcompat) 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ui/root/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ui/root/src/commonMain/kotlin/social/androiddev/root/root/RootComponentViewModel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.root.root 14 | 15 | import com.arkivanov.essenty.instancekeeper.InstanceKeeper 16 | import kotlinx.coroutines.CoroutineScope 17 | import kotlinx.coroutines.SupervisorJob 18 | import kotlinx.coroutines.cancel 19 | import kotlinx.coroutines.flow.SharingStarted 20 | import kotlinx.coroutines.flow.map 21 | import kotlinx.coroutines.flow.stateIn 22 | import social.androiddev.domain.authentication.model.AuthStatus 23 | import social.androiddev.domain.authentication.usecase.GetAuthStatus 24 | import kotlin.coroutines.CoroutineContext 25 | 26 | class RootComponentViewModel( 27 | coroutineContext: CoroutineContext, 28 | getAuthStatus: GetAuthStatus, 29 | ) : InstanceKeeper.Instance { 30 | private val viewModelScope = CoroutineScope(coroutineContext + SupervisorJob()) 31 | 32 | val authState = 33 | getAuthStatus() 34 | .map { it.toUiAuthStatus() } 35 | .stateIn(viewModelScope, SharingStarted.Lazily, UiAuthStatus.Loading) 36 | 37 | override fun onDestroy() { 38 | viewModelScope.cancel() 39 | } 40 | } 41 | 42 | private fun AuthStatus.toUiAuthStatus(): UiAuthStatus { 43 | return when (this) { 44 | is AuthStatus.Authorized -> UiAuthStatus.Authorized 45 | is AuthStatus.Unauthorized -> UiAuthStatus.Unauthorized 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ui/root/src/commonMain/kotlin/social/androiddev/root/root/UiAuthStatus.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.root.root 14 | 15 | sealed class UiAuthStatus { 16 | object Loading : UiAuthStatus() 17 | object Authorized : UiAuthStatus() 18 | object Unauthorized : UiAuthStatus() 19 | } 20 | -------------------------------------------------------------------------------- /ui/root/src/commonMain/kotlin/social/androiddev/root/splash/DefaultSplashComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.root.splash 14 | 15 | import com.arkivanov.decompose.ComponentContext 16 | 17 | class DefaultSplashComponent( 18 | private val componentContext: ComponentContext, 19 | ) : SplashComponent, ComponentContext by componentContext 20 | -------------------------------------------------------------------------------- /ui/root/src/commonMain/kotlin/social/androiddev/root/splash/SplashComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.root.splash 14 | 15 | /** 16 | * The base component describing all business logic needed for the splash screen 17 | */ 18 | interface SplashComponent 19 | -------------------------------------------------------------------------------- /ui/root/src/commonMain/kotlin/social/androiddev/root/splash/SplashContent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.root.splash 14 | 15 | import androidx.compose.foundation.layout.Box 16 | import androidx.compose.foundation.layout.fillMaxSize 17 | import androidx.compose.material.Text 18 | import androidx.compose.runtime.Composable 19 | import androidx.compose.ui.Alignment 20 | import androidx.compose.ui.Modifier 21 | 22 | /** 23 | * Stateless composable for rendering a simple Splash Screen 24 | * upon app launch. 25 | */ 26 | @Composable 27 | fun SplashContent( 28 | modifier: Modifier = Modifier, 29 | ) { 30 | Box( 31 | modifier = modifier.fillMaxSize(), 32 | contentAlignment = Alignment.Center, 33 | ) { 34 | Text("Loading") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ui/search/src/main/kotlin/social/androiddev/search/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/search/src/main/kotlin/social/androiddev/search/.gitkeep -------------------------------------------------------------------------------- /ui/search/src/test/kotlin/social/androiddev/search/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidDev-social/DodoForMastodon/ee7fea1718cad6424f9298e096e65cc305980994/ui/search/src/test/kotlin/social/androiddev/search/.gitkeep -------------------------------------------------------------------------------- /ui/settings/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.ui.settings" 7 | } 8 | 9 | kotlin { 10 | sourceSets { 11 | val commonMain by getting { 12 | dependencies { 13 | implementation(projects.ui.common) 14 | implementation(projects.domain.authentication) 15 | implementation(projects.data.persistence) 16 | implementation(projects.data.repository) 17 | implementation(libs.io.insert.koin.core) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ui/settings/src/commonMain/kotlin/social/androiddev/settings/RealSettingsComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.settings 14 | 15 | import com.arkivanov.decompose.ComponentContext 16 | import org.koin.core.component.KoinComponent 17 | import org.koin.core.component.inject 18 | import social.androiddev.domain.authentication.usecase.LogoutFromCurrentServer 19 | 20 | class RealSettingsComponent(ctx: ComponentContext) : SettingsComponent, ComponentContext by ctx, KoinComponent { 21 | 22 | val logoutFromCurrentServer: LogoutFromCurrentServer by inject() 23 | 24 | override fun logout() { 25 | logoutFromCurrentServer() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ui/settings/src/commonMain/kotlin/social/androiddev/settings/SettingsComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.settings 14 | 15 | interface SettingsComponent { 16 | fun logout() 17 | } 18 | -------------------------------------------------------------------------------- /ui/settings/src/commonMain/kotlin/social/androiddev/settings/SettingsContent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.settings 14 | 15 | import androidx.compose.foundation.layout.Box 16 | import androidx.compose.material.MaterialTheme 17 | import androidx.compose.runtime.Composable 18 | import androidx.compose.ui.Alignment 19 | import androidx.compose.ui.Modifier 20 | import social.androiddev.common.composables.buttons.DodoButton 21 | import social.androiddev.common.composables.buttons.buttonColors 22 | 23 | @Composable 24 | fun SettingsContent( 25 | component: SettingsComponent, 26 | modifier: Modifier = Modifier, 27 | ) { 28 | SettingsContent( 29 | modifier = modifier, 30 | onLogout = component::logout, 31 | ) 32 | } 33 | 34 | @Composable 35 | internal fun SettingsContent( 36 | onLogout: () -> Unit, 37 | modifier: Modifier = Modifier, 38 | ) { 39 | Box( 40 | modifier = modifier, 41 | contentAlignment = Alignment.BottomCenter 42 | ) { 43 | DodoButton( 44 | text = "Logout", 45 | onClick = onLogout, 46 | colors = buttonColors(backgroundColor = MaterialTheme.colors.error) 47 | ) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ui/signed-in/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | id("kotlin-parcelize") 4 | } 5 | 6 | android { 7 | namespace = "social.androiddev.ui.signed_in" 8 | } 9 | 10 | kotlin { 11 | sourceSets { 12 | val commonMain by getting { 13 | dependencies { 14 | implementation(projects.ui.common) 15 | implementation(projects.ui.timeline) 16 | implementation(projects.ui.settings) 17 | implementation(projects.data.persistence) 18 | implementation(projects.data.repository) 19 | implementation(projects.domain.timeline) 20 | implementation(libs.io.insert.koin.core) 21 | implementation(projects.kotlinUtils) 22 | } 23 | } 24 | 25 | val androidMain by getting { 26 | dependencies { 27 | implementation(libs.androidx.appcompat) 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ui/signed-in/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/NavHeaderSettings.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedin.navigation 14 | 15 | import androidx.compose.material.icons.Icons 16 | import androidx.compose.material.icons.filled.Settings 17 | import androidx.compose.ui.graphics.vector.ImageVector 18 | 19 | /** 20 | * Represents a different state of navigation header (title, actions) based on active route 21 | */ 22 | internal sealed class NavHeaderSettings( 23 | val title: String = "", 24 | val headerAction: HeaderActionWithIcon? = null, 25 | ) { 26 | object Empty : NavHeaderSettings("") 27 | object Settings : NavHeaderSettings("Settings") 28 | 29 | data class Timeline(val action: () -> Unit) : 30 | NavHeaderSettings( 31 | "Timeline", 32 | headerAction = HeaderActionWithIcon(icon = Icons.Default.Settings, action = action) 33 | ) 34 | } 35 | 36 | internal data class HeaderActionWithIcon(val icon: ImageVector, val action: () -> Unit) 37 | -------------------------------------------------------------------------------- /ui/signed-in/src/commonMain/kotlin/social/androiddev/signedin/navigation/SignedInRootComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedin.navigation 14 | 15 | import com.arkivanov.decompose.router.stack.ChildStack 16 | import com.arkivanov.decompose.value.Value 17 | import social.androiddev.settings.SettingsComponent 18 | import social.androiddev.timeline.navigation.TimelineComponent 19 | 20 | /** 21 | * The base component describing all business logic needed for the signed-in root entry point 22 | */ 23 | interface SignedInRootComponent { 24 | 25 | // Store a stack of components and their configurations in this root graph 26 | val childStack: Value> 27 | 28 | /** 29 | * Opens Settings screen 30 | */ 31 | fun navigateToSettings() 32 | 33 | /** 34 | * Pops one route in navigation stack 35 | */ 36 | fun navigateBack() 37 | 38 | /** 39 | * Supported "Child"s in this navigation stack. These are created from a configuration that 40 | * contains any arguments for this particular child in the navigation stack. 41 | */ 42 | sealed class Child { 43 | data class Timeline(val component: TimelineComponent) : Child() 44 | data class Settings(val component: SettingsComponent) : Child() 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ui/signed-out/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | id("kotlin-parcelize") 4 | } 5 | 6 | android { 7 | namespace = "social.androiddev.ui.signed_out" 8 | } 9 | 10 | kotlin { 11 | sourceSets { 12 | val commonMain by getting { 13 | dependencies { 14 | implementation(projects.ui.common) 15 | implementation(projects.domain.authentication) 16 | implementation(libs.io.insert.koin.core) 17 | } 18 | } 19 | 20 | val androidMain by getting { 21 | dependencies { 22 | implementation(libs.androidx.appcompat) 23 | implementation(libs.androidx.browser) 24 | implementation(libs.androidx.activity.compose) 25 | } 26 | } 27 | 28 | val desktopMain by getting { 29 | dependencies { 30 | implementation(compose.desktop.common) 31 | implementation(projects.ui.desktopWebview) 32 | 33 | } 34 | } 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /ui/signed-out/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ui/signed-out/src/androidMain/kotlin/social/androiddev/signedout/selectserver/AndroidRedirectScheme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.selectserver 14 | 15 | /** 16 | * Note: this _must_ match the value in the manifest for deep linking back to the app to work 17 | * correctly. 18 | */ 19 | actual val redirectScheme: String get() = "dodooauth2redirect" 20 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/landing/DefaultLandingComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.landing 14 | 15 | import com.arkivanov.decompose.ComponentContext 16 | 17 | class DefaultLandingComponent( 18 | private val componentContext: ComponentContext, 19 | private val onGetStartedClickedInternal: () -> Unit, 20 | ) : LandingComponent, ComponentContext by componentContext { 21 | 22 | override fun onGetStartedClicked() { 23 | onGetStartedClickedInternal() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/landing/LandingComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.landing 14 | 15 | /** 16 | * The base component describing all business logic needed for the welcome screen 17 | */ 18 | interface LandingComponent { 19 | 20 | /** 21 | * Callback invoked when user clicks the "Get Started" button in the Welcome Screen 22 | */ 23 | fun onGetStartedClicked() 24 | } 25 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/root/SignedOutRootComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.root 14 | 15 | import com.arkivanov.decompose.router.stack.ChildStack 16 | import com.arkivanov.decompose.value.Value 17 | import social.androiddev.signedout.landing.LandingComponent 18 | import social.androiddev.signedout.selectserver.SelectServerComponent 19 | import social.androiddev.signedout.signin.SignInComponent 20 | 21 | /** 22 | * The base component describing all business logic needed for the signed-out root entry point 23 | */ 24 | interface SignedOutRootComponent { 25 | 26 | // Store a stack of components and their configurations in this root graph 27 | val childStack: Value> 28 | 29 | /** 30 | * Supported "Child"s in this navigation stack. These are created from a configuration that 31 | * contains any arguments for this particular child in the navigation stack. 32 | */ 33 | sealed class Child { 34 | 35 | data class Landing(val component: LandingComponent) : Child() 36 | 37 | data class SelectServer(val component: SelectServerComponent) : Child() 38 | 39 | data class SignIn(val component: SignInComponent) : Child() 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/selectserver/RedirectScheme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.selectserver 14 | 15 | expect val redirectScheme: String 16 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/selectserver/SelectServerComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.selectserver 14 | 15 | import kotlinx.coroutines.flow.StateFlow 16 | 17 | /** 18 | * The base component describing all business logic needed for the select server screen 19 | */ 20 | interface SelectServerComponent { 21 | 22 | val state: StateFlow 23 | 24 | fun onServerSelected(server: String) 25 | 26 | data class State( 27 | val selectButtonEnabled: Boolean = true, 28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/signin/SignInComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.signin 14 | 15 | import kotlinx.coroutines.flow.StateFlow 16 | 17 | /** 18 | * The base component describing all business logic needed for the sign up or sign in screen 19 | */ 20 | interface SignInComponent { 21 | 22 | fun onCloseClicked() 23 | 24 | fun shouldCancelLoadingUrl(url: String): Boolean 25 | 26 | fun onErrorFromOAuth(error: String) 27 | 28 | val state: StateFlow 29 | 30 | data class State( 31 | val server: String, 32 | val oauthAuthorizeUrl: String, 33 | val redirectUri: String, 34 | val error: String? = null, 35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/signin/SignInWebView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.signin 14 | 15 | import androidx.compose.runtime.Composable 16 | import androidx.compose.ui.Modifier 17 | 18 | @Composable 19 | expect fun SignInWebView( 20 | url: String, 21 | onWebError: (message: String) -> Unit, 22 | onCancel: () -> Unit, 23 | shouldCancelLoadingUrl: (url: String) -> Boolean, 24 | modifier: Modifier = Modifier, 25 | ) 26 | -------------------------------------------------------------------------------- /ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/util/StringExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.util 14 | 15 | import java.net.URLEncoder 16 | 17 | fun String.encode(): String = URLEncoder.encode(this, "UTF-8") 18 | -------------------------------------------------------------------------------- /ui/signed-out/src/desktopMain/kotlin/social/androiddev/signedout/selectserver/DesktopRedirectScheme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.selectserver 14 | 15 | actual val redirectScheme: String get() = "https" 16 | -------------------------------------------------------------------------------- /ui/signed-out/src/desktopMain/kotlin/social/androiddev/signedout/signin/SignInWebView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.signedout.signin 14 | 15 | import androidx.compose.runtime.Composable 16 | import androidx.compose.ui.Modifier 17 | import social.androiddev.ui.desktop.webview.JFXWebView 18 | 19 | @Composable 20 | actual fun SignInWebView( 21 | url: String, 22 | onWebError: (message: String) -> Unit, 23 | onCancel: () -> Unit, 24 | shouldCancelLoadingUrl: (url: String) -> Boolean, 25 | modifier: Modifier, 26 | ) { 27 | JFXWebView( 28 | modifier = modifier, 29 | url = url, 30 | shouldCancelLoadingUrl = shouldCancelLoadingUrl 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /ui/timeline/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("social.androiddev.library.ui") 3 | } 4 | 5 | android { 6 | namespace = "social.androiddev.ui.timeline" 7 | } 8 | 9 | kotlin { 10 | sourceSets { 11 | val commonMain by getting { 12 | dependencies { 13 | implementation(projects.domain.timeline) 14 | implementation(projects.ui.common) 15 | implementation(libs.io.insert.koin.core) 16 | } 17 | } 18 | 19 | val androidMain by getting { 20 | dependencies { 21 | implementation(libs.androidx.appcompat) 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ui/timeline/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/HorizontalSpacer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.timeline 14 | 15 | import androidx.compose.foundation.layout.Spacer 16 | import androidx.compose.foundation.layout.width 17 | import androidx.compose.runtime.Composable 18 | import androidx.compose.ui.Modifier 19 | import androidx.compose.ui.unit.dp 20 | 21 | @Composable 22 | fun HorizontalSpacer(modifier: Modifier = Modifier) { 23 | Spacer(modifier.width(12.dp)) 24 | } 25 | -------------------------------------------------------------------------------- /ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/VerticalSpacer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.timeline 14 | 15 | import androidx.compose.foundation.layout.Spacer 16 | import androidx.compose.foundation.layout.height 17 | import androidx.compose.runtime.Composable 18 | import androidx.compose.ui.Modifier 19 | import androidx.compose.ui.unit.dp 20 | 21 | @Composable 22 | fun VerticalSpacer(modifier: Modifier = Modifier) { 23 | Spacer(modifier.height(8.dp)) 24 | } 25 | -------------------------------------------------------------------------------- /ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/DefaultTimelineComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.timeline.navigation 14 | 15 | import com.arkivanov.decompose.ComponentContext 16 | import com.arkivanov.essenty.instancekeeper.getOrCreate 17 | import kotlinx.collections.immutable.ImmutableList 18 | import kotlinx.coroutines.flow.StateFlow 19 | import org.koin.core.component.KoinComponent 20 | import org.koin.core.component.inject 21 | import org.mobilenativefoundation.store.store5.StoreResponse 22 | import social.androiddev.domain.timeline.FeedType 23 | import social.androiddev.domain.timeline.HomeTimelineRepository 24 | import social.androiddev.timeline.FeedItemState 25 | import kotlin.coroutines.CoroutineContext 26 | 27 | @Suppress("UnusedPrivateMember") 28 | class DefaultTimelineComponent( 29 | mainContext: CoroutineContext, 30 | private val componentContext: ComponentContext, 31 | ) : TimelineComponent, KoinComponent, ComponentContext by componentContext { 32 | 33 | private val homeTimelineRepository: HomeTimelineRepository by inject() 34 | 35 | private val viewModel = instanceKeeper.getOrCreate { 36 | TimelineViewModel( 37 | mainContext = mainContext, 38 | homeTimelineRepository, 39 | FeedType.Home 40 | ) 41 | } 42 | 43 | override val state: StateFlow>> = viewModel.state 44 | } 45 | -------------------------------------------------------------------------------- /ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineComponent.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Dodo. 3 | * 4 | * Dodo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as 5 | * published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | * 7 | * Dodo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 8 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 | * 10 | * You should have received a copy of the GNU General Public License along with Dodo. 11 | * If not, see . 12 | */ 13 | package social.androiddev.timeline.navigation 14 | 15 | import kotlinx.collections.immutable.ImmutableList 16 | import kotlinx.coroutines.flow.StateFlow 17 | import org.mobilenativefoundation.store.store5.StoreResponse 18 | import social.androiddev.timeline.FeedItemState 19 | 20 | /** 21 | * The base component describing all business logic needed for the timeline view 22 | */ 23 | interface TimelineComponent { 24 | val state: StateFlow>> 25 | } 26 | --------------------------------------------------------------------------------