Some tests were assuming the uiState would transition from .Loading to
.Success, without considering there might be a .LoadingThread
intermediate step. Cater for that to prevent test flakes.
Previous code was missing the JSON name of the event, so it wasn't
present when it should have been, resulting in a crash.
Also, the Mastodon documentation is incorrect about the relationship
count, which is instead represented as two properties, one for followers
and one for following. So model that, and display them separately in the
UI.
Fixes#1086
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>
Previous code would remove image attachments from the compose editor if
there was a problem uploading or updating them.
This caused a particular problem with image captions. You could attach a
valid image, then write a caption that was too long for the server. The
server would reject the status, and the status was saved to drafts.
Then you open the draft, which tries to upload the image again with a
too-long caption. The upload is rejected, and the image, along with the
caption, is removed.
Fix this.
- Change `QueuedMedia` to track the upload state as a `Result<_,_>`, so
any error messages are preserved and available to the UI.
- The different `Ok` types for the upload state contain the upload
progress percentage (if appropriate) or the server's ID for the uploaded
media.
- Change `ProgressImageView` to accept the upload state `Result`. If the
result is an error the image is drawn with a red overlay and white
"error" icon.
- If an upload is in an error state allow the user to click on it. That
shows a dialog explaining the error, and provides options to edit the
image, change the caption, etc.
- When changing the caption make the API call to change it on the server
(if the attachment has been uploaded). This makes the user aware of any
errors sooner in the process, so they can correct them.
Fixes#879
Some users report that returning to the `ComposeActivity` loses content
they've entered and returns to `MainActivity`. I can't reproduce this,
but it's possible that Android is clearing the task state and returning
to the root activity (`MainActivity` in this case).
Set `alwaysRetainTaskState` to true to keep the activity stack, and
hopefully prevent this from happening.
Previous code would remove image attachments from the compose editor
if there was a problem uploading or updating them.
This caused a particular problem with image captions. You could attach
a valid image, then write a caption that was too long for the server.
The server would reject the status, and the status was saved to drafts.
Then you open the draft, which tries to upload the image again with a
too-long caption. The upload is rejected, and the image, along with the
caption, is removed.
Fix this.
- Change `QueuedMedia` to track the upload state as a `Result<_,_>`,
so any error messages are preserved and available to the UI.
- The different `Ok` types for the upload state contain the upload
progress percentage (if appropriate) or the server's ID for the
uploaded media.
- Change `ProgressImageView` to accept the upload state `Result`.
If the result is an error the image is drawn with a red overlay and
white "error" icon.
- If an upload is in an error state allow the user to click on it.
That shows a dialog explaining the error, and provides options to
edit the image, change the caption, etc.
- When changing the caption make the API call to change it on the
server (if the attachment has been uploaded). This makes the user
aware of any errors sooner in the process, so they can correct them.
Previous layout didn't enable the character counter for entered text, so
it was difficult for the user to see how much they had used.
Fix that. To get the layout to play nicely switch to a ConstraintLayout
with a chain to split the dialog roughly 50/50 between the image and the
caption views.
While I'm here:
- Remove the margins around the image, so it's clearer, and is more
consistent with the "set focus" dialog.
- Set focus on the description immediately, so the keyboard pops up.
- Remove focusability from the image, since the user shouldn't be able
to interact with it.
Previous code passed the actionable status, so "Open boost author"
actually opened the account that posted the original status.
Pass the status representing the boost, so the correct account is
opened.
Fixes#1042
Users report that copying items can be difficult using Talkback.
Make this easier in the dialogs that appear for links, mentions, and
hashtags by using a dedicated adapter that displays a "Copy" button at
the end of each item.
Fixes#1038
Previous code checked the item was a `StatusViewData`, which is not true
for notifications, and meant the links, mentions, and hashtags
accessibility features were not available.
Change this to `IStatusViewData`, which notifications do implement.
Fixes#1037
Previous code only inflated the timeline fragment menu if swipe/refresh
was enabled -- a hold over from when "Refresh" was the only menu item.
There are other menu items now, and they were also hidden. Fix this by
always inflating the menu.
Provide two new lab preferences for controlling the layout and content
of main navigation tabs.
Tabs can now be justfied to start, end, or fully (if room). Start/end
justification may put the tabs closer to the user's fingers, depending
on how they hold the device. Fully justified uses the full width of the
tab bar (if the tabs don't require scrolling).
The content can be set to one of:
- Icon only (previous behaviour)
- Text only
- Icon with text beside
- Icon with text below
Fixes#336
Previous code didn't send the language to ComposeActivity when editing a
scheduled status so it always appeared to be dirty. This prompted the
user to save/discard changes when backing out, even if they hadn't made
any changes.
Fix this by collecting the language code when fetching scheduled posts
and passing it in `ComposeOptions`.