From e4a065ca9fa3c6fdc05160090050f0d25de3b3c8 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 10 Jun 2024 16:08:48 +0200 Subject: [PATCH] refactor: Move ServerRepository to core.data (#728) --- app/src/main/java/app/pachli/TimelineActivity.kt | 2 +- .../preference/AccountPreferencesFragment.kt | 2 +- .../components/timeline/FiltersRepository.kt | 2 +- .../main/java/app/pachli/fragment/SFragment.kt | 2 +- .../util/StatusDisplayOptionsRepository.kt | 2 +- app/src/main/res/values-es/strings.xml | 8 +------- app/src/main/res/values-fi/strings.xml | 8 +------- app/src/main/res/values-nl/strings.xml | 6 ------ app/src/main/res/values-sv/strings.xml | 6 ------ app/src/main/res/values/strings.xml | 6 ------ .../NotificationsViewModelTestBase.kt | 2 +- .../core/data/repository}/ServerRepository.kt | 16 ++++++++-------- core/data/src/main/res/values-es/strings.xml | 9 +++++++++ core/data/src/main/res/values-fi/strings.xml | 9 +++++++++ core/data/src/main/res/values-nl/strings.xml | 9 +++++++++ core/data/src/main/res/values-sv/strings.xml | 9 +++++++++ core/data/src/main/res/values/strings.xml | 9 +++++++++ 17 files changed, 61 insertions(+), 46 deletions(-) rename {app/src/main/java/app/pachli/network => core/data/src/main/kotlin/app/pachli/core/data/repository}/ServerRepository.kt (90%) create mode 100644 core/data/src/main/res/values-es/strings.xml create mode 100644 core/data/src/main/res/values-fi/strings.xml create mode 100644 core/data/src/main/res/values-nl/strings.xml create mode 100644 core/data/src/main/res/values-sv/strings.xml create mode 100644 core/data/src/main/res/values/strings.xml diff --git a/app/src/main/java/app/pachli/TimelineActivity.kt b/app/src/main/java/app/pachli/TimelineActivity.kt index f92d5b120..309adf6d0 100644 --- a/app/src/main/java/app/pachli/TimelineActivity.kt +++ b/app/src/main/java/app/pachli/TimelineActivity.kt @@ -31,6 +31,7 @@ import app.pachli.appstore.MainTabsChangedEvent import app.pachli.core.activity.BottomSheetActivity import app.pachli.core.common.extensions.viewBinding import app.pachli.core.common.util.unsafeLazy +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.model.Timeline import app.pachli.core.navigation.TimelineActivityIntent import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_CLIENT @@ -41,7 +42,6 @@ import app.pachli.core.network.model.FilterV1 import app.pachli.databinding.ActivityTimelineBinding import app.pachli.interfaces.ActionButtonActivity import app.pachli.interfaces.AppBarLayoutHost -import app.pachli.network.ServerRepository import at.connyduck.calladapter.networkresult.fold import com.github.michaelbull.result.getOrElse import com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/java/app/pachli/components/preference/AccountPreferencesFragment.kt b/app/src/main/java/app/pachli/components/preference/AccountPreferencesFragment.kt index 9ee83f33b..1784ed8cf 100644 --- a/app/src/main/java/app/pachli/components/preference/AccountPreferencesFragment.kt +++ b/app/src/main/java/app/pachli/components/preference/AccountPreferencesFragment.kt @@ -29,6 +29,7 @@ import app.pachli.core.accounts.AccountManager import app.pachli.core.activity.extensions.TransitionKind import app.pachli.core.activity.extensions.startActivityWithTransition import app.pachli.core.common.util.unsafeLazy +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.designsystem.R as DR import app.pachli.core.navigation.AccountListActivityIntent import app.pachli.core.navigation.FiltersActivityIntent @@ -45,7 +46,6 @@ import app.pachli.core.network.model.Account import app.pachli.core.network.model.Status import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.preferences.PrefKeys -import app.pachli.network.ServerRepository import app.pachli.settings.AccountPreferenceDataStore import app.pachli.settings.listPreference import app.pachli.settings.makePreferenceScreen diff --git a/app/src/main/java/app/pachli/components/timeline/FiltersRepository.kt b/app/src/main/java/app/pachli/components/timeline/FiltersRepository.kt index 6716826a4..9c539e756 100644 --- a/app/src/main/java/app/pachli/components/timeline/FiltersRepository.kt +++ b/app/src/main/java/app/pachli/components/timeline/FiltersRepository.kt @@ -17,12 +17,12 @@ package app.pachli.components.timeline +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_CLIENT import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_SERVER import app.pachli.core.network.model.Filter import app.pachli.core.network.model.FilterV1 import app.pachli.core.network.retrofit.MastodonApi -import app.pachli.network.ServerRepository import at.connyduck.calladapter.networkresult.fold import at.connyduck.calladapter.networkresult.getOrThrow import com.github.michaelbull.result.getOrElse diff --git a/app/src/main/java/app/pachli/fragment/SFragment.kt b/app/src/main/java/app/pachli/fragment/SFragment.kt index 0af1634c8..8e9812a4e 100644 --- a/app/src/main/java/app/pachli/fragment/SFragment.kt +++ b/app/src/main/java/app/pachli/fragment/SFragment.kt @@ -47,6 +47,7 @@ import app.pachli.core.activity.BottomSheetActivity import app.pachli.core.activity.PostLookupFallbackBehavior import app.pachli.core.activity.extensions.startActivityWithDefaultTransition import app.pachli.core.activity.openLink +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.database.model.AccountEntity import app.pachli.core.database.model.TranslationState import app.pachli.core.navigation.AttachmentViewData @@ -62,7 +63,6 @@ import app.pachli.core.network.parseAsMastodonHtml import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.ui.extensions.getErrorString import app.pachli.interfaces.StatusActionListener -import app.pachli.network.ServerRepository import app.pachli.usecase.TimelineCases import app.pachli.view.showMuteAccountDialog import app.pachli.viewdata.IStatusViewData diff --git a/app/src/main/java/app/pachli/util/StatusDisplayOptionsRepository.kt b/app/src/main/java/app/pachli/util/StatusDisplayOptionsRepository.kt index 190fc92c3..055d44d3d 100644 --- a/app/src/main/java/app/pachli/util/StatusDisplayOptionsRepository.kt +++ b/app/src/main/java/app/pachli/util/StatusDisplayOptionsRepository.kt @@ -21,11 +21,11 @@ import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting.Companion.PRIVATE import app.pachli.core.accounts.AccountManager import app.pachli.core.common.di.ApplicationScope +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.database.model.AccountEntity import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_STATUSES_TRANSLATE import app.pachli.core.preferences.PrefKeys import app.pachli.core.preferences.SharedPreferencesRepository -import app.pachli.network.ServerRepository import app.pachli.settings.AccountPreferenceDataStore import com.github.michaelbull.result.onFailure import com.github.michaelbull.result.onSuccess diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index a66fd6e08..17e79b36a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -641,13 +641,7 @@ Deshacer traducción Mantenimiento de caché… Tu servidor no soporta los filtros - /.well-known/nodeinfo no contiene esquemas comprensibles - fallo al obtener nodeinfo %1$s: %2$s - fallo al validar nodeinfo %1$s: %2$s - fallo al obtener /api/v1/instance: %1$s No se pudo obtener la info del servidor %1$s: %2$s - fallo al obtener /.well-known/nodeinfo: %1$s - fallo al analizar las capacidades del servidor: %1$s No se pudo descargar %1$s: %2$d %3$s Buscar actualizaciones ahora No hay actualizaciones disponibles @@ -676,4 +670,4 @@ Por lo menos se necesita una palabra clave o frase Por lo menos se necesita un contexto para el filtro Se necesita el título - \ No newline at end of file + diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index f848b44c2..1f55d2c84 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -624,13 +624,7 @@ (Ei muutosta) Media: %s Palvelimesi ei tue suodattimia - /.well-known/nodeinfo ei sisältänyt ymmärrettäviä kaavoja - solmun tietojen haku osoitteesta %1$s epäonnistui: %2$s - haku /api/v1/instance epäonnistui: %1$s - palvelimen tietojen jäsentely epäonnistui: %1$s Palvelintietoja ei voitu hakea osoitteelle %1$s:%2$s - haku /.well-known/nodeinfo epäonnistui: %1$s - solmun %1$s tietojen validointi epäonnistui: %2$s Etsi päivitystä nyt Seuraava ajoitettu tarkistus: %1$s Ei päivityksiä tarjolla @@ -657,4 +651,4 @@ Tarvitaan vähintään yksi avainsana tai lauseke Tarvitaan vähintään yksi suodatettava asia Otsikko vaaditaan - \ No newline at end of file + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 2ed8847f3..69cc9a06a 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -631,12 +631,6 @@ Cache onderhoud… UI tekst grootte Kon geen server info ophalen voor %1$s: %2$s - ophalen /.well-known/nodeinfo mislukt: %1$s - /.well-known/nodeinfo bevatte geen begrijpbare schemas - ophalen nodeinfo %1$s mislukt: %2$s - valideren van nodeinfo %1$s mislukt: %2$s - ophalen van /api/v1/instance mislukt: %1$s - verwerken van server mogelijkheden mislukt: %1$s Controleer nu op update Er zijn geen updates beschikbaar Volgende geplande controle: %1$s diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 3ff1e4dbc..535f5d539 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -637,11 +637,5 @@ Bild Ångra översättning Kunde inte hämta serverinformation för %1$s: %2$s - misslyckades med att hämta /.well-known/nodeinfo: %1$s - /.well-known/nodeinfo innehöll inte begripliga scheman - hämtning av nodeinfo %1$s misslyckades: %2$s - validering av nodeinfo %1$s misslyckades: %2$s - hämtning av /api/v1/instance misslyckades: %1$s - tolkning av serverfunktioner misslyckades: %1$s Din server stöder inte filter diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 227cb3540..dc5372b18 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -687,12 +687,6 @@ %1$s Could not fetch server info for %1$s: %2$s - fetching /.well-known/nodeinfo failed: %1$s - /.well-known/nodeinfo did not contain understandable schemas - fetching nodeinfo %1$s failed: %2$s - validating nodeinfo %1$s failed: %2$s - fetching /api/v1/instance failed: %1$s - parsing server capabilities failed: %1$s Check for update now There are no updates available Next scheduled check: %1$s diff --git a/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt b/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt index d438ab999..aa954a7f9 100644 --- a/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt +++ b/app/src/test/java/app/pachli/components/notifications/NotificationsViewModelTestBase.kt @@ -22,6 +22,7 @@ import app.pachli.appstore.EventHub import app.pachli.components.timeline.FilterKind import app.pachli.components.timeline.FiltersRepository import app.pachli.core.accounts.AccountManager +import app.pachli.core.data.repository.ServerRepository import app.pachli.core.database.model.AccountEntity import app.pachli.core.network.model.nodeinfo.UnvalidatedJrd import app.pachli.core.network.model.nodeinfo.UnvalidatedNodeInfo @@ -30,7 +31,6 @@ import app.pachli.core.network.retrofit.NodeInfoApi import app.pachli.core.preferences.SharedPreferencesRepository import app.pachli.core.testing.fakes.InMemorySharedPreferences import app.pachli.core.testing.rules.MainCoroutineRule -import app.pachli.network.ServerRepository import app.pachli.settings.AccountPreferenceDataStore import app.pachli.usecase.TimelineCases import app.pachli.util.StatusDisplayOptionsRepository diff --git a/app/src/main/java/app/pachli/network/ServerRepository.kt b/core/data/src/main/kotlin/app/pachli/core/data/repository/ServerRepository.kt similarity index 90% rename from app/src/main/java/app/pachli/network/ServerRepository.kt rename to core/data/src/main/kotlin/app/pachli/core/data/repository/ServerRepository.kt index 2973b9057..498596f76 100644 --- a/app/src/main/java/app/pachli/network/ServerRepository.kt +++ b/core/data/src/main/kotlin/app/pachli/core/data/repository/ServerRepository.kt @@ -15,23 +15,23 @@ * see . */ -package app.pachli.network +package app.pachli.core.data.repository import androidx.annotation.StringRes -import app.pachli.R import app.pachli.core.accounts.AccountManager import app.pachli.core.common.PachliError import app.pachli.core.common.di.ApplicationScope +import app.pachli.core.data.R +import app.pachli.core.data.repository.ServerRepository.Error.Capabilities +import app.pachli.core.data.repository.ServerRepository.Error.GetInstanceInfoV1 +import app.pachli.core.data.repository.ServerRepository.Error.GetNodeInfo +import app.pachli.core.data.repository.ServerRepository.Error.GetWellKnownNodeInfo +import app.pachli.core.data.repository.ServerRepository.Error.UnsupportedSchema +import app.pachli.core.data.repository.ServerRepository.Error.ValidateNodeInfo import app.pachli.core.network.Server import app.pachli.core.network.model.nodeinfo.NodeInfo import app.pachli.core.network.retrofit.MastodonApi import app.pachli.core.network.retrofit.NodeInfoApi -import app.pachli.network.ServerRepository.Error.Capabilities -import app.pachli.network.ServerRepository.Error.GetInstanceInfoV1 -import app.pachli.network.ServerRepository.Error.GetNodeInfo -import app.pachli.network.ServerRepository.Error.GetWellKnownNodeInfo -import app.pachli.network.ServerRepository.Error.UnsupportedSchema -import app.pachli.network.ServerRepository.Error.ValidateNodeInfo import at.connyduck.calladapter.networkresult.fold import com.github.michaelbull.result.Err import com.github.michaelbull.result.Ok diff --git a/core/data/src/main/res/values-es/strings.xml b/core/data/src/main/res/values-es/strings.xml new file mode 100644 index 000000000..263997308 --- /dev/null +++ b/core/data/src/main/res/values-es/strings.xml @@ -0,0 +1,9 @@ + + + fallo al obtener /.well-known/nodeinfo: %1$s + /.well-known/nodeinfo no contiene esquemas comprensibles + fallo al obtener nodeinfo %1$s: %2$s + fallo al validar nodeinfo %1$s: %2$s + fallo al obtener /api/v1/instance: %1$s + fallo al analizar las capacidades del servidor: %1$s + diff --git a/core/data/src/main/res/values-fi/strings.xml b/core/data/src/main/res/values-fi/strings.xml new file mode 100644 index 000000000..201ebe351 --- /dev/null +++ b/core/data/src/main/res/values-fi/strings.xml @@ -0,0 +1,9 @@ + + + haku /.well-known/nodeinfo epäonnistui: %1$s + /.well-known/nodeinfo ei sisältänyt ymmärrettäviä kaavoja + solmun tietojen haku osoitteesta %1$s epäonnistui: %2$s + solmun %1$s tietojen validointi epäonnistui: %2$s + haku /api/v1/instance epäonnistui: %1$s + palvelimen tietojen jäsentely epäonnistui: %1$s + diff --git a/core/data/src/main/res/values-nl/strings.xml b/core/data/src/main/res/values-nl/strings.xml new file mode 100644 index 000000000..3d8835dc5 --- /dev/null +++ b/core/data/src/main/res/values-nl/strings.xml @@ -0,0 +1,9 @@ + + + ophalen /.well-known/nodeinfo mislukt: %1$s + /.well-known/nodeinfo bevatte geen begrijpbare schemas + ophalen nodeinfo %1$s mislukt: %2$s + valideren van nodeinfo %1$s mislukt: %2$s + ophalen van /api/v1/instance mislukt: %1$s + verwerken van server mogelijkheden mislukt: %1$s + diff --git a/core/data/src/main/res/values-sv/strings.xml b/core/data/src/main/res/values-sv/strings.xml new file mode 100644 index 000000000..21cbcc6e1 --- /dev/null +++ b/core/data/src/main/res/values-sv/strings.xml @@ -0,0 +1,9 @@ + + + misslyckades med att hämta /.well-known/nodeinfo: %1$s + /.well-known/nodeinfo innehöll inte begripliga scheman + hämtning av nodeinfo %1$s misslyckades: %2$s + validering av nodeinfo %1$s misslyckades: %2$s + hämtning av /api/v1/instance misslyckades: %1$s + tolkning av serverfunktioner misslyckades: %1$s + diff --git a/core/data/src/main/res/values/strings.xml b/core/data/src/main/res/values/strings.xml new file mode 100644 index 000000000..46487c927 --- /dev/null +++ b/core/data/src/main/res/values/strings.xml @@ -0,0 +1,9 @@ + + + fetching /.well-known/nodeinfo failed: %1$s + /.well-known/nodeinfo did not contain understandable schemas + fetching nodeinfo %1$s failed: %2$s + validating nodeinfo %1$s failed: %2$s + fetching /api/v1/instance failed: %1$s + parsing server capabilities failed: %1$s +