Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite to Jetpack Compose #91

Closed
rfc2822 opened this issue Dec 23, 2022 · 6 comments · Fixed by #160 or #163
Closed

Rewrite to Jetpack Compose #91

rfc2822 opened this issue Dec 23, 2022 · 6 comments · Fixed by #160 or #163
Labels
refactoring Quality improvement of existing functions

Comments

@rfc2822
Copy link
Member

rfc2822 commented Dec 23, 2022

To experiment with Jetpack Compose (also for DAVx⁵), I'd suggest to rewrite ICSx⁵ to Jetpack Compose as a clean "sample" :)

Depends on #151

@rfc2822 rfc2822 added the refactoring Quality improvement of existing functions label Dec 23, 2022
@ArnyminerZ

This comment was marked as outdated.

@github-actions github-actions bot added the dependent Depends on other issues/PRs label Jan 22, 2023
@ArnyminerZ
Copy link
Member

A thing that must be discussed is whether to keep using Activities, or use a variant of Jetpack Compose's navigation system. I think that navigation would be more performant for using the app, but also having all the view models and logic in the same activity may not be the best option.

@ArnyminerZ
Copy link
Member

ArnyminerZ commented Jan 30, 2023

Implementation steps

Phase I - Setup

Description

In this phase the project is configured, and all the dependencies are added, as well as properly configuring Jetpack Compose. Even though more dependencies may be added in the following phases, the base ones will be in this one.

Steps

  • Add versions:
    • compose to 1.4.4
    • composeBom to 2023.01.00
  • Add Jetpack Compose dependencies.
    // Jetpack Compose
    def composeBom = platform("androidx.compose:compose-bom:${versions.composeBom}")
    implementation composeBom
    androidTestImplementation composeBom
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    implementation 'androidx.compose.material:material-icons-extended'
    implementation 'androidx.compose.material3:material3-window-size-class'
    implementation 'androidx.compose.runtime:runtime-livedata'
    implementation 'androidx.activity:activity-compose:1.6.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1'
  • Set android.buildFeatures.compose to true.
  • Set android.composeOptions.kotlinCompilerExtensionVersion = versions.compose
  • Create .ui.theme.Color.kt which contains all the colors to be used. Note that those will be fallback colors, the best thing would be to start using dynamic themes that were introduced in Android 12.
  • Create ui.theme.Theme.kt which contains the AppTheme, and sets the color declared in Color if not on Android 12.

Phase II - Foundations

Description

May be implemented together with Phase I. In this phase, we should design and discuss all the individual components needed by the application. Those will be packaged inside .ui.reusable.

Steps

  • Design ColorCircle. Replaces the current color circle view. Simply a view that draws a circle with the given color.
  • Design ColorPicker. It's a button that uses ColorCircle, and when clicked opens a dialog with some color options to choose from. In here we might also include the system's generated dynamic colors, and a custom color picker.
  • Design LoadingBox. Simply a progress indicator.
  • Design SwitchRow. It's a row with a title, subtitle, and a switch at the end. Used for preferences (ignore alarms...).

Phase III - Calendars list

Description

Since we are already using Room, migrating the calendars list screen (CalendarListActivity) is the easiest first step.
This would involve migrating all the fragments and layouts to a single activity with all the contents designed.

Steps

  • Remove the layouts calendar_list_activity.xml, calendar_list_item.xml and set_sync_interval.xml.
  • Remove the class CalendarListActivity.SubscriptionListAdapter.
  • Remove the functions onCreateOptionsMenu, onPrepareOptionsMenu, onRefresh, onRefreshRequested, onShowInfo, onSetSyncInterval, onToggleDarkMode; and clean the contents of onCreate (leave just the super call). checkSyncSettings will also be reworked completely, but can be left as is right now.
  • Create a composable function called Content, with a Scaffold. Adding the toolbar with the options dropdown, and a LazyColumn.
  • Create a composable function called CalendarListItem, that should match the current design for calendar_list_item.xml. Should take a Subscription as argument.
  • Inside the LazyColumn, load all the items from SubscriptionsModel.subscriptions.

@github-actions github-actions bot removed the dependent Depends on other issues/PRs label Feb 11, 2023
@ArnyminerZ
Copy link
Member

@rfc2822 I've finished the first three phases of the planning for the migration. I think it's a good start to migrate the calendar list screen, which is a quite simple Activity, and it would give a good feeling about the migration process, and how it works. It's Phase III on the planning above.

I've opened #140 so you can take a look, but that's just some dependencies and theme.

@github-actions github-actions bot added dependent Depends on other issues/PRs and removed dependent Depends on other issues/PRs labels May 2, 2023
@github-actions
Copy link

github-actions bot commented May 3, 2023

This PR/issue depends on: * #151

