Commit Graph

35 Commits

Author SHA1 Message Date
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 d8d15ab5b0
change: Simplify mapBoth operations to mapEither and map (#746) 2024-06-13 22:55:16 +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 7bf8c382e1
fix: Show/hide the list of lists appropriately when showing errors (#740)
Previous code didn't hide the list-of-lists if an error occurred after
the list was displayed (e.g., load the list, turn on airplane mode,
reload the list).

Hide the list when errors are shown, and show it when there is content.
2024-06-11 22:18:51 +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 b0fccb0aa7 change: Remove unnecessary null check 2024-04-30 16:23:34 +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 2a38f8e926 fix(l10n): Update Spanish translations
Currently translated at 100.0% (17 of 17 strings)

Translation: Pachli/Feature/Login
Translate-URL: https://hosted.weblate.org/projects/pachli/featurelogin/es/
2024-04-27 02:08:54 +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 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 f6bcded976 fix(l10n): Update Spanish translations
Currently translated at 100.0% (21 of 21 strings)

Translation: Pachli/Feature/Lists : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/featurelists-main/es/
2024-04-23 22:25:56 +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
Nik Clayton c89f91d058
feat: Show any errors when registering the app during login (#594)
Should make it easier for users to figure out what's gone wrong and
either fix it on their end, or provide more detailed bug reports.
2024-04-05 12:27:12 +02: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
ButterflyOfFire 76984763af fix(l10n): Update Kabyle translations
Currently translated at 9.8% (6 of 61 strings)

Translation: Pachli/Feature/About : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/featureabout-main/kab/
2024-03-18 19:31:42 +01:00
ButterflyOfFire fd6b6d0c07 fix(l10n): Update Kabyle translations
Currently translated at 41.1% (7 of 17 strings)

Translation: Pachli/Feature/Login
Translate-URL: https://hosted.weblate.org/projects/pachli/featurelogin/kab/
2024-03-18 19:31:42 +01:00
Weblate (bot) f64f9f03ae
fix(l10n): Translations update from Hosted Weblate (#541)
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/Core/Ui :
Main](https://hosted.weblate.org/projects/pachli/coreui-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/)



Current translation status:

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

---------

Co-authored-by: Languages add-on <noreply-addon-languages@weblate.org>
2024-03-17 00:24:12 +01:00
Nik Clayton 9e0a1f4015
refactor: Simplify use of BackgroundMessageView (#539)
Previous code expected callers to typically provide the drawable and the
error message string resource, resulting in duplicate code at many
callsites.

Replace with three canned messages for empty containers, generic errors,
and network errors respectively. The images for these are fixed, the
caller may choose a different string resource for the error if there is
a more specific option.

Update and simplify the call sites.
2024-03-16 22:12:54 +01:00
Nik Clayton e41722e16f
refactor: Extract user list functionality to `feature:lists` (#537)
Move `ListsActivity`, along with fragments and viewmodels, to a new
`feature:lists` module.

Previous code used the `item_follow_request` layout, which was not
ideal, so update it to use a dedicated layout, `item_account_in_list`.

The UI uses strings and views originally defined in the main app, so
move them elsewhere so they can be re-used.

- `BackgroundMessageView` moves to `core.ui`.

- `Lazy` moves to `core.common`.

- `ThrowableExtensions` split; the extensions specific to throwables
from network activity move to `core.network`, others move to `core.ui`.

- `BindingHolder` moves to `core.ui`

- Shared drawables and strings move to `core.ui`.
2024-03-16 18:42:11 +01:00
Juan M Sevilla a8dc83a63c fix(l10n): Update Spanish translations
Currently translated at 100.0% (61 of 61 strings)

Translation: Pachli/Feature/About : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/featureabout-main/es/
2024-03-04 20:33:08 +01:00
Nik Clayton af58de5a8f
refactor: Enable core library desugaring as build convention logic (#480)
Once desugaring is enabled it needs to be enabled for up/down the
dependency chain, so enable it in the shared configuration defined by
the build convention code.

Highlighted a failing test that wasn't being run, so fix that too.
2024-02-29 09:43:44 +01:00
Kalle Kniivilä db628f5dd6 fix(l10n): Update Finnish translations
Currently translated at 52.4% (32 of 61 strings)

Translation: Pachli/Feature/About : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/featureabout-main/fi/
2024-02-27 10:37:41 +01:00
Kalle Kniivilä bb8d6105d5 fix(l10n): Update Finnish translations
Currently translated at 100.0% (17 of 17 strings)

Translation: Pachli/Feature/Login
Translate-URL: https://hosted.weblate.org/projects/pachli/featurelogin/fi/
2024-02-27 10:37:41 +01:00
Martijn de Boer 486acecfe7 fix(l10n): Update Dutch translations
Currently translated at 100.0% (61 of 61 strings)

Translation: Pachli/Feature/About : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/featureabout-main/nl/
2024-02-25 15:53:32 +01:00
Nik Clayton 23e3cf1035
feat: Show information about notification fetches on "About" screen (#454)
Some users report that Pachli is not retrieving/displaying notifications
in a timely fashion.

To assist in diagnosing these errors, provide an additional set of tabs
on the "About" screen that contain information about how Pachli is
fetching notifications, and if not, why not.

Allow the user to save notification related logs and other details to a
file that can be attached to an e-mail or bug report.

Recording data:

- Provide a `NotificationConfig` singleton with properties to record
different aspects of the notification configuration. Update these
properties as different notification actions occur.

- Store logs in a `LogEntryEntity` table. Log events of interest with a
new `Timber` `LogEntryTree` that is planted in all cases.

- Add `PruneLogEntryEntityWorker` to trim saved logs to the last 48
hours.

Display:

- Add a `NotificationFragment` to `AboutActivity`. It hosts two other
fragments in tabs to show details from `NotificationConfig` and the
relevant logs, as well as controls for interacting with them.

Bug fixes:

- Filter out notifications with a null tag when processing active
notifications, prevents an NPE crash

Other changes:

- Log more details when errors occur so the bug reports are more helpful
2024-02-17 15:57:32 +01:00
Nik Clayton 96474a9ac3
change: Improve logging calls to Timber (#430)
- Use format strings so any overhead of building the string is only
incurred if the message is actually logged

- Pass throwables as the first parameter so they are logged with the
stacktrace
2024-02-09 17:33:01 +01:00
Nik Clayton d01c72b7d7
change: Disable SyntheticAccessor lint rule (#424)
Does not appear to be adding value, and R8 optimises the code to remove
the generated accessors.
2024-02-06 19:51:37 +01:00
Nik Clayton 75f75a7fc6
fix: Use string resource instead of hardcoded "About" (#421) 2024-02-06 12:57:50 +01:00
Nik Clayton 41c702fc1b
change: Display "About" information in tabs (#420)
Previously, `AboutActivity` had buttons and links to show the privacy
policy and licenses of dependencies.

Change this to a selection of fragments in tabs, one tab each for:

- General "About" information
- Licenses
- Privacy Policy

The information shown hasn't changed, but this lays the groundwork for
including additional tabs in the future for information like server
rules, detected capabilities, or troubleshooting information.
2024-02-06 00:43:26 +01:00
Languages add-on d7edeec3ee feat(l10n): Added Hebrew translation 2024-02-03 15:26:43 +01:00
Languages add-on 53d983743b feat(l10n): Added Odia translation 2024-02-03 15:26:43 +01:00
Nik Clayton 86d800b1c8
refactor: Modularise "about" activities (#405)
Continue modularisation by moving activities in the "About" feature to a
new `feature.about` module.

Implement `feature.about:
- Move `AboutActivity`, `LicenseActivity`, and `PrivacyPolicyActivity`
here.
- Update `markdown2resource` plugin to work with libraries

Implement `core.data`:
- Types and repositories used through the app
- Move `InstanceInfo` and `InstanceInfoRepository` here so they are
available to `feature.about`.

Implement `core.ui`:
- App-specific views, spans, and other UI content
- Move `ClickableSpanTextView` and `NoUnderlineURLSpan` here so they are
available to `feature.about`.
2024-02-02 15:14:31 +01:00
Weblate (bot) 1925860731
fix(l10n): Translations update from Hosted Weblate (#397)
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/App](https://hosted.weblate.org/projects/pachli/ui-strings/)

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

* [Pachli/F-Droid](https://hosted.weblate.org/projects/pachli/f-droid/)

* [Pachli/Core -
Network](https://hosted.weblate.org/projects/pachli/core-network/)

* [Pachli/Core - Design
System](https://hosted.weblate.org/projects/pachli/core-design-system/)

* [Pachli/Core -
Activity](https://hosted.weblate.org/projects/pachli/core-activity/)

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

* [Pachli/GitHub](https://hosted.weblate.org/projects/pachli/github/)



Current translation status:

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

---------

Co-authored-by: Languages add-on <noreply-addon-languages@weblate.org>
2024-01-30 16:39:45 +01:00
Nik Clayton f0fc0fd530
refactor: Modularise core activity classes, (#393)
Continue modularisation by moving core activity classes that almost all
activities depende on to a `core.activity` module. This includes
core "helper" classes as well.

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

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

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

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

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

Implement tools/mvstring
- Moves string resources (and all translations) from one module to
  another
2024-01-30 11:37:00 +01:00