Skip to content
Merged
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 @@ -142,7 +142,7 @@ class UnifiedSearchListAdapterIT : AbstractIT() {
fileThumbnailGenerator = FileThumbnailGenerator(
storageManager = Provider { sut.storageManager },
preferences = preferences,
viewThemeUtils = sut.viewThemeUtils,
viewThemeUtils = Provider { sut.viewThemeUtils },
context = targetContext,
accountManager = accountManager
),
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/nextcloud/client/di/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ AppNotificationManager notificationsManager(Context context,
return new AppNotificationManagerImpl(context,
context.getResources(),
platformNotificationsManager,
viewThemeUtilsProvider.get());
viewThemeUtilsProvider);
}

@Provides
Expand Down Expand Up @@ -274,7 +274,6 @@ CertificateValidator certificateValidator() {
}

@Provides
@Singleton
FolderThumbnailGenerator folderThumbnailGenerator(
AppPreferences appPreferences,
ViewThemeUtils viewThemeUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import com.owncloud.android.ui.preview.PreviewImageActivity
import com.owncloud.android.ui.preview.PreviewImageFragment
import com.owncloud.android.utils.theme.ViewThemeUtils
import javax.inject.Inject
import javax.inject.Provider

class AppNotificationManagerImpl @Inject constructor(
private val context: Context,
private val resources: Resources,
private val platformNotificationsManager: NotificationManager,
private val viewThemeUtils: ViewThemeUtils
private val viewThemeUtils: Provider<ViewThemeUtils>
) : AppNotificationManager {

companion object {
Expand All @@ -39,7 +40,7 @@ class AppNotificationManagerImpl @Inject constructor(
private fun builder(channelId: String): NotificationCompat.Builder {
val builder =
NotificationCompat.Builder(context, channelId)
viewThemeUtils.androidx.themeNotificationCompatBuilder(context, builder)
viewThemeUtils.get().androidx.themeNotificationCompatBuilder(context, builder)
return builder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import kotlin.math.roundToInt
class FileThumbnailGenerator @Inject constructor(
private val storageManager: Provider<FileDataStorageManager>,
private val preferences: AppPreferences,
private val viewThemeUtils: ViewThemeUtils,
private val viewThemeUtils: Provider<ViewThemeUtils>,
private val context: Context,
private val accountManager: UserAccountManager
) {
Expand Down Expand Up @@ -222,10 +222,11 @@ class FileThumbnailGenerator @Inject constructor(
}
}

private fun OCFile.mimeIcon(): Drawable? = MimeTypeUtil.getFileTypeIcon(mimeType, fileName, context, viewThemeUtils)
private fun OCFile.mimeIcon(): Drawable? =
MimeTypeUtil.getFileTypeIcon(mimeType, fileName, context, viewThemeUtils.get())

private fun OCFile.placeholder(): Bitmap = synchronized(placeholders) {
placeholders.getOrPut(mimeType.orEmpty()) {
placeholders.getOrPut("${accountManager.user.accountName}:${mimeType.orEmpty()}") {
val drawable = mimeIcon()
?: ResourcesCompat.getDrawable(context.resources, R.drawable.file_image, null)
?: Color.GRAY.toDrawable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ package com.nextcloud.utils.thumbnail
import android.widget.ImageView
import com.owncloud.android.datamodel.OCFile
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ThumbnailGenerator @Inject constructor(
val fileThumbnailGenerator: FileThumbnailGenerator,
val folderThumbnailGenerator: FolderThumbnailGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ internal class MaterialSchemesProviderImpl @Inject constructor(
private val themeCache: MutableMap<String, MaterialSchemes> = ConcurrentHashMap()

override fun getMaterialSchemesForUser(user: User): MaterialSchemes {
val url: String = user.server.uri.toString()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.server.uri.toString() -> only gives us something like http://localhost:8080

val accountName = user.accountName

if (!themeCache.containsKey(url)) {
if (!themeCache.containsKey(accountName)) {
val capability = CapabilityUtils.getCapability(user, context)
themeCache[url] = getMaterialSchemesForCapability(capability)
themeCache[accountName] = getMaterialSchemesForCapability(capability)
}

return themeCache[url]!!
return themeCache[accountName]!!
}

override fun getMaterialSchemesForCapability(capability: OCCapability): MaterialSchemes {
Expand Down
Loading