Commit Graph

97 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
Konrad Pozniak ee3760fcc9
correctly count emojis when composing a post (#4152)
Thx to @evant for the help 

closes #4140
2023-12-10 07:38:25 +01:00
Markus Unterwaditzer 6e6cf05d11
Remove garbage alt text from images attached via Gboard (#4068)
Steps to reproduce:

1. install Gboard

(https://play.google.com/store/apps/details?id=com.google.android.inputmethod.latin)

2. open a direct link to any image in Firefox
3. long-press the image to get a "Copy Image" dialogue (and copy the
   image)
4. compose a new post in Tusky
5. Gboard will suggest to paste the image from clipboard
6. paste image, see that when opening alt text editor, it is filled out
   with this garbage string

Why is this bad? It's not when I just fix the alt text. But it breaks
every mechanism that is supposed to remind me of adding alt text.

It's hard to argue that this is within scope of Tusky but I also don't
see it getting fixed in Gboard, so here we go.
2023-10-25 12:52:42 +02:00
Konrad Pozniak ff1c4a4b27
fix theme preference defaults (#4061)
closes #4060 

Also I noticed that we had the theme defaults twice in the code so I
refactored a bit so only one are still in there.
2023-10-14 14:20:20 +02:00
Conny Duck af5ec068e8 use PrefKeys everywhere 2023-09-11 19:12:33 +02:00
SpaceFox 85888ac238
Uses the system theme as default theme (#3813)
Set the "System Design" as the default theme.

This ensures that the app's initial behaviour respect's the user's system-wide theme choice, while still allowing the user to adjust it later.

This is only done for new installs of Tusky. If the user is upgrading from a previous release and they did not have an explicit theme set then the dark theme is used, and the UX does not change.
2023-08-23 15:04:24 +02:00
Konrad Pozniak dc9e9f2aeb
Improve account switching intents (#3732)
Before, intent creation was scattered across multiple sites, with account switching logic in both `ComposeActivity` and `MainActivity`.

Now, intents are only created in `MainActivity` Companion, and account switching only occurs in `MainActivity`

Fixes #3695
2023-08-19 12:31:47 +02:00
Nik Clayton e852aa64a5
Show the throwable error message when an upload fails (#3838) 2023-07-26 23:36:29 +02:00
Nik Clayton 480d412e4c
Set default alt-text to media label when pasting images (#3800)
GBoard and other IME's support pasting images, which are converted to attachments.

Sometimes these have labels that describe the image. If present, set it as the default alt-text.

Fixes #3799
2023-07-07 18:50:19 +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
Konrad Pozniak 85b7caa887
Replace deprecated getParcelable* methods with compat versions (#3633) 2023-06-11 12:58:55 +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
Nik Clayton 6dfdaec425
Ignore "@instance..." part of username when computing status length (#3392)
* Move compose.* tests to own namespace

* Ignore "@instance..." part of username when computing status length

In a status with a mention ("@foo@example.org") only the "@foo" part should
be included in the calculated status length. It wasn't, so the app was
prevening people from posting statuses that should have been allowed.

Fix this.

- Lift the length calculation code in to a separate static function (easier
  and faster to test)
- Add a `MentionSpan` type, to reuse existing code for detecting mentions
- Fix a bug in `FakeSpannable.getSpans()` (it was returning the outer type,
  not the wrapped inner span)
- Add additional fast tests

The tests made sense under the `components.compose.ComposeActivity` package,
so I also created that and moved the existing ComposeActivity tests there.

Fixes https://github.com/tuskyapp/Tusky/issues/3339

* Static import assertEquals
2023-03-13 10:22:33 +01:00
Goooler 43ea59ab2f
Replace DefaultTextWatcher with extensions in core-ktx (#3401)
* Replace DefaultTextWatcher with extensions in core-ktx

* Fix positiveButton.isEnabled

* editable!! for highlightSpans

* Fix style

* Put noteWatcher back
2023-03-10 20:27:24 +01:00
Goooler 2da7bc5bc8
Use TypedArray.use to obtain attrs (#3349)
17346638ff/core/core-ktx/src/main/java/androidx/core/content/res/TypedArray.kt (L227-L236)
2023-02-25 21:30:52 +01:00
Levi Bard f2b07196e6
Improve language list prioritization. (#3293)
Partially addresses #3277
2023-02-25 21:15:21 +01:00
Goooler 6cc79c8d75
Use unsafeLazy to simplify thread unsafe lazy initializations (#3276) 2023-02-20 20:14:54 +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
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 bc0d5b69d5.

* Revert "Enable build scan"

This reverts commit 1568e5e84f.

* 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 e4d1543bda.
2023-02-04 19:58:53 +01:00
Nik Clayton e5e076b0d3
Convert BezelImageView, EndlessOnScrollListener, ComposeScheduleView, ProgressImageView to Kotlin (#3147)
* Convert BezelImageView to Kotlin

* Convert EndlessOnScrollListener to Kotlin

* Convert ComposeScheduleView to use view binding

* Convert ComposeScheduleView to Kotlin

* Convert ProgressImageView to Kotlin

* Apply reviewer feedback
2023-01-13 19:49:56 +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
Nik Clayton 22834431ca
Convert util/{HttpHeaderLink,PairedList,TimestampUtils,ThemeUtils} to Kotlin (#3046)
* Fix off-by-one error in HttpHeaderLink

Link headers with multiple URLs with multiple parameters were being parsed
incorrectly.

Detected by adding unit tests ahead of converting to Kotlin.

* Convert util/HttpHeaderLink from Java to Kotlin

* Convert util/ThemeUtils from Java to Kotlin

* Convert util/TimestampUtils from Java to Kotlin

* Add tests for PairedList

* Convert util/PairedList from Java to Kotlin

* Implement feedback from PR

* Relicense as GPL
2022-12-31 13:01:35 +01:00
Nik Clayton c07dd0f919
Remove debug logging of keypresses (#3075)
While only present in a Log.d call, which should be stripped out of release
builds, this feels like an unnecessary privacy risk.
2022-12-30 11:41:11 +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
UlrichKu 2accfd0712
2890 show warning on missing description (#2919)
* issue 2890: Show a warning icon if media description is missing

* issue 2890: Remove disturbing additional signs

* issue 2890: Add another icon; use a snackbar; change wording; use orange as color

* issue 2890: Remove now unneeded new resource

* issue 2890: Use a toast (also) to avoid elevation problems

* issue 2890: Use snackbar with elevation again; refactor a bit
2022-12-06 19:28:44 +01:00
Konrad Pozniak 615c7adc86
hide "take photo" button when no Photo app is installed (#2997) 2022-12-05 19:15:58 +01:00
Konrad Pozniak bdeb88c41f
respect "animate emojis" setting in emoji picker (#2996) 2022-12-05 19:15:28 +01:00
Levi Bard 588307f7a1
Enable setting the default posting language from Tusky (#2946)
* Extract locale utils

* Extract makeIcon

* Allow setting the (server-synchronized) default posting language from Tusky.
Closes #2902

* Add copyright headers

* Address review feedback
2022-12-02 19:19:17 +01:00
Levi Bard 0126ee9500
Language selection fixes (#2917)
* Fix duplicated language entries from system and app language sets.
Closes #2900

* Prefer modern language codes.
Closes #2903

* Synchronize per-account default posting language with server.
Closes #2902

* Allow users to post in languages android doesn't know about yet (e.g. toki pona)

* Always put the preselected language at the top of the list
2022-11-24 15:45:19 +01:00
Levi Bard 3fb103aa14
Prioritize users' default locales in language list (#2850)
* Prioritize users' default locales in language list.
Closes #2844

* Add the configured app languages before the configured system languages
2022-11-19 19:03:42 +01:00
Konrad Pozniak 667a728dd5
fix media permissions on Android 10+ (#2837) 2022-11-16 20:43:49 +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
Josh Soref a9c6f69561
Warn about losing media (#2784)
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-09 19:33:48 +01:00
Konrad Pozniak 1fb58a9116
revert CompatExtensions (#2773) 2022-11-09 19:32:54 +01:00
Konrad Pozniak d17a0c43ab
Api 33 support (#2719)
* update to Api 33, fix some deprecations

* fix deprecated serializable/parcelable methods

* ask for notification permission

* fix code formatting

* add back comment in PreferencesActivity
2022-11-04 19:22:38 +01:00
fynngodau 050891ebe5
Retain instance state in compose activity (#2722)
* Correctly restore instance state in compose activity

Store post visiblity, schedule time, and visibility of content warning
field to instance state and restore upon restoration.

* Remove redundant line
2022-10-18 19:38:27 +02:00
mcclure 85a6b2d96b
Preference to disable multiple-login usernames (#2718)
* Preference to disable multiple-login usernames (with problems)

* Fix problem where 'show self username disambiguation' does not take effect immediately because MainActivity needed to be restarted

* Make 'show username in toolbars' a 3-option selector, default when multiple accounts logged in

* Move SHOW_SELF_USERNAME higher in preference fragment
2022-10-18 19:38:17 +02: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
Vivianne c908ebb3f1
Add display of handle when using multiple accounts (#2697)
- Shown on the main toolbar (subtitle)
- Shown just above the "replying to" message (even if not replying)
2022-09-17 19:05:56 +02:00
Prat 5bc680ab78
Refactor Caption Dialog to handle screen rotation (#2626) (#2693)
Co-authored-by: Prat T <pt2121@users.noreply.github.com>
2022-09-12 18:21:00 +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
QuirkyPony 17fb93626c
adapt file size error messages to show real instance upload limit (#2630)
* remove megabyte counts from file size error messages

The file size limits depend on the server; change strings to reflect that.

* show real file size limits instead of assuming Mastodon defaults

* correct previous commit

* correct previous commit (again)

* remove megabyte counts from file size error messages

The file size limits depend on the server; change strings to reflect that.

* Translated using Weblate (Galician)

Currently translated at 100.0% (489 of 489 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky

* Translated using Weblate (Finnish)

Currently translated at 5.5% (1 of 18 strings)

Translation: Tusky/Tusky description
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky-app/fi/

* correct previous commit

correct previous commit (again)

fixed type error caused by previous commits

* fix lint error...

* Update strings.xml

* improve code, calculate correct max size and format it

Co-authored-by: Laura <the-ceo-of-antifa@protonmail.com>
Co-authored-by: XoseM <xosem@disroot.org>
Co-authored-by: Konrad Pozniak <k.pozniak@gmx.at>
2022-08-05 18:55:13 +02:00
Konrad Pozniak 55796c9a30
update minSdkVersion to 23 (#2638)
closes #2606
2022-08-04 16:48:26 +02:00
Konrad Pozniak 2d2d7569e3
fix compose field focus when replying to post with cw (#2634) 2022-08-03 17:23:54 +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
mcclure 3ca8a0b549
Use specific term "image" in error UI, not "attachment" (#2592)
The new message for the crop feature, "The attachment could not be edited.", turned out to be awkward in some languages (French) where according to the translator it would be better to more specifically say "The image could not be edited." (as currently we can only edit images). Patch replaces error_media_edit_failed with a error_image_edit_failed and deletes the existing error_media_edit_failed-s.
2022-06-21 22:14:11 +02:00