Commit Graph

4172 Commits

Author SHA1 Message Date
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