Commit Graph

4128 Commits

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