@ArnyminerZ
Copy link
Member

Some screenshots of the new subscriptions list screen migrated to Jetpack Compose:
Screenshot_20230720-122906

Screenshot_20230720-122902

Screenshot_20230720-122853

Screenshot_20230720-123020

The only thing that cannot be migrated are the colors of the "pull-to-refresh" spinner. It's not supported by Jetpack Compose. Just one color can be set. We can just set it to the primary blue color and call it a day

This was linked to pull requests Jul 20, 2023
@ArnyminerZ ArnyminerZ reopened this Jul 28, 2023
rfc2822 pushed a commit that referenced this issue Feb 25, 2024
* Note

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Migrate to Kotlin DSL (#19)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Upgrade all dependencies (#22)

* Upgrade to Android 14 (#21)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Rewrite CredentialsFragment to compose (#26)

* Update import (#27)

* Update README.md

* Fix NPE on adding subscription (#33)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Arnau Mora <arnyminerz@proton.me>

* Make CredentialsFragment into a composable (#35)

* Using regular ubuntu image

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Migrate SubscriptionSettingsFragment to compose (#29)

* Migrate `AddCalendarValidationFragment` to Jetpack Compose (#31)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Migrate `AddCalendarEnterUrlFragment` to Jetpack Compose (#38)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Migrate AddCalendarDetailsFragment to compose (#40)

* Upgrade AGP to 8.2.1 (#42)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Upgrade Kotlin, KSP, Compose and others (#43)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Migrate `AddCalendarActivity` to Jetpack Compose (#45)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Added missing line break (#52)

* Remove unused view and layout (#54)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Added Dependabot (#51)

* Bump github/codeql-action from 2 to 3 (#62)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/checkout from 3 to 4 (#61)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-java from 3 to 4 (#58)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump joda-time:joda-time from 2.12.5 to 2.12.6 (#56)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.work:work-testing from 2.8.1 to 2.9.0 (#60)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Using BOM for OkHttp and downgrade to stable (#64)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Migrate EditCalendarActivity to jetpack compose (#46)

* Bump actions/cache from 3 to 4 (#65)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.android.tools.build:gradle from 8.2.1 to 8.2.2 (#66)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.compose.runtime:runtime-livedata from 1.5.4 to 1.6.0 (#78)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.compose:compose-bom from 2023.10.01 to 2024.01.00 (#79)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.google.accompanist:accompanist-themeadapter-material from 0.32.0 to 0.34.0 (#80)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnau Mora <arnyminerz@proton.me>

* Bump gradle/gradle-build-action from 2 to 3 (#82)

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnau Mora <arnyminerz@proton.me>

* Fix: Can't add subscription after going back once (#83)

* Update ical4android and cert4android (#73)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>

* Cleanup of Dialogs (#67)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Bump actions/upload-artifact from 2 to 4 (#63)

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnau Mora <arnyminerz@proton.me>

* Migrate `DonateDialogFragment` to Jetpack Compose (#75)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Final layout cleanup (#68)

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Ensured toast error is never null (#91)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Crash when going back into `CalendarListActivity` (standard flavour) (#90)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Migrate ColorPickerActivity to Jetpack Compose (closes #53, #87) (#94)

* Bump androidx.compose:compose-bom from 2024.01.00 to 2024.02.00 (#96)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.compose.runtime:runtime-livedata from 1.6.0 to 1.6.1 (#95)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump joda-time:joda-time from 2.12.6 to 2.12.7 (#93)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Edit Subscription: requires-auth toggle and credential fields trigger save-dismiss mechanism (#92)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Arnau Mora Gras <arnyminerz@proton.me>

* Removed package definition from manifest (#101)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Bump com.maxkeppeler.sheets-compose-dialogs:core from 1.2.1 to 1.3.0 (#103)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Use compose theming engine, (drop compatibility MdcTheming etc) (#48)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Migrated to Gradle Version Catalog (#99)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Check if we can reuse more composables and improve project structure (#106)

* Bump aboutLibs from 10.7.0 to 10.10.0 (#108)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.jetbrains.kotlinx:kotlinx-coroutines-android from 1.7.3 to 1.8.0 (#110)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Migrate to Material 3 (#109)

* Bump compose-ui from 1.6.1 to 1.6.2 (#111)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.compose.material:material-icons-extended from 1.6.1 to 1.6.2 (#112)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump androidx.compose.runtime:runtime-livedata from 1.6.1 to 1.6.2 (#113)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnau Mora <arnyminerz@proton.me>

* Quickfix for pull to refresh (#114)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

* Fix warnings (#115)

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>

---------

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Sunik Kupfer <kupfer@bitfire.at>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Quality improvement of existing functions
Projects
None yet
2 participants