Commit Graph

4278 Commits

Author SHA1 Message Date
Nik Clayton 8b099aba64
fix: Search filters use correct colours in dark and black mode (#881)
Two problems with the previous code when search filters were visible:

1. The link icon overrode the tint, so didn't appear correctly in dark
and black mode.

2. The horizontal scroll view had the wrong background colour in black
mode.

Fix both, by updating the icon and adding a new style for the scroll
view.

While I'm here remove an obsolete comment and tighten up visibility.

Fixes #875
2024-08-19 17:23:39 +02:00
Nik Clayton 8b9fe6d5ae
fix: Improve push and pull notification reliability (#880)
Clean up the notification handling code and fix a lot of bugs, hopefully
without introducing new ones in the process.

Specific bugs discovered and fixed:

- The code that tried to sync notification filtering state between the
server and Pachli could fail, leaving things in an inconsistent state,
resulting in dropped notifications. Remove that code, do filtering
client-side.

- Logging out of an account would disable push notifications for all
accounts.

- If any account did not support push notifications then push
notifications were disabled for all accounts.

- If any account did not support push notifications the user was
prompted to log out of all accounts. Drop that entirely.

- The UnifiedPush library could get to a state where configuring the
notification mechanism would silently fail,

The preferences UI now has a section for notifications, showing:

- The Unified Push distributor in use (if any)
- A mechanism to change the distributor
- Per-account configuration and notification fetch details
- Battery optimisation state

General changes:

- Update to UnifiedPush library 2.4.0.

- NotificationFetcher.fetchAndShow() can now fetch a single account's
notifications, or all accounts, depending on data passed to the worker.

- Use ApiResult for `push/subscription` responses.

- Drop the "needs migration" terminology for the more specific "has push
scope", to make it clear what the issue with the account is.
2024-08-18 15:17:57 +02:00
sunniva fcbcb4073e fix(l10n): Update Norwegian Bokmål translations
Currently translated at 83.9% (601 of 716 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/nb_NO/
2024-08-14 17:18:09 +02:00
Juan M Sevilla 93895fd78e fix(l10n): Update Spanish translations
Currently translated at 100.0% (716 of 716 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-08-11 16:20:31 +02:00
Kalle Kniivilä e6b7b306f8 fix(l10n): Update Finnish translations
Currently translated at 100.0% (716 of 716 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-08-06 19:38:02 +02:00
Kalle Kniivilä b1545272ac fix(l10n): Update Finnish translations
Currently translated at 100.0% (711 of 711 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-08-06 19:38:02 +02:00
Nik Clayton c919f867b2
feat: Experimental preference to reverse home timeline (#867)
Add a new set of preferences, "Lab experiments", to control features
that are under investigation and may never make it into the mainstream.

Add the first experimental feature, which reverses the order of the home
timeline, so posts are shown oldest first instead of newest first.
2024-08-05 15:48:14 +02:00
Juan M Sevilla 75a8152739 fix(l10n): Update Spanish translations
Currently translated at 100.0% (711 of 711 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-08-05 13:47:29 +02:00
Miles Krell 0720e6c462 fix(l10n): Update Spanish translations
Currently translated at 88.7% (631 of 711 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-08-04 01:52:05 +02:00
Nik Clayton c0ff447415
chore: Prepare release 2.7.1 (versionCode 19) (#861) 2024-07-31 15:10:18 +02:00
Nik Clayton ff8b71a2d8
fix: Correctly position preview card images, show card description (#860)
Byline changes inadvertently changed how the preview image is laid out,
breaking the "Image at start, info at end" variant.

Previous code did not always show the card description if the text was
present, fix that.
2024-07-31 12:32:14 +02:00
Nik Clayton a0b3b1ffac
chore: Prepare release 2.7.0 (versionCode 18) (#841) 2024-07-29 16:25:24 +02:00
Nik Clayton e61de1c5f2
fix: Reduce preview cards to minimum height required (#840)
Previous code set a min-height, which is no longer necessary after the
other layout changes. But it meant that a preview card with a one-line
title, no synopsis, and a URL, was taking up too much vertical space.
2024-07-29 14:48:35 +02:00
Nik Clayton 6b5f816b28
feat: Remove preview card placeholder icon (#839)
Previous code displayed a large placeholder icon if there was no preview
image for a preview card.

This reduces the amount of space available for the actual preview text
(i.e., title and description) and did not convey additional information
in the limited space available on the timeline.

So remove it.

While I'm here simplify the PreviewCard layout and migrate to
ConstraintLayout.
2024-07-28 16:24:20 +02:00
Ricky From Hong Kong 8457d92581 fix(l10n): Update Chinese (Traditional) translations
Currently translated at 61.7% (435 of 704 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/zh_Hant/
2024-07-28 15:57:29 +02:00
Ricky From Hong Kong 05aed67e1e fix(l10n): Update Chinese (Simplified) (zh_MO) translations
Currently translated at 41.7% (294 of 704 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/zh_MO/
2024-07-28 15:57:29 +02:00
Ricky From Hong Kong f594749c5f fix(l10n): Update Chinese (Traditional, Hong Kong) translations
Currently translated at 53.4% (376 of 704 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/zh_Hant_HK/
2024-07-28 15:57:29 +02:00
Kalle Kniivilä 22ce5c08f2 fix(l10n): Update Finnish translations
Currently translated at 100.0% (704 of 704 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-07-27 19:17:30 +02:00
Kalle Kniivilä 0dfb949207 fix(l10n): Update Finnish translations
Currently translated at 100.0% (611 of 611 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-07-27 19:17:30 +02:00
Nik Clayton b1d5cb548f
fix: Don't crash due to Filters/ServerRepository race condition (#837)
The `canFilter()` implementation could crash if `server` (marked
`lateinit`) hadn't been initialised at the point of use.

Fix this by removing it and adjusting the two callers to use the
`filters` flow and take appropriate action on error.
2024-07-25 18:43:34 +02:00
Nik Clayton 01831474dc
feat: Toggle display of search operators with toolbar action (#836)
Default to hiding the search operators, and provide a new toolbar icon
(always visible) to show them.

The toolbar icon is displayed with a badge if any operators are present.

Adjust the operator display to three horizontal scrolling rows, to
further limit the maximum amount of vertical space the operators use.
2024-07-24 18:51:00 +02:00
Nik Clayton 5d574d4d76
feat: Include pre-set date search options (#835)
When selecting a search date range show the user a dialog with some
pre-set options, and a button that allows them to pick a custom date
range.
2024-07-24 17:57:19 +02:00
Nik Clayton bad502e6c3
fix: Use show()/hide() to ensure animation is delayed (#834) 2024-07-24 17:20:44 +02:00
Nik Clayton e4a305f608
refactor: Shorten search operator chip label strings (#833)
Improves the information density when selecting search operators.
2024-07-23 15:48:08 +02:00
Nik Clayton 11444bd27d
feat: Search whenever one of the search operators changes (#832) 2024-07-23 15:02:54 +02:00
Nik Clayton ae8584422c
fix: Ensure trending tag name is fully visible (#831)
Previously re-binding the tag's text wouldn't re-measure the layout when
the text changed. So scrolling down a longer tag could be placed in a
textview that previously held a shorter tag.

Then it was cut off and the user couldn't see what the tag was. Use
`wrap_content` so size is measured when the content changes.
2024-07-22 17:27:52 +02:00
Nik Clayton 71e006b0d2
feat: Provide a UI to edit different search operators (#829)
Mastodon supports in-query search operators, such as `has:image`,
`language:en`, or `in:library`. Previously the user had to enter them in
to the query directly.

This provides a chip-based UI that allows the user to set values for
these operators.

## Server

- Add new search capabilities to record the faceted search features the
server reports.
- Update definitions for Mastodon, Friendica, and GoToSocial to specify
which versions of the operations they support.

## SearchOperator / SearchOperatorViewData

- Represents each supported operator and associated viewdata.

## SearchActivity / activity_search.xml

- Conditionally display a chip for each facet depending on the server's
level of support.
- Implement the UI for each chip. They display dialogs of varying levels
of complexity depending on the underlying operation.

## FragmentSearch

- Display the progress as a LinearProgressIndicator instead of an
indeterminate ProgressBar. This makes it more visible under the search
facets.
2024-07-22 17:11:08 +02:00
Nik Clayton c4bc7f81da
refactor: Use withStyledAttributes in FontFamilyDialogFragment (#827)
Ensures it is not possible to forget to recycle the attribute array.
2024-07-22 16:29:53 +02:00
Nik Clayton 6b55d107c1
feat: Edit a matching filter directly from the timeline (#819)
Previously, if a status was filtered with "WARN" and was shown in the
timeline with the name of the filter, and the user then decided to
change
that filter, they had to:

1. Open the left navigation menu
2. Navigate to "Account preferences"
3. Open "Filters"
4. Find the filter they want to edit, tap it
5. Make the change, and save
6. "Back" to the list of filters
7. "Back" to "Account preferences"
8. "Back" to the timeline

That's a lot of clicks for a simple action.

Change this. Now the filtered status includes an "Edit filter" button
that takes the user directly to step 5, and when they press "Back" they
return directly to the timeline.

To do this create a new filter action, `onEditFilterById`. Update the
listeners to launch `EditFilterActivity` if appropriate.

Modify `item_status_filtered.xml` to show the new button.

Update the accessibility delegate to show just the "Show anyway" and
"Edit filter" actions. Modify `FilterableStatusViewHolder` to expose
the information it needs to do this.
2024-07-19 13:45:24 +02:00
Nik Clayton 7ef692c2c8
fix: Don't focus search query when returning to the results list (#824)
Previous code always focused the search query. This meant that if the
user:

1. Searched for something
2. Opened a result (post, hashtag, account)
3. Navigated back to the search results

then because the query was focused the soft-keyboard would open,
obscuring the list of results. The user had to press "Back" again to
dismiss the keyboard.

New code only focuses the search query view if it is empty. This allows
the user to come back to the list of results and immediately open a new
result.
2024-07-15 09:02:07 +02:00
Nik Clayton b757765383
change: Remove copyWithCollapsed helper (#823)
Holdover from when Java interoperability was required.
2024-07-15 00:00:36 +02:00
Nik Clayton e560868749
feat: Animate filter keywords when added or removed (#817)
This makes it a little easier to see what's been changed.
2024-07-14 23:43:20 +02:00
Nik Clayton af11e3d3a1
refactor: Replace `getOrElse { null }` with get() (#820)
`getOrElse { null }` is synonymous with `get()` when using
kotlin-result.
2024-07-14 23:42:59 +02:00
Nik Clayton 311e45168e
fix: Ensure initial status length calculation includes the content warning (#821)
Previous code set `doOnTextChanged` listener for the content warning
*after* the initial value had been set. This meant the initial content
warning text was not included when calculating the status' initial
length.

Fix that by setting the listener before the text is set.

Fixes #815
2024-07-14 22:59:26 +02:00
Nik Clayton 00a2cd32d3
change: Implement more of FiltersRepository (#816)
The previous code had a number of problems, including:

- Calls to the filters API were scattered through UI and viewmodel code.
- Repeated places where the differences between the v1 and v2 Mastodon
filters API had to be handled.
- UI and viewmodel code using the network filter classes, which tied
them to the API implementation.
- Error handling was inconsistent.

Fix this.

## FiltersRepository

- All filter management now goes through `FiltersRepository`.
- `FiltersRepository` exposes the current set of filters as a
`StateFlow`, and automatically updates it when the current server
changes or any changes to filters are made. This makes
`FilterChangeEvent` obsolete.
- Other operations on filters are exposed through `FiltersRepository` as
functions for viewmodels to call.
- Within the bulk of the app a new `Filter` class is used to represent a
filter; handling the differences between the v1 and v2 APIs is
encapsulated in `FiltersRepository`.
- Represent errors when handling filters as subclasses of `PachliError`,
and use `Result<V, E>` throughout, including using `ApiResult` for all
filter API results.
- Provide different types to distinguish between new-and-unsaved
filters, new-and-unsaved keywords, and in-progress edits to filters.

## Editing filters

- Accept an optional complete filter, or filter ID, as parameters in the
intent that launches `EditFilterActivity`. Pass those to the viewmodel
using assisted injection so the viewmodel has the info immediately.
- In the viewmodel use a new `FilterViewData` type to model the data
used to display and edit the filter.
- Start using the UiSuccess/UiError model. Refrain from cutting over to
full the action implementation as that would be a much larger change.
- Use `FiltersRepository` instead of making any API calls directly.

## Listing filters

- Use `FiltersRepository` instead of making any API calls directly.

## EventHub

- Remove `FilterChangedEvent`. Update everywhere that used it to use the
flow from `FiltersRepository`.
2024-07-14 15:36:52 +02:00
Kalle Kniivilä 14e7bccfda fix(l10n): Update Finnish translations
Currently translated at 99.8% (610 of 611 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-07-13 09:43:18 +02:00
Miles Krell 963441e1e4 fix(l10n): Update Spanish translations
Currently translated at 99.8% (610 of 611 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-07-13 09:43:18 +02:00
Miles Krell f950fce82f fix(l10n): Update Spanish translations
Currently translated at 99.0% (605 of 611 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-07-13 09:43:18 +02:00
Aindriú Mac Giolla Eoin 58a5136153 fix(l10n): Update Irish translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Fdroid
Translate-URL: https://hosted.weblate.org/projects/pachli/app-fdroid/ga/
2024-07-13 09:43:18 +02:00
Aindriú Mac Giolla Eoin 16b7257ac0 fix(l10n): Update Irish translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Google
Translate-URL: https://hosted.weblate.org/projects/pachli/app-google/ga/
2024-07-13 09:43:18 +02:00
Nik Clayton 0f80ec4abf
fix: Correctly punctuate a status content description (#808)
Previous code blindly inserted commas and semi-colons as separators
between the components of a content description. If some of those
components were null you could have a content description that looked
like "... , , , ..." or similar, and the repeated reading of "comma" by
screen readers was jarring and reduced accessibility.

Fix this by inserting punctuation only where necessary, building up the
string piece by piece instead of using a string resource with hardcoded
punctuation.

Fixes #791.
2024-07-06 19:29:02 +02:00
Nik Clayton 4dac29cc52
feat: Show autocomplete hashtags with usage counts, sort by popularity (#807)
When autocompleting hashtags while composing a status the previous code
showed the hashtags in the same order they're returned by the server,
with no additional information.

This doesn't allow the user to make an informed choice about which
hashtag might be better to use. For example, trying to choose between
"#nivenly" and "#NivenlyFoundation".

To fix that, include the hashtag's usage when receiving data from the
server. Sum that, and show it to the user in the hashtag list. Sort the
hashtags by popularity, most popular first.
2024-07-06 14:25:46 +02:00
sunniva 18d33468b1 fix(l10n): Update Norwegian Bokmål translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Google
Translate-URL: https://hosted.weblate.org/projects/pachli/app-google/nb_NO/
2024-07-06 14:13:42 +02:00
sunniva f308a9bedc fix(l10n): Update Norwegian Bokmål translations
Currently translated at 98.6% (600 of 608 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/nb_NO/
2024-07-06 14:13:42 +02:00
sunniva 8b79090349 fix(l10n): Update Norwegian Bokmål translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Fdroid
Translate-URL: https://hosted.weblate.org/projects/pachli/app-fdroid/nb_NO/
2024-07-06 14:13:42 +02:00
Nik Clayton ea05dec6c5
feat: Show author bylines on preview cards, tap to view profile (#805)
Mastodon now supports additional (optional) author information to show
as a byline on preview cards.

Use this (if included), to show the author's avatar, name, and link to
their profile. If tapped a click on a new `Target.BYLINE` target is
registered allowing fragments/activities to launch
`ViewProfileActivity`.

Include this as an action in `ListStatusAccessibilityDelegate`, and
provide `TrendingLinksAccessibilityDelegate` to provide accessibility
actions when viewing trending links.
2024-07-06 00:30:24 +02:00
Weblate (bot) 222d7afba4
fix(l10n): Translations update from Hosted Weblate (#804)
Translations update from [Hosted Weblate](https://hosted.weblate.org)
for [Pachli/Fastlane
Metadata](https://hosted.weblate.org/projects/pachli/fastlane-metadata/).


It also includes following components:

* [Pachli/Core/Network :
Main](https://hosted.weblate.org/projects/pachli/corenetwork-main/)

* [Pachli/App :
Main](https://hosted.weblate.org/projects/pachli/app-main/)

* [Pachli/Feature/About :
Main](https://hosted.weblate.org/projects/pachli/featureabout-main/)

* [Pachli/Feature/Suggestions :
Main](https://hosted.weblate.org/projects/pachli/featuresuggestions-main/)

* [Pachli/Core/Data :
Main](https://hosted.weblate.org/projects/pachli/coredata-main/)

* [Pachli/App :
Google](https://hosted.weblate.org/projects/pachli/app-google/)

*
[Pachli/Feature/Login](https://hosted.weblate.org/projects/pachli/featurelogin/)

* [Pachli/Core/Activity :
Orange](https://hosted.weblate.org/projects/pachli/coreactivity-orange/)

* [Pachli/Core/Activity :
Main](https://hosted.weblate.org/projects/pachli/coreactivity-main/)

* [Pachli/App :
Fdroid](https://hosted.weblate.org/projects/pachli/app-fdroid/)

* [Pachli/Feature/Lists :
Main](https://hosted.weblate.org/projects/pachli/featurelists-main/)

* [Pachli/Core/Designsystem :
Main](https://hosted.weblate.org/projects/pachli/coredesignsystem-main/)

* [Pachli/Core/Ui :
Main](https://hosted.weblate.org/projects/pachli/coreui-main/)



Current translation status:

![Weblate translation
status](https://hosted.weblate.org/widget/pachli/fastlane-metadata/horizontal-auto.svg)
2024-07-05 20:18:28 +02:00
Nik Clayton 5aacb02ea0
feat: Provide more detail in errors, especially media upload errors (#801)
Previous code assumed server responses would always be JSON, and had no
special handling for mis-configured servers that sometimes return HTML;
for example, if the server has a bug, or there's a reverse proxy in
front of the server issuing DoS-prevention challenges.

This could cause errors to show with no useful debugging information.

Update `ApiResult` to check the content-type in the response and return
one of two new errors if the content-type is missing or wrong. Also
include the HTTP code in `ApiResponse` for use elsewhere.

Update `ThrowableExtensions` to pull the `error` and optional
`description` out of the error body.

Update `PachliError` so `formatArgs` can be an array of arbitrary types,
not just strings.

Update `MediaUploader`; expose the different errors as new
`MediaUploaderError` types instead of `Exception` subclasses, and return
`Result<V, E>` where appropriate.

Update `ComposeViewModel` to use the new `MediaUploaderError` types and
create new `PickMediaError` to report issues there, replacing
`VideoOrImageException`.

Update `ComposeActivity` to use the new error types and show errors
until the user dismisses them, so they're better able to see and report
problems.

Fixes #704.
2024-07-04 19:16:24 +02:00
Nik Clayton 4fc52f9bc2
feat: Warn the user if the posting language might be incorrect (#792)
The user has to specify the language they're posting in, and sometimes
they might get it wrong (e.g., replying to a post that also had the
language set incorrectly, forgetfulness, etc).

This has accessiblity issues (only following statuses in a given
language fails, translation can fail, etc).

Prevent this by trying to detect the language the status is written in
when the user tries to post it. If the detected language and the set
language do not match, and the detection is 60+% confident, warn the
user the status language might be incorrect, and offer to correct it
before posting.

How this works differs by device and API level.

- API 23 - 28, fdroid and github build flavours
   - Not supported. A no-op language detector is used.
- API 29 and above, fdroid and github build flavours
   - Uses Android TextClassifier to detect the likely language
- AP 23 and above, google build flavour
   - Uses ML Kit language identification

To do this:

- Add `LanguageIdentifier`, with methods to do the identification, and
`LanguageIdentifier.Factory` to create the identifiers.
- Inject the factory in `ComposeActivity`
- Detect the language when the user posts, showing a dialog if there's a
sufficiently large discrepancy.

The ML Kit dependencies (language models) will be installed by the Play
libraries, so there's some machinery to check that they're installed,
and kick off the installation if not. If they can't be installed then
the language check is bypassed.

Update the privacy policy, as the ML Kit libraries may send some data to
Google.
2024-07-02 20:22:17 +02:00
Juan M Sevilla 3849c04ea7 fix(l10n): Update Spanish translations
Currently translated at 100.0% (595 of 595 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-07-02 09:02:10 +02:00
Nik Clayton 1b7c90896b
chore: Prepare release 2.6.0 (versionCode 17) (#790) 2024-06-27 11:30:59 +02:00
Nik Clayton 30ec3982ff
revert: Use androidx.startup for startup activities (#784)
This reverts commit 3870267701.

With this commit Pachli Current crash reports in Google Play showed
instances of:

```
Exception java.lang.RuntimeException:
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7716)
  at android.app.ActivityThread.-$$Nest$mhandleBindApplication
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2478)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at android.app.ActivityThread.main (ActivityThread.java:8919)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
Caused by java.lang.IllegalStateException: WorkManager is not initialized properly.  You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.
  at androidx.work.impl.WorkManagerImpl.getInstance (WorkManagerImpl.java:170)
  at androidx.work.WorkManager.getInstance (WorkManager.java:184)
  at app.pachli.PachliApplication.onCreate (PachliApplication.kt:96)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1316)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7711)
```

on Samsung devices at API 34.

By my understanding this is a "can't happen" issue, the `WorkManager` is
supposed to be initialised by the androidx.startup content provider
before `PachliApplication` starts.

But it clearly does, so revert this change to be safe.
2024-06-26 23:34:17 +02:00
Nik Clayton a23933a77c
fix: Set font size and family when going back from Preferences (#781)
Implementing predictive back support inadvertently broke the code
ensuring activities are restarted when the font size or family changes.
So the user could change the font in Preferences, see the change be
immediately reflected in the preferences screen, then go back to the
previous activity and the change wouldn't be reflected.

Fix this by restoring some of the previous code.
2024-06-25 21:47:26 +02:00
Nik Clayton 04b7ce47a2
fix: Correctly handle setting / editing a status' language (#780)
Previous code set the initial status text, and then set up the callbacks
which meant that the status' length was initially 0, even when editing a
status.

This meant that, e.g., editing a status to change its language would
erroneously report the status body was empty. It also meant that editing
a status and changing just the language would not prompt to save or
discard the changes if moving back.

Fix this.

First, only set the status content after the callbacks that compute the
status length.

Second, provide a function that sets the status' language, and update
the close confirmation state when the language changes. Modify isDirty()
to compare the original and current language when determining if the
status is dirty.

Fixes #701
2024-06-25 13:39:14 +02:00
Nik Clayton 2ac9e0918e
change: Combine variable declaration and assignments (#779)
Simplifies `init` blocks.
2024-06-25 12:16:24 +02:00
Nik Clayton f477c63ab4
fix: Improve readability of status media labels (#778)
Previous code did not provide whitespace between different media labels
when media is not loaded.

In addition, the icon for the media was centre-aligned vertically with
the text, making it difficult to scan and determine when one media label
ends and another one starts.

Fix this by adding an 8dp margin between the media labels, and using a
TextView subclass that vertically aligns the media icon with the first
line of text.

Set the compound drawables with relative alignment, so they behave
appropriately in RTL layouts.

Fixes #751.
2024-06-25 11:53:47 +02:00
Kalle Kniivilä 1d87ac82bd fix(l10n): Update Finnish translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Google
Translate-URL: https://hosted.weblate.org/projects/pachli/app-google/fi/
2024-06-24 14:56:30 +02:00
Kalle Kniivilä 711beba91c fix(l10n): Update Finnish translations
Currently translated at 100.0% (595 of 595 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-06-24 14:56:30 +02:00
Nik Clayton 1f2194cc3e
fix: Ensure text in nav menu account header is legible (#773)
The user might have set a profile header image that is close to the
colour of the text in the account header in the left navigation menu.
This can make the text difficult or impossible to see.

Work around this by drawing a partially transparent scrim behind the
text so it's always displayed over a background that makes the text
legible.

Fixes #298
2024-06-22 16:55:57 +02:00
Nik Clayton 597833d660
fix: Don't exceed the maximum number of created shortcuts (#771)
Previous code created one shortcut per account, which could exceed the
maximum number of shortcuts allowed, causing a crash.

Fix this by creating no more than the max number of shortcuts while
ensuring that the active account is always included.

Fixes #752
2024-06-20 13:26:31 +02:00
Nik Clayton f3354d1aae
refactor: Improve IO performance and simplify code with Okio (#769)
`ImageDownsizer.downsizeImage()`:
- Remove the return value, it was ignored
- Throw `FileNotFoundException` when `openInputStream` returns null

`ImageDownsizer.getImageOrientation()`:
- Throw `FileNotFoundException` when `openInputStream` returns null

`MediaUploader.prepareMedia()`:
- Copy URI contents using Okio buffers / source / sink

`UriExtensions`:
- Rename from `IOUtils`
- Implement `Uri.copyToFile()` using Okio buffers / source / sink
- Replace `ProgressRequestBody()` with `Uri.asRequestBody()` using Okio
buffers / source / sink

`DraftHelper.copyToFolder()`
- Use Okio buffers / source / sink

`CompositeWithOpaqueBackground`
- Use constants `SIZE_BYTES` and `CHARSET` instead of magic values
- Use `Objects.hash` when hashing multiple objects

Based on work by Christophe Beyls in
- https://github.com/tuskyapp/Tusky/pull/4366
- https://github.com/tuskyapp/Tusky/pull/4372
2024-06-20 13:18:58 +02:00
Miles Krell 160e434bf8 fix(l10n): Update Spanish translations
Currently translated at 99.8% (594 of 595 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-06-19 20:25:52 +02:00
Nik Clayton 4551313bd2
refactor: Use androidx.core:core-splashscreen library (#766)
Previous code depended on, but did not initialise, the androidx
splashscreen library.

Fix that, using the library on API < 31, or the platform implementation
otherwise.

`SplashActivity` is no longer needed, launching goes straight in to
`MainActivity`.

Version 1.2.0-alpha01 is needed to fix some theme corruption bugs in
earlier versions of the library.
2024-06-19 16:27:49 +02:00
Nik Clayton ce938239e8
fix: Use default "Navigate up" content description in ViewThreadActivity (#764)
Previous layout set `navigationContentDescription` to
`action_open_drawer`, which is not correct for that part of the UI.

Remove it, and the default "Navigate up" is used.
2024-06-19 14:32:22 +02:00
Nik Clayton bd6bc95b01
refactor: Use androidx.startup for startup activities (#762)
Move initialisation of WorkManager and Timber in to new `Initializer`
classes, managed by `androidx.startup`.

There's a false-positive `BadConfigurationProvider` lint message because
the `Configuration.Provider` is in the content provider and not the
application class.
2024-06-19 14:02:58 +02:00
Nik Clayton 1468936970
chore(deps): update agp to v8.5.0, lint to 31.5.0 (#756)
New lint checks mean:

- Some trivial uses of String.format() are replaced with templates
- Use a string resource for the scheduled date and time

Some reported SetTextI18n warnings have been ignored, as they relate to
e.g., clearing a view's text by setting it to "".
2024-06-18 13:58:37 +02:00
Nik Clayton 3d5c2dd32f
feat: Show "Suggested accounts" (#734)
Implement suggestions as a new `feature:suggestions` module, with
associated activity, fragment, etc.

Suggested accounts are shown with their normal information, as well as
information about the number of follows / followers, and a guide to
posting frequency, so the user can make a more informed decision about
whether to follow or not.
2024-06-17 21:43:12 +02:00
Nik Clayton 2327ab5221
refactor: Move actions.xml to core.ui (#754) 2024-06-17 20:38:19 +02:00
Nik Clayton 3a1a0073e9
refactor: Move action_{links,mentions,hashtags}, title_{hashtags,links}_dialog strings to core.ui (#753)
Moving ahead of Suggestions work to minimise diffs.
2024-06-17 20:21:53 +02:00
Nik Clayton 8fb3f62db7
chore: Remove unused ui_error_unknown string resource (#748) 2024-06-13 23:18:14 +02:00
Nik Clayton e41c42081d
change: Dismiss the error snackbar before showing a new one (#745) 2024-06-13 22:40:51 +02:00
Nik Clayton dd0e01a15c
refactor: Move IconUtils to core.ui (#744) 2024-06-13 21:34:49 +02:00
Nik Clayton 892663cab3
refactor: Move ReselectableFragment to core.activity (#743) 2024-06-13 21:16:10 +02:00
Nik Clayton efd1c8e556
refactor: Use the PachliError type for ApiError (#739)
In the previous code `PachliError` could correctly chain errors and
generate error messages, `ApiError` didn't, which is why there was the
temporary `ApiError.fmt()` extension function.

Rewrite `ApiError` to implement `PachliError` so it gets these benefits
and to reduce the number of different error-handling mechanisms in the
code.

Main changes:

- `PachliError` is now an interface so it can be extended by other
  error interfaces.
- All the `ApiError` subclasses implement `PachliError`, and can
  specify the error string and interpolated variables at the point of
  declaration.
- Update `ListsRepository` and `ServerRepository` to return
  `PachliError` subclasses.
2024-06-12 10:22:27 +02:00
Nik Clayton d0432dbd24
refactor: Move string post_username_format to core.designsystem (#736) 2024-06-10 21:06:31 +02:00
Nik Clayton 9f4652c6cf
refactor: Move LinkHelper and AsciiFolding to core.ui (#735) 2024-06-10 20:38:16 +02:00
Nik Clayton 7cf7476c49
refactor: Move throttleFirst to core.common (#733) 2024-06-10 19:57:47 +02:00
Nik Clayton 46c7307c0d
refactor: Move LinkListener to core.ui (#732) 2024-06-10 17:40:23 +02:00
Nik Clayton a68e1bf63b
refactor: Move StatusDisplayOptions and Repository to core.data (#731) 2024-06-10 17:29:09 +02:00
Nik Clayton dc61030b98
refactor: Move AccountPreferenceDataStore to core.data (#730) 2024-06-10 16:54:14 +02:00
Nik Clayton 5dd1b9a2f9
refactor: Move CardViewMode to core.preferences (#729) 2024-06-10 16:28:55 +02:00
Nik Clayton e4a065ca9f
refactor: Move ServerRepository to core.data (#728) 2024-06-10 16:08:48 +02:00
Nik Clayton a2fa9f60fb
change: Use getErrorString for UploadServerError types (#726) 2024-06-05 18:21:20 +02:00
Miles Krell 368f9a8f70 fix(l10n): Update Spanish translations
Currently translated at 100.0% (607 of 607 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-06-02 15:15:10 +02:00
Nik Clayton 7f094b1781
chore: Prepare release 2.5.2 (versionCode 16) (#723) 2024-05-31 12:27:27 +02:00
Miles Krell 5610cd23fa
fix: Prevent crash on "hidden domains" page (#703)
The crash was caused by an uncaught exception when calling
`MastodonApi#domainBlocks`.

Update the `BackgroundMessageView` for the error message so it fills the
screen like on other pages.

Fixes #696
2024-05-30 19:35:39 +02:00
Miles Krell ab08974fc9 fix(l10n): Update Spanish translations
Currently translated at 100.0% (607 of 607 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-05-30 19:26:07 +02:00
Miles Krell fe4813283b fix(l10n): Update Spanish translations
Currently translated at 100.0% (607 of 607 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-05-30 19:26:07 +02:00
Black_Eyes 4944e6fde1 fix(l10n): Update French translations
Currently translated at 100.0% (2 of 2 strings)

Translation: Pachli/App : Fdroid
Translate-URL: https://hosted.weblate.org/projects/pachli/app-fdroid/fr/
2024-05-30 19:26:07 +02:00
Kalle Kniivilä 071af59ad7 fix(l10n): Update Finnish translations
Currently translated at 100.0% (607 of 607 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-05-30 19:26:07 +02:00
Nik Clayton 4520a29c74
fix: Generate useful error messages for all errors (#719)
Previous code was inconsistent about using getServerErrorMessage() and
whether or not the case where getServerErrorMessage() returns null was
handled.

Switch to using getErrorString() which does handle the null case and
always returns a usable string.

Some string resources are rendered temporarily unused by this change.
They will be used again soon, so configure lint to ignore them at the
moment.
2024-05-30 19:14:43 +02:00
Nik Clayton 84fdf4abb7
fix: Only include transitionKind in intents for Pachli activities (#716)
Previous code always included the transitionKind enum as an extra, and
could cause a crash if the activity launched by the intent was not a
Pachli activity.

Fixes #700.
2024-05-30 14:05:42 +02:00
Nik Clayton 61afde882c
fix: Only suggest upgrading to a version F-Droid has built (#717)
The F-Droid API can return a `suggestedVersionCode` that F-Droid has not
successfully built (e.g., there was a network issue preventing F-Droid
from fetching the source code at the time of the last build).

This meant users were being prompted to update when there was not a
built package to update to.

Fix this by verifying that `suggestedVersionCode` appears in the list of
packages. If it doesn't then fall back to the highest version code in
the list of packages.

Fixes #684
2024-05-30 13:49:42 +02:00
Nik Clayton de7e5a9df9
fix: Re-enable accessiblity actions in all timelines (#715)
22729df1 broke accessiblity actions in non-notification timelines by
returning too early if the status was not a NotificationViewData.
2024-05-29 22:07:08 +02:00
Nik Clayton a12d03b2b7
fix: Prompt user to save/discard changes after editing bio (#678)
Previous code didn't get the viewmodel to check if the content had
changed, so `onBackPressedCallback` wasn't enabled, and the user could
edit the bio and press "back" without being prompted to save their
changes.
2024-05-01 22:42:53 +02:00
Nik Clayton 1c7e4747f0
chore: Update lint, mark item_status_filtered text non-selectable (#677) 2024-04-30 17:18:18 +02:00
Miles Krell ee8f2b69b8
remove: remove janky animation warning (#658)
This warning (added in #274) includes a comment saying that we can
remove it after 2024-03-01, so the time has come :)
2024-04-30 16:25:05 +02:00
Nik Clayton 8ee5463bba change: Add anonymous parameter to `forEach` lambda 2024-04-30 16:23:34 +02:00
Nik Clayton 02da503721 change: Use `tools:text` for design-time text 2024-04-30 16:23:34 +02:00
Nik Clayton e97d9c30fe change: Set the visiblity explicitly 2024-04-30 16:23:34 +02:00
Nik Clayton 5cd0083807 change: Remove unnecessary `Companion` qualifier 2024-04-30 16:23:34 +02:00
Nik Clayton b0fccb0aa7 change: Remove unnecessary null check 2024-04-30 16:23:34 +02:00
Nik Clayton d87a6718cc change: Use "…" instead of "..." in Korean localisation 2024-04-30 16:23:34 +02:00
Nik Clayton 86d79276c6 change: Correct some package references in KDoc 2024-04-30 16:23:34 +02:00
Nik Clayton 1f50a9cbe7 change: Remove unnecessary types 2024-04-30 16:23:34 +02:00
Nik Clayton 4ddd23dda6 change: Correct constructor parameter visibility 2024-04-30 16:23:34 +02:00
Nik Clayton c8532c9fb4 change: Remove dead code 2024-04-30 16:23:34 +02:00
Nik Clayton 6fd993acf6 change: Use supportFragmentManager.commit 2024-04-30 16:23:34 +02:00
Nik Clayton 286a152fde change: Move MediaUploadApi to the correct package 2024-04-30 16:23:34 +02:00
Nik Clayton 2d0cf6c17e change: Mark some properties private 2024-04-30 16:23:34 +02:00
Nik Clayton bf474a5eef
fix(deps): update dependency androidx.core:core-ktx to v1.13.0 (#673)
Use `GestureDetector` as this release deprecates
`GestureDetectorCompat`.
2024-04-30 16:14:11 +02:00
Nik Clayton 2236f53838
fix: Show edit history for status' with polls (#672)
Edited polls only include the list of options with titles; no other
metadata (poll ID, single/multiple choice, vote counts, etc). Since the
data shape didn't match Moshi wasn't decoding the data.

Provide dedicated data classes to model the response, and add a fourth
poll display option to represent viewing an edit history snapshot.
2024-04-30 14:38:36 +02:00
Nik Clayton c7783b65f9
refactor: Use AppCompatResources.getDrawable() (#671)
Replace `ContextCompat.getDrawable()`, as the app-compat version has
platform fixes and backports.

appcompat-lint warns about bare `context.getDrawable()`, but does not
cover `ContextCompat` (https://issuetracker.google.com/issues/337905331)
2024-04-30 13:30:19 +02:00
Nik Clayton c6d6f0f810
chore: Prepare release 2.5.1 (versionCode 15) (#670) 2024-04-29 18:52:34 +02:00
Nik Clayton 22729df1b7
fix: Only enable accessible actions on notifications attached to a status
Fixes #669
2024-04-29 18:43:39 +02:00
Nik Clayton fc5061f777
chore: Prepare release 2.5.0 (versionCode 14) (#668) 2024-04-29 12:44:59 +02:00
Miles Krell 6fed74099a fix(l10n): Update Spanish translations
Currently translated at 100.0% (609 of 609 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-04-29 08:58:44 +02:00
Nik Clayton e65bc13184
fix: Mark tab drag icon as unimportant for accessiblity (#663)
Talkback was speaking it as "Unlabeled". It's not necessary for
Talkback, as the tab name describes it in the list.
2024-04-28 23:53:38 +02:00
Nik Clayton f771dd7026
fix: Enable talkback actions in notifications and conversations (#661)
`ListStatusAccessiblityDelegate` was ignoring notifications because it
was checking the status against the concrete `StatusViewData` and not
the interface `IStatusViewData`.

Fix that and now notifications have accessibility actions.

`ConversationsFragment` didn't set the accessibility delegate, so no
actions appeared. Fix that so they do.
2024-04-28 23:46:11 +02:00
Nik Clayton 362cdfeb27
fix: Prevent crash when Pachli is a share target (#659)
Crash was occuring because the instance info hadn't been fetched, trying
to take the last item of an empty list.

To fix:

- Expose the instance info as a state flow, with a default. New instance
info is fetched whenever the active account changes.

- Do the same for the emojis supported by the server.

- Update call sites as appropriate.

- Mark `InstanceInfoRepository` as `@Singleton` so it isn't repeatedly
created causing fresh content fetches.

The tests needed updating to get this to work.

- Extract the network fake modules in to a network-test module so
multiple other modules can use them.

- Rewrite `InstanceInfoRepositoryTest` to use Hilt and use Turbine to
test the new flows.

Checking this showed cosmetic bugs in the About layout when instance
info is missing, clean those up.
2024-04-28 18:19:13 +02:00
Miles Krell 1f4930ff79 fix(l10n): Update Spanish translations
Currently translated at 100.0% (606 of 606 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-04-27 02:08:54 +02:00
Nik Clayton 78cda01ec8
change: Adjust SwipeRefreshLayout offset in AccountActivity (#652)
The change in 5959d23d resulted in a stuck margin when scrolling up in
the account view.

Fix the `SwipeRefreshLayout` offset in a different way that doesn't have
that problem; move the spinner's start position to the top of the screen
(instead of the negative offset it normally has) and keep the same
relative offset from the end position.

Have it scale in on the drag to complete the effect.
2024-04-27 00:15:21 +02:00
Nik Clayton 93e6b38d43
feat: Update activity transitions, prepare for predictive-back (#650)
Previous code used a single animation type (slide) when transitioning,
the transition was quite slow, and didn't behave appropriately if the
device was set to a RTL writing system.

In addition, handling the back affordance didn't work well with the new
"Predictive Back" feature in Android 14

(https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture).

Fix this.

## Transitions

To update the transitions the `startActivityWithSlideInAnimation()`
implementation (and associated `finishWithoutSlideOutAnimation()`) have
been replaced.

There are three transitions; `default`, `slide`, and `explode`,
represented as an enum passed to the activity intent.

The `default` transition is the activity transition from Android 14,
from the Android open source project

(https://cs.android.com/android/platform/superproject/+/android-14.0.0_r18:frameworks/base/core/res/res/anim/;bpv=1).
This is used for most transitions.

The `slide` transition is the pre-existing slide transition, with a
shorter transition time so it feels more responsive, and an RTL
implementation. This is used when there is a strong spatial component to
the navigation, for example, when going from:

- a status to its thread
- a preference menu item to its subscreen
- a filter in a list to the "edit filter" screen
- viewing your profile to editing your profile

The `explode` transition is used when the state of the app changes
significantly, such as when switching accounts.

Activities are now started with `startActivityWithTransition()` which
sets the intent and prepares the transition. `BaseActivity` checks the
intent for the transition type and makes further changes to the
transition as necessary.

## Predictive back

"Predictive back" needs to know what the back button would do before the
user interacts with it with an `onBackPressedCallback` that is either
enabled or disabled. This required refactoring some code (particularly
in `ComposeActivity`) to gather data ahead of time and enable/disable
the callback appropriately.

## Fixed bugs

- Back button wasn't stepping back through the tabs in AccountActivity
- Modifying a filter and pressing back without saving wasn't prompting
the user to save the changes
- Writing a content warning and then hiding it would still count the
text of the content warning toward's the post's length

## Other cleanups

- Use `ViewCompat.setTransitionName()` instead of setting the
`transitionName` property
- Delete the unused `fade_in` and `fade_out` animations.
- Use androidx-activity 1.9.0 to get the latest predictive back support
library code
- Show validation errors when creating / editing filters
2024-04-26 23:18:30 +02:00
Nik Clayton 12eccb63ae
refactor: Prefer System.currentTimeMillis() to Date().getTime() (#645)
Avoids unnecessary object creation.

Add a lint rule to catch this.
2024-04-24 12:07:05 +02:00
Nik Clayton 3e1d94ded2
feat: Use Let's Encrypt certificates on API 23 devices (#640)
Android 7 devices no longer trust certificates issued by Let's Encrypt
(see https://letsencrypt.org/2020/11/06/own-two-feet and
https://letsencrypt.org/2023/07/10/cross-sign-expiration.html for
details).

To work around that provide the Let's Encrypt root certs as resources.

On API 24+ devices add those via network_security_config.xml.

On API 23 devices they need to be installed manually for OkHttp SSL
connections, and checked when there is an SSL error in
LoginWebViewActivity.

The root certificates were downloaded from
https://letsencrypt.org/certificates/:

- https://letsencrypt.org/certs/isrgrootx1.der (self-signed)
- https://letsencrypt.org/certs/isrg-root-x1-cross-signed.der
(cross-signed)
- https://letsencrypt.org/certs/isrg-root-x2.der (self-signed)
- https://letsencrypt.org/certs/isrg-root-x2-cross-signed.der
(cross-signed)

Fixes #638
2024-04-24 10:32:50 +02:00
Miles Krell 4fdb997d7e fix(l10n): Update Spanish translations
Currently translated at 100.0% (606 of 606 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/es/
2024-04-23 22:25:56 +02:00
Nik Clayton 5959d23d89
change: Move SwipeRefreshLayout margin in AccountActivity (#642)
AccountActivity is full screen, so the swipe spinner was appearing very
close to the top system bar. Adjust the spinner's top margin to avoid
the system bar, and have it scale in/out so it doesn't appear to slide
out from an invisible barrier.
2024-04-23 15:58:32 +02:00
Nik Clayton b3bce36ccc
fix: Improve transitions in/out of playing video (#636)
Previous code didn't trigger the transition from `ViewMediaActivity`
when playing a video until the video had loaded. If the connection was
slow or had other issues this resulted in the video "sticking" in the
timeline until it loaded.

Change this, and trigger the transition immediately.

Fixes #598

While looking at this:

- Save the play/pause state of the video during a swipe, pause the
video, and restore the state when the swipe is cancelled.
- Transition the entire video view, to improve the animated transition
back to the activity.
- Remove the custom progress spinner, use the one provided by the
player.
- Display the player controller via the layout XML instead of code
2024-04-23 11:35:11 +02:00
Nik Clayton aa930f3a6f
feat: Fetch more trending posts, links, and hashtags (#634)
The previous code didn't set a limit for the number of posts, links, and
hashtags to fetch on the trending pages, so used the conservative
defaults.

Increase these to the API maximums to show the user more information.
2024-04-22 21:34:22 +02:00
Nik Clayton b0d63e4243
fix: Update PageCache to handle non-chronological ordering (#633)
The PageCache implementation wasn't properly dealing with timelines that
could return statuses in non-chronological order.

For example, if you bookmark a recent status, then go back in the
timeline and bookmark an older status; the bookmarks timeline is ordered
by the time of the bookmark event, not the creation time of the status
that was bookmarked.

If a sufficiently old status was bookmarked so it straddled a page
boundary you could have a situation where the range of status IDs in two
different cached pages overlapped.

E.g., this log extract:

```
0: k: 110912736679636090, prev: 3521487, next: 3057175, size: 40, range: 112219564107059218..110912736679636090
1: k: 111651744569170291, prev: 3049659, next: 2710596, size: 40, range: 111926741634665808..111651744569170291
```

The range of IDs in page 0 overlaps with the range of IDs in page 1.

The previous `PageCache` assumed this couldn't happen, and broke in
various interesting ways when it did.

E.g., you can't find the page that contains a given status by looking
for the largest key less than the needle's status id. Given the pages
above looking for ID 112219564107059218 (first status in page 0) would
suggest page 1 as having the greatest key less than that ID. This
manifested as the correct page briefly appearing in the UI (page 0),
then being completely replaced with page 1.

Rewrite PageCache to fix this. The previous implementation used a single
`TreeMap` assuming items were always sorted by ID. The new code keeps an
unordered map from status IDs to the page that contains that status, and
a separate `LinkedList` that contains the pages in order they're
provided by the API. This decouples the ordering of pages in the cache
with the overall ordering of items within the pages.
2024-04-22 20:34:16 +02:00
Nik Clayton b8939dd2cf
fix: Ensure actionbar title is set correctly (#628)
https://github.com/pachli/pachli-android/pull/589 changed the initial
setting of the action bar title to use `binding.mainToolbar.title`
instead of `supportActionBar?.title`.

Not sure why, but this doesn't work on first use, and was showing
"Pachli Current" until the user changes tabs. Swap one usage back to
`supportActionBar?.title` to fix this, and update the other to do the
same thing to keep the code consistent.
2024-04-15 22:42:22 +02:00
Nik Clayton 7752cf9210
fix: Set correct text direction for localised error messages (#601)
Use `unicodeWrap` when inserting placeholders in error messages so they
set the correct text direction.

Update some strings with formatting directives to (a) include `_fmt`
in the name, and (b) use `%1$s` instead of `%s`.
2024-04-09 14:26:15 +02:00
Weblate (bot) 9e35147658
fix(l10n): Translations update from Hosted Weblate (#588)
Translations update from [Hosted Weblate](https://hosted.weblate.org)
for [Pachli/Fastlane
Metadata](https://hosted.weblate.org/projects/pachli/fastlane-metadata/).


It also includes following components:

* [Pachli/Core/Network :
Main](https://hosted.weblate.org/projects/pachli/corenetwork-main/)

* [Pachli/App :
Main](https://hosted.weblate.org/projects/pachli/app-main/)

* [Pachli/Feature/About :
Main](https://hosted.weblate.org/projects/pachli/featureabout-main/)

* [Pachli/Feature/Lists :
Main](https://hosted.weblate.org/projects/pachli/featurelists-main/)

* [Pachli/App :
Google](https://hosted.weblate.org/projects/pachli/app-google/)

*
[Pachli/Feature/Login](https://hosted.weblate.org/projects/pachli/featurelogin/)

* [Pachli/Core/Designsystem :
Main](https://hosted.weblate.org/projects/pachli/coredesignsystem-main/)

* [Pachli/Core/Activity :
Orange](https://hosted.weblate.org/projects/pachli/coreactivity-orange/)

* [Pachli/Core/Activity :
Main](https://hosted.weblate.org/projects/pachli/coreactivity-main/)

* [Pachli/App :
Fdroid](https://hosted.weblate.org/projects/pachli/app-fdroid/)

* [Pachli/Core/Ui :
Main](https://hosted.weblate.org/projects/pachli/coreui-main/)



Current translation status:

![Weblate translation
status](https://hosted.weblate.org/widget/pachli/fastlane-metadata/horizontal-auto.svg)

---------

Co-authored-by: ButterflyOfFire <boffire@users.noreply.hosted.weblate.org>
Co-authored-by: Kalle Kniivilä <kalle.kniivila@gmail.com>
Co-authored-by: Nik Clayton <nik@ngo.org.uk>
2024-04-05 17:52:39 +02:00
Nik Clayton b52ec248b0
refactor: Remove unnecessary whitespace in poll_info_format resource (#595) 2024-04-05 16:46:38 +02:00
Angelo Suzuki 6507e2bec1
fix: Setup compose button when creating MainActivity (#589)
The compose button isn't initially working on `MainActivity`. It is only
properly setup after changing tabs.

Fix by calling `MainActivity.refreshComposeButtonState(TabViewData)` on
creation.
2024-04-04 13:33:43 +02:00
Nik Clayton 6bef6f2fae
feat: Simplify adding/removing timelines from tabs (#587)
Previously, modifying any tabs meant opening the left-side nav, opening
Account preferences > Tabs, and then adding / removing tabs. This is
time consuming, and difficult for new users to discover.

In addition, it was possible to remove the Home tab, and there was a
hardcoded minimum of at least two tabs.

Fix this.

When viewing a timeline that is not already in a tab an "Add to tab"
menu item is enabled, which appends the timeline to the list of existing
tabs.

When viewing a timeline in a tab (that is not the Home timeline) a
"Remove tab" menu item is enabled, which removes the tab from the list
of existing tabs.

If the user removes the active tab (either with this menu item, or
through preferences) the tab to the left of the active tab becomes the
new active tab.

A new "Manage tabs" menu item is also provided, as a shortcut to the
existing Account preferences > Tabs screen.

When managing tabs the Home timeline can not be removed; the button to
remove it is removed, and swiping is disabled on that list item. The
restriction of "at least two tabs" has also been removed.

`NotificationsActivity` has been removed, as `TimelineActivity` can
display `NotificationsFragment`.

To make the three "Trending" types (hashtags, links, and posts) more
visually distinct add two new icons for links (ic_newspaper) and posts
(ic_whatshot).

Fixes #572, #584, #585, #569
2024-04-03 00:10:09 +02:00
Nik Clayton 0829d91989
fix: Stop crash in FollowedTagsActivity when view is not created (#586) 2024-04-02 17:51:46 +02:00
Nik Clayton 4ea42f4a2c
feat: Add left-nav entries for Local, Federated, and Direct Messages (#583)
Fixes #570
2024-04-01 21:42:28 +02:00
Nik Clayton d65d969257
fix: Allow filter expiration to be set to "indefinite" (#582)
Mastodon API uses an "empty" `expires_in` value for a filter to mean
"Does not expire" (i.e., indefinite).

This was modelled as a null. Which doesn't work, because Retrofit does
not send name/value pairs in encoded forms if the value is null.

Fix this by making the API type a `String?`, and explicitly using the
empty string when indefinite expiry is used. This has to be converted
back to an Int? in a few places.

See
https://github.com/mastodon/documentation/issues/1216#issuecomment-2030222940
2024-04-01 20:48:11 +02:00
Nik Clayton c45408088a
refactor: Use the `minutes` helper to create the duration (#581) 2024-04-01 20:14:19 +02:00
Nik Clayton 55c12dde44
refactor: Improve show/hide FAB logic (#580)
Previous code was inconsistent about how and when the FAB was hidden if
the user had set the relevant preference.

- Sometimes the FAB has hidden by setting the visibility to false, which
removed it with no animation.

- Sometimes the value of the preference was checked once, when the
fragment or activity was created.

- Some timelines didn't show the FAB (Hashtags, Favourites, Bookmarks,
TrendingLinks, TrendingStatuses).

- Logic for figuring out which `ComposeActivity` intent to use was
scattered across different files.

Improve this by:

- Expose changes to the `FAB_HIDE` preference in the relevant viewmodels
as a flow the UI component can collect.

- Centralise the show/hide logic in a new `ActionButtonScrollListener`
class, and always using `show()`/`hide()` to animate the transition.

- Centralise the logic for creating the `ComposeActivity` intent in
`TabViewData`.
2024-04-01 19:57:46 +02:00
Nik Clayton 53fa56bbb4
feat: Support adding "Favourites" to a tab (#578) 2024-03-31 00:03:32 +01:00
Nik Clayton 64fae0ceb6
refactor: Rename `StatusListActivity` to `TimelineActivity` (#577)
More accurately reflects what it does, and simplies the diffs for
upcoming work.
2024-03-30 23:48:04 +01:00
Nik Clayton 8257ded395
refactor: Remove `TabData` type (#576)
`TabData` recorded the type of the timeline the user had added to a tab.
`TimelineKind` is another type that records general information about
configured timelines, with identical properties.

There's no need for both, so remove `TabData` and use `TimelineKind` in
its place.

`TimelineKind` is itself mis-named; it's not just the timeline's kind
but also holds data necessary to display that timeline (e.g., the list
ID if it's a `.UserList`, or the hashtags if it's a `.Hashtags`) so
rename to `Timeline` to better reflect its usage. Move it to a new
`core.model` module.
2024-03-30 23:27:25 +01:00
Nik Clayton 09ca6ae0a8
fix: Create a dedicated menu for NotificationsActivity (#571)
Previous code (probably copy/paste error) used R.menu.activity_trending.
2024-03-29 21:37:45 +01:00
Nik Clayton c2db3dfbcc
chore: Prepare release 2.4.0 (versionCode 13) (#568) 2024-03-28 11:46:06 +01:00
Nik Clayton 0bb269a37d
fix: Don't crash on invalid avatars (#566)
Workaround a Glide bug where the error() handler is not always called,
in this case when the URL does not resolve to an image; for example, a
misconfigured server that redirects requests for the image to an HTML
page.

Catch the exception and use the default avatar image in these cases.
2024-03-24 19:32:28 +01:00
Nik Clayton d3c7c7c89a
fix: Surface all exceptions to the user instead of crashing (#565)
Previous code would handle some expected exceptions (IO, HTTP) when
fetching a timeline, and show them to the user. Any other exception
would crash.

Now, surface all exceptions. Treat IO and HTTP exceptions as retryable
and show the "Retry" option, all others are considered non-retryable.

Provide a specific error string for exceptions caused by bad JSON.
2024-03-24 18:36:28 +01:00
Nik Clayton 2a4126a542
fix: Improve URL / tag / mention extraction when composing (#564)
Previous code used custom regular expressions to extract URLs, hashtags,
and mentions from text while the user was writing a post. These were
inconsistent with the ones that Mastodon uses so the derived character
count could be wrong.

As well as being visually incorrect this could prevent the user from
posting a status that was within the length limit, or allow them to
attempt to post a status that was over the length limit (which would
then fail).

Fix this by dropping the homegrown regular expressions and using the
same text parsing library that Mastodon users; twitter-text. This has
been converted to Kotlin and the functionality related to Twitter
specific features has been removed.

The hashtag handling has been adjusted, as Mastodon is more permissive
about the positions where hashtags can appear than Twitter is, in
particular, a hashtag does not need to be preceded with whitespace if
the tag appears after some scripts, such as Hirigana.
2024-03-23 14:14:07 +01:00
Kalle Kniivilä d75c4354bb fix(l10n): Update Finnish translations
Currently translated at 100.0% (594 of 594 strings)

Translation: Pachli/App : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/app-main/fi/
2024-03-21 17:43:55 +01:00