Commit Graph

4056 Commits

Author SHA1 Message Date
Konrad Pozniak 88fbf33832
fix crash when quickly unfollowing hashtags (#4404)
Steps to reproduce: Quickly unfollow a bunch of hashtags, try clicking
unfollow buttons multiple times. If you are faster than the network, the
app crashes.

```
java.lang.ArrayIndexOutOfBoundsException: length=20; index=-1
       at java.util.ArrayList.remove(ArrayList.java:506)
       at com.keylesspalace.tusky.components.followedtags.FollowedTagsActivity$unfollow$1.invokeSuspend(FollowedTagsActivity.kt:152)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7872)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
```
2024-05-01 18:43:45 +02:00
Konrad Pozniak b2547c5eef
fix crash in ViewThreadFragment (#4401)
Fragments don't necessarily have the same lifecycle as their views, so
their is a rare race condition when collecting a Flow from the
`lifecycleScope` of the Fragment where the view is already disposed but
the collect lambda is still executed. Accessing the view from such a
lambda can therefore led to a crash.
Collecting from the `viewLifecycleOwner.lifecycleScope` fixes the
problem.

```
Exception java.lang.IllegalStateException:
  at androidx.fragment.app.Fragment.requireView (Fragment.java:2062)
  at com.keylesspalace.tusky.util.ViewLifecycleLazy.getValue (ViewBindingExtensions.kt:32)
  at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment.getBinding (ViewThreadFragment.kt:79)
  at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment.access$getBinding (ViewThreadFragment.kt:67)
  at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment$onViewCreated$3$1.emit (ViewThreadFragment.java:250)
  at com.keylesspalace.tusky.components.viewthread.ViewThreadFragment$onViewCreated$3$1.emit (ViewThreadFragment.java:248)
  at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl (SharedFlow.kt:392)
  at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend (SharedFlow.kt:13)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTaskKt.resume (DispatchedTask.kt:231)
  at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined (DispatchedTask.kt:187)
  at kotlinx.coroutines.DispatchedTaskKt.dispatch (DispatchedTask.kt:159)
  at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume (CancellableContinuationImpl.kt:470)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:504)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:493)
  at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:364)
  at kotlinx.coroutines.flow.SharedFlowImpl.tryEmit (SharedFlow.kt:409)
  at kotlinx.coroutines.flow.SharedFlowImpl.emit$suspendImpl (SharedFlow.kt:414)
  at kotlinx.coroutines.flow.SharedFlowImpl.emit (SharedFlow.kt:1)
  at com.keylesspalace.tusky.components.viewthread.ViewThreadViewModel$loadThread$1.invokeSuspend (ViewThreadViewModel.kt:172)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:210)
  at android.os.Looper.loop (Looper.java:299)
  at android.app.ActivityThread.main (ActivityThread.java:8319)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1038)
```
2024-04-29 19:52:08 +02:00
Konrad Pozniak 05b78a2a00
add content description for bottom nav menu button (#4400) 2024-04-29 19:51:59 +02:00
Ümit Solmaz 389059da43 Translated using Weblate (Turkish)
Currently translated at 100.0% (639 of 639 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-04-29 11:07:09 +00:00
Connyduck 6bdbbfd4bb Translated using Weblate (German)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Connyduck <weblate@connyduck.at>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/de/
Translation: Tusky/Tusky
2024-04-29 11:07:09 +00:00
Konrad Pozniak 9087b4186f
fix deserializing Akkoma cards (#4395)
Akkoma does not always set all attributes for Cards and when they are
loaded from the database, the app crashes. When they are loaded from the
network, Tusky displays an error. Adding more default values fixes the
problem.

```
com.squareup.moshi.JsonDataException: Required value 'authorName' (JSON name 'author_name') missing at $
    at com.squareup.moshi.internal.Util.missingProperty(Util.java:660)
    at com.keylesspalace.tusky.entity.CardJsonAdapter.fromJson(CardJsonAdapter.kt:122)
    at com.keylesspalace.tusky.entity.CardJsonAdapter.fromJson(CardJsonAdapter.kt:22)
    at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
    at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:70)
    at com.keylesspalace.tusky.components.timeline.TimelineTypeMappersKt.toViewData(TimelineTypeMappers.kt:168)
    at com.keylesspalace.tusky.components.timeline.viewmodel.CachedTimelineViewModel$statuses$2$1.invoke(CachedTimelineViewModel.kt:110)
    at com.keylesspalace.tusky.components.timeline.viewmodel.CachedTimelineViewModel$statuses$2$1.invoke(CachedTimelineViewModel.kt:108)
    at androidx.paging.PagingDataTransforms$map$2$1$1.invokeSuspend(PagingDataTransforms.kt:58)
    at androidx.paging.PagingDataTransforms$map$2$1$1.invoke(Unknown Source:8)
    at androidx.paging.PagingDataTransforms$map$2$1$1.invoke(Unknown Source:2)
    at androidx.paging.PageEvent$Insert.map(PageEvent.kt:128)
    at androidx.paging.PagingDataTransforms$map$2$1.invokeSuspend(PagingDataTransforms.kt:58)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@de2cbd5, Dispatchers.Main.immediate]
```

closes #4393
2024-04-26 19:19:29 +02:00
Balázs Meskó cc6925d866 Translated using Weblate (Hungarian)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Balázs Meskó <mesko.balazs@fsf.hu>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/
Translation: Tusky/Tusky
2024-04-26 04:45:00 +00:00
Ümit Solmaz 7b2b4612c5 Translated using Weblate (Turkish)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-04-25 14:29:30 +00:00
Konrad Pozniak c55d79562c
fix scheduling posts (#4392)
Mastodon returns different reponses when posting normally and when
scheduling. This was previously ignored silently, but Moshi is more
correct than Gson and fails, which causes the `SendStatusService` to
retry sending forever and a lot of posts are scheduled.
Mastodon should actually ignore multiple attempts at scheduling the same
post, but doesn't so I filed this
https://github.com/mastodon/mastodon/issues/30039

cc @cbeyls
2024-04-25 17:08:57 +02:00
Konrad Pozniak f2ffba1679
never create more than the allowed number of shortcuts (#4389)
The only crash so far in the 25.0-beta1 crash reports. Probably not a
regression though as that code did not change in a while.

```
Exception java.lang.IllegalArgumentException: Max number of dynamic shortcuts exceeded
  at android.os.Parcel.createExceptionOrNull (Parcel.java:3032)
  at android.os.Parcel.createException (Parcel.java:3012)
  at android.os.Parcel.readException (Parcel.java:2995)
  at android.os.Parcel.readException (Parcel.java:2937)
  at android.content.pm.IShortcutService$Stub$Proxy.addDynamicShortcuts (IShortcutService.java:618)
  at android.content.pm.ShortcutManager.addDynamicShortcuts (ShortcutManager.java:240)
  at androidx.core.content.pm.ShortcutManagerCompat.addDynamicShortcuts (ShortcutManagerCompat.java:334)
  at com.keylesspalace.tusky.util.ShareShortcutHelper$updateShortcut$1.invokeSuspend (ShareShortcutHelper.kt:96)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104)
  at android.os.Handler.handleCallback (Handler.java:984)
  at android.os.Handler.dispatchMessage (Handler.java:104)
  at android.os.Looper.loopOnce (Looper.java:238)
  at android.os.Looper.loop (Looper.java:357)
  at android.app.ActivityThread.main (ActivityThread.java:8094)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:957)
Caused by android.os.RemoteException: Remote stack trace:
  at com.android.server.pm.ShortcutService.enforceMaxActivityShortcuts (ShortcutService.java:1768)
  at com.android.server.pm.ShortcutPackage.enforceShortcutCountsBeforeOperation (ShortcutPackage.java:1551)
  at com.android.server.pm.ShortcutService.addDynamicShortcuts (ShortcutService.java:2161)
  at android.content.pm.IShortcutService$Stub.onTransact (IShortcutService.java:281)
  at android.os.Binder.execTransactInternal (Binder.java:1294)
```
2024-04-25 17:08:46 +02:00
Weblate fe7103f2b9
Translations update from Weblate (#4388)
Translations update from [Weblate](https://weblate.tusky.app) for
[Tusky/Tusky](https://weblate.tusky.app/projects/tusky/tusky/).



Current translation status:

![Weblate translation
status](https://weblate.tusky.app/widget/tusky/tusky/horizontal-auto.svg)

---------

Co-authored-by: Manuel <mannivuwiki@gmail.com>
Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com>
2024-04-22 19:46:06 +02:00
Weblate 7960db6c78
Translations update from Weblate (#4385)
Translations update from [Weblate](https://weblate.tusky.app) for
[Tusky/Tusky](https://weblate.tusky.app/projects/tusky/tusky/).



Current translation status:

![Weblate translation
status](https://weblate.tusky.app/widget/tusky/tusky/horizontal-auto.svg)

---------

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Co-authored-by: Luna Jernberg <droidbittin@gmail.com>
2024-04-21 10:26:36 +02:00
Conny Duck 0a9485f8e9 upgrade version to 25.0 beta 1 2024-04-20 19:13:49 +02:00
Christophe Beyls 72ee0b4292
Enable support for WebVTT and TTML subtitles for the player (#4377)
All subtitle formats used to be enabled by default in older versions of
media3.
After the media3 library was upgraded to 1.3.0, Extractors should
specify a `SubtitleParser.Factory` explicitly. By default, no subtitle
formats are supported when using the now deprecated empty constructor of
Extractors.

Limit support to **WebVTT** and **TTML** which are the only true web
standards amongst all the subtitle formats supported by ExoPlayer.

Note that only subtitles embedded in MP4 and WebM files are supported
until Mastodon provides a way to upload subtitles separately.
2024-04-17 21:29:21 +02:00
Konrad Pozniak 4e822c9a0a
larger background for toolbar icons in AccountActivity (#4375)
Looks way better.
[I also wanted to change the color of the status bar, but nobody seems
to like it](https://chaos.social/@ConnyDuck/112178196967742268), so
let's leave it.

before/after
<img
src="https://github.com/tuskyapp/Tusky/assets/10157047/4e93c722-c1a3-4fc4-808f-037a1398a944"
width="260"/> <img
src="https://github.com/tuskyapp/Tusky/assets/10157047/2a58785b-d3f4-4613-9bd9-0e09436f7142"
width="260"/>
2024-04-17 18:41:51 +02:00
Christophe Beyls f69cae2315
Optimize I/O code using Okio - part 2 (#4372)
- Read license resource using Okio inside a coroutine (instead of the
main thread) in `LicenseActivity`
- Use Okio and its buffer system to copy ContentProvider streams and
files to a temporary file in `MediaUploader.prepareMedia()`
- Properly close the input file after copying it to a temporary file in
`MediaUploader.prepareMedia()`
- Properly close sink in case of null body source during file copy in
`Uri.copyToFolder()` in `DraftHelper.kt`
- Add comment explaining the current value of `DEFAULT_CHUNK_SIZE` in
`UriRequestBody.kt` and indent the file properly
- Replace hardcoded `Charset` and `Int` byte size with the proper
constants, and align the `hashCode()` implementation with other
`BitmapTransformation` implementations in
`CompositeWithOpaqueBackground`
- Properly close `InputStream` in case of error during Bitmap size
decoding in `getImageSquarePixels()`
- return `Int` instead of `Long` in `getImageSquarePixels()`, since the
current code simply converts the `Int` result to a `Long` _after_
multiplication and not before (and `Int.MAX_VALUE` is already way above
the maximum number of pixels a decoded Bitmap could return)
- Simplify `getImageOrientation()`
- Add explicit dependency to the Okio library and upgrade it to its
latest version.
2024-04-14 16:39:29 +02:00
Konrad Pozniak 2504f42f7b
Apply window insets to SwipeRefreshLayout in AccountActivity to not obscure spinner (#4371)
before & after

<img
src="https://github.com/tuskyapp/Tusky/assets/10157047/b029f5ff-9b17-48be-b306-a2e7e03ef6f7"
width="240"/>
<img
src="https://github.com/tuskyapp/Tusky/assets/10157047/ea9d3aa8-1f76-4709-9677-f478e2e0064a"
width="240"/>
2024-04-14 16:13:41 +02:00
Christophe Beyls 65af26993b
Optimize I/O code using Okio (#4366)
This pull request takes advantage of the Okio library to simplify, fix
or improve performance of some I/O related code in Tusky.

- Return early or throw `FileNotFoundException` early in case
`contentResolver.openInputStream()` returns `null` instead of throwing
`NullPointerException` later. Change the signature of
`Closeable.closeQuietly()` to only accept a non-null `Closeable`.
- Reimplement `Uri.copyToFile()` using Okio. This takes advantage of the
built-in high-performance buffers of the library so a buffer doesn't
need to be allocated or managed manually. The new implementation also
makes sure that the input and output streams are always closed, as the
original code could in some cases return without properly closing a
stream.
- Reimplement `ProgressRequestBody` as `Uri.asRequestBody()` (adding to
the existing extension functions available in the Okio library to create
a `RequestBody`). The new implementation uses Okio's `Buffer` instead of
a manually managed byte array, which allows to avoid copying bytes from
one buffer to the next. The max number of bytes read at once was
increased from 2K to 8K to improve performance. Avoid division by zero
in case `contentLength` is `0`. Finally, this implementation now takes a
`Uri` as input instead of an `InputStream`, because a `RequestBody` must
be replayable in case Okio retries the request, and an `InputStream` can
only be used once.
2024-04-10 21:52:55 +02:00
Ümit Solmaz 9e0796ae6c Translated using Weblate (Turkish)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-04-10 19:09:08 +00:00
Christophe Beyls ec599c8f8a
Replace java.util.Random with kotlin Random object (#4364)
This also improves randomness by avoiding to reinitialize the random
number generator repeatedly from a seed based on the current time.
Typically, if the number generator is reinitialized repeatedly at
non-random times (like multiple times in a row), then generated numbers
have a higher chance of repeating.

The Kotlin Random object is only initialized once, using the best seed
available for the current Android version.
2024-04-10 21:47:27 +02:00
Konrad Pozniak 2a4d60bed8
fix deserializing audio attachments (#4362)
closes #4361 

```
com.squareup.moshi.JsonDataException: Required value 'width' missing at $.statuses[0].media_attachments[0].meta.original
       at com.squareup.moshi.internal.Util.missingProperty(Util.java:660)
       at com.keylesspalace.tusky.entity.Attachment_SizeJsonAdapter.fromJson(Attachment_SizeJsonAdapter.kt:81)
       at com.keylesspalace.tusky.entity.Attachment_SizeJsonAdapter.fromJson(Attachment_SizeJsonAdapter.kt:23)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.keylesspalace.tusky.entity.Attachment_MetaDataJsonAdapter.fromJson(Attachment_MetaDataJsonAdapter.kt:64)
       at com.keylesspalace.tusky.entity.Attachment_MetaDataJsonAdapter.fromJson(Attachment_MetaDataJsonAdapter.kt:23)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.keylesspalace.tusky.entity.AttachmentJsonAdapter.fromJson(AttachmentJsonAdapter.kt:66)
       at com.keylesspalace.tusky.entity.AttachmentJsonAdapter.fromJson(AttachmentJsonAdapter.kt:22)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.squareup.moshi.CollectionJsonAdapter.fromJson(CollectionJsonAdapter.java:81)
       at com.squareup.moshi.CollectionJsonAdapter$2.fromJson(CollectionJsonAdapter.java:55)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.keylesspalace.tusky.entity.StatusJsonAdapter.fromJson(StatusJsonAdapter.kt:195)
       at com.keylesspalace.tusky.entity.StatusJsonAdapter.fromJson(StatusJsonAdapter.kt:26)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.squareup.moshi.CollectionJsonAdapter.fromJson(CollectionJsonAdapter.java:81)
       at com.squareup.moshi.CollectionJsonAdapter$2.fromJson(CollectionJsonAdapter.java:55)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at com.keylesspalace.tusky.entity.SearchResultJsonAdapter.fromJson(SearchResultJsonAdapter.kt:51)
       at com.keylesspalace.tusky.entity.SearchResultJsonAdapter.fromJson(SearchResultJsonAdapter.kt:21)
       at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
       at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:46)
       at retrofit2.converter.moshi.MoshiResponseBodyConverter.convert(MoshiResponseBodyConverter.java:27)
       at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:246)
       at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:156)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)
```
2024-04-10 21:47:05 +02:00
Konrad Pozniak f1b0e0fbc2
enableDecoderFallback for ExoPlayer (#4360)
This helps playing some media even if there is a problem with the
primary decoder.
E.g. [this
video](https://mastodon.social/@krzyzanowskim/112208964123517040) fails
on my Fairphone 4 without this change.


<img
src="https://github.com/tuskyapp/Tusky/assets/10157047/215d932c-9ed1-4ee8-8be7-e6ca28ddec23"
width="200"/>

<details>
  <summary>Stacktrace</summary>

```
androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640034, -1, null, [1920, 1440, 119.99593, ColorInfo(BT709, Limited range, sRGB, false, 8bit Luma, 8bit Chroma)], [-1, -1]), format_supported=YES
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:620)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, null, video/avc, avc1.640034, -1, null, [1920, 1440, 119.99593, ColorInfo(BT709, Limited range, sRGB, false, 8bit Luma, 8bit Chroma)], [-1, -1])
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1114)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560)
      at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814)
      at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loopOnce(Looper.java:201) 
      at android.os.Looper.loop(Looper.java:288) 
      at android.os.HandlerThread.run(HandlerThread.java:67) 
  Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff4
      at android.media.MediaCodec.native_configure(Native Method)
      at android.media.MediaCodec.configure(MediaCodec.java:2215)
      at android.media.MediaCodec.configure(MediaCodec.java:2131)
      at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.initialize(AsynchronousMediaCodecAdapter.java:174)
      at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter.access$100(AsynchronousMediaCodecAdapter.java:54)
      at androidx.media3.exoplayer.mediacodec.AsynchronousMediaCodecAdapter$Factory.createAdapter(AsynchronousMediaCodecAdapter.java:119)
      at androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:117)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1195)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1103)
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:551) 
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1560) 
      at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:1152) 
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:994) 
      at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:814) 
      at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:940) 
      at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102) 
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loopOnce(Looper.java:201) 
      at android.os.Looper.loop(Looper.java:288) 
      at android.os.HandlerThread.run(HandlerThread.java:67) 
```

</details>
2024-04-10 21:46:52 +02:00
Konrad Pozniak 0d3b1b1c5a
show rules of the correct instance on the auth screen (#4358)
closes #4357
2024-04-05 12:01:54 +02:00
XoseM 98864e8097 Translated using Weblate (Galician)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky
2024-04-03 18:30:31 +00:00
Konrad Pozniak fa3c7db919
add the correct information to regenerate the lint baseline file (#4351)
also regenenerate the file
2024-04-02 21:02:51 +02:00
Christophe Beyls df7b11afc3
Replace Gson library with Moshi (#4309)
**! ! Warning**: Do not merge before testing every API call and database
read involving JSON !

**Gson** is obsolete and has been superseded by **Moshi**. But more
importantly, parsing Kotlin objects using Gson is _dangerous_ because
Gson uses Java serialization and is **not Kotlin-aware**. This has two
main consequences:

- Fields of non-null types may end up null at runtime. Parsing will
succeed, but the code may crash later with a `NullPointerException` when
trying to access a field member;
- Default values of constructor parameters are always ignored. When
absent, reference types will be null, booleans will be false and
integers will be zero.

On the other hand, Kotlin-aware parsers like **Moshi** or **Kotlin
Serialization** will validate at parsing time that all received fields
comply with the Kotlin contract and avoid errors at runtime, making apps
more stable and schema mismatches easier to detect (as long as logs are
accessible):

- Receiving a null value for a non-null type will generate a parsing
error;
- Optional types are declared explicitly by adding a default value. **A
missing value with no default value declaration will generate a parsing
error.**

Migrating the entity declarations from Gson to Moshi will make the code
more robust but is not an easy task because of the semantic differences.

With Gson, both nullable and optional fields are represented with a null
value. After converting to Moshi, some nullable entities can become
non-null with a default value (if they are optional and not nullable),
others can stay nullable with no default value (if they are mandatory
and nullable), and others can become **nullable with a default value of
null** (if they are optional _or_ nullable _or_ both). That third option
is the safest bet when it's not clear if a field is optional or not,
except for lists which can usually be declared as non-null with a
default value of an empty list (I have yet to see a nullable array type
in the Mastodon API).

Fields that are currently declared as non-null present another
challenge. In theory, they should remain as-is and everything will work
fine. In practice, **because Gson is not aware of nullable types at
all**, it's possible that some non-null fields currently hold a null
value in some cases but the app does not report any error because the
field is not accessed by Kotlin code in that scenario. After migrating
to Moshi however, parsing such a field will now fail early if a null
value or no value is received.

These fields will have to be identified by heavily testing the app and
looking for parsing errors (`JsonDataException`) and/or by going through
the Mastodon documentation. A default value needs to be added for
missing optional fields, and their type could optionally be changed to
nullable, depending on the case.

Gson is also currently used to serialize and deserialize objects to and
from the local database, which is also challenging because backwards
compatibility needs to be preserved. Fortunately, by default Gson omits
writing null fields, so a field of type `List<T>?` could be replaced
with a field of type `List<T>` with a default value of `emptyList()` and
reading back the old data should still work. However, nullable lists
that are written directly (not as a field of another object) will still
be serialized to JSON as `"null"` so the deserializing code must still
be handling null properly.

Finally, changing the database schema is out of scope for this pull
request, so database entities that also happen to be serialized with
Gson will keep their original types even if they could be made non-null
as an improvement.

In the end this is all for the best, because the app will be more
reliable and errors will be easier to detect by showing up earlier with
a clear error message. Not to mention the performance benefits of using
Moshi compared to Gson.

- Replace Gson reflection with Moshi Kotlin codegen to generate all
parsers at compile time.
- Replace custom `Rfc3339DateJsonAdapter` with the one provided by
moshi-adapters.
- Replace custom `JsonDeserializer` classes for Enum types with
`EnumJsonAdapter.create(T).withUnknownFallback()` from moshi-adapters to
support fallback values.
- Replace `GuardedBooleanAdapter` with the more generic `GuardedAdapter`
which works with any type. Any nullable field may now be annotated with
`@Guarded`.
- Remove Proguard rules related to Json entities. Each Json entity needs
to be annotated with `@JsonClass` with no exception, and adding this
annotation will ensure that R8/Proguard will handle the entities
properly.
- Replace some nullable Boolean fields with non-null Boolean fields with
a default value where possible.
- Replace some nullable list fields with non-null list fields with a
default value of `emptyList()` where possible.
- Update `TimelineDao` to perform all Json conversions internally using
`Converters` so no Gson or Moshi instance has to be passed to its
methods.
- ~~Create a custom `DraftAttachmentJsonAdapter` to serialize and
deserialize `DraftAttachment` which is a special entity that supports
more than one json name per field. A custom adapter is necessary because
there is not direct equivalent of `@SerializedName(alternate = [...])`
in Moshi.~~ Remove alternate names for some `DraftAttachment` fields
which were used as a workaround to deserialize local data in 2-years old
builds of Tusky.
- Update tests to make them work with Moshi.
- Simplify a few `equals()` implementations.
- Change a few functions to `val`s
- Turn `NetworkModule` into an `object` (since it contains no abstract
methods).

Please test the app thoroughly before merging. There may be some fields
currently declared as mandatory that are actually optional.
2024-04-02 21:01:04 +02:00
Konrad Pozniak 5343766886
fix swipe-refresh spinner showing forever when refreshing AccountActivity (#4345)
The flow must emit every update even if the values are the same, so use
SharedFlow instead of StateFlow.

Regression from https://github.com/tuskyapp/Tusky/pull/4337 cc @Goooler
2024-03-30 11:31:29 +01:00
Konrad Pozniak b022767ae6
fix translating polls and spoilers (#4344)
The docs are wrong https://github.com/mastodon/documentation/pull/1423 🙄
2024-03-29 21:13:57 +01:00
Zongle Wang ba495f41a5
Remove redundant crossinline (#4348)
Seems we don't need them in newer Kotlin.
2024-03-29 21:12:49 +01:00
Zongle Wang 1acae50845
Convert some sealed classes to interfaces (#4347)
There is no non-abstract field in them, we can just fall back to
interfaces.
2024-03-29 20:11:53 +01:00
Zongle Wang e865ffafde
Don't use mutable shared flows in UI (#4346) 2024-03-29 20:02:12 +01:00
Konrad Pozniak b85ada930b
fix warnings in test runs (#4340)
Found while working on #4026 but not directly related.

Two cases of unmocked methods and one of unclosed resource.
2024-03-28 09:13:05 +01:00
Weblate efa29d37b2 Update translation files
Updated by "Remove blank strings" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/
Translation: Tusky/Tusky
2024-03-27 09:57:03 +00:00
fin-w 3fdb2c14a9 Translated using Weblate (English (United Kingdom))
Currently translated at 2.5% (16 of 639 strings)

Translated using Weblate (Welsh)

Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: fin-w <fin-w@tutanota.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/en_GB/
Translation: Tusky/Tusky
2024-03-27 09:57:03 +00:00
Ümit Solmaz adf4dcb3c8 Translated using Weblate (Turkish)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-03-27 09:57:03 +00:00
xzFantom eb75cf0818 Translated using Weblate (Belarusian)
Currently translated at 91.3% (584 of 639 strings)

Co-authored-by: xzFantom <xzfantom@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/
Translation: Tusky/Tusky
2024-03-27 09:57:03 +00:00
Zongle Wang f029b7f84d
Migrate LiveData to Flow (#4337) 2024-03-27 11:34:17 +01:00
Zongle Wang a3d87de8ac
Don't use mutable state flows in UI (#4336) 2024-03-27 11:17:42 +01:00
Konrad Pozniak c7a1ddd589
fix crash when instance info fails to load (#4335)
Steps to reproduce: Cold start the app while being logged in and
offline.
2024-03-26 18:25:34 +01:00
Zongle Wang 83cbbe9ada
Retrofit 2.10.0 (#4330)
https://github.com/square/retrofit/releases/tag/2.10.0
2024-03-19 08:32:14 +01:00
Deleted User 010a3ed5fb Translated using Weblate (German)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Deleted User <noreply+314@weblate.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/de/
Translation: Tusky/Tusky
2024-03-18 04:45:01 +00:00
fin-w 08f1525b6e Translated using Weblate (Welsh)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: fin-w <fin-w@tutanota.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-03-18 04:45:00 +00:00
Ihor Hordiichuk fa43d7738f Translated using Weblate (Ukrainian)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/
Translation: Tusky/Tusky
2024-03-18 04:45:00 +00:00
Sveinn í Felli d516c6e3a1 Translated using Weblate (Icelandic)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/
Translation: Tusky/Tusky
2024-03-18 04:45:00 +00:00
fin-w fd78cc7355 Translated using Weblate (Welsh)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: fin-w <puffinux@tutanota.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-03-18 04:45:00 +00:00
fin-w 594b89408f Translated using Weblate (Welsh)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: fin-w <puffinux@tutanota.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-03-13 06:33:19 +00:00
Gera, Zoltan 55e763a34b Translated using Weblate (Hungarian)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Gera, Zoltan <gerazo@manioka.hu>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/
Translation: Tusky/Tusky
2024-03-13 06:33:19 +00:00
cuithon 6d7a66a441
chore: fix typo (#4321) 2024-03-12 08:50:55 +01:00
Konrad Pozniak 0b87ba2031
prevent media visibility from changing when refreshing timelines (#4319)
classic operator precendence issue

closes #4317
2024-03-11 17:18:43 +01:00
Hồ Nhất Duy 23dd0d447c Translated using Weblate (Vietnamese)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/
Translation: Tusky/Tusky
2024-03-10 04:45:01 +00:00
fin-w b05965923d Translated using Weblate (Welsh)
Currently translated at 100.0% (639 of 639 strings)

Co-authored-by: fin-w <puf@users.noreply.weblate.tusky.app>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-03-10 04:45:01 +00:00
Willow fbb22799dc
Machine translation of posts (#4307) 2024-03-09 16:12:18 +01:00
Ümit Solmaz 071ae0bed2 Translated using Weblate (Turkish)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-03-09 09:28:37 +00:00
Konrad Pozniak be8b7c3a31
improve MainActivity / LoginActivity transitions (#4301)
I overlooked those in https://github.com/tuskyapp/Tusky/pull/4224
2024-03-09 11:04:29 +01:00
Christophe Beyls 9901376d38
Move ExoPlayer initialization to a Dagger module and optimize its dependencies (#4296)
Currently, ExoPlayer is initialized explicitly in `ViewMediaFragment`
with all its dependencies, including many that are not useful for
viewing Mastodon media attachments.

This pull request moves most ExoPlayer initialization and configuration
to a new Dagger module, and instead a `Provider<ExoPlayer>` factory is
injected in the Fragment so it can create new instances when needed.

The following ExoPlayer components will be configured:

- **Renderers**: all of them (audio, video, metadata, subtitles) except
for the `CameraMotionRenderer`.
- **Extractors**: FLAC, Wav, Mp4, Ogg, Matroska/WebM and MP3 containers,
to provide the same support as Firefox or Chrome browsers. Other
container formats that are either image formats (already covered by
Glide), not web-friendly or reserved for live streaming are skipped.
- **MediaSource**: only progressive download (through OkHttp) is
provided. Live streaming support using protocols like RTSP, MPEG/Dash or
HLS is skipped, because Mastodon servers don't use these protocols to
download attachments.

The Mastodon documentation mentions the [supported media formats for
attachments](https://docs.joinmastodon.org/user/posting/#media) and this
covers them and even more. The docs also mentions that the video and
audio files are transcoded to MP4 and MP3 upon upload but that was not
the case in the past (for example WebM was used) and it could change
again in the future.

Specifying these components manually allows reducing the APK size by
about 200 KB thanks to R8 shrinking.

There are also a few extra code changes:
- Remove the code specific to API < 24 since the min SDK of the app is
now 24.
- Add support for pausing a video when unplugging headphones.
- Specify the audio attributes according to content type to help the
Android audio mixer.
2024-03-09 11:04:04 +01:00
Konrad Pozniak f09a5b00e0
fix boost/reply filters not working correctly in home timelines (#4308)
closes #4306
2024-03-06 13:21:29 +01:00
XoseM 0132b758af Translated using Weblate (Galician)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky
2024-03-06 11:31:48 +00:00
Hồ Nhất Duy c4bc15c04f Translated using Weblate (Vietnamese)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/
Translation: Tusky/Tusky
2024-03-06 11:31:48 +00:00
Ümit Solmaz df75dd61c9 Translated using Weblate (Turkish)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-03-06 11:31:48 +00:00
Konrad Pozniak 7a05530359
put r8 rules for enums back in to fix crash in AccountListActivity (#4299)
Regression from #4291 // cc @cbeyls 

<details>
  <summary>Stacktrace</summary>
  
  ```
Process: com.keylesspalace.tusky, PID: 31230
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.keylesspalace.tusky/com.keylesspalace.tusky.components.accountlist.AccountListActivity}:
java.lang.RuntimeException: java.lang.NoSuchMethodException: h4.a.values
[]
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3635)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
at
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7839)
	at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException:
h4.a.values []
	at java.lang.Enum.enumValues(Enum.java:270)
	at java.lang.Enum.access$000(Enum.java:61)
	at java.lang.Enum$1.create(Enum.java:277)
	at java.lang.Enum$1.create(Enum.java:275)
	at libcore.util.BasicLruCache.get(BasicLruCache.java:63)
	at java.lang.Enum.getSharedConstants(Enum.java:289)
	at java.lang.Enum.valueOf(Enum.java:243)
	at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1841)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1409)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427)
	at android.os.Parcel.readSerializable(Parcel.java:3507)
	at android.os.Parcel.readValue(Parcel.java:3277)
	at android.os.Parcel.readArrayMapInternal(Parcel.java:3623)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
	at android.os.BaseBundle.unparcel(BaseBundle.java:236)
	at android.os.BaseBundle.getSerializable(BaseBundle.java:1268)
	at android.os.Bundle.getSerializable(Bundle.java:1104)
	at android.content.Intent.getSerializableExtra(Intent.java:8575)
at
com.keylesspalace.tusky.components.accountlist.AccountListActivity.onCreate(SourceFile:23)
	at android.app.Activity.performCreate(Activity.java:8051)
	at android.app.Activity.performCreate(Activity.java:8031)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792) 
at
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 
at
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210) 
	at android.os.Handler.dispatchMessage(Handler.java:106) 
	at android.os.Looper.loopOnce(Looper.java:201) 
	at android.os.Looper.loop(Looper.java:288) 
	at android.app.ActivityThread.main(ActivityThread.java:7839) 
	at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
Caused by: java.lang.NoSuchMethodException: h4.a.values []
	at java.lang.Class.getMethod(Class.java:2103)
	at java.lang.Class.getDeclaredMethod(Class.java:2081)
	at java.lang.Enum.enumValues(Enum.java:267)
	at java.lang.Enum.access$000(Enum.java:61) 
	at java.lang.Enum$1.create(Enum.java:277) 
	at java.lang.Enum$1.create(Enum.java:275) 
	at libcore.util.BasicLruCache.get(BasicLruCache.java:63) 
	at java.lang.Enum.getSharedConstants(Enum.java:289) 
	at java.lang.Enum.valueOf(Enum.java:243) 
	at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1841) 
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1409) 
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:427) 
	at android.os.Parcel.readSerializable(Parcel.java:3507) 
	at android.os.Parcel.readValue(Parcel.java:3277) 
	at android.os.Parcel.readArrayMapInternal(Parcel.java:3623) 
at
android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292) 
	at android.os.BaseBundle.unparcel(BaseBundle.java:236) 
	at android.os.BaseBundle.getSerializable(BaseBundle.java:1268) 
	at android.os.Bundle.getSerializable(Bundle.java:1104) 
	at android.content.Intent.getSerializableExtra(Intent.java:8575) 
at
com.keylesspalace.tusky.components.accountlist.AccountListActivity.onCreate(SourceFile:23) 
	at android.app.Activity.performCreate(Activity.java:8051) 
	at android.app.Activity.performCreate(Activity.java:8031) 
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) 
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608) 
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792) 
at
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 
at
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210) 
	at android.os.Handler.dispatchMessage(Handler.java:106) 
	at android.os.Looper.loopOnce(Looper.java:201) 
	at android.os.Looper.loop(Looper.java:288) 
	at android.app.ActivityThread.main(ActivityThread.java:7839) 
	at java.lang.reflect.Method.invoke(Native Method) 
at
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
  ```
</details>

closes #4297
2024-03-04 06:54:09 +01:00
Sveinn í Felli 9084116305 Translated using Weblate (Icelandic)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/
Translation: Tusky/Tusky
2024-03-01 06:32:34 +00:00
Luna Jernberg f083c463a0 Translated using Weblate (Swedish)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Luna Jernberg <droidbittin@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/sv/
Translation: Tusky/Tusky
2024-03-01 06:32:34 +00:00
Ihor Hordiichuk b1ac7e587d Translated using Weblate (Ukrainian)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/
Translation: Tusky/Tusky
2024-03-01 06:32:34 +00:00
XoseM 4aa1980033 Translated using Weblate (Galician)
Currently translated at 99.6% (632 of 634 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky
2024-03-01 06:32:34 +00:00
fin-w 21e97faf78 Translated using Weblate (Welsh)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: fin-w <puf@users.noreply.weblate.tusky.app>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-03-01 06:32:34 +00:00
Christophe Beyls 722b75e5c2
Optimize Proguard rules (#4291)
Using saner defaults for R8 while reducing the app size even further.
- Add Kotlin compiler options to skip adding assertions in release
builds
- Remove `optimizations`, `optimizationpasses` and `dontpreverify` rules
that are ignored by R8
- Only keep runtime annotations by default. If other attributes are
needed by a specific library, these will already be provided by the
library rules (for example Retrofit or coroutines)
- Remove the obsolete rule allowing a View to reflectively call any
arbitrary public Activity method accepting a View as argument. This has
always been a bad practice and is not used in this project anyway
- Remove the rules related to enums. R8 already optimizes enums properly
out-of-the-box and keeping these rules may prevent some of these
optimizations
- Add support for the `@Keep` annotation. Even if it's not currently
used in the code base, it can be handy in the future
- Add a missing rule to prevent generic signature of `NetworkResult`
class from being removed in `MastodonApi` so Retrofit works
- Allow obfuscation and shrinking of `kotlin.coroutines.Continuation`,
matching the rule defined in the next release of Retrofit
- Remove the rule forcing the removal of `String.format()`. This method
is actually used in the code (and in third-party libraries) for other
things than logging so forcing its removal can do more harm than good.
2024-02-29 15:29:05 +01:00
Christophe Beyls 40fde54e0b
Replace RxJava3 code with coroutines (#4290)
This pull request removes the remaining RxJava code and replaces it with
coroutine-equivalent implementations.

- Remove all duplicate methods in `MastodonApi`:
- Methods returning a RxJava `Single` have been replaced by suspending
methods returning a `NetworkResult` in order to be consistent with the
new code.
- _sync_/_async_ method variants are replaced with the _async_ version
only (suspending method), and `runBlocking{}` is used to make the async
variant synchronous.
- Create a custom coroutine-based implementation of `Single` for usage
in Java code where launching a coroutine is not possible. This class can
be deleted after remaining Java code has been converted to Kotlin.
- `NotificationsFragment.java` can subscribe to `EventHub` events by
calling the new lifecycle-aware `EventHub.subscribe()` method. This
allows using the `SharedFlow` as single source of truth for all events.
- Rx Autodispose is replaced by `lifecycleScope.launch()` which will
automatically cancel the coroutine when the Fragment view/Activity is
destroyed.
- Background work is launched in the existing injectable
`externalScope`, since using `GlobalScope` is discouraged.
`externalScope` has been changed to be a `@Singleton` and to use the
main dispatcher by default.
- Transform `ShareShortcutHelper` to an injectable utility class so it
can use the application `Context` and `externalScope` as provided
dependencies to launch a background coroutine.
- Implement a custom Glide extension method
`RequestBuilder.submitAsync()` to do the same thing as
`RequestBuilder.submit().get()` in a non-blocking way. This way there is
no need to switch to a background dispatcher and block a background
thread, and cancellation is supported out-of-the-box.
- An utility method `Fragment.updateRelativeTimePeriodically()` has been
added to remove duplicate logic in `TimelineFragment` and
`NotificationsFragment`, and the logic is now implemented using a simple
coroutine instead of `Observable.interval()`. Note that the periodic
update now happens between onStart and onStop instead of between
onResume and onPause, since the Fragment is not interactive but is still
visible in the started state.
- Rewrite `BottomSheetActivityTest` using coroutines tests.
- Remove all RxJava library dependencies.
2024-02-29 15:28:48 +01:00
Konrad Pozniak 7448fd2416
change SendStatusService type to shortService (#4292)
This way the `FOREGROUND_SERVICE_REMOTE_MESSAGING` permission is not
needed and we should be able to publish on Google Play again. Drawback:
The service can get killed after a while (usually 3 mins) on Android 14.
I also tried using [user initiated data transfer
jobs](https://developer.android.com/about/versions/14/changes/user-initiated-data-transfers),
but that is not available on all api levels, and `WorkManager`, but that
is a huge refactoring and sending would probably work differently than
before.
2024-02-29 12:21:15 +01:00
Konrad Pozniak 6249b53718
Fix some warnings & recreate lint-baseline.xml (#4278) 2024-02-25 16:20:26 +01:00
Willow c666a6b534
Better screen transitions (#4285)
I mostly took Android 13 transitions and removed the sliding for the
"deeper"/background one because "extend" animations are not available
until Android 13.

Here are the original ones:
https://cs.android.com/android/platform/superproject/+/android-13.0.0_r8:frameworks/base/core/res/res/anim/;bpv=1

Initially I've made separate versions fro Android 13+ that are close to
the original but I think it's not worth it to keep both.



https://github.com/tuskyapp/Tusky/assets/3099142/616fc40c-f944-45b4-bf6f-167f62d30493
2024-02-25 16:20:15 +01:00
Christophe Beyls a19540f0e4
Simplify and reduce overhead of lazy view binding in Fragments (#4269)
This reduces complexity of view binding inflation in Fragments, and also
reduces overhead (no `KProperty` objects need to be generated by the
compiler) by implementing `Lazy` instead of `ReadOnlyProperty`.

For a full explanation, see this [detailed blog
post](https://medium.com/@bladecoder/viewlifecyclelazy-and-other-ways-to-avoid-view-memory-leaks-in-android-fragments-4aa982e6e579).
2024-02-23 20:10:33 +01:00
Konrad Pozniak 7dca2fed58
fix sending posts on Api 34 (#4274)
```
java.lang.RuntimeException: Unable to start service com.keylesspalace.tusky.service.SendStatusService@1eb9198 with Intent { cmp=com.keylesspalace.tusky.test/com.keylesspalace.tusky.service.SendStatusService (has extras) }: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{18608f7 22134:com.keylesspalace.tusky.test/u0a193} targetSDK=34
           at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4839)
           at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
           at android.os.Handler.dispatchMessage(Handler.java:106)
           at android.os.Looper.loopOnce(Looper.java:205)
           at android.os.Looper.loop(Looper.java:294)
           at android.app.ActivityThread.main(ActivityThread.java:8177)
           at java.lang.reflect.Method.invoke(Native Method)
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
          Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{18608f7 22134:com.keylesspalace.tusky.test/u0a193} targetSDK=34
           at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
           at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
           at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
           at android.os.Parcel.readParcelable(Parcel.java:4852)
           at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
           at android.os.Parcel.createException(Parcel.java:3041)
           at android.os.Parcel.readException(Parcel.java:3024)
           at android.os.Parcel.readException(Parcel.java:2966)
           at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
           at android.app.Service.startForeground(Service.java:775)
           at com.keylesspalace.tusky.service.SendStatusService.onStartCommand(SendStatusService.kt:137)
           at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4821)
           at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289) 
           at android.os.Handler.dispatchMessage(Handler.java:106) 
           at android.os.Looper.loopOnce(Looper.java:205) 
           at android.os.Looper.loop(Looper.java:294) 
           at android.app.ActivityThread.main(ActivityThread.java:8177) 
           at java.lang.reflect.Method.invoke(Native Method) 
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
```
2024-02-23 16:50:33 +01:00
Weblate 0dec496ccb Update translation files
Updated by "Cleanup translation files" hook in Weblate.

Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/
Translation: Tusky/Tusky
2024-02-23 13:22:59 +00:00
Zongle Wang 88c75c8d9b
Room 2.6.1 with Kotlin code generation (#4081)
https://developer.android.com/jetpack/androidx/releases/room#2.6.0
2024-02-23 12:21:31 +01:00
Konrad Pozniak b976fe5296
full sdk 34 support (#4224)
builds upon work from #4082 

Additionally fixes some deprecations and adds support for [predictive
back](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture).
I also refactored how the activity transitions work because they are
closely related to predictive back. The awkward
`finishWithoutSlideOutAnimation` is gone, activities that have been
started with slide in will now automatically close with slide out.

To test predictive back you need an emulator or device with Sdk 34
(Android 14) and then enable it in the developer settings.

Predictive back requires the back action to be determined before it
actually occurs so the system can play the right predictive animation,
which made a few reorganisations necessary.

closes #4082 
closes #4005 
unlocks a bunch of dependency upgrades that require sdk 34

---------

Co-authored-by: Goooler <wangzongler@gmail.com>
2024-02-23 10:27:19 +01:00
Konrad Pozniak fa8bede7d6
fix compose notification action not recreating MainActivity (#4249)
closes #4247
2024-02-23 10:27:07 +01:00
Konrad Pozniak 7d3aafdd65
fix quick replies from notifications (#4250)
While working on #4249 I noticed that quick replies also don't work as
expected. The notification just stays in the sending state forever.
There are actually 2 problems:
- Notifications are sent in `NotificationFetcher` with the id of the
Mastodon notification as tag and the current account id as id. The wrong
notification id was forwarded to `SendStatusBroadcastReceiver` so it
never had a chance of updating the notification.
- Notifications containing an active remote input can't be cancelled
(they just stop their animation when doing so). So instead I update the
notification with info that the reply is being sent and have it dismiss
automatically.

I also tried replacing the original notification with the "sending"
notification of `SendStatusService`, but that doesn't work because
`Service.startForeground` doesn't have a tag parameter, only an id.

---------

Co-authored-by: Willow <charlag@tuta.io>
2024-02-23 10:26:46 +01:00
Willow 22ec78c75a
Improve detailed status looks (#4260)
#4205 did change how the counters for the detailed posts behave and for
a good reason I believe.

However I find the changed order very confusing and not aesthetically
pleasing.

I have tried a few options, including reserving space for it but it was
confusing (when counters are not displayed there would be a danging
separator or if we show separator together with it it would be confusing
as well).

I propose we simply show the counters independent on the counts. I know
we try to de-emphasize the counters but I believe this is fine to do in
detailed view.

One disadvantage is that we need translators to update the translations.

Additionally I've done two spacing changes: I removed a separator
between the counters and the buttons, removed padding around the
counters and increased the space between the counters and the buttons
instead. I believe it's better to use space than separators. This also
makes the space above/below the media/counters separator balanced.

In the second commit I've also made the metadata/counters separators
thinner, I think it looks better.

here's the combined version:


![proposal_final](https://github.com/tuskyapp/Tusky/assets/3099142/ea9d4c0c-fe6a-4f2e-8427-673b2a833e6b)
2024-02-23 10:25:05 +01:00
Salif Mehmed 4e43feb9dc Translated using Weblate (Bulgarian)
Currently translated at 86.4% (548 of 634 strings)

Co-authored-by: Salif Mehmed <mail@salif.eu>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/bg/
Translation: Tusky/Tusky
2024-02-21 04:45:01 +00:00
Rhoslyn Prys 2c13805d84 Translated using Weblate (Welsh)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Rhoslyn Prys <post@meddal.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-02-21 04:45:01 +00:00
Levi Bard 6994693496
Move the statistics bar in the detailed view below the button bar (#4205)
Rationale: In the current layout, when performing multiple interactions
(e.g. fav+boost, fav+reply) on a post that hasn't been interacted with
before, the statistics bar appears and pushes the buttons down, so the
second tap goes to the statistics bar instead
2024-02-20 10:17:13 +01:00
Konrad Pozniak 7173d5e1e7
make badge for new direct messages blue (#4257)
This makes the dot badge that we show on the direct messages tab when
there are unread messages blue instead of red. I prefer it that way
because its more subtle and doesn't look like there is some kind of
error.

before / after:

<img
src="https://github.com/tuskyapp/Tusky/assets/10157047/f4b241a5-0fa4-4134-9790-18f74caa2dae"
width="240"/> <img
src="https://github.com/tuskyapp/Tusky/assets/10157047/56788d5c-f19c-4fa5-b83e-e824aed995f4"
width="240"/>
2024-02-19 09:22:14 +01:00
Konrad Pozniak 1cd8b497f7
set greenDebug as default flavor (#4251)
I had it happen multiple times recently that I was testing green Tusky
but Android Studio actually put blue Tusky on my device and I wasted a
lot of time until I found out 😣
This change should tell it that greenDebug is the preferred flavor for
developing.
2024-02-17 15:15:19 +01:00
Konrad Pozniak 17e99bbc2e
Revert "Migrate to Hilt KSP compiler (#4136)" (#4246)
This reverts commit 6494247301.

Seems like dagger/ksp is still a bit buggy, I'm getting one of these
errors every other build, so lets revert this for now.

https://github.com/google/dagger/issues/4181
https://github.com/google/ksp/issues/1196
2024-02-10 10:42:31 +01:00
Ihor Hordiichuk e2c2db1d31 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/
Translation: Tusky/Tusky
2024-02-04 04:45:01 +00:00
Hồ Nhất Duy dbe82fe1b0 Translated using Weblate (Vietnamese)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/
Translation: Tusky/Tusky
2024-02-04 04:45:01 +00:00
Ümit Solmaz b826ca15a9 Translated using Weblate (Turkish)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: Ümit Solmaz <usnotv@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/tr/
Translation: Tusky/Tusky
2024-02-04 04:45:01 +00:00
fin-w 61de55efa7 Translated using Weblate (Welsh)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: fin-w <puf@users.noreply.weblate.tusky.app>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/cy/
Translation: Tusky/Tusky
2024-02-04 04:45:00 +00:00
XoseM c9d29fa92f Translated using Weblate (Galician)
Currently translated at 100.0% (634 of 634 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky
2024-02-04 04:45:00 +00:00
Konrad Pozniak 7fef19efc6
Revert "make timestamp abbreviations plurals (#4202)" (#4230)
This reverts commit 5174c00558.

closes #4145
2024-01-28 19:48:35 +01:00
ButterflyOfFire 5ae6611072 Translated using Weblate (French)
Currently translated at 93.5% (592 of 633 strings)

Translated using Weblate (Arabic)

Currently translated at 91.4% (579 of 633 strings)

Co-authored-by: ButterflyOfFire <butterflyoffire@protonmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ar/
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/fr/
Translation: Tusky/Tusky
2024-01-28 17:35:57 +00:00
Konrad Pozniak d66866648e
improve null safety of instance info (#4226)
according to crash logs there are seem to be some instances that don't
always return the expected json, so lets be extra safe here

```
Exception java.lang.NullPointerException:
  at com.keylesspalace.tusky.components.instanceinfo.InstanceInfoRepository$getInstanceInfo$2.invokeSuspend (InstanceInfoRepository.kt:67)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:108)
  at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run (LimitedDispatcher.java:115)
  at kotlinx.coroutines.scheduling.TaskImpl.run (Tasks.kt:103)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.java:584)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:793)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:697)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:684)
```
2024-01-28 19:08:44 +01:00
Konrad Pozniak 0c2b8b114b
make sure link preview card is not shown when cw is collapsed (#4218)
The sensitive flag indicates sensitive media, but we want to check if
there is a contentwarning on the post. I think statuses that have a
contentwarning but no sensitive flag are rare so we never noticed this
bug.

closes #4201
2024-01-28 19:07:51 +01:00
Konrad Pozniak 0b9f61c100
bring back the notification filter preference (#4225)
It was probably forgotten when we restored the old notifications
behavior.
closes #4222
2024-01-28 19:07:29 +01:00
Konrad Pozniak 750e255029
fix check that ensures only one bookmark tab is added (#4217)
closes #4214
2024-01-28 19:07:17 +01:00
XoseM 88dbc8de12 Translated using Weblate (Galician)
Currently translated at 100.0% (633 of 633 strings)

Co-authored-by: XoseM <xosem@disroot.org>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/gl/
Translation: Tusky/Tusky
2024-01-17 04:45:01 +00:00
Sveinn í Felli 5b04a0e8e1 Translated using Weblate (Icelandic)
Currently translated at 100.0% (633 of 633 strings)

Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/
Translation: Tusky/Tusky
2024-01-17 04:45:01 +00:00
Hồ Nhất Duy 9005e6525c Translated using Weblate (Vietnamese)
Currently translated at 100.0% (633 of 633 strings)

Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/
Translation: Tusky/Tusky
2024-01-17 04:45:01 +00:00
Bruno Miguel 6f22072d0e Translated using Weblate (Portuguese (Portugal))
Currently translated at 100.0% (633 of 633 strings)

Co-authored-by: Bruno Miguel <brunoalexandremiguel@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/pt_PT/
Translation: Tusky/Tusky
2024-01-17 04:45:01 +00:00
João Alves 8df7a58679 Translated using Weblate (Portuguese (Portugal))
Currently translated at 100.0% (633 of 633 strings)

Co-authored-by: João Alves <joao.2003.couto+weblate@gmail.com>
Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/pt_PT/
Translation: Tusky/Tusky
2024-01-17 04:45:01 +00:00