use separate file icons depending on the extension

This commit is contained in:
tibbi 2020-04-22 12:14:12 +02:00
parent fb8b384669
commit 45cb3c5169
7 changed files with 49 additions and 34 deletions

View File

@ -58,7 +58,6 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
private val TYPE_FILE_DIR = 1 private val TYPE_FILE_DIR = 1
private val TYPE_SECTION = 2 private val TYPE_SECTION = 2
private lateinit var folderDrawable: Drawable private lateinit var folderDrawable: Drawable
private lateinit var fileDrawable: Drawable
private var currentItemsHash = listItems.hashCode() private var currentItemsHash = listItems.hashCode()
private var textToHighlight = "" private var textToHighlight = ""
private val hasOTGConnected = activity.hasOTGConnected() private val hasOTGConnected = activity.hasOTGConnected()
@ -154,9 +153,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
fun initDrawables() { fun initDrawables() {
folderDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_folder_vector, textColor) folderDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_folder_vector, textColor)
fileDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_file_vector, textColor)
folderDrawable.alpha = 180 folderDrawable.alpha = 180
fileDrawable.alpha = 180
} }
private fun isOneFileSelected() = isOneItemSelected() && getItemWithKey(selectedKeys.first())?.isDirectory == false private fun isOneFileSelected() = isOneItemSelected() && getItemWithKey(selectedKeys.first())?.isDirectory == false
@ -713,7 +710,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
val options = RequestOptions() val options = RequestOptions()
.signature(listItem.mPath.getFileSignature()) .signature(listItem.mPath.getFileSignature())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.error(fileDrawable) .error(getFileIcon(fileName.substringAfterLast(".").toLowerCase()))
.centerCrop() .centerCrop()
val itemToLoad = getImagePathToLoad(listItem.path) val itemToLoad = getImagePathToLoad(listItem.path)
@ -753,4 +750,42 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
return itemToLoad return itemToLoad
} }
private fun getFileIcon(extension: String): Drawable {
val id = when (extension) {
"aep" -> R.drawable.ic_file_after_effects
"ai" -> R.drawable.ic_file_ai
"avi" -> R.drawable.ic_file_avi
"css" -> R.drawable.ic_file_css
"csv" -> R.drawable.ic_file_csv
"dbf" -> R.drawable.ic_file_dbf
"doc", "docx" -> R.drawable.ic_file_doc
"dwg" -> R.drawable.ic_file_dwg
"exe" -> R.drawable.ic_file_exe
"fla" -> R.drawable.ic_file_fla
"flv" -> R.drawable.ic_file_flash
"htm", "html" -> R.drawable.ic_file_html
"indd" -> R.drawable.ic_file_indesign
"iso" -> R.drawable.ic_file_iso
"jpg", "jpeg" -> R.drawable.ic_file_jpg
"js" -> R.drawable.ic_file_javascript
"json" -> R.drawable.ic_file_json
"mp3" -> R.drawable.ic_file_mp3
"mp4" -> R.drawable.ic_file_mp4
"pdf" -> R.drawable.ic_file_pdf
"plproj" -> R.drawable.ic_file_prelude
"prproj" -> R.drawable.ic_file_premiere
"psd" -> R.drawable.ic_file_psd
"rtf" -> R.drawable.ic_file_rtf
"sesx" -> R.drawable.ic_file_audition
"svg" -> R.drawable.ic_file_svg
"txt" -> R.drawable.ic_file_txt
"xls" -> R.drawable.ic_file_xls
"xml" -> R.drawable.ic_file_xml
"zip" -> R.drawable.ic_file_zip
else -> R.drawable.ic_file_generic
}
return resources.getDrawable(id)
}
} }

View File

