Commit Graph

10 Commits

Author SHA1 Message Date
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
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 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 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
Konrad Pozniak d839f18267
update ktlint plugin to 11.3.1, format code (#3442) 2023-03-13 13:16:39 +01:00
Konrad Pozniak 16ffcca748
add ktlint plugin to project and apply default code style (#2209)
* add ktlint plugin to project and apply default code style

* some manual adjustments, fix wildcard imports

* update CONTRIBUTING.md

* fix formatting
2021-06-28 21:13:24 +02:00
Konrad Pozniak 40b24cd242
migrate to RxJava3 (#2146)
* migrate to RxJava3

* remove unused import
2021-05-16 19:53:27 +02:00
Konrad Pozniak b280e25727
use AndroidX WorkManager instead of Evernote Android Job (#1783)
* use AndroidX WorkManager instead of Evernote Android Job

* move notification related classes to their own package

* fix missing import
2020-05-12 18:46:49 +02:00
Konrad Pozniak d6ec5ca8d3
fix crashes related to missing Rx error handler (#1561) 2019-11-17 20:59:13 +01:00
Konrad Pozniak 78b5aa8baf
Upgrade api level to Android 10, implement new sharing api (#1537)
* upgrade api level to Android 10, resolve compile errors

* use androidx.preference.PreferenceManager instead of deprecated platform class

* add hyphenation to important TextViews

*  setBottomSheetCallback -> addBottomSheetCallback

* implement new sharing api

* improve TuskyTileService so it shows account picker when multiple accounts are present

* delete unused AccountChooserService

* fix test

* improve ShareShortcutHelper

* remove debug log statement

* improve image loading fallback behavior in ShareShortcutHelper

* improve behavior on foldable devices
2019-10-22 21:18:20 +02:00