Commit Graph

10 Commits

Author SHA1 Message Date
Nik Clayton 710e209e34
refactor: Ongoing work to remove the `activeAccount` idiom (#964)
Continue the work to remove the "activeAccount" idiom.

- Uses a new PachliAccount type through most of the app. This holds
information that was previously accessed separately (e.g., content
filters, lists) in one place. The information is loaded when the app
launches or the active account switches.

- Fetching data when the account is switched / loaded simplifies error
handling, as more code can now assume the data has already been loaded.
If it hasn't the code path is simply unreachable.

- This opens up the possibility of "acting as one account while logged
in as another". E.g., have two accounts, and be logged in to one account
and boost a post you've seen from your other account.

- Add a database migration to populate existing accounts with default
data when the user updates the app.

- Refactor code that used those list and filter repositories to get the
data from the PachliAccount instead. New local and remote data sources
are implemented, and the list and filter repositories mediate between
those sources.

- Start a ViewModel for MainActivity, which includes:
  - Sending user actions as UiAction objects
  - Providing a flow of uiState for MainActivity to react to
  - Remove most uses of SharedPreferencesRepository from MainActivity
  - Show messages about errors that occur when logging in

- Refactor intent routing in MainActivity to make the logic clearer.

- Add new `core.data` types to push more `core.network` types out of the
UI code
  - `core.data.model.MastodonList` for `core.network.model.MastoList`
  - `core.data.model.Server` for `core.network.model.Server`

- Continue the work to send the Pachli account ID to the code that uses
it.
  - Most view models now get the account ID via assisted injection.
- QueuedMedia now includes the AccountEntity so it can operate with any
account. Modify the `uploadMedia` API call to include explicit
authentication details.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-13 11:45:16 +01:00
Nik Clayton 8b192ab18d
change: Bump compileSdk to 35 (#1070) 2024-10-31 19:38:22 +01:00
Nik Clayton f10e125a5f
ci: Upload SARIF files with lint results (#1060)
Perform the lint check as normal, saving the exit code and ignoring any
error exit codes.

Then upload the lint results as SARIF files for display in GitHub.

Then exit with whatever exit code lint returned, to ensure that a lint
failure causes the CI job to fail too.
2024-10-29 17:17:12 +01:00
Nik Clayton 7076dc6ed6
refactor: Replace deprecated `kotlinOptions` with `compilerOptions` (#763) 2024-06-19 14:27:10 +02:00
Nik Clayton 5f198b0d90
build: Simplify build infrastructure for command line tools (#613)
Provide a build convention plugin for command line tools, and use
`libs.versions.toml` for command line tool dependencies. Adjust the
individual tool `build.gradle.kts` files accordingly.

Remove unnecessary `gradle.properties` and `settings.gradle` files for
projects that are included as subprojects, not included builds.

Add a trivial test for each command line tool so there are tests to run
and provide some confidence that automated library upgrades don't break
command line tool compilation.
2024-04-15 15:06:55 +02:00
Nik Clayton 72e5ca887d
fix(deps): update agp to v8.3.0, lint to 31.3.0 (#483)
New lint rules highlighted a potential crash; the use of named match
groups (used here when extracting server versions) requires API >= 26 or
throws an exception.

Use the group numbers instead of names when extracting the value, but
keep the group names in the regular expressions for readability.
2024-03-01 23:07:14 +01:00
Nik Clayton af58de5a8f
refactor: Enable core library desugaring as build convention logic (#480)
Once desugaring is enabled it needs to be enabled for up/down the
dependency chain, so enable it in the shared configuration defined by
the build convention code.

Highlighted a failing test that wasn't being run, so fix that too.
2024-02-29 09:43:44 +01:00
Nik Clayton f0fc0fd530
refactor: Modularise core activity classes, (#393)
Continue modularisation by moving core activity classes that almost all
activities depende on to a `core.activity` module. This includes
core "helper" classes as well.

Implement core.activity:
- Contains BaseActivity, BottomSheetActivity
- Contains LinkHelper and other utility classes used by activities

Implement core.common.extensions:
- Move ViewBindingExtensions and ViewExtensions here

Implement core.common.util:
- Move BlurHashDecoder and VersionName here

Implement core.designsystem:
- Holds common resources (animations, colours, drawables, etc) used
  through the app
- Import "core.designsystem.R as DR" through the app to distinguish
  from the module's own resources

Implement feature.login:
- Move the LoginActivity and related code/resources to its own module

Implement tools/mvstring
- Moves string resources (and all translations) from one module to
  another
2024-01-30 11:37:00 +01:00
Nik Clayton bf36837b04
feat: Allow the user to report crashes in orange builds (#317)
Add a dependency on ACRA (in orange builds only), and catch crashes.

The user is given the option to e-mail the crash report data to the
support address, and can view and edit/redact the data before doing so.
2023-12-12 23:25:09 +01:00
Nik Clayton e749b362ca
refactor: Start creating core modules (#286)
The existing code base is a single monolithic module. This is relatively
simple to configure, but many of the tasks to compile the module and
produce the final app have to run in series.

This is unnecessarily slow.

This change starts to split the code in to multiple modules, which are:

- :core:account - AccountManager, to break a dependency cycle
- :core:common - low level types or utilities used in many other modules
- :core:database - database types, DAOs, and DI infrastructure
- :core:network - network types, API definitions, and DI infrastructure
- :core:preferences - shared preferences definitions and DI
infrastructure
- :core:testing - fakes and rules used across different modules

Benchmarking with gradle-profiler shows a ~ 17% reduction in incremental
build times after an ABI change. That will improve further as more code
is moved to modules.

The rough mechanics of the changes are:

- Create the modules, and move existing files in to them. This causes a
  lot of churn in import arguments.

- Convert build.gradle files to build.gradle.kts

- Separate out the data required to display a tab (`TabViewData`) from
  the data required to configure a tab (`TabData`) to avoid circular
  dependencies.

- Abstract the repeated build logic shared between the modules in to
  a set of plugins under `build-logic/`, to simplify configuration of
  the application and library builds.

- Be explicit that some nullable types are non-null at time of use.
  Nullable properties in types imported from modules generally can't be
  smart cast to non-null. There's a detailed discussion of why this
restriction exists at
https://discuss.kotlinlang.org/t/what-is-the-reason-behind-smart-cast-being-impossible-to-perform-when-referenced-class-is-in-another-module/2201.

The changes highlight design problems with the current code, including:

- The main application code is too tightly coupled to the network types
- Too many values are declared unnecessarily nullable
- Dependency cycles between code that make modularisation difficult

Future changes will add more modules.

See #291.
2023-12-04 16:58:36 +01:00