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.
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.
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.
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.
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.
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
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`.
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.
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.
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.
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.
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.
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.
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.
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
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.
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
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
`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
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.
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.
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.
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 "".
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.