Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ class LoginActivity : AppCompatActivity(), SslUntrustedCertDialog.OnSslUntrusted
clientId = clientId,
responseType = ResponseType.CODE.string,
scope = scope,
prompt = if (oidcSupported) mdmProvider.getBrandingString(CONFIGURATION_OAUTH2_OPEN_ID_PROMPT, R.string.oauth2_openid_prompt) else "",
prompt = if (!oidcSupported) "" else if (loginAction == ACTION_CREATE) "login"
else mdmProvider.getBrandingString(CONFIGURATION_OAUTH2_OPEN_ID_PROMPT, R.string.oauth2_openid_prompt),
codeChallenge = authenticationViewModel.codeChallenge,
state = authenticationViewModel.oidcState,
username = username,
Expand Down Expand Up @@ -1117,6 +1118,7 @@ class LoginActivity : AppCompatActivity(), SslUntrustedCertDialog.OnSslUntrusted
private fun saveAuthState() {
val prefs = getSharedPreferences("auth_state", android.content.Context.MODE_PRIVATE)
prefs.edit().apply {
clear() // Remove stale state from any previous auth flow
putString(KEY_CODE_VERIFIER, authenticationViewModel.codeVerifier)
putString(KEY_CODE_CHALLENGE, authenticationViewModel.codeChallenge)
putString(KEY_OIDC_STATE, authenticationViewModel.oidcState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@ object ThumbnailsRequester : KoinComponent {
}

private fun buildThumbnailImageLoader(account: Account): ImageLoader {
val openCloudClient = clientManager.getClientForCoilThumbnails(account.name)
val interceptor = CoilRequestHeaderInterceptor(clientManager, account.name)
return ImageLoader(appContext).newBuilder()
.okHttpClient(
openCloudClient.okHttpClient.newBuilder()
.okHttpClient {
// Lazy: deferred to first image request (off main thread).
// getClientForCoilThumbnails calls blockingGetAuthToken which
// must not run on the main thread.
clientManager.getClientForCoilThumbnails(account.name)
.okHttpClient.newBuilder()
.addInterceptor(interceptor).build()
)
}
.apply { if (preferencesProvider.getBoolean("enable_logging", false)) logger(DebugLogger()) }
.memoryCache { sharedMemoryCache }
.diskCache { sharedDiskCache }
Expand All @@ -163,15 +166,15 @@ object ThumbnailsRequester : KoinComponent {
}

private fun buildAvatarImageLoader(account: Account): ImageLoader {
val openCloudClient = clientManager.getClientForCoilThumbnails(account.name)
val interceptor = CoilRequestHeaderInterceptor(clientManager, account.name)
return ImageLoader(appContext).newBuilder()
.okHttpClient(
openCloudClient.okHttpClient.newBuilder()
.okHttpClient {
clientManager.getClientForCoilThumbnails(account.name)
.okHttpClient.newBuilder()
.addInterceptor(interceptor)
.cache(avatarHttpCache)
.build()
)
}
.apply { if (preferencesProvider.getBoolean("enable_logging", false)) logger(DebugLogger()) }
.memoryCache { sharedMemoryCache }
// No Coil disk cache — OkHttp's HTTP cache handles persistence
Expand All @@ -187,7 +190,18 @@ object ThumbnailsRequester : KoinComponent {
) : Interceptor {

override fun intercept(chain: Interceptor.Chain): Response {
val openCloudClient = clientManager.getClientForCoilThumbnails(accountName)
val openCloudClient = try {
clientManager.getClientForCoilThumbnails(accountName)
} catch (e: Exception) {
Timber.d(e, "Account $accountName not found, skipping thumbnail request")
return Response.Builder()
.request(chain.request())
.protocol(okhttp3.Protocol.HTTP_1_1)
.code(401)
.message("Account not found")
.body(okhttp3.ResponseBody.create(null, ""))
.build()
}
val credentials = openCloudClient.credentials
?: return Response.Builder()
.request(chain.request())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ fun View.updatePaddingTop(@Px paddingTop: Int) {

fun View.updatePaddingBottom(@Px paddingBottom: Int) {
updatePadding(bottom = paddingBottom)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,10 @@ class FileDisplayActivity : FileActivity(),
}

private fun navigateTo(newFileListOption: FileListOption, initialState: Boolean = false) {
// account can be null if it was removed while the activity was still visible.
// swapToDefaultAccount (called from onRestart/onNewIntent) launches the login
// wizard asynchronously, but we can't navigate without an account.
if (account == null) return
val previousFileListOption = fileListOption
when (newFileListOption) {
FileListOption.ALL_FILES -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:id="@+id/text_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:paddingTop="@dimen/standard_half_margin"
android:paddingBottom="@dimen/standard_half_margin"
android:layout_marginStart="@dimen/standard_margin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class GetSpaceWithSpecialsByIdForAccountUseCase(

override fun run(params: Params): OCSpace? {
if (params.spaceId == null) return null
return spacesRepository.getSpaceWithSpecialsByIdForAccount(params.spaceId, params.accountName)
return try {
spacesRepository.getSpaceWithSpecialsByIdForAccount(params.spaceId, params.accountName)
} catch (_: Exception) {
null
}
}

data class Params(
Expand Down
Loading