1
0
mirror of https://github.com/element-hq/element-x-android.git synced 2026-10-23 18:49:00 +03:00

192 Commits

Author SHA1 Message Date
Jorge Martin Espinosa
8a5c50d2b8 Fix File.getSizeOfFiles() double counting some files (#7907)
The `File.length()` docs state:

> Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.

On Android, it *seems* to currently have the right behaviour, summing up the size of its children, which made `File.getSizeOfFiles()` double-count the size of some directories.

To avoid this, and be able to control the actual behaviour no matter what future Android versions do, let's count those ourselves.
2026-10-14 11:13:14 +02:00
Benoit Marty
b9ed090400 Use only ClipboardHelper to copy to the clipboard, and do not render feedback on Android 13+
Since Android 13, the system displays its own confirmation when content
is copied to the clipboard, so the application does not render its own
Toast or Snackbar anymore on those versions.

Context.copyToClipboard, CopyToClipboardUseCase and the direct
ClipboardManager usage in EventDebugInfoView are removed.
ClipboardHelper.copyPlainText(text, isSensitive, onSuccessOnOldDevice)
is now the only entry point, and AndroidClipboardHelper is the only
class using ClipboardManager.

Copy actions from the views are moved to their Presenter through new
events, or to the Node when there is no Presenter. A ToastHelper is
introduced so that Toasts are kept where they were used before.
Snackbars are kept where they were already used.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 11:40:08 +02:00
Bardi Harborow
f59f5da64c Mark the recovery key as sensitive when copying it to the clipboard
The recovery key was copied without EXTRA_IS_SENSITIVE, so Android 13+
showed it in the clipboard preview and keyboards could store it in
their clipboard history.

Add an isSensitive option to CopyToClipboardUseCase and
Context.copyToClipboard, and set it when copying the recovery key.
2026-10-04 20:26:48 +11:00
Benoit Marty
55bfcac6ff Remove empty (or comment only) proguard files. 2026-09-04 11:51:59 +02:00
Benoit Marty
4c4cdd1678 Merge branch 'develop' into fix/6371-save-file-name-conflicts 2026-08-24 09:38:35 +02:00
Jorge Martin Espinosa
614619e306 Make PIP react to camera orientation changes in the other participant's device (#6951)
* Make PIP react to camera orientation changes in the other participant's device

Adds a `controls.onPipMediaOrientationUpdate` callback for the WebView that will trigger a new `pipParamsBuilder.setAspectRatioFromOrientation(orientation)` method

* Fix warning about `PictureInPictureParams.Builder.setAspectRatio` only being available on API 26+
2026-08-21 09:47:49 +00:00
Benoit Marty
a740423343 Sync strings. 2026-08-17 11:34:52 +02:00
Benoit Marty
3029218dde Merge branch 'develop' into fix/2614-linkify-ipv6-urls 2026-08-12 13:48:36 +02:00
Benoit Marty
f7508cb29a Merge pull request #7356 from hayaksi1/fix/4008-fediverse-handle-not-email
Do not linkify the server part of a fediverse handle as an email address
2026-08-11 14:48:40 +02:00
Jorge Martín
e92016c68e Improve host extraction in DefaultWellknownRetriever 2026-08-11 13:18:49 +02:00
hayaksi1
e5337b42e0 Validate the bracketed authority with a URI parser instead of a regex
Review feedback: the previous pattern hardcoded http, https and ftp and
guessed at the address grammar. Candidates are now found by scheme and
handed to java.net.URI, which accepts any scheme and rejects an authority
that is not a real IPv6 literal, an unclosed bracket, or array syntax
such as values[0]:1. Also drops the explanatory comments.
2026-08-09 15:44:14 +03:00
hayaksi1
fbdb99019e Drop the MediaStore explanation from the save helper
Review feedback: the retry itself is short enough to read, and the
platform limit it works around belongs in the commit, not the source.
The contract of the name helper keeps its one-line KDoc.
2026-08-09 15:40:20 +03:00
hayaksi1
f5a2d5bf88 Do not linkify the server part of a fediverse handle as an email address
A fediverse handle such as `@name@server.tld` contains a substring that
`Linkify.EMAIL_ADDRESSES` recognises as a valid address, so the timeline
renders `name@server.tld` as a tappable `mailto:` link. Tapping it opens a
mail composer addressed to an account that does not accept mail.

Drop a newly added `mailto:` span when the character immediately before it
is `@`. This mirrors what Android already does for web URLs, where
`Linkify.sUrlMatchFilter` rejects a match preceded by `@` — which is why
the handle currently produces exactly one stray mailto span and no partial
link is left behind once it is removed.

Author-supplied links are unaffected: spans that were already present
before linkification are excluded from the check and restored as before. A
genuine address written directly after an `@` — "mail me @support@element.io"
— is no longer linkified, which is the same trade-off Android already makes
for web URLs.
2026-08-09 13:16:04 +03:00
hayaksi1
0ccb9b23cc Linkify URLs whose host is a bracketed IPv6 address
Patterns.WEB_URL, which LinkifyCompat uses to find links, has no
production for a bracketed IPv6 authority, so a URL such as
http://[2001:db8::1]:8008/path was never turned into a link. Worse, the
phone number matcher claimed the digit runs inside the address, leaving a
tel: link over part of it.

LinkifyHelper now runs its own pass for those URLs. It requires both a
scheme and the brackets, so array syntax like values[0]:1 is not matched,
and it runs after LinkifyCompat.addLinks, which strips any span set before
it, but before the pre-existing spans are restored, so real anchors and
pill spans keep their precedence. Any span Linkify left inside the address
is evicted, and the same trailing punctuation trimming as the other links
is applied.

Relates to https://github.com/element-hq/element-x-android/issues/2614
2026-08-09 03:51:49 +03:00
hayaksi1
17365a50d1 Keep saving files to Downloads once 32 files share the same name
MediaStore de-duplicates the display name of a new file itself, but its
uniquifier gives up after 32 collisions and throws IllegalStateException.
Saving then failed with "Sorry, an error occurred" and wrote nothing, and
because image.png is the name most screenshots arrive with, a user who
saves media regularly could reach a state where that name never saved
again without deleting files from Downloads by hand.

A new saveWithUniqueFileName helper in androidutils retries the insert
once with a suffixed name when the platform reports it cannot build a
unique one; a second failure propagates so genuine errors still surface.
withFileNameSuffix builds that name by inserting the suffix before the
extension, and handles names without one.

Both call sites are fixed: AndroidLocalMediaActions and DefaultFileSave
carried byte-identical logic and therefore the identical defect. While in
AndroidLocalMediaActions, a null output uri from ContentResolver.insert
now throws instead of reporting success without writing anything.

The pre-Android-Q path is untouched: it overwrites rather than
uniquifying, so it never reaches this limit.

Relates to https://github.com/element-hq/element-x-android/issues/6371
2026-08-09 01:59:25 +03:00
ganfra
74bc2c0f5d Add local network address classifier and permission advisor 2026-07-08 17:11:26 +02:00
Benoit Marty
c430877d87 Ensure Robolectric test are run using API 36 until the library support API 37. 2026-06-18 12:18:32 +02:00
Benoit Marty
e54d93cd50 Compile with SDK 37 2026-06-18 12:18:31 +02:00
Jorge Martin Espinosa
a91e1fa2ae Make Vulkan a *not required* feature (#6961)
* Make Vulkan a *not required* feature

* Add `DeviceHasVulkanSupport` helper to check this on runtime

* When trying to open a screen with a map in it, check if vulkan is supported and display a new error dialog in that case

* Fix random lint issue

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2026-06-04 13:08:19 +00:00
Jorge Martin Espinosa
80de3e4c5d Create log messages from WebView just once (#6923)
We were creating the same message twice by mistake.

Also, check the retrieved message for passwords before formatting the log line instead of after: this way we don't create a new formatted log line to just discard it
2026-06-01 15:11:04 +02:00
Jorge Martin Espinosa
1e00353f29 Avoid SQLCipher key derivation (#6774)
* Avoid SQLCipher key derivation by manually providing the generated as a raw key: this needs a series of DB re-key operations, performed as part of a 'dummy' DB migration

* Set key generation length to 32 bytes in `RandomSecretPassphraseProvider`.

* Use `ClientSecret` for handling the keys for SQLCipher. Move `ClientSecret` to `:libraries:androidutils` so it's shared.
2026-05-27 17:25:51 +02:00
ElementBot
0aaa80cbdc Sync Strings from Localazy (#6856)
Co-authored-by: bmarty <3940906+bmarty@users.noreply.github.com>
2026-05-26 08:05:07 +00:00
Benoit Marty
61f074ddc1 Let our Json parser accept comments and trailing comma. 2026-05-04 10:05:11 +02:00
Benoit Marty
8c5caabed4 Sign in with Classic 2026-04-13 11:16:05 +02:00
bmarty
23c1112dcf Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
Jorge Martin Espinosa
87184328eb Fix crash when using View.hideKeyboardAndAwaitAnimation (#6502)
* Fix crash when using `View.hideKeyboardAndAwaitAnimation`

Remove the `View.OnApplyWindowInsetsListener` used in modern Android versions to detect if the insets changed after they do the first time: this is a single use operation and the listener will be called every time the insets change

Also, replace `Mutex` with `CompletableDeferred` so it doesn't matter if it's called several times, we only care about the first one.

* Don't try to hide the keyboard if it's already hidden. Also, add a 1s timeout in case everything goes wrong and we somehow never complete the future.
2026-03-31 16:45:10 +00:00
Jorge Martin Espinosa
054b7302f1 Fix crash when starting a DM (#6419)
`AnchoredDraggable.requireOffset` was called before it was populated when displaying  `CreateDmConfirmationBottomSheet`, because the keyboard and the bottom sheet were causing conflicting animations related to the insets.

Hiding the keyboard before displaying the bottom sheet seems to fix the issue, and `skipPartiallyExpanded` results in a better UX (and also worked around the issue by itself).
2026-03-23 16:00:04 +01:00
bmarty
299d5a9394 Sync Strings from Localazy 2026-03-16 00:42:32 +00:00
Jorge Martin Espinosa
edd747327b When linkifying, adjust the URLSpan's url too (#6188) 2026-02-12 12:12:57 +00:00
Jorge Martin Espinosa
13d5068b6d Fix linkify helper index out of bounds with parenthesis (#6140)
When parenthesis were mismatched by having more opening parenthesis than closing ones, we could end up incorrectly making the URLSpan `end` value greater than the actual text length, causing an `IndexOutOfBoundsException`
2026-02-05 09:33:38 +01:00
Benoit Marty
74585866b5 Fix test compilation 2025-12-29 12:47:21 +01:00
Benoit Marty
c19c8e87a6 Fix class cast exception
java.lang.ClassCastException: io.element.android.libraries.androidutils.json.DefaultJsonProvider cannot be cast to kotlinx.serialization.json.Json
2025-12-29 12:00:58 +01:00
Jorge Martin Espinosa
57f8fbe206 Merge branch 'develop' into fix/crash-on-nightly-incorrect-di-cast 2025-12-22 16:04:25 +01:00
renovate[bot]
00dcbf4a7f fix(deps): update kotlin to 2.3.0 (#5917)
* fix(deps): update kotlin to 2.3.0

* Cleanup - remove `datetime` compat version

* Fix several lint issues caused by the Kotlin compiler inference working better (checks in nullables, vars, etc.)

* Fix tests by removing mock in `File.readBytes`, it seems like it's no longer allowed. Using a tmp file works well enough.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
2025-12-22 14:28:15 +01:00
Jorge Martín
d094233250 Change JsonProvider from a parent interface to a typealias
This fixes the error seen in the nightlies
2025-12-22 14:17:08 +01:00
Benoit Marty
2a9765ad33 Upgrade robolectric to version 4.16 (#5923)
* Update dependency org.robolectric:robolectric to v4.16

* Fix file size formatter output on API 26+

* Use more realistic value for maxUploadSize

* Update screenshots

* Fix test issue: "java.security.KeyStoreException: AndroidKeyStore not found"

* Add exceptions.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ElementBot <android@element.io>
2025-12-19 15:37:38 +01:00
Benoit Marty
08aeb55651 Fix file size formatter output on API 26+ 2025-12-18 11:18:25 +01:00
Benoit Marty
a073117d62 Link new device using QrCode. 2025-12-16 16:14:04 +01:00
ElementBot
ad881c303a Sync Strings from Localazy (#5904)
Co-authored-by: bmarty <3940906+bmarty@users.noreply.github.com>
2025-12-15 23:51:19 +01:00
Jorge Martín
ca21e16c26 URL-encode deep link path segments in DefaultDeepLinkCreator
Decode them later in `DefaultDeepLinkParser` too
2025-12-10 15:58:41 +01:00
Benoit Marty
54e742075d Detekt: enable rule exceptions.SwallowedException and fix existing issue. 2025-12-05 09:45:23 +01:00
Jorge Martin Espinosa
bf0274074d Enable logging OkHttp traffic based on the current log level (#5750)
* Use `LogLevel` to decide whether to log the HTTP requests and responses

Added `DynamicHttpLoggingInterceptor` for this.

* Code cleanup.

* Use Timber.d

* OutOfMemoryError should not be caught. They are considered unrecoverable.

* Improve code in DefaultBugReporter.

---------

Co-authored-by: Benoit Marty <benoit@matrix.org>
2025-11-18 15:18:27 +01:00
Benoit Marty
eb31505dc7 Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
Benoit Marty
f86431e663 Copyright: Add final period 2025-11-10 10:13:41 +01:00
Benoit Marty
c4e0370f41 Copyright: run command uv run license-editor --repository ../element-x-android 2025-11-10 10:09:26 +01:00
Benoit Marty
9baf948b35 Merge pull request #5592 from element-hq/feature/bma/constValKey
Improve how data is handled for the WorkManager.
2025-10-24 19:20:44 +02:00
Benoit Marty
3bd4aa746d Add missing test. 2025-10-23 09:59:24 +02:00
Benoit Marty
263e761907 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
Benoit Marty
df48ed5a2d Introduce JsonProvider.
It will ensure that classes are using the correct Json instances in the unit tests.
2025-10-20 09:40:42 +02:00
Jorge Martin Espinosa
c0d6862b6e Fix media viewer not being dismissed with reduced motion enabled (#5555)
This is also called 'remove animations' in some Android versions. It seems like the associated coroutine dispatcher never allows the `delay` calls to complete, or maybe they take too long and the coroutine is cancelled before they finish.
2025-10-17 10:10:13 +00:00