Commit Graph

187 Commits

Author SHA1 Message Date
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 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
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 33e1b418cf
refactor: Improve blurhash decoding performance (#770)
By Christophe Beyls in https://github.com/tuskyapp/Tusky/pull/4515.
Their commit notes:

Improve the performance of `BlurHashDecoder` while also reducing memory
allocations.

- Precompute cosines tables before composing the image so each cosine
value is only computed once.
- Compute cosines tables once if both are identical (for square images
with the same number of colors in both dimensions).
- Store colors in a one-dimension array instead of a two-dimension array
to reduce memory allocations.
- Use a simple String.indexOf() to find the index of a Base83 char,
which is both faster and needs less memory than a HashMap thanks to
better locality and no boxing of chars.
- No cache is used, so computations may be performed in parallel on
background threads without the need for synchronization which limits
throughput.
2024-06-20 13:19:15 +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
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 da01241874
feat: Support server filters in GoToSocial 0.16.0 (#765) 2024-06-19 14:38:01 +02:00
renovate[bot] 0e150c7b45
fix(deps): update dependency com.google.android.material:material to v1.12.0 (#692)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[com.google.android.material:material](https://togithub.com/material-components/material-components-android)
| `1.11.0` -> `1.12.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.android.material:material/1.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.android.material:material/1.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.android.material:material/1.11.0/1.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.android.material:material/1.11.0/1.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>material-components/material-components-android
(com.google.android.material:material)</summary>

###
[`v1.12.0`](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0)

[Compare
Source](https://togithub.com/material-components/material-components-android/compare/1.11.0...1.12.0)

### What's new since 1.11.0

- `Slider` and `Progress Indicator` have been updated to better support
Non-Text Contrast Accessibility requirements.
- Predictive Back Fragment/View support added to Material motion
transitions (`MaterialSharedAxis`, `MaterialFadeThrough`,
`MaterialFade`, `MaterialElevationScale`).

#### Important

Required `minSdkVersion` is now 19 or higher, for Material and AndroidX
([blog
post](https://android-developers.googleblog.com/2023/10/androidx-minsdkversion-19.html)).

#### Dependency Updates

| Dependency | Previous version | New version |
| - | - | - |
| androidx.transition | 1.2.0 | 1.5.0 |

#### Library Updates

-   `Gradle`
- Update library minSdkVersion to 19.
([`1bbb43d`](1bbb43d155))
- Upgrade to //third_party/gradle to 8.4
([`1756f23`](1756f233ec))
-   `Carousel`
- Shifted keylines in contained strategies when there exists padding,
and clipToPadding=false
([`1ef42e2`](1ef42e2f23))
- Fixed Javadoc formatting error in `FullScreenCarouselStrategy` class
documentation.
([`a0a1c6e`](a0a1c6e044))
- Added support for cross axis wrap_content RecyclerViews
([`e88a1b9`](e88a1b98d2))
- Added documentation recommending snapping for multi-browse strategy
([`9e64a1f`](9e64a1f5f6))
- Add attributes to change small item size
([`92a5444`](92a5444de9))
-   `CollapsingToolbarLayout`
- Fix text shadow fading when transitioning between expanded and
collapsed states
([`7674e12`](7674e12ea8))
-   `Checkbox`
- Updated string translations
([`198e08c`](198e08cf5e))
-   `Dialog`
- Unified scrim opacity in Material themes/theme overlays.
([`f3e4439`](f3e4439ca6))
-   `Divider`
- Fixed divider instantly appearing or disappearing on insertion or
removal
([`ef4a0c5`](ef4a0c5e36))
-   `i18n`
- Update translated strings
([`a8307ef`](a8307ef792))
-   `MaterialDatePicker`
- Fix date validation on Samsung devices
([`5aa6edf`](5aa6edfaed))
-   `MaterialAutoCompleteTextView`
- Enabled switch access in MaterialAutoCompleteTextView.
([`14a7b40`](14a7b40363))
-   `NavigationDrawer`
- Fixed wrong item selected after click
([`a3af20a`](a3af20a869))
-   `NavigationRail`
- Added label padding for when the label is long enough to reach the
sides of the nav rail
([`2439dc0`](2439dc0e81))
- Increased padding in between items as per design specs
([`16eca7e`](16eca7eef3))
-   `Predictive Back`
- Animated corners during predictive back when no drawerLayoutCornerSize
is set
([`c8b9b1c`](c8b9b1c0bb))
-   `ProgressIndicator`
- Updated inactive track color from primary container to secondary
container.
([`c8cb0c6`](c8cb0c6037))
- Updated the setter of track thickness to not update track corner
radius.
([`540f5ee`](540f5ee983))
- Added the limit to not have stop indicator size bigger than track
thickness.
([`689e04f`](689e04f9ed))
- Fixed the rounded ends overlapping bug with semi-transparent
track/indicator color in Circular default style.
([`8167c11`](8167c115e3))
- Removed the call to draw a transparent full track.
([`3f80fdb`](3f80fdb9e1))
- Flipped the canvas for different circular directions.
([`bcc27a3`](bcc27a3638))
- Split stop indicator drawing from indicator drawing.
([`76207cb`](76207cb270))
- Added ActiveIndicator to improve readability.
([`6fd920a`](6fd920a2c1))
- Fixed ESCAPE animation in linear and added ESCAPE animation in
circular.
([`98284e7`](98284e74ad))
- Updated to use the same drawing delegate object between determinate
drawable and indeterminate drawable to prevent inconsistent drawings
when specs update.
([`52b4845`](52b48450fc))
- Added missing graphics updates when spec changes.
([`93b3010`](93b30109b0))
- Update styles for new Accessibility updates
([`15b533f`](15b533fffb))
- Added static drawable for Circular type when system animator is
disabled.
([`22e054b`](22e054ba68))
-   `Search`
- Excluded icons from search bar handwriting bounds
([`387f59b`](387f59b706))
- Made `searchbar_scrolling_view_behavior` string public
([`ce386e4`](ce386e4c20))
- Updated string translations
([`198e08c`](198e08cf5e))
-   `SideSheet`
- Moved the modal side sheet default width/height into style so they can
be customized
- Updated string translations
([`198e08c`](198e08cf5e))
-   `Slider`
- Made tick size defaults to the stop indicator size if set
([`92bc02c`](92bc02c37c))
- Fixed incorrect style of stop indicators near handles
([`d61cffd`](d61cffd7eb))
- Resolved issues that crash when assigning a large value to `valueTo`
([`4d1b9e5`](4d1b9e58a5))
- Updated the track drawing for some corner cases.
([`10484df`](10484df407))
- Fixed ripple not transparent on API 33
([`cd4f618`](cd4f618d38))
- Updated documentation
([`a641e18`](a641e18b6a))
- Updated styles
([`c218b3c`](3b278d7097))
- Fixed slider label not moving while scrolling
([`144b515`](144b5159ce))
-   `Tabs`
- Fixed title being announced twice when there's a badge in TalkBack
mode.
([`aaa7034`](aaa7034cbf))
-   `Theming`
- Add NoActionBar dynamic color themes
([`81d1b77`](81d1b772b9))
- Update Shape Theming bottom sheet text color
([`8ca016f`](8ca016fb01))
-   `Tokens`
- Update tokens to v4.0.0.
([`88acfcd`](88acfcdb63))
- Added formatting to break long lines and differentiate different
comments.
([`857d6a2`](857d6a2fd9))
-   `TopAppBar`
- Use an accessibility delegate to add and perform actions
([`929c80f`](929c80f753))
- Fixed compress effect clipping on API 21-24
([`2ac8c1c`](2ac8c1cbf6))
-   `TextInputLayout`
- Limited the min height reset in text change listener only when line
count changes.
([`9b9449c`](9b9449cde1))
- Fixed unnecessary min height when losing focus with multiple lines.
([`4a2654a`](4a2654a3f3))
-   `Transitions / Motion`
- Updated androidx transition dep to version 1.5.0-beta01
([`8c63848`](8c63848829))
- Added predictive fade through fragment transition demo to Catalog.
([`6092a7d`](6092a7dfe9))
- Added titles to fade through demo fragments in Catalog.
([`104043c`](104043caee))
- Added predictive transition support for fragments and views to the
Material motion library, and enabled it in shared axis fragment
transition demo.
([`8ccec33`](8ccec334bd))

#### Full list of release notes

-
[1.12.0-alpha01](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0-alpha01)
-
[1.12.0-alpha02](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0-alpha02)
-
[1.12.0-alpha03](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0-alpha03)
-
[1.12.0-beta01](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0-beta01)
-
[1.12.0-rc01](https://togithub.com/material-components/material-components-android/releases/tag/1.12.0-rc01)

#### Full list of changes

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/pachli/pachli-android).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQxMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nik Clayton <nik@ngo.org.uk>
2024-06-18 18:40:45 +02:00
renovate[bot] 882103893a
fix(deps): update dependency org.robolectric:robolectric to v4.12.2 (#707)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.robolectric:robolectric](http://robolectric.org)
([source](https://togithub.com/robolectric/robolectric)) | `4.12.1` ->
`4.12.2` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.robolectric:robolectric/4.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.robolectric:robolectric/4.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.robolectric:robolectric/4.12.1/4.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.robolectric:robolectric/4.12.1/4.12.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/pachli/pachli-android).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nik Clayton <nik@ngo.org.uk>
2024-06-18 14:30:17 +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 00a88c7874
refactor: Allow PachliError.formatArgs to be null (#755)
Simplifies the case where there are no format args.
2024-06-17 21:29:22 +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 d8d15ab5b0
change: Simplify mapBoth operations to mapEither and map (#746) 2024-06-13 22:55:16 +02:00
Weblate (bot) 6d266bce6d
fix(l10n): Translations update from Hosted Weblate (#737)
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/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/About :
Main](https://hosted.weblate.org/projects/pachli/featureabout-main/)

* [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)

---------

Co-authored-by: Languages add-on <noreply-addon-languages@weblate.org>
2024-06-13 22:54:02 +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 3b5d7d3f2d
fix: Disable BackgroundMessageView button when it's clicked (#742) 2024-06-13 21:12:11 +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 c5fe30088d
chore(deps): update kotlin to v2 (major) (#725) 2024-06-05 15:15:56 +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 51c4469e85
feat: Check Hometown/Glitch server instanceinfo for translation support (#718)
Previous code only looked for translation support on Mastodon servers.
It may be present on Hometown/Glitch servers too, so check.

Fixes #714
2024-05-30 19:14:27 +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
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 45b7e8777f change: Use SAM with `sortWith` comparator 2024-04-30 16:23:34 +02:00
Nik Clayton 3c9dd8655d change: `!x.isEmpty()` -> `x.isNotEmpty()` 2024-04-30 16:23:34 +02:00
Nik Clayton 56b0505955 change: Remove obsolete @Suppress annotations 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 01887d427b change: Remove unnecessary `constructor` keyword 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 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 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
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 d4105ecf2f fix(l10n): Update Spanish translations
Currently translated at 100.0% (12 of 12 strings)

Translation: Pachli/Core/Ui : Main
Translate-URL: https://hosted.weblate.org/projects/pachli/coreui-main/es/
2024-04-23 22:25:56 +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 cc9efbfa7a
ci: Simplify and improve CI speed (#615)
Abstract common CI setup tasks (setting up Java, Gradle, etc) in to a
single action that can be used by all CI workflows.

Run the lint, test, and assemble CI tasks in parallel for each variant
rather than in series, which cuts ~ 7 minutes (approx. 50%) off the CI
runtime.

Update code in checks and core/navigation to fix new tests.
2024-04-15 15:24:07 +02:00
Nik Clayton dd2efe9795
feat: Disable filters for accounts on servers running Sharkey (#610)
Fixes #600.
2024-04-09 16:23:04 +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 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