@ -1,6 +0,0 @@
<vector android:height="24dp" android:viewportHeight="52"
android:viewportWidth="52" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#69461E" android:pathData="M40.824,52H11.176C5.003,52 0,46.997 0,40.824V11.176C0,5.003 5.003,0 11.176,0h29.649C46.997,0 52,5.003 52,11.176v29.649C52,46.997 46.997,52 40.824,52z"/>
<path android:fillColor="#FBC500" android:pathData="M21.2,39h-9.08V11h8.64c2.187,0 3.94,0.574 5.26,1.72C27.34,13.867 28,15.627 28,18c0,2.374 -0.88,4.16 -2.64,5.36c-0.027,0.026 -0.04,0.054 -0.04,0.08v0.04c1.173,0.533 2.153,1.394 2.94,2.579c0.787,1.188 1.18,2.728 1.18,4.62c0,1.681 -0.36,3.2 -1.08,4.561C27.08,37.747 24.693,39 21.2,39zM15,22.48h5.16c3.12,0 4.68,-1.467 4.68,-4.4c0,-2.854 -1.587,-4.28 -4.76,-4.28H15V22.48zM15,36.32h5.56c1.786,0 3.18,-0.413 4.18,-1.24c1,-0.826 1.5,-2.227 1.5,-4.2c0,-1.973 -0.5,-3.399 -1.5,-4.28c-1,-0.88 -2.207,-1.319 -3.62,-1.319H15V36.32z"/>
<path android:fillColor="#FBC500" android:pathData="M36.16,39h-2.88V18.96h2.8V20c1.2,-0.88 2.72,-1.32 4.56,-1.32c0.906,0 1.906,0.107 3,0.32l-0.72,2.72c-0.934,-0.293 -1.899,-0.439 -2.899,-0.439c-1,0 -1.895,0.26 -2.681,0.779c-0.787,0.521 -1.18,1.221 -1.18,2.101V39z"/>
</vector>

View File

@ -1,6 +0,0 @@
<vector android:height="24dp" android:viewportHeight="52"
android:viewportWidth="52" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#255C26" android:pathData="M40.824,52H11.176C5.003,52 0,46.997 0,40.824V11.176C0,5.003 5.003,0 11.176,0h29.649C46.997,0 52,5.003 52,11.176v29.649C52,46.997 46.997,52 40.824,52z"/>
<path android:fillColor="#25EB00" android:pathData="M12.521,39H4.2V10.96h7.521c3.013,0 5.313,0.827 6.899,2.48S21,17.294 21,20.04V31C21,36.334 18.174,39 12.521,39zM18.12,31.4V19.64c0,-2 -0.58,-3.486 -1.74,-4.46c-1.159,-0.973 -2.579,-1.46 -4.26,-1.46H7.08V36.4h4.8c2.96,0 4.854,-0.787 5.681,-2.36C17.934,33.347 18.12,32.467 18.12,31.4z"/>
<path android:fillColor="#25EB00" android:pathData="M42.721,39h-3.44l-3.68,-14.56L31.88,39H28.44L22.2,18.96h3.08l4.84,16.08l4.12,-16.08h2.84l4.12,16.08l4.72,-16.08H49L42.721,39z"/>
</vector>

View File

@ -1,6 +0,0 @@
<vector android:height="24dp" android:viewportHeight="52"
android:viewportWidth="52" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#5E4F11" android:pathData="M40.824,52H11.176C5.003,52 0,46.997 0,40.824V11.176C0,5.003 5.003,0 11.176,0h29.649C46.997,0 52,5.003 52,11.176v29.649C52,46.997 46.997,52 40.824,52z"/>
<path android:fillColor="#E7EB00" android:pathData="M10.88,39H8V11h13.36v2.8H10.88v8.681h6.48l-1.08,2.8h-5.4V39z"/>
<path android:fillColor="#E7EB00" android:pathData="M39.72,39h-3.44L32.6,24.44L28.88,39h-3.44L19.2,18.96h3.08l4.84,16.08l4.12,-16.08h2.84l4.12,16.08l4.72,-16.08H46L39.72,39z"/>
</vector>

View File

