Commit Graph

3750 Commits

Author SHA1 Message Date
Nik Clayton 2bcb595777 fix: Label the image on the focus dialog 2023-09-20 19:05:35 +02:00
Nik Clayton 254edf5e6f refactor: Mark the image overlay is not important for accessibility 2023-09-20 19:05:35 +02:00
Nik Clayton 0fadb6f3fd fix: Set the contentDescription for avatars 2023-09-20 19:05:35 +02:00
Nik Clayton acaf2a7d89 refactor: Remove warnings about unclosed resources
In `MediaUploader` the lint warning can be ignored, as the stream is
closed elsewhere.

In the other files `.use` is used to simplify the code and remove
the need for Closeable.closeQuietly (as `.use` catches exceptions that
are thrown when closing).
2023-09-20 19:05:35 +02:00
Nik Clayton d00dc97a5f refactor: Suppress an unncessary CheckResult lint error
The result is used, lint isn't smart enough to figure that out.
2023-09-20 19:05:35 +02:00
Nik Clayton d555e2a69c refactor: Fix KDoc warnings 2023-09-20 19:05:35 +02:00
Nik Clayton 1aea1cde8b refactor: Resolve theoretical `BaseActivity` NPEs 2023-09-20 19:05:35 +02:00
Nik Clayton 4db1af5b50 refactor: Resolve theoretical `StatusBaseViewHolder` NPEs
Use `assert` to note when a nullable value is known to be non-null.

Extract a method call to a variable where necessary to do this.
2023-09-20 19:05:35 +02:00
Nik Clayton a6bad12271 refactor: Resolve theoretical Notification NPEs
Use `assert` to note when a nullable value is known to be non-null.

Extract a method call to a variable where necessary to do this.

Update `CharSequence.unicodeWrap()` to handle a null `CharSequence`.
2023-09-20 19:05:35 +02:00
Nik Clayton 7b7976c31b refactor: Rewrite `onRequestPermissionsResult` to remove a theoretical NPE 2023-09-20 19:05:35 +02:00
Nik Clayton e762008a2a refactor: Use Java enhanced switch 2023-09-20 19:05:35 +02:00
Nik Clayton 1a817d9b29 fix: Fix potential NPE in `ConversationViewHolder`
`ConversationViewHolder` calls `getDisplayName()`, which may return
null.

