diff --git a/app/build.gradle b/app/build.gradle index f801f16085..31706a7996 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,6 +48,7 @@ android { minifyEnabled true shrinkResources true proguardFiles 'proguard-rules.pro' + signingConfig signingConfigs.debug kotlinOptions { freeCompilerArgs = [ @@ -145,7 +146,6 @@ dependencies { implementation libs.gson implementation libs.bundles.retrofit - implementation libs.networkresult.calladapter implementation libs.bundles.okhttp diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6be2265e05..41278375eb 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -61,14 +61,8 @@ -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken -# Retain generic signatures of classes used in MastodonApi so Retrofit works --keep,allowobfuscation,allowshrinking class retrofit2.Response --keep,allowobfuscation,allowshrinking class kotlin.collections.List --keep,allowobfuscation,allowshrinking class kotlin.collections.Map --keep,allowobfuscation,allowshrinking class retrofit2.Call - -# https://github.com/square/retrofit/pull/3563 --keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation +# TODO: Remove this after https://github.com/square/retrofit/pull/4018 is merged. +-keep,allowobfuscation,allowshrinking class kotlin.Result # preserve line numbers for crash reporting -keepattributes SourceFile,LineNumberTable diff --git a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt index 73c87cf2e8..37d5792699 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt @@ -23,7 +23,6 @@ import android.widget.LinearLayout import android.widget.Toast import androidx.annotation.VisibleForTesting import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.bottomsheet.BottomSheetBehavior import com.keylesspalace.tusky.components.account.AccountActivity import com.keylesspalace.tusky.components.viewthread.ViewThreadActivity diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index fa37839c3b..3b9edbe09b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -55,7 +55,6 @@ import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.lifecycleScope import androidx.preference.PreferenceManager import androidx.viewpager2.widget.MarginPageTransformer -import at.connyduck.calladapter.networkresult.fold import com.bumptech.glide.Glide import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.request.target.CustomTarget diff --git a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt index c844f22568..e3afd86d17 100644 --- a/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/StatusListActivity.kt @@ -23,7 +23,6 @@ import android.view.Menu import android.view.MenuItem import androidx.fragment.app.commit import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.PreferenceChangedEvent diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt index 0bd622b9e5..86e94b2fb1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/AccountViewModel.kt @@ -4,7 +4,6 @@ import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.BlockEvent import com.keylesspalace.tusky.appstore.DomainMuteEvent import com.keylesspalace.tusky.appstore.EventHub diff --git a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt index 5113b9fe06..f7af2a89e6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/account/list/ListsForAccountViewModel.kt @@ -18,10 +18,6 @@ package com.keylesspalace.tusky.components.account.list import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.getOrThrow -import at.connyduck.calladapter.networkresult.onFailure -import at.connyduck.calladapter.networkresult.onSuccess -import at.connyduck.calladapter.networkresult.runCatching import com.keylesspalace.tusky.entity.MastoList import com.keylesspalace.tusky.network.MastodonApi import javax.inject.Inject diff --git a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt index 729933114a..ffc6829c2e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/accountlist/AccountListFragment.kt @@ -26,7 +26,6 @@ import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.SimpleItemAnimator -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.BottomSheetActivity import com.keylesspalace.tusky.PostLookupFallbackBehavior diff --git a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt index 9fad312ebc..4b649f9718 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/announcements/AnnouncementsViewModel.kt @@ -20,7 +20,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.AnnouncementReadEvent import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.components.instanceinfo.InstanceInfoRepository diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt index 3c64e43b70..0c2530314f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt @@ -20,7 +20,6 @@ import android.util.Log import androidx.core.net.toUri import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeKind import com.keylesspalace.tusky.components.compose.ComposeActivity.QueuedMedia import com.keylesspalace.tusky.components.compose.ComposeAutoCompleteAdapter.AutocompleteResult diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt index c4cd2a6f74..fba37fe95f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsViewModel.kt @@ -23,7 +23,6 @@ import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn import androidx.paging.map -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.db.AppDatabase import com.keylesspalace.tusky.network.MastodonApi diff --git a/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksRepository.kt index bdc9b9367f..930afa50ae 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksRepository.kt @@ -22,8 +22,6 @@ import androidx.paging.InvalidatingPagingSourceFactory import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingSource -import at.connyduck.calladapter.networkresult.NetworkResult -import at.connyduck.calladapter.networkresult.onSuccess import com.keylesspalace.tusky.network.MastodonApi import javax.inject.Inject @@ -49,14 +47,14 @@ class DomainBlocksRepository @Inject constructor( factory.invalidate() } - suspend fun block(domain: String): NetworkResult { + suspend fun block(domain: String): Result { return api.blockDomain(domain).onSuccess { domains.add(domain) factory.invalidate() } } - suspend fun unblock(domain: String): NetworkResult { + suspend fun unblock(domain: String): Result { return api.unblockDomain(domain).onSuccess { domains.remove(domain) factory.invalidate() diff --git a/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksViewModel.kt index 04f4f426d1..5f763f4d11 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/domainblocks/DomainBlocksViewModel.kt @@ -5,8 +5,6 @@ import androidx.annotation.StringRes import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import androidx.paging.cachedIn -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.onFailure import com.keylesspalace.tusky.R import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt index 1db7982c6d..0c6e343397 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsActivity.kt @@ -25,7 +25,6 @@ import androidx.activity.viewModels import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.BaseActivity diff --git a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt index 813a424faa..82d3920043 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/drafts/DraftsViewModel.kt @@ -20,7 +20,6 @@ import androidx.lifecycle.viewModelScope import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn -import at.connyduck.calladapter.networkresult.NetworkResult import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.db.AppDatabase import com.keylesspalace.tusky.db.DraftEntity @@ -64,7 +63,7 @@ class DraftsViewModel @Inject constructor( } } - suspend fun getStatus(statusId: String): NetworkResult { + suspend fun getStatus(statusId: String): Result { return api.status(statusId) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt index 709e2c5f76..38e27e5f7b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterActivity.kt @@ -12,7 +12,6 @@ import androidx.core.content.IntentCompat import androidx.core.view.size import androidx.core.widget.doAfterTextChanged import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.chip.Chip import com.google.android.material.snackbar.Snackbar import com.google.android.material.switchmaterial.SwitchMaterial diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt index f98d983afc..9524a59663 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/EditFilterViewModel.kt @@ -3,7 +3,6 @@ package com.keylesspalace.tusky.components.filters import android.content.Context import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.entity.Filter import com.keylesspalace.tusky.entity.FilterKeyword diff --git a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt index 315af81db7..0e1cc4d8aa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/filters/FiltersViewModel.kt @@ -3,7 +3,6 @@ package com.keylesspalace.tusky.components.filters import android.view.View import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.PreferenceChangedEvent diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt index 82a17265d5..3bd485d2da 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsActivity.kt @@ -15,7 +15,6 @@ import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.SimpleItemAnimator -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.R diff --git a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt index f3376c13b7..9a5b2a2c7a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/followedtags/FollowedTagsViewModel.kt @@ -7,7 +7,6 @@ import androidx.paging.ExperimentalPagingApi import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.components.compose.ComposeAutoCompleteAdapter import com.keylesspalace.tusky.components.search.SearchType import com.keylesspalace.tusky.di.Injectable diff --git a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt index b0bbff827a..337df54362 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/instanceinfo/InstanceInfoRepository.kt @@ -16,9 +16,6 @@ package com.keylesspalace.tusky.components.instanceinfo import android.util.Log -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.getOrElse -import at.connyduck.calladapter.networkresult.onSuccess import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.db.AppDatabase import com.keylesspalace.tusky.db.EmojisEntity diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt index 1cdadd20e0..cd412a8deb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginActivity.kt @@ -27,7 +27,6 @@ import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.core.net.toUri import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.fold import com.bumptech.glide.Glide import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.BuildConfig diff --git a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt index 01aa34288f..152325d36a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/login/LoginWebViewViewModel.kt @@ -18,7 +18,6 @@ package com.keylesspalace.tusky.components.login import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.util.isHttpNotFound import javax.inject.Inject diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt index c89823e6d4..7221f68d1e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/PushNotificationHelper.kt @@ -24,8 +24,6 @@ import android.util.Log import android.view.View import androidx.appcompat.app.AlertDialog import androidx.preference.PreferenceManager -import at.connyduck.calladapter.networkresult.onFailure -import at.connyduck.calladapter.networkresult.onSuccess import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.R import com.keylesspalace.tusky.components.login.LoginActivity diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt index 96b169c3fb..9cbbea9a90 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/ReportViewModel.kt @@ -23,7 +23,6 @@ import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn import androidx.paging.map -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.BlockEvent import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.MuteEvent diff --git a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt index 9b9238ed52..440c07a4e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/report/adapter/StatusesPagingSource.kt @@ -18,7 +18,6 @@ package com.keylesspalace.tusky.components.report.adapter import android.util.Log import androidx.paging.PagingSource import androidx.paging.PagingState -import at.connyduck.calladapter.networkresult.getOrThrow import com.keylesspalace.tusky.entity.Status import com.keylesspalace.tusky.network.MastodonApi import kotlinx.coroutines.async diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt index 57535b810c..6fe578a111 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusPagingSource.kt @@ -18,7 +18,6 @@ package com.keylesspalace.tusky.components.scheduled import android.util.Log import androidx.paging.PagingSource import androidx.paging.PagingState -import at.connyduck.calladapter.networkresult.getOrThrow import com.keylesspalace.tusky.entity.ScheduledStatus import com.keylesspalace.tusky.network.MastodonApi diff --git a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt index 821364b9e9..a2914288f5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledStatusViewModel.kt @@ -21,7 +21,6 @@ import androidx.lifecycle.viewModelScope import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.entity.ScheduledStatus import com.keylesspalace.tusky.network.MastodonApi diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt index 1dd8d85a64..27ef56b653 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt @@ -21,9 +21,6 @@ import androidx.lifecycle.viewModelScope import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn -import at.connyduck.calladapter.networkresult.NetworkResult -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.onFailure import com.keylesspalace.tusky.components.search.adapter.SearchPagingSourceFactory import com.keylesspalace.tusky.db.AccountEntity import com.keylesspalace.tusky.db.AccountManager @@ -180,7 +177,7 @@ class SearchViewModel @Inject constructor( } } - fun deleteStatusAsync(id: String): Deferred> { + fun deleteStatusAsync(id: String): Deferred> { return viewModelScope.async { timelineCases.delete(id) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt index d91f929af1..75b21f1f7b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/adapter/SearchPagingSource.kt @@ -17,7 +17,6 @@ package com.keylesspalace.tusky.components.search.adapter import androidx.paging.PagingSource import androidx.paging.PagingState -import at.connyduck.calladapter.networkresult.getOrThrow import com.keylesspalace.tusky.components.search.SearchType import com.keylesspalace.tusky.entity.SearchResult import com.keylesspalace.tusky.network.MastodonApi diff --git a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt index 24f3065de6..101f2656aa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt @@ -38,7 +38,6 @@ import androidx.paging.PagingDataAdapter import androidx.preference.PreferenceManager import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager -import at.connyduck.calladapter.networkresult.fold import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.R diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt index d27c6e6bae..d3a6d15327 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/viewmodel/TimelineViewModel.kt @@ -20,9 +20,6 @@ import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import androidx.paging.PagingData -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.getOrElse -import at.connyduck.calladapter.networkresult.getOrThrow import com.keylesspalace.tusky.appstore.BlockEvent import com.keylesspalace.tusky.appstore.DomainMuteEvent import com.keylesspalace.tusky.appstore.Event diff --git a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt index 5a7ad9232e..ff06f6ce64 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/trending/viewmodel/TrendingTagsViewModel.kt @@ -18,7 +18,6 @@ package com.keylesspalace.tusky.components.trending.viewmodel import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.PreferenceChangedEvent import com.keylesspalace.tusky.entity.Filter diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt index a5607f354c..c34b30fa80 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt @@ -18,9 +18,6 @@ package com.keylesspalace.tusky.components.viewthread import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.getOrElse -import at.connyduck.calladapter.networkresult.getOrThrow import com.google.gson.Gson import com.keylesspalace.tusky.appstore.BlockEvent import com.keylesspalace.tusky.appstore.EventHub diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt index 5f5258c83c..50ce78e105 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/edits/ViewEditsViewModel.kt @@ -17,7 +17,6 @@ package com.keylesspalace.tusky.components.viewthread.edits import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.getOrElse import com.keylesspalace.tusky.components.viewthread.edits.EditsTagHandler.Companion.DELETED_TEXT_EL import com.keylesspalace.tusky.components.viewthread.edits.EditsTagHandler.Companion.INSERTED_TEXT_EL import com.keylesspalace.tusky.entity.StatusEdit diff --git a/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt index 3fdc802335..47944ac585 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/NetworkModule.kt @@ -19,7 +19,6 @@ import android.content.Context import android.content.SharedPreferences import android.os.Build import android.util.Log -import at.connyduck.calladapter.networkresult.NetworkResultCallAdapterFactory import com.google.gson.Gson import com.google.gson.GsonBuilder import com.keylesspalace.tusky.BuildConfig @@ -45,6 +44,7 @@ import okhttp3.Cache import okhttp3.OkHttp import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.ResultCallAdapterFactory import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.create @@ -117,7 +117,7 @@ class NetworkModule { return Retrofit.Builder().baseUrl("https://" + MastodonApi.PLACEHOLDER_DOMAIN) .client(httpClient) .addConverterFactory(GsonConverterFactory.create(gson)) - .addCallAdapterFactory(NetworkResultCallAdapterFactory.create()) + .addCallAdapterFactory(ResultCallAdapterFactory.create()) .build() } diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt index 8072a684a4..8257fc86b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.kt @@ -34,8 +34,6 @@ import androidx.appcompat.widget.PopupMenu import androidx.core.app.ActivityOptionsCompat import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.onFailure import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.BaseActivity import com.keylesspalace.tusky.BottomSheetActivity diff --git a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt index 51e3d983de..145af09e06 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt +++ b/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt @@ -15,7 +15,6 @@ package com.keylesspalace.tusky.network -import at.connyduck.calladapter.networkresult.NetworkResult import com.keylesspalace.tusky.entity.AccessToken import com.keylesspalace.tusky.entity.Account import com.keylesspalace.tusky.entity.Announcement @@ -81,24 +80,24 @@ interface MastodonApi { } @GET("/api/v1/custom_emojis") - suspend fun getCustomEmojis(): NetworkResult> + suspend fun getCustomEmojis(): Result> @GET("api/v1/instance") suspend fun getInstanceV1( @Header(DOMAIN_HEADER) domain: String? = null - ): NetworkResult + ): Result @GET("api/v2/instance") - suspend fun getInstance(): NetworkResult + suspend fun getInstance(): Result @GET("api/v1/filters") - suspend fun getFiltersV1(): NetworkResult> + suspend fun getFiltersV1(): Result> @GET("api/v2/filters/{filterId}") - suspend fun getFilter(@Path("filterId") filterId: String): NetworkResult + suspend fun getFilter(@Path("filterId") filterId: String): Result @GET("api/v2/filters") - suspend fun getFilters(): NetworkResult> + suspend fun getFilters(): Result> @GET("api/v1/timelines/home") @Throws(Exception::class) @@ -165,7 +164,7 @@ interface MastodonApi { @Header(DOMAIN_HEADER) domain: String, @Field("home[last_read_id]") homeLastReadId: String? = null, @Field("notifications[last_read_id]") notificationsLastReadId: String? = null - ): NetworkResult + ): Result @GET("api/v1/notifications") suspend fun notificationsWithAuth( @@ -176,7 +175,7 @@ interface MastodonApi { ): Response> @POST("api/v1/notifications/clear") - suspend fun clearNotifications(): NetworkResult + suspend fun clearNotifications(): Result @FormUrlEncoded @PUT("api/v1/media/{mediaId}") @@ -184,7 +183,7 @@ interface MastodonApi { @Path("mediaId") mediaId: String, @Field("description") description: String?, @Field("focus") focus: String? - ): NetworkResult + ): Result @GET("api/v1/media/{mediaId}") suspend fun getMedia(@Path("mediaId") mediaId: String): Response @@ -195,10 +194,10 @@ interface MastodonApi { @Header(DOMAIN_HEADER) domain: String, @Header("Idempotency-Key") idempotencyKey: String, @Body status: NewStatus - ): NetworkResult + ): Result @GET("api/v1/statuses/{id}") - suspend fun status(@Path("id") statusId: String): NetworkResult + suspend fun status(@Path("id") statusId: String): Result @PUT("api/v1/statuses/{id}") suspend fun editStatus( @@ -207,16 +206,16 @@ interface MastodonApi { @Header(DOMAIN_HEADER) domain: String, @Header("Idempotency-Key") idempotencyKey: String, @Body editedStatus: NewStatus - ): NetworkResult + ): Result @GET("api/v1/statuses/{id}/source") - suspend fun statusSource(@Path("id") statusId: String): NetworkResult + suspend fun statusSource(@Path("id") statusId: String): Result @GET("api/v1/statuses/{id}/context") - suspend fun statusContext(@Path("id") statusId: String): NetworkResult + suspend fun statusContext(@Path("id") statusId: String): Result @GET("api/v1/statuses/{id}/history") - suspend fun statusEdits(@Path("id") statusId: String): NetworkResult> + suspend fun statusEdits(@Path("id") statusId: String): Result> @GET("api/v1/statuses/{id}/reblogged_by") suspend fun statusRebloggedBy( @@ -231,54 +230,54 @@ interface MastodonApi { ): Response> @DELETE("api/v1/statuses/{id}") - suspend fun deleteStatus(@Path("id") statusId: String): NetworkResult + suspend fun deleteStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/reblog") - suspend fun reblogStatus(@Path("id") statusId: String): NetworkResult + suspend fun reblogStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/unreblog") - suspend fun unreblogStatus(@Path("id") statusId: String): NetworkResult + suspend fun unreblogStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/favourite") - suspend fun favouriteStatus(@Path("id") statusId: String): NetworkResult + suspend fun favouriteStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/unfavourite") - suspend fun unfavouriteStatus(@Path("id") statusId: String): NetworkResult + suspend fun unfavouriteStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/bookmark") - suspend fun bookmarkStatus(@Path("id") statusId: String): NetworkResult + suspend fun bookmarkStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/unbookmark") - suspend fun unbookmarkStatus(@Path("id") statusId: String): NetworkResult + suspend fun unbookmarkStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/pin") - suspend fun pinStatus(@Path("id") statusId: String): NetworkResult + suspend fun pinStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/unpin") - suspend fun unpinStatus(@Path("id") statusId: String): NetworkResult + suspend fun unpinStatus(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/mute") - suspend fun muteConversation(@Path("id") statusId: String): NetworkResult + suspend fun muteConversation(@Path("id") statusId: String): Result @POST("api/v1/statuses/{id}/unmute") - suspend fun unmuteConversation(@Path("id") statusId: String): NetworkResult + suspend fun unmuteConversation(@Path("id") statusId: String): Result @GET("api/v1/scheduled_statuses") suspend fun scheduledStatuses( @Query("limit") limit: Int? = null, @Query("max_id") maxId: String? = null - ): NetworkResult> + ): Result> @DELETE("api/v1/scheduled_statuses/{id}") suspend fun deleteScheduledStatus( @Path("id") scheduledStatusId: String - ): NetworkResult + ): Result @GET("api/v1/accounts/verify_credentials") suspend fun accountVerifyCredentials( @Header(DOMAIN_HEADER) domain: String? = null, @Header("Authorization") auth: String? = null - ): NetworkResult + ): Result @FormUrlEncoded @PATCH("api/v1/accounts/update_credentials") @@ -304,7 +303,7 @@ interface MastodonApi { @Part(value = "fields_attributes[2][value]") fieldValue2: RequestBody?, @Part(value = "fields_attributes[3][name]") fieldName3: RequestBody?, @Part(value = "fields_attributes[3][value]") fieldValue3: RequestBody? - ): NetworkResult + ): Result @GET("api/v1/accounts/search") suspend fun searchAccounts( @@ -312,10 +311,10 @@ interface MastodonApi { @Query("resolve") resolve: Boolean? = null, @Query("limit") limit: Int? = null, @Query("following") following: Boolean? = null - ): NetworkResult> + ): Result> @GET("api/v1/accounts/{id}") - suspend fun account(@Path("id") accountId: String): NetworkResult + suspend fun account(@Path("id") accountId: String): Result /** * Method to fetch statuses for the specified account. @@ -355,16 +354,16 @@ interface MastodonApi { @Path("id") accountId: String, @Field("reblogs") showReblogs: Boolean? = null, @Field("notify") notify: Boolean? = null - ): NetworkResult + ): Result @POST("api/v1/accounts/{id}/unfollow") - suspend fun unfollowAccount(@Path("id") accountId: String): NetworkResult + suspend fun unfollowAccount(@Path("id") accountId: String): Result @POST("api/v1/accounts/{id}/block") - suspend fun blockAccount(@Path("id") accountId: String): NetworkResult + suspend fun blockAccount(@Path("id") accountId: String): Result @POST("api/v1/accounts/{id}/unblock") - suspend fun unblockAccount(@Path("id") accountId: String): NetworkResult + suspend fun unblockAccount(@Path("id") accountId: String): Result @FormUrlEncoded @POST("api/v1/accounts/{id}/mute") @@ -372,21 +371,21 @@ interface MastodonApi { @Path("id") accountId: String, @Field("notifications") notifications: Boolean? = null, @Field("duration") duration: Int? = null - ): NetworkResult + ): Result @POST("api/v1/accounts/{id}/unmute") - suspend fun unmuteAccount(@Path("id") accountId: String): NetworkResult + suspend fun unmuteAccount(@Path("id") accountId: String): Result @GET("api/v1/accounts/relationships") suspend fun relationships( @Query("id[]") accountIds: List - ): NetworkResult> + ): Result> @POST("api/v1/pleroma/accounts/{id}/subscribe") - suspend fun subscribeAccount(@Path("id") accountId: String): NetworkResult + suspend fun subscribeAccount(@Path("id") accountId: String): Result @POST("api/v1/pleroma/accounts/{id}/unsubscribe") - suspend fun unsubscribeAccount(@Path("id") accountId: String): NetworkResult + suspend fun unsubscribeAccount(@Path("id") accountId: String): Result @GET("api/v1/blocks") suspend fun blocks(@Query("max_id") maxId: String?): Response> @@ -403,12 +402,12 @@ interface MastodonApi { @FormUrlEncoded @POST("api/v1/domain_blocks") - suspend fun blockDomain(@Field("domain") domain: String): NetworkResult + suspend fun blockDomain(@Field("domain") domain: String): Result @FormUrlEncoded // @DELETE doesn't support fields @HTTP(method = "DELETE", path = "api/v1/domain_blocks", hasBody = true) - suspend fun unblockDomain(@Field("domain") domain: String): NetworkResult + suspend fun unblockDomain(@Field("domain") domain: String): Result @GET("api/v1/favourites") suspend fun favourites( @@ -428,10 +427,10 @@ interface MastodonApi { suspend fun followRequests(@Query("max_id") maxId: String?): Response> @POST("api/v1/follow_requests/{id}/authorize") - suspend fun authorizeFollowRequest(@Path("id") accountId: String): NetworkResult + suspend fun authorizeFollowRequest(@Path("id") accountId: String): Result @POST("api/v1/follow_requests/{id}/reject") - suspend fun rejectFollowRequest(@Path("id") accountId: String): NetworkResult + suspend fun rejectFollowRequest(@Path("id") accountId: String): Result @FormUrlEncoded @POST("api/v1/apps") @@ -441,7 +440,7 @@ interface MastodonApi { @Field("redirect_uris") redirectUris: String, @Field("scopes") scopes: String, @Field("website") website: String - ): NetworkResult + ): Result @FormUrlEncoded @POST("oauth/token") @@ -452,7 +451,7 @@ interface MastodonApi { @Field("redirect_uri") redirectUri: String, @Field("code") code: String, @Field("grant_type") grantType: String - ): NetworkResult + ): Result @FormUrlEncoded @POST("oauth/revoke") @@ -460,15 +459,15 @@ interface MastodonApi { @Field("client_id") clientId: String, @Field("client_secret") clientSecret: String, @Field("token") token: String - ): NetworkResult + ): Result @GET("/api/v1/lists") - suspend fun getLists(): NetworkResult> + suspend fun getLists(): Result> @GET("/api/v1/accounts/{id}/lists") suspend fun getListsIncludesAccount( @Path("id") accountId: String - ): NetworkResult> + ): Result> @FormUrlEncoded @POST("api/v1/lists") @@ -476,7 +475,7 @@ interface MastodonApi { @Field("title") title: String, @Field("exclusive") exclusive: Boolean?, @Field("replies_policy") replyPolicy: String - ): NetworkResult + ): Result @FormUrlEncoded @PUT("api/v1/lists/{listId}") @@ -485,16 +484,16 @@ interface MastodonApi { @Field("title") title: String, @Field("exclusive") exclusive: Boolean?, @Field("replies_policy") replyPolicy: String - ): NetworkResult + ): Result @DELETE("api/v1/lists/{listId}") - suspend fun deleteList(@Path("listId") listId: String): NetworkResult + suspend fun deleteList(@Path("listId") listId: String): Result @GET("api/v1/lists/{listId}/accounts") suspend fun getAccountsInList( @Path("listId") listId: String, @Query("limit") limit: Int - ): NetworkResult> + ): Result> @FormUrlEncoded // @DELETE doesn't support fields @@ -502,14 +501,14 @@ interface MastodonApi { suspend fun deleteAccountFromList( @Path("listId") listId: String, @Field("account_ids[]") accountIds: List - ): NetworkResult + ): Result @FormUrlEncoded @POST("api/v1/lists/{listId}/accounts") suspend fun addAccountToList( @Path("listId") listId: String, @Field("account_ids[]") accountIds: List - ): NetworkResult + ): Result @GET("/api/v1/conversations") suspend fun getConversations( @@ -528,7 +527,7 @@ interface MastodonApi { @Field("irreversible") irreversible: Boolean?, @Field("whole_word") wholeWord: Boolean?, @Field("expires_in") expiresInSeconds: Int? - ): NetworkResult + ): Result @FormUrlEncoded @PUT("api/v1/filters/{id}") @@ -539,10 +538,10 @@ interface MastodonApi { @Field("irreversible") irreversible: Boolean?, @Field("whole_word") wholeWord: Boolean?, @Field("expires_in") expiresInSeconds: Int? - ): NetworkResult + ): Result @DELETE("api/v1/filters/{id}") - suspend fun deleteFilterV1(@Path("id") id: String): NetworkResult + suspend fun deleteFilterV1(@Path("id") id: String): Result @FormUrlEncoded @POST("api/v2/filters") @@ -551,7 +550,7 @@ interface MastodonApi { @Field("context[]") context: List, @Field("filter_action") filterAction: String, @Field("expires_in") expiresInSeconds: Int? - ): NetworkResult + ): Result @FormUrlEncoded @PUT("api/v2/filters/{id}") @@ -561,10 +560,10 @@ interface MastodonApi { @Field("context[]") context: List? = null, @Field("filter_action") filterAction: String? = null, @Field("expires_in") expiresInSeconds: Int? = null - ): NetworkResult + ): Result @DELETE("api/v2/filters/{id}") - suspend fun deleteFilter(@Path("id") id: String): NetworkResult + suspend fun deleteFilter(@Path("id") id: String): Result @FormUrlEncoded @POST("api/v2/filters/{filterId}/keywords") @@ -572,7 +571,7 @@ interface MastodonApi { @Path("filterId") filterId: String, @Field("keyword") keyword: String, @Field("whole_word") wholeWord: Boolean - ): NetworkResult + ): Result @FormUrlEncoded @PUT("api/v2/filters/keywords/{keywordId}") @@ -580,39 +579,39 @@ interface MastodonApi { @Path("keywordId") keywordId: String, @Field("keyword") keyword: String, @Field("whole_word") wholeWord: Boolean - ): NetworkResult + ): Result @DELETE("api/v2/filters/keywords/{keywordId}") suspend fun deleteFilterKeyword( @Path("keywordId") keywordId: String - ): NetworkResult + ): Result @FormUrlEncoded @POST("api/v1/polls/{id}/votes") suspend fun voteInPoll( @Path("id") id: String, @Field("choices[]") choices: List - ): NetworkResult + ): Result @GET("api/v1/announcements") suspend fun listAnnouncements( @Query("with_dismissed") withDismissed: Boolean = true - ): NetworkResult> + ): Result> @POST("api/v1/announcements/{id}/dismiss") - suspend fun dismissAnnouncement(@Path("id") announcementId: String): NetworkResult + suspend fun dismissAnnouncement(@Path("id") announcementId: String): Result @PUT("api/v1/announcements/{id}/reactions/{name}") suspend fun addAnnouncementReaction( @Path("id") announcementId: String, @Path("name") name: String - ): NetworkResult + ): Result @DELETE("api/v1/announcements/{id}/reactions/{name}") suspend fun removeAnnouncementReaction( @Path("id") announcementId: String, @Path("name") name: String - ): NetworkResult + ): Result @FormUrlEncoded @POST("api/v1/reports") @@ -621,7 +620,7 @@ interface MastodonApi { @Field("status_ids[]") statusIds: List, @Field("comment") comment: String, @Field("forward") isNotifyRemote: Boolean? - ): NetworkResult + ): Result @GET("api/v1/accounts/{id}/statuses") suspend fun accountStatuses( @@ -631,7 +630,7 @@ interface MastodonApi { @Query("min_id") minId: String?, @Query("limit") limit: Int?, @Query("exclude_reblogs") excludeReblogs: Boolean? - ): NetworkResult> + ): Result> @GET("api/v2/search") suspend fun search( @@ -641,14 +640,14 @@ interface MastodonApi { @Query("limit") limit: Int? = null, @Query("offset") offset: Int? = null, @Query("following") following: Boolean? = null - ): NetworkResult + ): Result @FormUrlEncoded @POST("api/v1/accounts/{id}/note") suspend fun updateAccountNote( @Path("id") accountId: String, @Field("comment") note: String - ): NetworkResult + ): Result @FormUrlEncoded @POST("api/v1/push/subscription") @@ -662,7 +661,7 @@ interface MastodonApi { // Should be generated dynamically from all the available notification // types defined in [com.keylesspalace.tusky.entities.Notification.Types] @FieldMap data: Map - ): NetworkResult + ): Result @FormUrlEncoded @PUT("api/v1/push/subscription") @@ -670,16 +669,16 @@ interface MastodonApi { @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String, @FieldMap data: Map - ): NetworkResult + ): Result @DELETE("api/v1/push/subscription") suspend fun unsubscribePushNotifications( @Header("Authorization") auth: String, @Header(DOMAIN_HEADER) domain: String - ): NetworkResult + ): Result @GET("api/v1/tags/{name}") - suspend fun tag(@Path("name") name: String): NetworkResult + suspend fun tag(@Path("name") name: String): Result @GET("api/v1/followed_tags") suspend fun followedTags( @@ -690,13 +689,13 @@ interface MastodonApi { ): Response> @POST("api/v1/tags/{name}/follow") - suspend fun followTag(@Path("name") name: String): NetworkResult + suspend fun followTag(@Path("name") name: String): Result @POST("api/v1/tags/{name}/unfollow") - suspend fun unfollowTag(@Path("name") name: String): NetworkResult + suspend fun unfollowTag(@Path("name") name: String): Result @GET("api/v1/trends/tags") - suspend fun trendingTags(): NetworkResult> + suspend fun trendingTags(): Result> @GET("api/v1/trends/statuses") suspend fun trendingStatuses( diff --git a/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt b/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt index e68e7b3420..f224d0e00e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/service/SendStatusService.kt @@ -32,7 +32,6 @@ import androidx.annotation.StringRes import androidx.core.app.NotificationCompat import androidx.core.app.ServiceCompat import androidx.core.content.IntentCompat -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.MainActivity import com.keylesspalace.tusky.R import com.keylesspalace.tusky.appstore.EventHub diff --git a/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt b/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt index acb60b7a5b..23915bddd4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt +++ b/app/src/main/java/com/keylesspalace/tusky/usecase/TimelineCases.kt @@ -16,11 +16,6 @@ package com.keylesspalace.tusky.usecase import android.util.Log -import at.connyduck.calladapter.networkresult.NetworkResult -import at.connyduck.calladapter.networkresult.fold -import at.connyduck.calladapter.networkresult.onFailure -import at.connyduck.calladapter.networkresult.onSuccess -import at.connyduck.calladapter.networkresult.runCatching import com.keylesspalace.tusky.appstore.BlockEvent import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.MuteConversationEvent @@ -49,7 +44,7 @@ class TimelineCases @Inject constructor( private val eventHub: EventHub ) { - suspend fun reblog(statusId: String, reblog: Boolean): NetworkResult { + suspend fun reblog(statusId: String, reblog: Boolean): Result { return if (reblog) { mastodonApi.reblogStatus(statusId) } else { @@ -69,7 +64,7 @@ class TimelineCases @Inject constructor( return Single { reblog(statusId, reblog) } } - suspend fun favourite(statusId: String, favourite: Boolean): NetworkResult { + suspend fun favourite(statusId: String, favourite: Boolean): Result { return if (favourite) { mastodonApi.favouriteStatus(statusId) } else { @@ -83,7 +78,7 @@ class TimelineCases @Inject constructor( return Single { favourite(statusId, favourite) } } - suspend fun bookmark(statusId: String, bookmark: Boolean): NetworkResult { + suspend fun bookmark(statusId: String, bookmark: Boolean): Result { return if (bookmark) { mastodonApi.bookmarkStatus(statusId) } else { @@ -97,7 +92,7 @@ class TimelineCases @Inject constructor( return Single { bookmark(statusId, bookmark) } } - suspend fun muteConversation(statusId: String, mute: Boolean): NetworkResult { + suspend fun muteConversation(statusId: String, mute: Boolean): Result { return if (mute) { mastodonApi.muteConversation(statusId) } else { @@ -125,23 +120,23 @@ class TimelineCases @Inject constructor( } } - suspend fun delete(statusId: String): NetworkResult { + suspend fun delete(statusId: String): Result { return mastodonApi.deleteStatus(statusId) .onSuccess { eventHub.dispatch(StatusDeletedEvent(statusId)) } .onFailure { Log.w(TAG, "Failed to delete status", it) } } - suspend fun pin(statusId: String, pin: Boolean): NetworkResult { + suspend fun pin(statusId: String, pin: Boolean): Result { return if (pin) { mastodonApi.pinStatus(statusId) } else { mastodonApi.unpinStatus(statusId) }.fold({ status -> eventHub.dispatch(StatusChangedEvent(status)) - NetworkResult.success(status) + Result.success(status) }, { e -> Log.w(TAG, "Failed to change pin state", e) - NetworkResult.failure(TimelineError(e.getServerErrorMessage())) + Result.failure(TimelineError(e.getServerErrorMessage())) }) } @@ -149,9 +144,9 @@ class TimelineCases @Inject constructor( statusId: String, pollId: String, choices: List - ): NetworkResult { + ): Result { if (choices.isEmpty()) { - return NetworkResult.failure(IllegalStateException()) + return Result.failure(IllegalStateException()) } return mastodonApi.voteInPoll(pollId, choices).onSuccess { poll -> diff --git a/app/src/main/java/com/keylesspalace/tusky/util/Single.kt b/app/src/main/java/com/keylesspalace/tusky/util/Single.kt index d77bdb5a7f..412dc6e843 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/Single.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/Single.kt @@ -2,8 +2,6 @@ package com.keylesspalace.tusky.util import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope -import at.connyduck.calladapter.networkresult.NetworkResult -import at.connyduck.calladapter.networkresult.fold import java.util.function.Consumer import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -13,7 +11,7 @@ import kotlinx.coroutines.launch * Simple reimplementation of RxJava's Single using a Kotlin coroutine, * intended to be consumed by legacy Java code only. */ -class Single(private val producer: suspend CoroutineScope.() -> NetworkResult) { +class Single(private val producer: suspend CoroutineScope.() -> Result) { fun subscribe( owner: LifecycleOwner, onSuccess: Consumer, diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt index 4765bd849c..87c56e4c04 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/AccountsInListViewModel.kt @@ -19,7 +19,6 @@ package com.keylesspalace.tusky.viewmodel import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.entity.TimelineAccount import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.util.Either diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt index 9c74a3d85f..f2f142e0fc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt @@ -21,7 +21,6 @@ import androidx.core.net.toUri import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.ProfileEditedEvent import com.keylesspalace.tusky.components.instanceinfo.InstanceInfo diff --git a/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt index 500500328a..0183e87f55 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/viewmodel/ListsViewModel.kt @@ -18,7 +18,6 @@ package com.keylesspalace.tusky.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import at.connyduck.calladapter.networkresult.fold import com.keylesspalace.tusky.entity.MastoList import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.util.replacedFirstWhich diff --git a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt index 19a013d570..7e70810c1e 100644 --- a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt @@ -16,7 +16,6 @@ package com.keylesspalace.tusky import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import at.connyduck.calladapter.networkresult.NetworkResult import com.keylesspalace.tusky.entity.SearchResult import com.keylesspalace.tusky.entity.Status import com.keylesspalace.tusky.entity.TimelineAccount @@ -52,7 +51,7 @@ class BottomSheetActivityTest { private val statusQuery = "http://mastodon.foo.bar/@User/345678" private val nonexistentStatusQuery = "http://mastodon.foo.bar/@User/345678000" private val nonMastodonQuery = "http://medium.com/@correspondent/345678" - private val emptyResult = NetworkResult.success(SearchResult(emptyList(), emptyList(), emptyList())) + private val emptyResult = Result.success(SearchResult(emptyList(), emptyList(), emptyList())) private val account = TimelineAccount( id = "1", @@ -63,7 +62,7 @@ class BottomSheetActivityTest { url = "http://mastodon.foo.bar/@User", avatar = "" ) - private val accountResult = NetworkResult.success(SearchResult(listOf(account), emptyList(), emptyList())) + private val accountResult = Result.success(SearchResult(listOf(account), emptyList(), emptyList())) private val status = Status( id = "1", @@ -96,7 +95,7 @@ class BottomSheetActivityTest { language = null, filtered = null ) - private val statusResult = NetworkResult.success(SearchResult(emptyList(), listOf(status), emptyList())) + private val statusResult = Result.success(SearchResult(emptyList(), listOf(status), emptyList())) @Before fun setup() { diff --git a/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt index 6770e08d63..90bad9d58a 100644 --- a/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/MainActivityTest.kt @@ -8,7 +8,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import androidx.viewpager2.widget.ViewPager2 import androidx.work.testing.WorkManagerTestInitHelper -import at.connyduck.calladapter.networkresult.NetworkResult import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.components.accountlist.AccountListActivity import com.keylesspalace.tusky.components.notifications.NotificationHelper @@ -130,8 +129,8 @@ class MainActivityTest { activity.shareShortcutHelper = mock {} activity.externalScope = TestScope() activity.mastodonApi = mock { - onBlocking { accountVerifyCredentials() } doReturn NetworkResult.success(account) - onBlocking { listAnnouncements(false) } doReturn NetworkResult.success(emptyList()) + onBlocking { accountVerifyCredentials() } doReturn Result.success(account) + onBlocking { listAnnouncements(false) } doReturn Result.success(emptyList()) } controller.create().start() return activity diff --git a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivityTest.kt index c331e7dd97..3efefebf34 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/compose/ComposeActivityTest.kt @@ -21,7 +21,6 @@ import android.content.Intent import android.os.Looper.getMainLooper import android.widget.EditText import androidx.test.ext.junit.runners.AndroidJUnit4 -import at.connyduck.calladapter.networkresult.NetworkResult import com.google.gson.Gson import com.keylesspalace.tusky.R import com.keylesspalace.tusky.components.instanceinfo.InstanceInfoRepository @@ -106,19 +105,19 @@ class ComposeActivityTest { } apiMock = mock { - onBlocking { getCustomEmojis() } doReturn NetworkResult.success(emptyList()) + onBlocking { getCustomEmojis() } doReturn Result.success(emptyList()) onBlocking { getInstance() } doReturn instanceResponseCallback?.invoke().let { instance -> if (instance == null) { - NetworkResult.failure(HttpException(Response.error(404, "Not found".toResponseBody()))) + Result.failure(HttpException(Response.error(404, "Not found".toResponseBody()))) } else { - NetworkResult.success(instance) + Result.success(instance) } } onBlocking { getInstanceV1() } doReturn instanceV1ResponseCallback?.invoke().let { instance -> if (instance == null) { - NetworkResult.failure(Throwable()) + Result.failure(Throwable()) } else { - NetworkResult.success(instance) + Result.success(instance) } } } diff --git a/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt b/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt index 55b57b3b56..3634cfcd64 100644 --- a/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModelTest.kt @@ -5,7 +5,6 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.room.Room import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry -import at.connyduck.calladapter.networkresult.NetworkResult import com.google.gson.Gson import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.StatusChangedEvent @@ -131,8 +130,8 @@ class ViewThreadViewModelTest { @Test fun `should emit status even if context fails to load`() { api.stub { - onBlocking { status(threadId) } doReturn NetworkResult.success(mockStatus(id = "2", inReplyToId = "1", inReplyToAccountId = "1")) - onBlocking { statusContext(threadId) } doReturn NetworkResult.failure(IOException()) + onBlocking { status(threadId) } doReturn Result.success(mockStatus(id = "2", inReplyToId = "1", inReplyToAccountId = "1")) + onBlocking { statusContext(threadId) } doReturn Result.failure(IOException()) } viewModel.loadThread(threadId) @@ -154,8 +153,8 @@ class ViewThreadViewModelTest { @Test fun `should emit error when status and context fail to load`() { api.stub { - onBlocking { status(threadId) } doReturn NetworkResult.failure(IOException()) - onBlocking { statusContext(threadId) } doReturn NetworkResult.failure(IOException()) + onBlocking { status(threadId) } doReturn Result.failure(IOException()) + onBlocking { statusContext(threadId) } doReturn Result.failure(IOException()) } viewModel.loadThread(threadId) @@ -171,8 +170,8 @@ class ViewThreadViewModelTest { @Test fun `should emit error when status fails to load`() { api.stub { - onBlocking { status(threadId) } doReturn NetworkResult.failure(IOException()) - onBlocking { statusContext(threadId) } doReturn NetworkResult.success( + onBlocking { status(threadId) } doReturn Result.failure(IOException()) + onBlocking { statusContext(threadId) } doReturn Result.success( StatusContext( ancestors = listOf(mockStatus(id = "1")), descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1")) @@ -343,8 +342,8 @@ class ViewThreadViewModelTest { private fun mockSuccessResponses() { api.stub { - onBlocking { status(threadId) } doReturn NetworkResult.success(mockStatus(id = "2", inReplyToId = "1", inReplyToAccountId = "1", spoilerText = "Test")) - onBlocking { statusContext(threadId) } doReturn NetworkResult.success( + onBlocking { status(threadId) } doReturn Result.success(mockStatus(id = "2", inReplyToId = "1", inReplyToAccountId = "1", spoilerText = "Test")) + onBlocking { statusContext(threadId) } doReturn Result.success( StatusContext( ancestors = listOf(mockStatus(id = "1", spoilerText = "Test")), descendants = listOf(mockStatus(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")) diff --git a/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt b/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt index 988cd6e441..62ba0e0442 100644 --- a/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/usecase/TimelineCasesTest.kt @@ -2,7 +2,6 @@ package com.keylesspalace.tusky.usecase import androidx.test.ext.junit.runners.AndroidJUnit4 import app.cash.turbine.test -import at.connyduck.calladapter.networkresult.NetworkResult import com.keylesspalace.tusky.appstore.EventHub import com.keylesspalace.tusky.appstore.StatusChangedEvent import com.keylesspalace.tusky.entity.Status @@ -43,7 +42,7 @@ class TimelineCasesTest { val pinnedStatus = mockStatus(pinned = true) api.stub { - onBlocking { pinStatus(statusId) } doReturn NetworkResult.success(pinnedStatus) + onBlocking { pinStatus(statusId) } doReturn Result.success(pinnedStatus) } runBlocking { @@ -57,7 +56,7 @@ class TimelineCasesTest { @Test fun `pin failure with server error throws TimelineError with server message`() { api.stub { - onBlocking { pinStatus(statusId) } doReturn NetworkResult.failure( + onBlocking { pinStatus(statusId) } doReturn Result.failure( HttpException( Response.error( 422, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23e0c568a9..cffdf7a83b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,16 +33,15 @@ glide = "4.16.0" # Deliberate downgrade, https://github.com/tuskyapp/Tusky/issues/3631 glide-animation-plugin = "2.23.0" gson = "2.10.1" -kotlin = "1.9.22" +kotlin = "2.0.0-Beta4" image-cropper = "4.3.2" material = "1.11.0" material-drawer = "8.4.5" material-typeface = "4.0.0.2-kotlin" mockito-inline = "5.2.0" mockito-kotlin = "5.2.1" -networkresult-calladapter = "1.1.0" okhttp = "4.12.0" -retrofit = "2.9.0" +retrofit = "2.10.0" robolectric = "4.11.1" sparkbutton = "4.2.0" touchimageview = "3.6" @@ -53,7 +52,7 @@ xmlwriter = "1.0.4" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } -google-ksp = "com.google.devtools.ksp:1.9.22-1.0.17" +google-ksp = "com.google.devtools.ksp:2.0.0-Beta4-1.0.17" kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } @@ -123,11 +122,10 @@ material-typeface = { module = "com.mikepenz:google-material-typeface", version. mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito-inline" } mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" } -networkresult-calladapter = { module = "at.connyduck:networkresult-calladapter", version.ref = "networkresult-calladapter" } okhttp-core = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } -retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } -retrofit-core = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit-converter-gson = { module = "io.github.goooler.retrofit2:converter-gson", version.ref = "retrofit" } +retrofit-core = { module = "io.github.goooler.retrofit2:retrofit", version.ref = "retrofit" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } sparkbutton = { module = "at.connyduck.sparkbutton:sparkbutton", version.ref = "sparkbutton" } touchimageview = { module = "com.github.MikeOrtiz:TouchImageView", version.ref = "touchimageview" }