Commit Graph

56 Commits

Author SHA1 Message Date
Nik Clayton b9be125c95
Show the difference between edited statuses (#3314)
* Show the difference between edited statuses

Diff each status against the previous version, comparing the different
HTML as XML to produce a structured diff.

Mark new content with `<ins>`, deleted content with `<del>`.

Convert these to styled spans in `ViewEditsAdapter`.

* Update diffx to 1.1.1

Fixes issue with diffs splitting on accented characters

* Style edited strings with Android spans

Don't use HTML spans and try and format them, create real Android spans.

Do this with a custom tag handler that can add custom spans that set the
text paint appropriately.

* Lint

* Move colors in to theme_colors.xml

* Draw a roundrect for the backoround, add start/end padding

Make the background slightlysofter by drawing it as a roundrect.

Make the spans easier to understand by padding the start/end of each one with
the width of a " " character. This is visual only, the underlying text is not
changed.

* Catch exceptions when parsing XML

* Move sorting in to Dispatchers.Default coroutine

* Scope the loader type

* Remove alpha
2023-03-10 20:30:55 +01:00
Nik Clayton 4d401c7878
Convert NotificationsFragment and related code to Kotlin, use the Paging library (#3159)
* Unmodified output from "Convert Java to Kotlin" on NotificationsFragment.java

* Bare minimum changes to get this to compile and run

- Use `lateinit` for `eventhub`, `adapter`, `preferences`, and `scrolllistener`
- Removed override for accountManager, it can be used from the superclass
- Add `?.` where non-nullity could not (yet) be guaranteed
- Remove `?` from type lists where non-nullity is guaranteed
- Explicitly convert lists to mutable where necessary
- Delete unused function `findReplyPosition`

* Remove all unnecessary non-null (!!) assertions

The previous change meant some values are no longer nullable. Remove the
non-null assertions.

* Lint ListStatusAccessibilityDelegate call

- Remove redundant constructor
- Move block outside of `()`

* Use `let` when handling compose button visibility on scroll

* Replace a `requireNonNull` with `!!`

* Remove redundant return values

* Remove or rename unused lambda parameters

* Remove unnecessary type parameters

* Remove unnecessary null checks

* Replace cascading-if statement with `when`

* Simplify calculation of `topId`

* Use more appropriate list properties and methods

- Access the last value with `.last()`
- Access the last index with `.lastIndex`
- Replace logical-chain with `asRightOrNull` and `?.`
- `.isNotEmpty()`, not `!...isEmpty()`

* Inline unnecessary variable

* Use PrefKeys constants instead of bare strings

* Use `requireContext()` instead of `context!!`

* Replace deprecated `onActivityCreated()` with `onViewCreated()`

* Remove unnecessary variable setting

* Replace `size == 0` check with `isEmpty()`

* Format with ktlint, no functionality changes

* Convert NotifcationsAdapter to Kotlin

Does not compile, this is the unchanged output of the "Convert to Kotlin"
function

* Minimum changes to get NotificationsAdapter to compile

* Remove unnecessary visibility modifiers

* Use `isNotEmpty()`

* Remove unused lambda parameters

* Convert cascading-if to `when`

* Simplifiy assignment op

* Use explicit argument names with `copy()`

* Use `.firstOrNull()` instead of `if`

* Mark as lateinit to avoid unnecessary null checks

* Format with ktlint, whitespace changes only

* Bare minimum necessary to demonstrate paging in notifications

Create `NotificationsPagingSource`. This uses a new `notifications2()` API
call, which will exist until all the code has been adapted. Instead of
using placeholders,

Create `NotificationsPagingAdapter` (will replace `NotificationsAdapater`)
to consume this data.

Expose the paging source view a new `NotificationsViewModel` `flow`, and
submit new pages to the adapter as they are available in
`NotificationsFragment`.

Comment out any other code in `NotificationsFragment` that deals with
loading data from the network. This will be updated as necessary, either
here, or in the view model.

Lots of functionality is missing, including:

- Different views for different notification types
- Starting at the remembered notification position
- Interacting with notifications
- Adjusting the UI state to match the loading state

These will be added incrementally.

* Migrate StatusNotificationViewHolder impl. to NotificationsPagingAdapter

With this change `NotificationsPagingAdapter` shows notifications about a
status correctly.

- Introduce a `ViewHolder` abstract class that all Notification view holders
  derive from. Modify the fallback view holder to use this.

- Implement `StatusNotificationViewHolder`. Much of the code is from the
  existing implementation in the `NotificationAdapater`.

- The original code split the code that binds values to views between the
  adapter's `bindViewHolder` method and the view holder's methods.

  In this code, all of the binding code is in the view holder, in a `bind`
  method. This is called by the adapter's `bindViewHolder` method. This keeps
  all the binding logic in the view holder, where it belongs.

- The new `StatusNotificationViewHolder` uses view binding to access its views
  instead of `findViewById`.

- Logically, information about whether to show sensitive media, or open
  content warnings should be part of the `StatusDisplayOptions`. So add those
  as fields, and populate them appropriately.

  This affects code outside notification handling, which will be adjusted
  later.

* Note some TODOs to complete before the PR is finished

* Extract StatusNotificationViewHolder to a new file

* Add TODO for NotificationViewData.Concrete

* Convert the adapter to take NotificationViewData.Concrete

* Add a view holder for regular status notifications

* Migrate Follow and FollowRequest notifications

* Migrate report notifications

* Convert onViewThread to use the adapter data

* Convert onViewMedia to use the adapter data

* Convert onMore to use the adapter data

* Convert onReply to use the adapter data

* Convert NotificationViewData to Kotlin

* Re-implement the reblog functionality

- Move reblogging in to the view model
- Update the UI via the adapter's `snapshot()` and `notifyItemChanged()`
  methods

* Re-implement the favourite functionality

Same approach as reblog

* Re-implement the bookmark functionality

Same approach as reblog

* Add TODO re StatusActionListener interface

* Add TODO re event handling

* Re-implementing the voting functionality

* Re-implement viewing hidden content

- Hidden media
- Content behind a content warning

* Add a TODO re pinning

* Re-implement "Show more" / "Show less"

* Delete unused updateStatus() function

* Comment out the scroll listener for the moment

* Re-implement applying filters to notifications

Introduce `NotificationsRepository`, to provide access to the notifications
stream.

When changing the filters the flow is as follows:

- User clicks "Apply" in the fragment.

- Fragment calls `viewModel.accept()` with a `UiAction.ApplyFilter` (new
  class).

- View model maintains a private flow of incoming UI actions. The new action
  is emitted to that flow.

- In view model, `notificationFilter` waits for `.ApplyFilter` actions, and
  ensures the filter is saved, then emits it.

- In view model, `pagingDataFlow` waits for new items from
  `notificationsFilter` and fetches the notifications from the repository in
  response. The repository provides `Notification`, so the model maps them to
  `NotificationViewData.Concrete` for display by the adapter.

- In view model the UI state also waits for new items from
  `notificationsFilter` and emits a new `UiState` every time the filter is
  changed.

When opening the fragment for the first time:

- All of the above machinery, but `notificationFilter` also fetches the filter
  from the active account and emits that first. This triggers the first fetch
  and the first update of `uiState`.

Also:

- Add TODOs for functionality that is not implemented yet

- Delete a lot of dead code from NotificationsFragment

* Include important preference values in `uiState`

Listen to the flow of eventHub events, filtered to preference changes that
are relevant to the notification view.

When preferences change (or when the view model starts), fetch the current
values, and include them in `uiState`.

Remove preference handling from `NotificationsFragment`, and just use
the values from `uiState`.

Adjust how the `useAbsoluteTime` preference is handled. The previous code
loaded new content (via a diffutil) in to the adapter, which would trigger
a re-binding of the timestamp.

As the adapter content is immutable, the new code simply triggers a
re-binding of the views that are currently visible on screen.

* Update UI in response to different load states

Notifications can be loaded at the top and bottom of the timeline. Add a
new layout to show the progress of these loads, and any errors that can
occur.

Catch network errors in `NotificationsPagingSource` and convert to
`LoadState.Error`.

Add a header/footer to the notifications list to show the load state.

Collect the load state from the adapter, use this to drive the visibility
of different views.

* Save and restore the last read notification ID

Use this when fetching notifications, to centre the list around the
notification that was last read.

* Call notifyItemRangeChanged with the correct parameters

* Don't try and save list position if there are no items in the list

* Show/hide the "Nothing to see" view appropriately

* Update comments

* Handle the case where the notification key no longer exists

* Re-implement support for showMediaPreview and other settings

* Re-implement "hide FAB when scrolling" preference

* Delete dead code

* Delete Notifications Adapater and Placeholder types

* Remove NotificationViewData.Concrete subclass

Now there's no Placeholder, everything is a NotificationViewData.

* Improve how notification pages are loaded if the first notification is missing or filtered

* Re-implement clear notifications, show errors

* s/default/from/

* Add missing headers

* Don't process bookmarking via EventHub

- Initiating a bookmark is triggered by the fragment sending a
  StatusUiAction.Bookmark
- View model receives this, makes API call, waits for response, emits either
  a success or failure state
- Fragment collects success/failure states, updates the UI accordingly

* Don't process favourites via EventHub

* Don't process reblog via EventHub

* Don't process poll votes with EventHub

This removes EventHub from the fragment

* Respond to follow requests via the view model

* Docs and cleanup

* Typo and editing pass

* Minor edits for clarity

* Remove newline in diagram

* Reorder sequence diagram

* s/authorize/accept/

* s/pagingDataFlow/pagingData/

* Add brief KDoc

* Try and fetch a full first page of notifications

* Call the API method `notifications` again

* Log UI errors at the point of handling

* Remove unused variable

* Replace String.format() with interpolation

* Convert NotificationViewData to data class

* Rename copy() to make(), to avoid confusion with default copy() method

* Lint

* Update app/src/main/res/layout/simple_list_item_1.xml

* Update app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsPagingAdapter.kt

* Update app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsViewModel.kt

* Update app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.kt

* Update app/src/main/java/com/keylesspalace/tusky/viewdata/NotificationViewData.kt

* Initial NotificationsViewModel tests

* Add missing import

* More tests, some cleanup

* Comments, re-order some code

* Set StateRestorationPolicy.PREVENT_WHEN_EMPTY

* Mark clearNotifications() as "suspend"

* Catch exceptions from clearNotifications and emit

* Update TODOs with explanations

* Ensure initial fetch uses a null ID

* Stop/start collecting pagingData based on the lifecycle

* Don't hide the list while refreshing

* Refresh notifications on mutes and blocks

* Update tests now clearNotifications is a suspend fun

* Add "Refresh" menu to NotificationsFragment

* Use account.name over account.displayName

* Update app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.kt

Co-authored-by: Konrad Pozniak <connyduck@users.noreply.github.com>

* Mark layoutmanager as lateinit

* Mark layoutmanager as lateinit

* Refactor generating UI text

* Add Copyright header

* Correctly apply notification filters

* Show follow request header in notifications

* Wait for follow request actions to complete, so the reqeuest is sent

* Remove duplicate copyright header

* Revert copyright change in unmodified file

* Null check response body

* Move NotificationsFragment to component.notifications

* Use viewlifecycleowner.lifecyclescope

* Show notification filter as a dialog rather than a popup window

The popup window:

- Is inconsistent UI
- Requires a custom layout
- Didn't play nicely with viewbinding

* Refresh adapter on block/mute

* Scroll up slightly when new content is loaded

* Restore progressbar

* Lint

* Update app/src/main/res/layout/simple_list_item_1.xml

---------

Co-authored-by: Konrad Pozniak <connyduck@users.noreply.github.com>
2023-03-10 20:12:33 +01:00
renovate[bot] ce6a350267
chore(deps): update dependency gradle to v8.0.2 (#3372)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-05 16:56:19 +01:00
renovate[bot] e98925b426
chore(deps): update dependency com.android.application to v7.4.2 (#3395)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-28 22:05:32 +01:00
renovate[bot] e46e2720a4
Update dependency androidx.arch.core:core-testing to v2.2.0 (#3378)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-28 21:35:31 +01:00
Konrad Pozniak 9340e7a6f4
update Glide to 4.15.0 (#3384) 2023-02-27 08:54:26 +01:00
renovate[bot] b3f173b2b0
fix(deps): update dependency org.mockito:mockito-inline to v5 (#3373)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 08:54:07 +01:00
renovate[bot] 92bd2153e9
Update dependency org.mockito:mockito-inline to v4.11.0 (#3365)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-25 21:28:09 +01:00
Goooler c6f7ecdb5b
Gradle 8.0.1 (#3338)
https://docs.gradle.org/8.0/release-notes.html
2023-02-25 20:59:39 +01:00
renovate[bot] 9eec1ab5c0
Update emoji2 to v1.2.0 (#3368)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-25 20:38:14 +01:00
renovate[bot] a0ee3072f0
Update dependency org.mockito.kotlin:mockito-kotlin to v4.1.0 (#3364)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-25 20:37:40 +01:00
renovate[bot] 77dbf3c1a9
Update dependency com.google.android.material:material to v1.8.0 (#3361)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-25 20:36:18 +01:00
renovate[bot] 60fd9cf0e7
Update dependency com.google.code.gson:gson to v2.10.1 (#3362)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-23 17:34:04 +01:00
renovate[bot] 142fe4b743
Update dependency io.reactivex.rxjava3:rxandroid to v3.0.2 (#3348)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 20:17:45 +01:00
renovate[bot] 62c7d63131
Update dependency com.github.CanHub:Android-Image-Cropper to v4.3.2 (#3347)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:43:51 +01:00
renovate[bot] b35cc1fd6b
Update dependency com.github.penfeizhou.android.animation:glide-plugin to v2.24.0 (#3358)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:41:53 +01:00
renovate[bot] fc71e398d5
Update dependency com.github.UnifiedPush:android-connector to v2.1.1 (#3357)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:39:49 +01:00
renovate[bot] 01eefd94a0
Update dependency androidx.browser:browser to v1.5.0 (#3356)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:39:39 +01:00
renovate[bot] b62fc9bf07
Update dagger to v2.45 (#3355)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:37:44 +01:00
renovate[bot] 53f7afd9ee
Update androidx-work to v2.8.0 (#3354)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:37:33 +01:00
renovate[bot] aa14013adc
Update dependency io.reactivex.rxjava3:rxjava to v3.1.6 (#3353)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-21 19:37:07 +01:00
renovate[bot] 8f3869d42e
Update dependency androidx.exifinterface:exifinterface to v1.3.6 (#3344)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-20 20:36:22 +01:00
renovate[bot] ac87482e7a
Update dependency androidx.appcompat:appcompat to v1.6.1 (#3343)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-20 20:36:11 +01:00
Goooler cfea5700b0
Code cleanups (#3264)
* Kotlin 1.8.10

https://github.com/JetBrains/kotlin/releases/tag/v1.8.10

* Migrate onActivityCreated to onViewCreated

* More final modifiers

* Java Cleanups

* Kotlin cleanups

* More final modifiers

* Const value TOOLBAR_HIDE_DELAY_MS

* Revert
2023-02-20 19:58:37 +01:00
Konrad Pozniak 006f0de05c
Upgrade AndroidX dependencies (#3169)
* upgrade AndroidX dependencies

* use new @Upsert in InstanceDao

* fix crash because of new Room nullchecks

* make TimelineStatusEntity.reblogAccount a val as well
2023-02-04 20:22:29 +01:00
Goooler 3592318dc1
Modernize a bit (#3171)
* Remove redundant ignore file

* Add .gitattributes

* Generate new wrapper

* Apply plugins in `plugins`

* Adopt new dsl

* Enable stable config cache

* Ignore all build folders

* Enable build scan

* Disable buildFeatures flags by default

* Migrate to nonTransitive R class

* Tweak flags

* Bump AGP to 7.4.0

* Bump deps

* Run `ktlintFormat`

* Add an icon for IDEA to display

* Revert "Bump deps"

This reverts commit bc0d5b69d59f70289d5d5c4887a85e6af23cc662.

* Revert "Enable build scan"

This reverts commit 1568e5e84f1ee51064b3f426b1da0cf35fb67856.

* Remove com.android.library

* Enable Gradle cache

* Enable room incremental build

* Cleanups

* Cleanups

* Add .editorconfig

* Defer clean task

* Migrate `flavorDimensions`

* Merge instance-build.gradle into app's build.gradle

* Declare compileOptions & kotlinOptions

* Bump jvmTarget to 17

* Fix conflicts

* Xmx4g

* Rename output apks

* Revert "Bump jvmTarget to 17"

This reverts commit e4d1543bda65b6d2979ae0712bceee33fa8298a6.
2023-02-04 19:58:53 +01:00
Constantin A ca01776847
Update FilemojiCompat to version 3.2.7 (#3151) 2023-01-09 21:06:47 +01:00
Konrad Pozniak 157f4adfa1
Upgrade gradle to 7.6 and AGP to 7.3.1 (#2977) 2022-12-05 19:10:55 +01:00
Konrad Pozniak c96a81571c
support Android 13 per-app languages (#2829)
* support Android 13 per-app languages

* fix tests

* fix language ids in locales_config.xml

* fix language setting default in ComposeActivity
2022-11-16 19:45:18 +01:00
Eva Tatarka b39cb06748
Navigate to the Follow Requests page from notification (#2757)
* Navigate to the Follow Requests page from notification

Fixes #2655

* Fix lock status
2022-11-07 20:04:07 +01:00
Constantin A b17823137b
Update FilemojiCompat to version 3.2.6 (#2733) 2022-11-07 19:56:13 +01:00
Colin Lee 3fb1173d3f
Introduce Gradle version catalogs for versioning (#2745)
* Introduce Gradle version catalogs for versioning

* Correct some versions for version catalogs
2022-11-04 20:10:26 +01:00
Konrad Pozniak 8ae3e4e173
update Gradle to 7.5.1 (#2640)
* update Gradle to 7.5

* update gradle to 7.5.1
2022-08-07 19:13:44 +02:00
Konrad Pozniak 90ceb9514e
update Gradle and Android Gradle Plugin (#2380) 2022-03-13 16:08:15 +01:00
Konrad Pozniak 1586817c3d
Update gradle, kotlin and other dependencies (#2291)
* update gradle, kotlin and other dependencies

* fix new warnings

* remove unused import

* update Proguard rules

* add explicit dependency on Gson to get the newest version

* remove debug flag from proguard rules again

* fix typo
2022-01-20 21:10:32 +01:00
Konrad Pozniak 9c9f8ebf2c
upgrade gradle to 7.0.2 (#2161) 2021-05-19 07:40:56 +02:00
Konrad Pozniak 3e135b0480
upgrade gradle to 6.8.1 (#2057) 2021-01-31 19:35:53 +01:00
Konrad Pozniak e572e653ee
upgrade gradle and android gradle plugin (#1957) 2020-10-19 14:47:40 +02:00
Konrad Pozniak b5bf78a19e
upgrade gradle wrapper, materialdrawer and AndroidX fragment (#1837) 2020-06-21 18:27:07 +02:00
Konrad Pozniak df5490b5b9
upgrade gradle, AGP and dependencies (#1818)
* upgrade gradle, AGP and dependencies

* fix new layout related warnings
2020-06-04 20:16:48 +02:00
Konrad Pozniak c80fa68dbe
upgrade dependencies, fix some warnings (#1747)
* upgrade dependencies, fix some warnings

* fix tests
2020-04-06 11:46:38 +02:00
Konrad Pozniak 0c159e587d
upgrade Gradle and Android plugin (#1709)
* upgrade Gradle and Android plugin

* upgrade Android Gradle plugin to 3.6.1
2020-03-02 19:58:15 +01:00
Frieder Bluemle ef470bcdb6
Update Gradle Wrapper to 6.1.1 2020-02-01 11:14:31 -08:00
Konrad Pozniak e67d608bb8
upgrade dependencies (#1596) 2019-12-20 21:31:41 +01:00
Frieder Bluemle bd7f0dfe62 Update Gradle wrapper to 5.4.1 (#1233) 2019-05-09 19:21:06 +02:00
Bernd d0ca965cc8 Update Deps (#1176)
* Update Deps

* Update Deps

* Update Deps

* Update build.gradle

* Update build.gradle
2019-04-07 19:37:04 +02:00
Bernd 0db1a23c4f Update Deps + Cleanup (#1158)
* Fix Typo

* Update build.gradle

* Update Deps

* Update Tests

* Fixes Tests

Without this some tests fail on my PC...

+ also:
"Put this in your gradle.properties:

android.enableUnitTestBinaryResources=true"
from http://robolectric.org/migrating/#project-configuration

* Make everything private

* Fix Warning

* Update TimelineFragment.java

* Update build.gradle

* Update gradle-wrapper.properties

* Update gradle-wrapper.properties

* Update gradle-wrapper.properties

* Fix Compile Errors

e.g.

Type inference failed. Expected type mismatch: inferred type is Preference? but Preference was expected

Type inference failed. Please try to specify type arguments explicitly.

* fix crash

* Grandle Wrapper 5.3

* Revert "Fix Compile Errors"

This reverts commit 4a774a4fe3ce82c84bd7b4d78e1a1c64af97cd0d.

* requirePreference

* oops

* Cleanup

* Update gradle-wrapper.properties
2019-03-30 15:18:16 +01:00
Frieder Bluemle 53aae1b3da Update Gradle wrapper to 4.10.3 2019-02-26 18:34:29 +01:00
Conny Duck cdfc8a713d update gradle and build tools 2019-01-15 20:50:50 +01:00
Conny Duck 26b0ad521e upgrade gradle and build tools 2018-09-25 19:05:37 +02:00