@ -1,6 +0,0 @@
<vector android:height="24dp" android:viewportHeight="52"
android:viewportWidth="52" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#6D4C13" android:pathData="M40.824,52H11.176C5.003,52 0,46.997 0,40.824V11.176C0,5.003 5.003,0 11.176,0h29.649C46.997,0 52,5.003 52,11.176v29.649C52,46.997 46.997,52 40.824,52z"/>
<path android:fillColor="#FFBD2E" android:pathData="M30.68,39h-3.24l-2.76,-9.04h-8.32L13.72,39H10.6l8.24,-28h3.32L30.68,39zM23.96,27l-3.48,-11.36L17.12,27H23.96z"/>
<path android:fillColor="#FFBD2E" android:pathData="M37.479,12.24c0,0.453 -0.16,0.84 -0.48,1.16c-0.32,0.319 -0.7,0.479 -1.14,0.479c-0.44,0 -0.827,-0.166 -1.16,-0.5c-0.334,-0.333 -0.5,-0.713 -0.5,-1.14s0.166,-0.807 0.5,-1.141c0.333,-0.333 0.72,-0.5 1.16,-0.5c0.44,0 0.82,0.16 1.14,0.48C37.32,11.4 37.479,11.787 37.479,12.24zM37.24,39h-2.88V18.96h2.88V39z"/>
</vector>

View File