Replace with `getName()`, which is consistent with usage in other
classes. Mark `getDisplayName()` as deprecated to prevent future
usage.
2023-09-20 19:05:35 +02:00
Nik Clayton da808793f5 refactor: Remove unncessary `val` from constructor parameter 2023-09-20 19:05:35 +02:00
Nik Clayton 26ff8e5bad refactor: Remove unnecessary return type from `handleProfileClick` 2023-09-20 19:05:35 +02:00
Nik Clayton 8c95472d42 refactor: Remove unused `consumed` property 2023-09-20 19:05:35 +02:00
Nik Clayton 249718edf3 refactor: Remove unused `statusAsync` function 2023-09-20 19:05:35 +02:00
Nik Clayton 7b7c304f61 refactor: Remove unused `hasTab` function 2023-09-20 19:05:35 +02:00
Nik Clayton c335fa6217 refactor: Suppress lint errors for unused log TAG variables 2023-09-20 19:05:35 +02:00
Nik Clayton 986ccd0532 refactor: Remove unnecessary `?:` operator
Left hand side of the operation was always non-null.
2023-09-20 19:05:35 +02:00
Nik Clayton 20e5877a29 refactor: Convert sealed sub-objects to `data object` 2023-09-20 19:05:35 +02:00
Nik Clayton 9f81be7bb7 refactor: Replace `try/finally` with `use` 2023-09-20 19:05:35 +02:00
Nik Clayton b157791058
refactor: Convert ProgressRequestBody to Kotlin (#78) 2023-09-19 22:18:29 +02:00
Nik Clayton 9de829995b
fix: Check permissions before sending a failure notification (#77) 2023-09-19 22:18:17 +02:00
Nik Clayton 0f6975ffcc
fix: Check build version is >= T before POST_NOTIFICATIONS request (#76) 2023-09-19 22:04:42 +02:00
Nik Clayton ffa8ea615b
refactor: Convert AccountActionListener to Kotlin (#74) 2023-09-19 21:38:27 +02:00
Nik Clayton 5193f31ad8
refactor: Convert StatusActionListener to Kotlin (#73) 2023-09-19 17:57:35 +02:00
Nik Clayton 0bf459d385
refactor: Use "compat" drawables where appropriate (#72)
Use AppCompatResources.getDrawable() and app:drawableStartCompat.
Resolves existing lint issues.
2023-09-19 17:42:20 +02:00
Nik Clayton c97c3a4156
refactor: Add @NonNull and @Nullable annotations where appropriate (#71)
Adding the annotations cleans up an entire class of lint errors, and
it will be easire to convert from Java to Kotlin later.
2023-09-19 17:17:31 +02:00
Nik Clayton 4775ef85e9
chore: Prepare release 1.1 (versionCode 2) (#59) 2023-09-18 15:47:33 +02:00
Nik Clayton b739dc0a94
fix: Use correct colours for preference switches (#56)
The previous code used SwitchPreference to generate the switches, which
didn't apply the Material colours. This made it difficult to distinguish
between the on/off states, as the non-Material colours for those states
are very similar.

Fix by using SwitchPreferenceCompat which uses the correct Material
colours.
2023-09-18 12:21:49 +02:00
Nik Clayton b787f76cf6
fix: Use correct colour on "mute account" dialog (#55)
The previous code used "?attr/colorOnTertiary", which is the wrong
colour for the default background. Remove the override, so the correct
styled colour is used.
2023-09-18 12:12:35 +02:00
Nik Clayton 8ebc4e19ea
change: Fetch cached timeline when lifecycle is CREATED (#51)
Fetching data for a cached timeline can start on `onCreateView`, as soon
as the `viewLifecycle` state transitions to `CREATED`.
2023-09-16 15:32:43 +02:00
Nik Clayton f4e14dcf44
fix: Restore the user's reading position in more circumstances (#49)
The previous code only attempted to restore the user's reading position
once, after any initial refresh.

Adjust this so the position is restored after any refresh (which may
have been triggered from a menu instead of a swipe), and use
`scrollToPositionWithOffset` to ensure it's visible.
2023-09-15 16:09:18 +02:00
Nik Clayton ccb8ec06e7
fix: Fix toolbar flickering in additional activities (#48)
Testing showed additional activities with toolbar flicking issues. Fix
as before, using `setLiftOnScrollTargetView` to specify the scrolling
view the toolbar should lift above.
2023-09-14 22:19:26 +02:00
Nik Clayton 676c1eea2b
fix: Use the correct contrast colour on hashtag tab chips (#47)
The chips for adding a new hashtag to a tab specified the background
colour without setting the text colour, resulting in the colour being
too low-contrast against the background.

Use `?colorOnPrimary` to get the correct colour.
2023-09-14 22:19:10 +02:00
Nik Clayton 3577084b41
fix: Scale the monochrome icon to fit (#46)
The icon was appearing zoomed in when the user enabled theming in the
launcher.

Scale and translate the path to position it correctly.
2023-09-14 22:18:52 +02:00
Nik Clayton 7bb1e6fe17
change: Restore dividers between list items (#45)
Switching to the Material 3 themes caused the previous list dividers to
disappear.

Replace `DividerItemDecoration` with `MaterialDividerItemDecoration` to
restore them.
2023-09-14 19:10:59 +02:00
Nik Clayton fd7912e73c
fix: Restore the user's home timeline position (#44)
The previous code would always fetch the latest statuses when the app
restarts, jumping the user to the top of the home timeline. This is
because state.anchorPosition was null in this case.

Fix this by passing the saved initialKey to CachedTimelineRemoteMediator
and using it to construct a page of statuses around the requested
status.

This restores the user's reading position, and ensures that if the
user is at the top of the list their reading position is not reset
to the second item in the list.

Fixes #41, #42
2023-09-14 17:19:02 +02:00
Nik Clayton 402bcef588
fix: Ensure refreshing does not create a gap in the timeline (#43)
The previous code did not handle refreshing correctly; it retained some
of the cache, and tried merge new statuses in to the cache. This does
not work, and resulted in the app creating gaps in the timeline if more
than a page's worth of statuses had appeared since the user last
refreshed (e.g., overnight).

Fix this by treating the on-device cache as disposable, as the Paging3
library intends. On refresh the cached timeline is emptied and replaced
with a fresh page.

This causes a problem for state that is not stored on the server but is
part of a status' viewdata (has the user toggled viewing a piece of
media, expanded a CW, etc).

The previous code tried to work around that by pulling the state out of
the page cache and copying it in to the new statuses. That won't work
when the page cache is being destroyed.

So do it properly -- store the viewdata state in a separate (sparse)
table that contains only rows for statuses that have a non-default
state.

Save changes to the state when the user interacts with a status, and
use the state to ensure that the viewdata for a status in a thread
matches the viewdata for the same status if it is shown on the home
timeline (and vice-versa).

Fixes #16
2023-09-14 15:12:48 +02:00
Nik Clayton ec66942ae9
fix: Show the FAB according to the user's preferences (#29)
The previous code didn't collect the uiState, so it was fixed at the
default value, ignoring any changes that happened over the life of
the viewmodel.

Fix that, so that the FAB will hide/show on scroll according to the
user's preferences.

While I'm here simplify the show/hide logic. The previous code would
ignore the user's preference if scrolling up. There doesn't seem to
be a good reason for that, and spelunking 6+ years back through the
history didn't find a justification for that behaviour in the original
commit.

Fixes #15
2023-09-11 21:19:45 +02:00
Nik Clayton ecd81e80b0
fix: Fix toolbar flickering when scrolling lists (#26)
Scrolling a thread, set of search results, or viewing a thread would
cause the toolbar to flicker as items moved under it.

Fix this by configuring the toolbar to `liftOnScroll` in the relevant
layouts.

It needs to be configured with the view (or ID of the view) that it
will be scrolling. For views that are in the same layout this is done
with the `liftOnScrollTargetViewId` attribute.

For views that are in different layouts (e.g. the toolbar is in
the activity and the scrolling view is in a fragment) the app bar's
`setLiftOnScrollTargetView` method must be called.

Do this in `TimelineFragment` if the hosting activity is a new
interface `AppBarLayoutHost`. Implement this interface in
`StatusListActivity`.

Update the relevant layouts to use `MaterialToolbar`.

Fixes #21
2023-09-11 17:48:42 +02:00
Nik Clayton 811856a3b6
fix: Fix crash on entering MainActivity on Pixel C devices (#25)
First crash appeared to be caused by a failure to find the
`attr/colorBackgroundAccent` colour from the theme.

It wasn't clear why the attribute could not be found, so to fix it was
simpler to remove the color and attribute entirely, and replace it with
something more appropriate from the Material 3 tokens.

- Preview cards are stroked with `colorOutline`
- Poll options use `colorPrimary` (user's vote) or `colorSecondary`
  (other choices) with appropriate text colours.
- Links in link preview cards use `android:attr/textColorLink`
- The placeholder icon in preview cards uses `?android/textColorLink`
- Remove it from `help_message_background`, and stroke with
  `?colorOutline`

Doing this I discovered several places where a colour was being
specified unnecessarily, those have been removed.

To make it easier to understand the theme hierarchy that has been
collapsed and renamed to follow Android conventions.

- AppTheme -> Base.Theme.Pachli
- BaseTheme -> Theme.Pachli
- DefaultTheme has been removed as unnecessary

This unearthed a second crash, where `attr/actionBarSizeWithSubtitle`
was not found.

To fix that create an explicit style for toolbars that need it, and
apply the style (`Pachli.Widget.Toolbar`).

This also surfaced a third problem, where the `fragment_timeline*`
layouts had not been updated in `layout-sw640dp`, so those have been
updated to reflect the same views/IDs as the default `fragment_timeline`
layout.

These changes caused a small chain of "unused resource" lint errors,
which have been fixed by removing the unused colours.

The Android Material libraries were also being implicitly depended on
through other library imports instead of being explicit. So include
them as an explicit dependency.

Fixes #18
2023-09-11 13:54:29 +02:00
Nik Clayton ef007fcf23
fix: Correct apply setClickableText, prevent spurious underlines (#5)
The previous code was operating on the wrong text, resulting in normal
URL spans (which have an underline) being applied, instead of the
correct spans (which don't).

Fix this by using the correct length.
2023-09-05 22:20:28 +02:00
Nik Clayton 8a9dd7dc60
fix: Create hashtag filters with the `#` character (#3)
Previous code created hashtag filters without the `#`, so muting the
tag `#something` would filter all posts that contained `something`,
with or without the `#`.

Fix this when creating filters, and only remove filters (when unmuting)
if the title and contents match.

Show a snackbar when hashtags are successfully muted/unmuted, so the
user is aware something happened.
2023-09-05 21:54:18 +02:00
Nik Clayton 4879f0449f
docs: Add a privacy policy (#2)
While drafting the policy I noticed that the `READ_MEDIA_*` permissions
could be added (for newer devices), the `ACCESS_NETWORK_STATE`
permission was missing, and `VIBRATE` was unnecessary.
2023-09-05 15:35:06 +02:00
Nik Clayton 1bf13b10f8
refactor: Transition from Tusky to Pachli
- Rename packages to app.pachli.*
- Switch to Pachli icons (blue / orange)
- Reset database schema version to 1
- Reset versionCode to 1 and versionName to "1.0"
- Update colour scheme, use colorPrimary etc through the app
- Use Material UI components for toolbars
- Use "Pachli" in strings (UI, constants, etc)
- Update copyright on code I contributed
- Update README
- Update fastlane metadata
2023-09-05 13:33:37 +02:00
Nik Clayton a441576bf6
style: Require trailing comma, and break lines
Requiring trailing commas on multi-line lists of items (declarations
and call sites) reduces future repository churn when those lines are
changed, but introduces additional churn now.

Bite the bullet and make the change, as well as adjusting lines that
were too long / indented incorrectly.

The changes were performed automatically, using the `ktlintFormat` task.

Based on https://github.com/tuskyapp/Tusky/pull/3968 by
https://github.com/tinsukE
2023-09-04 20:22:10 +02:00
Nik Clayton cf26af25d8
docs: Update copyright statement on relevant files
Update the copyright statement on files I wrote or substantially
rewrote.
2023-09-04 20:22:09 +02:00
Nik Clayton 72ebeb3400
fix: Add support for filtering notifications
Filters that the user had set for the notifications timeline were not
being applied.

Fix this in NotificationsViewModel; fetch the user's filters and apply
them against the status in a notification. If the status should be
hidden it is removed, and if it should show a warning it does so.

The user can click through the warning to show the status.
2023-09-04 20:22:09 +02:00
Nik Clayton fc2a830ea1
feat: Remove explicit "Load more", load on demand
Prior to this change the user had to repeatedly tap "Load more" when
scrolling. This is tedious for the user.

In addition, the previous code had bugs that meant that not all statuses
were being loaded. Users could leave the app for a while (overnight,
say), and when returning would discover far fewer statuses than had
actually been posted.

Fix this, following the architecture first introduced for notifications
(Fragment -> ViewModel -> Repository -> Source/Mediator).

- Load statuses for cached and non-cached timelines using Paging3
- Show Failures during a load, and the user can retry
- Delete the "Reading order" preference, it is no longer necessary
2023-09-04 20:22:08 +02:00