Skip to content

Commit

Permalink
Rebase and PR minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JustFanta01 committed Sep 6, 2024
1 parent 00f766f commit 68b8744
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ abstract class CryptoImplDecorator(
return getOrCreateLruCache(getCacheTypeFromCloudType(type), sharedPreferencesHandler.lruCacheSize())
}

private fun getOrCreateLruCache(key: LruFileCacheUtil.Cache, cacheSize: Int): DiskLruCache? {
return diskLruCache.computeIfAbsent(key) {
val where = LruFileCacheUtil(context).resolve(it)
private fun getOrCreateLruCache(cache: LruFileCacheUtil.Cache, cacheSize: Int): DiskLruCache? {
return diskLruCache.computeIfAbsent(cache) {
val cacheFile = LruFileCacheUtil(context).resolve(it)
try {
DiskLruCache.create(where, cacheSize.toLong())
DiskLruCache.create(cacheFile, cacheSize.toLong())
} catch (e: IOException) {
Timber.tag("CryptoImplDecorator").e(e, "Failed to setup LRU cache for $where.name")
Timber.tag("CryptoImplDecorator").e(e, "Failed to setup LRU cache for $cacheFile.name")
null
}
}
}
protected fun renameFileInCache(source: CryptoFile, target: CryptoFile){

protected fun renameFileInCache(source: CryptoFile, target: CryptoFile) {
val oldCacheKey = generateCacheKey(source.cloudFile)
val newCacheKey = generateCacheKey(target.cloudFile)
source.cloudFile.cloud?.type()?.let { cloudType ->
Expand Down Expand Up @@ -467,14 +468,7 @@ abstract class CryptoImplDecorator(
}

protected fun generateCacheKey(cloudFile: CloudFile): String {
return buildString {
if (cloudFile.cloud?.id() != null)
this.append(cloudFile.cloud!!.id())
else
this.append("c") // "common"
this.append("-")
this.append(cloudFile.path.hashCode())
}
return String.format("%s-%d", cloudFile.cloud?.id() ?: "common", cloudFile.path.hashCode())
}

private fun isGenerateThumbnailsEnabled(cache: DiskLruCache?, fileName: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cryptomator.presentation.model

import android.graphics.Bitmap
import org.cryptomator.domain.CloudNode
import java.io.Serializable

Expand All @@ -9,7 +8,6 @@ abstract class CloudNodeModel<T : CloudNode> internal constructor(private val cl
var oldName: String? = null
var progress: ProgressModel? = null
var isSelected = false

val name: String
get() = cloudNode.name
val simpleName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.cryptomator.presentation.presenter

import android.content.ActivityNotFoundException
import android.content.Intent
import android.graphics.BitmapFactory
import android.net.Uri
import android.provider.DocumentsContract
import android.widget.Toast
Expand Down Expand Up @@ -514,7 +513,6 @@ class BrowseFilesPresenter @Inject constructor( //
)
} else if (!lowerFileName.endsWith(".gif") && isImageMediaType(cloudFile.name)) {
val cloudFileNodes = previewCloudFileNodes

val imagePreviewStore = ImagePreviewFilesStore( //
cloudFileNodes, //
cloudFileNodes.indexOf(cloudFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class VaultListPresenter @Inject constructor( //
sharedPreferencesHandler.vaultsRemovedDuringMigration(null)
}

checkLicense()
// checkLicense()

checkPermissions()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.cryptomator.presentation.ui.adapter
import android.graphics.BitmapFactory
import android.os.PatternMatcher
import android.view.LayoutInflater
import android.util.Size
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
Expand Down Expand Up @@ -140,13 +139,11 @@ constructor(
}

private fun bindNodeImage(node: CloudNodeModel<*>) {
binding.cloudNodeImage.setImageResource(bindCloudNodeImage(node))

if (node is CloudFileModel && isImageMediaType(node.name) && node.thumbnail != null) {
val bitmap = BitmapFactory.decodeFile(node.thumbnail!!.absolutePath)
itemView.cloudNodeImage.setImageBitmap(bitmap)
binding.cloudNodeImage.setImageBitmap(bitmap)
} else {
itemView.cloudNodeImage.setImageResource(bindCloudNodeImage(node))
binding.cloudNodeImage.setImageResource(bindCloudNodeImage(node))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ class FileSettingsBottomSheet : BaseBottomSheet<FileSettingsBottomSheet.Callback
val cloudFileModel = requireArguments().getSerializable(FILE_ARG) as CloudFileModel
val parentFolderPath = requireArguments().getString(PARENT_FOLDER_PATH_ARG)

binding.ivFileImage.setImageResource(cloudFileModel.icon.iconResource)
binding.tvFileName.text = cloudFileModel.name
binding.tvFilePath.text = parentFolderPath
cloudFileModel.thumbnail?.let {
val thumbnail = BitmapFactory.decodeFile(it.absolutePath)
iv_file_image.setImageBitmap(thumbnail)
binding.ivFileImage.setImageBitmap(thumbnail)
}
if (binding.ivFileImage.drawable == null) {
binding.ivFileImage.setImageResource(cloudFileModel.icon.iconResource)
}
if(iv_file_image.drawable == null)
iv_file_image.setImageResource(cloudFileModel.icon.iconResource)

tv_file_name.text = cloudFileModel.name
tv_file_path.text = parentFolderPath

val lowerFileName = cloudFileModel.name.lowercase()
if (lowerFileName.endsWith(".txt") || lowerFileName.endsWith(".md") || lowerFileName.endsWith(".todo")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.cryptomator.presentation.model.ProgressModel
import org.cryptomator.presentation.presenter.BrowseFilesPresenter
import org.cryptomator.presentation.ui.adapter.BrowseFilesAdapter
import org.cryptomator.presentation.util.ResourceHelper.Companion.getPixelOffset
import org.cryptomator.util.SharedPreferencesHandler
import java.util.Optional
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.cryptomator.presentation.ui.dialog.DisableSecureScreenDisclaimerDialo
import org.cryptomator.presentation.ui.dialog.MicrosoftWorkaroundDisclaimerDialog
import org.cryptomator.util.SharedPreferencesHandler
import org.cryptomator.util.SharedPreferencesHandler.Companion.CRYPTOMATOR_VARIANTS
import org.cryptomator.util.SharedPreferencesHandler.Companion.THUMBNAIL_GENERATION
import org.cryptomator.util.file.LruFileCacheUtil
import java.lang.Boolean.FALSE
import java.lang.Boolean.TRUE
Expand Down

0 comments on commit 68b8744

Please sign in to comment.