@ -1,6 +0,0 @@
<vector android:height="24dp" android:viewportHeight="52"
android:viewportWidth="52" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#393687" android:pathData="M40.824,52H11.176C5.003,52 0,46.997 0,40.824V11.176C0,5.003 5.003,0 11.176,0h29.649C46.997,0 52,5.003 52,11.176v29.649C52,46.997 46.997,52 40.824,52z"/>
<path android:fillColor="#89D3FF" android:pathData="M12.16,39H9.28V11h9.64c2.613,0 4.553,0.813 5.82,2.44c1.266,1.626 1.9,3.76 1.9,6.399c0,0.934 -0.027,1.74 -0.08,2.42c-0.054,0.681 -0.22,1.534 -0.5,2.561c-0.28,1.026 -0.66,1.866 -1.14,2.52c-0.48,0.654 -1.213,1.227 -2.2,1.72c-0.987,0.494 -2.16,0.74 -3.52,0.74h-7.04V39zM12.16,27h6.68c0.96,0 1.773,-0.187 2.44,-0.56c0.666,-0.374 1.153,-0.773 1.46,-1.2c0.306,-0.427 0.546,-1.04 0.72,-1.84c0.173,-0.801 0.267,-1.4 0.28,-1.801c0.013,-0.399 0.02,-0.973 0.02,-1.72c0,-4.053 -1.694,-6.08 -5.08,-6.08h-6.52V27z"/>
<path android:fillColor="#89D3FF" android:pathData="M29.48,33.92l2.8,-0.12c0.106,0.987 0.6,1.754 1.48,2.3c0.88,0.547 1.893,0.82 3.04,0.82s2.14,-0.26 2.98,-0.78c0.84,-0.52 1.26,-1.266 1.26,-2.239s-0.36,-1.747 -1.08,-2.32c-0.72,-0.573 -1.6,-1.026 -2.64,-1.36c-1.04,-0.333 -2.086,-0.686 -3.14,-1.06c-1.054,-0.373 -1.98,-0.96 -2.78,-1.76c-0.987,-0.934 -1.48,-2.073 -1.48,-3.42s0.54,-2.601 1.62,-3.761s2.833,-1.739 5.26,-1.739c0.854,0 1.653,0.1 2.4,0.3c0.746,0.2 1.28,0.394 1.6,0.58l0.48,0.279l-0.92,2.521c-0.854,-0.666 -1.974,-1 -3.36,-1c-1.387,0 -2.42,0.26 -3.1,0.78c-0.68,0.52 -1.02,1.18 -1.02,1.979c0,0.88 0.426,1.574 1.28,2.08c0.853,0.507 1.813,0.934 2.88,1.28c1.066,0.347 2.126,0.733 3.18,1.16c1.053,0.427 1.946,1.094 2.68,2s1.1,2.106 1.1,3.6c0,1.494 -0.6,2.794 -1.8,3.9C41,39.046 39.246,39.6 36.94,39.6c-2.307,0 -4.114,-0.547 -5.42,-1.64C30.213,36.867 29.533,35.52 29.48,33.92z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector android:height="24dp" android:viewportHeight="56"
android:viewportWidth="56" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#E9E9E0" android:pathData="M36.985,0H7.963C7.155,0 6.5,0.655 6.5,1.926V55c0,0.345 0.655,1 1.463,1h40.074c0.808,0 1.463,-0.655 1.463,-1V12.978c0,-0.696 -0.093,-0.92 -0.257,-1.085L37.607,0.257C37.442,0.093 37.218,0 36.985,0z"/>
<path android:fillColor="#5889C4" android:pathData="M48.037,56H7.963C7.155,56 6.5,55.345 6.5,54.537V39h43v15.537C49.5,55.345 48.845,56 48.037,56z"/>
<path android:fillColor="#FFFFFF" android:pathData="M17.385,53h-1.641V42.924h2.898c0.428,0 0.852,0.068 1.271,0.205c0.419,0.137 0.795,0.342 1.128,0.615c0.333,0.273 0.602,0.604 0.807,0.991s0.308,0.822 0.308,1.306c0,0.511 -0.087,0.973 -0.26,1.388c-0.173,0.415 -0.415,0.764 -0.725,1.046c-0.31,0.282 -0.684,0.501 -1.121,0.656s-0.921,0.232 -1.449,0.232h-1.217V53zM17.385,44.168v3.992h1.504c0.2,0 0.398,-0.034 0.595,-0.103c0.196,-0.068 0.376,-0.18 0.54,-0.335c0.164,-0.155 0.296,-0.371 0.396,-0.649c0.1,-0.278 0.15,-0.622 0.15,-1.032c0,-0.164 -0.023,-0.354 -0.068,-0.567c-0.046,-0.214 -0.139,-0.419 -0.28,-0.615c-0.142,-0.196 -0.34,-0.36 -0.595,-0.492c-0.255,-0.132 -0.593,-0.198 -1.012,-0.198H17.385z"/>
<path android:fillColor="#FFFFFF" android:pathData="M29.73,50.238c0,0.364 -0.075,0.718 -0.226,1.06s-0.362,0.643 -0.636,0.902s-0.611,0.467 -1.012,0.622c-0.401,0.155 -0.857,0.232 -1.367,0.232c-0.219,0 -0.444,-0.012 -0.677,-0.034s-0.467,-0.062 -0.704,-0.116c-0.237,-0.055 -0.463,-0.13 -0.677,-0.226c-0.214,-0.096 -0.399,-0.212 -0.554,-0.349l0.287,-1.176c0.127,0.073 0.289,0.144 0.485,0.212c0.196,0.068 0.398,0.132 0.608,0.191c0.209,0.06 0.419,0.107 0.629,0.144c0.209,0.036 0.405,0.055 0.588,0.055c0.556,0 0.982,-0.13 1.278,-0.39c0.296,-0.26 0.444,-0.645 0.444,-1.155c0,-0.31 -0.105,-0.574 -0.314,-0.793c-0.21,-0.219 -0.472,-0.417 -0.786,-0.595s-0.654,-0.355 -1.019,-0.533c-0.365,-0.178 -0.707,-0.388 -1.025,-0.629c-0.319,-0.241 -0.583,-0.526 -0.793,-0.854c-0.21,-0.328 -0.314,-0.738 -0.314,-1.23c0,-0.446 0.082,-0.843 0.246,-1.189s0.385,-0.641 0.663,-0.882c0.278,-0.241 0.602,-0.426 0.971,-0.554s0.759,-0.191 1.169,-0.191c0.419,0 0.843,0.039 1.271,0.116c0.428,0.077 0.774,0.203 1.039,0.376c-0.055,0.118 -0.119,0.248 -0.191,0.39c-0.073,0.142 -0.142,0.273 -0.205,0.396c-0.064,0.123 -0.119,0.226 -0.164,0.308c-0.046,0.082 -0.073,0.128 -0.082,0.137c-0.055,-0.027 -0.116,-0.063 -0.185,-0.109s-0.167,-0.091 -0.294,-0.137c-0.128,-0.046 -0.296,-0.077 -0.506,-0.096c-0.21,-0.019 -0.479,-0.014 -0.807,0.014c-0.183,0.019 -0.355,0.07 -0.52,0.157s-0.31,0.193 -0.438,0.321c-0.128,0.128 -0.228,0.271 -0.301,0.431c-0.073,0.159 -0.109,0.313 -0.109,0.458c0,0.364 0.104,0.658 0.314,0.882c0.209,0.224 0.469,0.419 0.779,0.588c0.31,0.169 0.647,0.333 1.012,0.492c0.364,0.159 0.704,0.354 1.019,0.581s0.576,0.513 0.786,0.854C29.625,49.261 29.73,49.7 29.73,50.238z"/>
<path android:fillColor="#FFFFFF" android:pathData="M39.629,47.682c0,0.829 -0.089,1.538 -0.267,2.126s-0.403,1.08 -0.677,1.477s-0.581,0.709 -0.923,0.937s-0.672,0.398 -0.991,0.513c-0.319,0.114 -0.611,0.187 -0.875,0.219C35.632,52.984 35.436,53 35.309,53h-3.814V42.924h3.035c0.848,0 1.593,0.135 2.235,0.403s1.176,0.627 1.6,1.073s0.74,0.955 0.95,1.524C39.524,46.494 39.629,47.08 39.629,47.682zM34.762,51.797c1.112,0 1.914,-0.355 2.406,-1.066s0.738,-1.741 0.738,-3.09c0,-0.419 -0.05,-0.834 -0.15,-1.244c-0.101,-0.41 -0.294,-0.781 -0.581,-1.114s-0.677,-0.602 -1.169,-0.807s-1.13,-0.308 -1.914,-0.308h-0.957v7.629H34.762z"/>
<path android:fillColor="#C8BDB8" android:pathData="M38.894,11.163c-0.463,-0.301 -1.082,-0.171 -1.384,0.291c-1.433,2.196 -3.979,5.164 -5.19,6.375l-2.788,2.788l-2.828,-2.828L29.49,15c1.771,-1.771 6.271,-5.442 8.116,-6.102c0.04,-0.006 0.091,-0.015 0.112,-0.02c0.521,-0.117 0.827,-0.617 0.735,-1.143c-0.093,-0.526 -0.616,-0.885 -1.143,-0.814l-0.283,0.062c-2.439,0.813 -7.457,5.108 -8.952,6.604l-7.185,7.185c-0.095,-0.004 -0.189,-0.014 -0.285,-0.014c-2.971,0 -5.463,2.125 -5.983,5.016l-0.108,0.073l-0.02,0.536c-0.034,0.942 -0.302,4.052 -2.343,4.546c-0.517,0.129 -0.858,0.625 -0.793,1.152L11.52,33h6.98l0.02,0v0l2.086,-0.03c3.367,0 6.107,-2.74 6.107,-6.107c0,-0.193 -0.011,-0.383 -0.029,-0.572l7.049,-7.048c1.305,-1.305 3.925,-4.358 5.451,-6.696C39.486,12.084 39.356,11.465 38.894,11.163zM20.606,30.97h-3.739L16.882,31h-1.661c0.887,-1.341 1.161,-3.037 1.244,-4.045l0.082,-0.504c0.213,-2.106 1.958,-3.694 4.06,-3.694c0.121,0 0.235,0.025 0.354,0.036l0.167,0.021c1.045,0.134 1.956,0.655 2.6,1.411c0.058,0.069 0.118,0.135 0.171,0.208c0.082,0.11 0.155,0.227 0.226,0.345c0.05,0.085 0.097,0.172 0.142,0.26c0.063,0.126 0.124,0.254 0.174,0.387c0.03,0.08 0.052,0.164 0.077,0.247c0.045,0.147 0.091,0.294 0.12,0.449l0.005,0.026c0.041,0.234 0.072,0.471 0.072,0.716C24.713,29.127 22.871,30.97 20.606,30.97zM25.516,23.247c-0.007,-0.009 -0.013,-0.017 -0.02,-0.026c-0.605,-0.811 -1.405,-1.465 -2.332,-1.895l2.123,-2.123l2.828,2.828l-2.071,2.07C25.893,23.801 25.715,23.516 25.516,23.247z"/>
<path android:fillColor="#D9D7CA" android:pathData="M37.5,0.151l0,11.849l11.849,0z"/>
</vector>