mirror of https://github.com/readrops/Readrops.git
Add Nextcloud News login
This commit is contained in:
parent
b879d0ae9d
commit
9a63c1a777
|
@ -10,8 +10,9 @@ import com.readrops.api.services.freshrss.adapters.FreshRSSFoldersAdapter
|
|||
import com.readrops.api.services.freshrss.adapters.FreshRSSItemsAdapter
|
||||
import com.readrops.api.services.freshrss.adapters.FreshRSSItemsIdsAdapter
|
||||
import com.readrops.api.services.freshrss.adapters.FreshRSSUserInfoAdapter
|
||||
import com.readrops.api.services.nextcloudnews.NewNextcloudNewsDataSource
|
||||
import com.readrops.api.services.nextcloudnews.NewNextcloudNewsService
|
||||
import com.readrops.api.services.nextcloudnews.NextNewsDataSource
|
||||
import com.readrops.api.services.nextcloudnews.NextNewsService
|
||||
import com.readrops.api.services.nextcloudnews.adapters.NextNewsFeedsAdapter
|
||||
import com.readrops.api.services.nextcloudnews.adapters.NextNewsFoldersAdapter
|
||||
import com.readrops.api.services.nextcloudnews.adapters.NextNewsItemsAdapter
|
||||
|
@ -24,7 +25,6 @@ import okhttp3.OkHttpClient
|
|||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||
import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
@ -77,14 +77,15 @@ val apiModule = module {
|
|||
|
||||
factory { params -> NextNewsDataSource(get(parameters = { params })) }
|
||||
|
||||
factory { params -> NewNextcloudNewsDataSource(get(parameters = { params })) }
|
||||
|
||||
factory { (credentials: Credentials) ->
|
||||
Retrofit.Builder()
|
||||
.baseUrl(credentials.url)
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.client(get())
|
||||
.addConverterFactory(MoshiConverterFactory.create(get(named("nextcloudNewsMoshi"))))
|
||||
.build()
|
||||
.create(NextNewsService::class.java)
|
||||
.create(NewNextcloudNewsService::class.java)
|
||||
}
|
||||
|
||||
single(named("nextcloudNewsMoshi")) {
|
||||
|
|
|
@ -4,8 +4,8 @@ import androidx.security.crypto.EncryptedSharedPreferences
|
|||
import androidx.security.crypto.MasterKey
|
||||
import com.readrops.api.services.Credentials
|
||||
import com.readrops.app.compose.account.AccountScreenModel
|
||||
import com.readrops.app.compose.account.credentials.AccountCredentialsScreenModel
|
||||
import com.readrops.app.compose.account.credentials.AccountCredentialsScreenMode
|
||||
import com.readrops.app.compose.account.credentials.AccountCredentialsScreenModel
|
||||
import com.readrops.app.compose.account.selection.AccountSelectionScreenModel
|
||||
import com.readrops.app.compose.feeds.FeedScreenModel
|
||||
import com.readrops.app.compose.item.ItemScreenModel
|
||||
|
@ -13,6 +13,7 @@ import com.readrops.app.compose.repositories.BaseRepository
|
|||
import com.readrops.app.compose.repositories.FreshRSSRepository
|
||||
import com.readrops.app.compose.repositories.GetFoldersWithFeeds
|
||||
import com.readrops.app.compose.repositories.LocalRSSRepository
|
||||
import com.readrops.app.compose.repositories.NextcloudNewsRepository
|
||||
import com.readrops.app.compose.timelime.TimelineScreenModel
|
||||
import com.readrops.db.entities.account.Account
|
||||
import com.readrops.db.entities.account.AccountType
|
||||
|
@ -47,6 +48,10 @@ val composeAppModule = module {
|
|||
get(), account,
|
||||
get(parameters = { parametersOf(Credentials.toCredentials(account)) })
|
||||
)
|
||||
AccountType.NEXTCLOUD_NEWS -> NextcloudNewsRepository(
|
||||
get(), account,
|
||||
get(parameters = { parametersOf(Credentials.toCredentials(account)) })
|
||||
)
|
||||
else -> throw IllegalArgumentException("Unknown account type")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.readrops.app.compose.repositories
|
||||
|
||||
import com.readrops.api.services.Credentials
|
||||
import com.readrops.api.services.SyncResult
|
||||
import com.readrops.api.services.nextcloudnews.NewNextcloudNewsDataSource
|
||||
import com.readrops.api.utils.AuthInterceptor
|
||||
import com.readrops.db.Database
|
||||
import com.readrops.db.entities.Feed
|
||||
import com.readrops.db.entities.account.Account
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class NextcloudNewsRepository(
|
||||
database: Database,
|
||||
account: Account,
|
||||
private val dataSource: NewNextcloudNewsDataSource
|
||||
) : BaseRepository(database, account), KoinComponent {
|
||||
|
||||
override suspend fun login(account: Account) {
|
||||
val authInterceptor = get<AuthInterceptor>()
|
||||
authInterceptor.credentials = Credentials.toCredentials(account)
|
||||
|
||||
val displayName = dataSource.login(get(), account)
|
||||
account.displayedName = displayName
|
||||
}
|
||||
|
||||
override suspend fun synchronize(
|
||||
selectedFeeds: List<Feed>,
|
||||
onUpdate: (Feed) -> Unit
|
||||
): Pair<SyncResult, ErrorResult> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun synchronize(): SyncResult {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun insertNewFeeds(
|
||||
newFeeds: List<Feed>,
|
||||
onUpdate: (Feed) -> Unit
|
||||
): ErrorResult {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue