Commit Graph

53 Commits

Author SHA1 Message Date
Konrad Pozniak 5192fb08a5
upgrade ktlint plugin to 12.0.3 (#4169)
There are some new rules, I think they mostly make sense, except for the
max line length which I had to disable because we are over it in a lot
of places.

---------

Co-authored-by: Goooler <wangzongler@gmail.com>
2024-01-04 17:00:55 +01:00
Levi Bard f99cb6d1d5
Fix lint warnings (#4019)
Clears the baseline of issues in our code, and resolves most of the
straightforward warnings from the report
2023-09-13 09:20:53 +02:00
Goooler 40bd95d752
Kotlin 1.9.0 (#3835)
Update to Kotlin 1.9.0 and migrate to newer language idioms.

- Remove unnecessary @OptIn for features migrated to mainstream
- Use `data object` where appropriate
- Use new enum `entries` property
2023-08-02 09:04:24 +02:00
Prat 485a4c364e
Improve prompts when draft is empty (#3699)
When the user is closing the compose view,

    if it's new and empty, don't show a prompt.
    if it's an existing draft and now empty, ask if the user wants to delete it or continue editing. I don't think there is much value in saving an empty draft.
---------
2023-06-13 15:45:17 +02:00
Nik Clayton 34de33220c
Don't overwrite the active account when composing from a notification (#3688)
Fix a bug where the active account can be overwritten.

1. Have two accounts logged in to Tusky, A and B
2. Open Tusky as account A
3. Send a DM to account B (doesn't have to be a DM, just anything that creates a notification for account B)
4. Restart Tusky so the Android notification for the DM is displayed immediately. You are still acting as account A.
5. Drag down the Android notification, you should see two options, "Quick reply" and "Compose"
6. Tap "Compose"
7. ComposeActivity will start. You are now acting as account B. Compose and send a reply
8. You'll be returned to the "Home" tab.

The UI will show you are still account A (i.e., it's account A's avatar at the top of the screen, if you have the "Show username in toolbars" option turned on it will be account A's username in the toolbar).

But you are now seeing the home timeline for account B.

Fix this.

ComposeViewModel
- Do not rely on the active account in sendStatus(), receive the account ID as a parameter

ComposeActivity
- Use either the account ID from the intent, or the current active account. **Do not** change the active account
- Pass the account ID to use in the sendStatus() call
2023-05-29 13:32:56 +02:00
UlrichKu 24d7ef7ccb
Always publish image alt text
Previous code would discard the image alt-text if the user finished writing the text before the image had finished uploading.

This code ensures the text is set after the image has completed uploading.
2023-04-24 11:48:40 +02:00
Konrad Pozniak d839f18267
update ktlint plugin to 11.3.1, format code (#3442) 2023-03-13 13:16:39 +01:00
Levi Bard 395e21c956
Add support for updating media description and focus point when editing statuses (#3215)
* Add support for updating media description and focus point when editing statuses

* Don't publish description/focus point updates via the standard api when editing a published post
2023-02-14 21:13:38 +01:00
Konrad Pozniak 8cd4521e2f
don't show sending failed dialog when sending was cancelled (#3226)
* don't show sending failed dialog when sending was cancelled

* still mark cancelled statuses as failed but don't show alert
2023-01-28 12:40:36 +01:00
Nik Clayton a5f479d79c
Fix saving changes to statuses when editing (#3103)
* Fix saving changes to statuses when editing

With the previous code backing out of a status editing operation where changes
had been made  (whether it was editing an existing status, a scheduled status,
or a draft) would prompt the user to save the changes as a new draft.

See https://github.com/tuskyapp/Tusky/issues/2704 and
https://github.com/tuskyapp/Tusky/issues/2705 for more detail.

The fix:

- Create an enum to represent the four different kinds of edits that can
  happen
  - Editing a new status (i.e., composing it for the first time)
  - Editing a posted status
  - Editing a draft
  - Editing a scheduled status

- Store this in ComposeOptions, and set it appropriately everywhere
  ComposeOptions is created.

- Check the edit kind when backing out of ComposeActivity, and use this to
  show one of three different dialogs as appropriate so the user can:
  - Save as new draft or discard changes
  - Continue editing or discard changes
  - Update existing draft or discard changes

Also fix ComposeViewModel.didChange(), which erroneously reported false if the
old text started with the new text (e.g., if the old text was "hello, world"
and it was edited to "hello", didChange() would not consider that to be a
change).

Fixes https://github.com/tuskyapp/Tusky/issues/2704,
https://github.com/tuskyapp/Tusky/issues/2705

* Use orEmpty extension function
2022-12-31 13:04:49 +01:00
Konrad Pozniak abca91a420
Handoff media upload (#2947)
* handoff media upload to SendStatusService

* fix bugd

* improve code

* don't check processing state when upload returned 200
2022-12-29 19:58:23 +01:00
Levi Bard a6b6a40ba6
Add post editing capability (#2828)
* Add post editing capability

* Don't try to reprocess already uploaded attachments.
Fixes editing posts with existing media

* Don't mark post edits as modified until editing occurs

* Disable UI for things that can't be edited when editing a post

* Finally convert SFragment to kotlin

* Use api endpoint for fetching status source for editing

* Apply review feedback
2022-12-08 10:18:12 +01:00
mcclure 7684f06938
Add UI for image-attachment "focus" (#2620)
* Attempt-zero implementation of a "focus" feature for image attachments. Choose "Set focus" in the attachment menu, tap once to select focus point (no visual feedback currently), tap "OK". Works in tests.

* Remove code duplication between 'update description' and 'update focus'

* Fix ktlint/bitrise failures

* Make updateMediaItem private

* When focus is set on a post attachment the preview focuses correctly. ProgressImageView now inherits from MediaPreviewImageView.

* Replace use of PointF for Focus where focus is represented, fix ktlint

* Substitute 'focus' for 'focus point' in strings

* First attempt draw focus point. Only updates on initial load. Modeled on code from RoundedCorners builtin from Glide

* Redraw focus after each tap

* Dark curtain where focus isn't (now looks like mastosoc)

* Correct ktlint for FocusDialog

* draft: switch to overlay for focus indicator

* Draw focus circle, but ImageView and FocusIndicatorView seem to share a single canvas

* Switch focus circle to path approach

* Correctly scale, save and load focuses. Clamp to visible area. Focus editor looks and feels right

* ktlint fixes and comments

* Focus indicator drawing should use device-independent pixels

* Shrink focus window when it gets unattractively tall (no linting, misbehaves on wide aspect ratio screens)

* Correct max-height behavior for screens in landscape mode

* Focus attachment result is are flipped on x axis; fix this

* Correctly thread focus through on scheduled posts, redrafted posts, and drafts (but draft focus is lost on post)

* More focus ktlint fixes

* Fix specific case where a draft is given a focus, then deleted, then posted in that order

* Fix accidental file change in focus PR

* ktLint fix

* Fix property style warnings in focus

* Fix remaining style warnings from focus PR

Co-authored-by: Conny Duck <k.pozniak@gmx.at>
2022-09-21 20:28:06 +02:00
Levi Bard 0041acf2d4
Add language dropdown to compose view (#2651)
* Add UI for selecting post language

* Apply selected language when sending status

* Save/restore post language with drafts

* Fall back to english if the configured language isn't found in the locale list (no-NB)

* Remove comment about no_NB

* Move language dropdown to top of compose view

* Preserve language when redrafting

* Set default language to target post's language when replying

* Add Tusky license header to new source file

* Tweak language dropdown button width
2022-08-31 18:53:57 +02:00
Konrad Pozniak 2d2d7569e3
fix compose field focus when replying to post with cw (#2634) 2022-08-03 17:23:54 +02:00
Martin Marconcini 8b026991e0
2616: Save Scheduled Time for Drafts. (#2624)
* 2616: Save Scheduled Time for Drafts.

Signed-off-by: Martin Marconcini <martin.marconcini.rodriguez@nl.abnamro.com>

* Revert 39.json schema to the original state before my changes.
2022-07-27 21:06:51 +02:00
Konrad Pozniak 1b6a0908f6
Handle even more instance defaults (#2612)
* handle media size instance limits

* remove unused attributes from Instance entity

* support max_media_attachments

* support pleroma field limits, remove max_bio_chars support

* improve field input margin

* fix tests

* MAX_ACCOUNT_FIELDS -> DEFAULT_MAX_ACCOUNT_FIELDS

* improve "add field" button behavior

* fix copy paste mistake in AccountFieldEditAdapter

* refactor sendStatus to be a suspending function
2022-07-26 20:24:50 +02:00
Konrad Pozniak 62c4cfde89
improve media upload error messages (#2602) 2022-06-30 20:51:05 +02:00
Konrad Pozniak e1c8461423
replace kotlin-result-calladapter with networkresult-calladapter (#2569)
* replace kotlin-result-calladapter with networkresult-calladapter

* fix tests
2022-05-30 20:03:40 +02:00
mcclure 00c139190e
Ability to crop images attached to posts (#2531)
* First attachment crop attempt: Can crop in place, but does not delete/replace on server so has no effect

* Attachment crop feature works

* ktlint fixes on attachment crop patch

* Upgrade Android-Image-Cropper to 4.2.1

* An error message should be displayed if attachment cropping fails and it is not because the user intentionally cancelled.

* Remove 2 of the 3 "state passing" variables by using MediaUtils

* Cropper should use content uri (MIME type bearing) and setOutputCompressFormat so that PNGs reach the server safely.

* Change to crop requested by Conny: Store inflight cropImageItemOld in view model

* Change to crop requested by Conny: Sort cropImage with the other contracts

* ktlint fixes on attachment crop patch (again)
2022-05-22 21:01:14 +02:00
Konrad Pozniak cec8f6dd65
modernize autocomplete (#2510)
* modernize autocomplete

* use @WorkerThread annotation
2022-05-17 19:55:37 +02:00
Konrad Pozniak d9c6269d44
fix deleting media attachments removing the wrong ones (#2517) 2022-05-12 18:21:43 +02:00
Konrad Pozniak beaed6b875
Fix crash when saving redrafted media to drafts (#2502)
* fix crash when saving draft from redraft

* fix crash when saving draft from redraft

* replace ... with …
2022-05-09 19:39:43 +02:00
Konrad Pozniak 444e7365c9
fix race condition where multiple uploaded media can get same internal id (#2479)
* fix race condition where multiple uploaded media can get same internal id

* atomically update media stateflow

* atomically update media stateflow
2022-05-03 19:12:35 +02:00
Konrad Pozniak 671d2c6a45
Check if media processing finished before sending status (#2458)
* make MastodonApi.createStatus suspending

* check if media processing has finished before sending status

* add backoff for retrying processed media check
2022-04-28 20:37:31 +02:00
Konrad Pozniak d2bfceae7b
refactor compose & announcements to coroutines (#2446)
* refactor compose & announcements to coroutines

* fix code formatting

* add javadoc to InstanceInfoRepository

* fix comments in ImageDownsizer

* remove unused Either extensions

* add explicit return type for InstanceInfoRepository.getEmojis

* make ComposeViewModel.pickMedia return Result

* cleanup code in ImageDownsizer
2022-04-21 18:46:21 +02:00
Konrad Pozniak 3e8c6a318a
introduce KotlinResultCallAdapter for nice suspending network calls (#2415)
* introduce KotlinResultCallAdapter for nice suspending network calls

* fix tests
2022-04-14 19:49:49 +02:00
Konrad Pozniak d9931e3d2c
Rename Toots to Posts (#2396)
* rename toots -> posts in strings

* extract tusky_compose_post_quicksetting_label string

* rename toot -> status in code
2022-03-20 20:21:42 +01:00
Levi Bard 7114575497
Instance configuration: the easy parts (#2341)
* Add data model for instance configuration

* Support instance.configuration.statuses.max_characters

* Support instance.configuration.statuses.characters_reserved_per_url

* Support instance.configuration.polls.max_options and max_characters_per_option

* Pacify ktlint

* Support instance-configured poll durations

* Fixup versions for migration after rebase
2022-03-01 19:43:36 +01:00
Konrad Pozniak eea81d7106
use POST api/v2/media to upload media (#2327) 2022-02-25 18:57:18 +01:00
Mélanie Chauvel c8ed6b482e
increase default poll max option chars from 25 to 50 (#2343)
25 is old Mastodon default, the new one is 50
2022-02-18 20:08:38 +01:00
Konrad Pozniak 2cc53d6772 fix codestyle 2021-06-28 22:04:34 +02:00
Konrad Pozniak f6dd131b95
migrate drafts to paging 3 (#2206)
* migrate drafts to paging 3

* migrate DraftHelper to coroutines
2021-06-24 21:23:29 +02:00
Konrad Pozniak 751109ac39
upgrade kotlin to 1.5.0 (#2162)
* upgrade kotlin to 1.5.0

* don't explicitly set kotlin jvmtarget
2021-05-21 17:51:35 +02:00
Konrad Pozniak 40b24cd242
migrate to RxJava3 (#2146)
* migrate to RxJava3

* remove unused import
2021-05-16 19:53:27 +02:00
Konrad Pozniak 6c37cc770c
remove SavedToots (#2141)
* remove SavedToots

* fix tests
2021-05-16 19:17:56 +02:00
Alibek Omarov 455942505c
ComposeViewModel: remove unused variable (#2060) 2021-01-31 18:58:45 +01:00
Konrad Pozniak 940d6d395a
Drafts v2 (#2032)
* cleanup warnings, reorganize some code

* move ComposeAutoCompleteAdapter to compose package

* composeOptions doesn't need to be a class member

* add DraftsActivity and DraftsViewModel

* drafts

* remove unnecessary Unit in ComposeViewModel

* add schema/25.json

* fix db migration

* drafts

* cleanup code

* fix compose activity rotation bug

* fix media descriptions getting lost when restoring a draft

* improve deleting drafts

* fix ComposeActivityTest

* improve draft layout for almost empty drafts

* reformat code

* show toast when opening reply to deleted toot

* improve item_draft layout
2021-01-21 18:57:09 +01:00
Konrad Pozniak 34fb546200
upgrade dependencies (#1990)
* upgrade dependencies

* fix tests
2020-11-22 19:02:54 +01:00
Garrit Franke af44b25c29
Delete scheduled post after editing (#1947)
* Delete scheduled post after editing

This ensures that editing a scheduled toot will not duplicate it.

Fixes #1924

* Fix scheduled toot editing

* Convert isEditingScheduledToot to property

* Replace MediatorLiveData with combineLiveData

* Remove dead code

* Fix observer emission

* Fix "Finish media upload" appearing for split second
2020-10-25 18:41:11 +01:00
Levi Bard e237639adc
Save draft when redrafting a post (#1744) 2020-10-02 18:32:46 +02:00
Sylvia van Os 386d197851
Fix content warning state being lost after screen rotation (#1756)
* Restore compose options after rotation

* Fix in ViewModel instead

* Move showContentWarning change into ViewModel
2020-04-18 15:06:24 +02:00
Levi Bard 9c4898117e
Ensure media are marked sensitive any time there's a content warning (#1728)
Addresses the most critical part of #1725, and may also apply to #1721
2020-03-17 19:46:32 +01:00
Konrad Pozniak 11a4de858c fix crash when opening Poll dialog and instanceParams are null (#1668) 2020-02-09 22:34:44 +01:00
Konrad Pozniak 7d5a9da992
fix crash when closing ComposeActivity (#1651) 2020-01-29 19:15:53 +01:00
Levi Bard 9dccd06a06 Add support for uploading audio attachments (#1630)
* Add support for audio attachments.
Partially addresses #1337

* Register Tusky as a target for audio sharing

* Use icon with textColorTertiary for audio preview
2020-01-16 19:05:52 +01:00
Levi Bard 6a2c9bdbe4 Don't drop content warning when replying (#1631) 2020-01-13 15:18:55 +01:00
Konrad Pozniak 8a9d62e654
Merge pull request #1610 from tuskyapp/improve_scheduled_toot
Improve ScheduledTootActivity
2019-12-31 15:00:23 +01:00
Konrad Pozniak 54f04fb4d7 address PR feedback 2019-12-31 13:57:24 +01:00
kyori19 2994af7091 Fix ComposeOptions.visibility not applied (#1605) 2019-12-27 21:02:16 +01:00