mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
File block | Add icons for different mime types (#288)
This commit is contained in:
parent
ab1b602176
commit
b88ff0e05c
12 changed files with 166 additions and 14 deletions
|
@ -620,9 +620,14 @@ sealed class BlockViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||
size.text = FileSizeFormatter.formatFileSize(itemView.context, item.size)
|
||||
when (MimeTypes.category(item.mime)) {
|
||||
MimeTypes.Category.PDF -> icon.setImageResource(R.drawable.ic_mime_pdf)
|
||||
else -> {
|
||||
// TODO add images when they are ready.
|
||||
}
|
||||
MimeTypes.Category.IMAGE -> icon.setImageResource(R.drawable.ic_mime_image)
|
||||
MimeTypes.Category.AUDIO -> icon.setImageResource(R.drawable.ic_mime_music)
|
||||
MimeTypes.Category.TEXT -> icon.setImageResource(R.drawable.ic_mime_text)
|
||||
MimeTypes.Category.VIDEO -> icon.setImageResource(R.drawable.ic_mime_video)
|
||||
MimeTypes.Category.ARCHIVE -> icon.setImageResource(R.drawable.ic_mime_archive)
|
||||
MimeTypes.Category.TABLE -> icon.setImageResource(R.drawable.ic_mime_table)
|
||||
MimeTypes.Category.PRESENTATION -> icon.setImageResource(R.drawable.ic_mime_presentation)
|
||||
MimeTypes.Category.OTHER -> icon.setImageResource(R.drawable.ic_mime_other)
|
||||
}
|
||||
itemView.setOnClickListener { onDownloadFileClicked(item.id) }
|
||||
}
|
||||
|
|
13
core-ui/src/main/res/drawable/ic_mime_archive.xml
Normal file
13
core-ui/src/main/res/drawable/ic_mime_archive.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#8C9EA5"
|
||||
android:pathData="M6,3.0303L18,3.0303A3,3 0,0 1,21 6.0303L21,18.0303A3,3 0,0 1,18 21.0303L6,21.0303A3,3 0,0 1,3 18.0303L3,6.0303A3,3 0,0 1,6 3.0303z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M11.9844,3H13.9844V4H12V5H10V4H11.9844V3ZM12,6V5H14V6H12ZM12,7H10V6H12V7ZM12,8V7H14V8H12ZM12,9H10V8H12V9ZM12,10V9H14V10H12ZM12,11H10V10H12V11ZM12,11H14V11.9844V12V18H10V11.9844H12V11ZM13,17V16H11V17H13Z" />
|
||||
</vector>
|
18
core-ui/src/main/res/drawable/ic_mime_image.xml
Normal file
18
core-ui/src/main/res/drawable/ic_mime_image.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#0FC8BA"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M10.4805,9.9697L5.5,17.9697H12.5H15.5H18.5L15.5,12.9697L13.9665,15.5256L10.4805,9.9697Z" />
|
||||
<path
|
||||
android:fillAlpha="0.70106"
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M15,9.9697C16.1046,9.9697 17,9.0743 17,7.9697C17,6.8652 16.1046,5.9697 15,5.9697C13.8954,5.9697 13,6.8652 13,7.9697C13,9.0743 13.8954,9.9697 15,9.9697Z"
|
||||
android:strokeAlpha="0.70106" />
|
||||
</vector>
|
13
core-ui/src/main/res/drawable/ic_mime_music.xml
Normal file
13
core-ui/src/main/res/drawable/ic_mime_music.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#AB50CC"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M17,6.9697L12,5.9697L12.0078,6.9697H12V13.4695C11.5822,13.1557 11.0628,12.9697 10.5,12.9697C9.1193,12.9697 8,14.089 8,15.4697C8,16.8504 9.1193,17.9697 10.5,17.9697C11.8807,17.9697 13,16.8504 13,15.4697V8.1672L17,8.9697V6.9697Z" />
|
||||
</vector>
|
20
core-ui/src/main/res/drawable/ic_mime_other.xml
Normal file
20
core-ui/src/main/res/drawable/ic_mime_other.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#3E58EB"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7.9805,17.2095a3.2577,6.5154 45,1 0,9.2141 -9.2141a3.2577,6.5154 45,1 0,-9.2141 9.2141z" />
|
||||
<path
|
||||
android:fillColor="#3E58EB"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M14.4255,8.4465L14.4261,8.4458C12.7705,6.7902 10.0862,6.7902 8.4306,8.4458C6.7948,10.0817 6.7752,12.7217 8.3719,14.3815C8.3839,14.3947 8.3962,14.4077 8.4089,14.4204C9.2367,15.2482 11.2499,14.5771 12.9055,12.9215C14.5469,11.2801 15.2206,9.2873 14.4255,8.4465Z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M8.3719,14.3815C6.7752,12.7217 6.7948,10.0817 8.4306,8.4458C9.8427,7.0338 12.0029,6.8261 13.6351,7.8226C13.8921,7.9795 14.136,8.1662 14.3618,8.3828C14.3834,8.4035 14.4048,8.4246 14.4261,8.4458L14.4255,8.4465C15.2206,9.2873 14.5469,11.2801 12.9055,12.9215C11.2499,14.5771 9.2367,15.2482 8.4089,14.4204C8.3962,14.4077 8.3839,14.3947 8.3719,14.3815ZM13.6911,9.1254C12.424,7.8879 10.3936,7.8971 9.1377,9.1529C7.8878,10.4028 7.8728,12.4202 9.0926,13.6882L9.1031,13.6991L9.1132,13.7103L9.116,13.7133C9.1178,13.715 9.3296,13.8872 10.0306,13.6535C10.6681,13.441 11.4566,12.9562 12.1984,12.2144C12.9336,11.4792 13.4167,10.6977 13.6322,10.0626C13.8688,9.365 13.7053,9.1403 13.6989,9.1336L13.6911,9.1254Z" />
|
||||
</vector>
|
|
@ -1,13 +1,13 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18">
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#F55522"
|
||||
android:pathData="M2,0L16,0A2,2 0,0 1,18 2L18,16A2,2 0,0 1,16 18L2,18A2,2 0,0 1,0 16L0,2A2,2 0,0 1,2 0z" />
|
||||
android:pathData="M6,2.9375L18,2.9375A3,3 0,0 1,21 5.9375L21,17.9375A3,3 0,0 1,18 20.9375L6,20.9375A3,3 0,0 1,3 17.9375L3,5.9375A3,3 0,0 1,6 2.9375z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M7.4534,3.8617C7.6352,3.4063 8.0107,3.0303 8.5857,3.0303C8.8285,3.0303 9.0634,3.0921 9.2671,3.233C9.4686,3.3723 9.6067,3.566 9.6972,3.7768C9.8712,4.1818 9.8937,4.7038 9.8366,5.2607C9.7661,5.9497 9.5622,6.7915 9.2424,7.7391C9.4333,8.0453 9.6544,8.3492 9.9069,8.6422C10.3059,9.1053 10.7248,9.5157 11.1395,9.8664C11.932,9.7651 12.6314,9.7428 13.2012,9.8003C13.7158,9.8523 14.193,9.9754 14.5301,10.2254C14.7067,10.3563 14.8566,10.5312 14.9377,10.7559C15.0193,10.9821 15.0161,11.2172 14.9551,11.4415C14.8886,11.6859 14.751,11.8953 14.5434,12.042C14.3427,12.1839 14.1103,12.2436 13.8856,12.2569C13.4481,12.2827 12.943,12.1389 12.4408,11.9088C11.9429,11.6806 11.3987,11.3448 10.8491,10.918C10.345,10.9975 9.7963,11.1099 9.2116,11.2576C8.5914,11.4142 7.9884,11.6005 7.4246,11.8051C6.9412,12.6415 6.4386,13.355 5.9559,13.8919C5.5347,14.3602 5.0914,14.7364 4.654,14.9151C4.4298,15.0067 4.1792,15.0578 3.923,15.0149C3.6567,14.9704 3.4308,14.8318 3.258,14.6258C3.0783,14.4115 2.9868,14.1544 3.0015,13.8779C3.0155,13.6156 3.1225,13.3779 3.2596,13.1754C3.529,12.7776 3.9927,12.4015 4.5365,12.0618C5.138,11.6861 5.8933,11.3209 6.7328,10.9965C7.022,10.4719 7.3054,9.8962 7.5718,9.2816C7.7907,8.7766 7.9823,8.2957 8.1463,7.8435C7.6903,7.0045 7.421,6.1587 7.3265,5.4257C7.2521,4.8491 7.2801,4.296 7.4534,3.8617ZM8.5979,6.4181C8.7233,5.9429 8.8048,5.5202 8.8419,5.1588C8.893,4.66 8.8517,4.3422 8.7784,4.1715C8.7453,4.0944 8.7138,4.0661 8.6984,4.0555C8.6852,4.0464 8.6558,4.0303 8.5857,4.0303C8.5345,4.0303 8.4598,4.0381 8.3822,4.2325C8.2961,4.448 8.2555,4.8107 8.3183,5.2978C8.3623,5.6394 8.4545,6.0198 8.5979,6.4181ZM8.8192,8.8863C8.7161,9.1453 8.6061,9.4099 8.4893,9.6793C8.3635,9.9696 8.2334,10.2529 8.1001,10.528C8.385,10.4421 8.6746,10.3618 8.9667,10.288C9.2806,10.2088 9.5873,10.1385 9.8854,10.0773C9.6347,9.8333 9.388,9.572 9.1493,9.295C9.0337,9.1608 8.9237,9.0244 8.8192,8.8863ZM5.7853,12.5071C5.5235,12.6399 5.2824,12.7749 5.0663,12.9099C4.5628,13.2244 4.2398,13.5113 4.0876,13.7361C4.0139,13.8449 4.0013,13.9084 4.0001,13.9311C4.0001,13.9315 4.0001,13.932 4,13.9324C3.9995,13.9408 3.9987,13.9528 4.0242,13.9832C4.058,14.0235 4.0774,14.0269 4.088,14.0286C4.1088,14.0321 4.1668,14.0339 4.2758,13.9894C4.5049,13.8958 4.8265,13.6522 5.2123,13.2232C5.3981,13.0165 5.5903,12.7766 5.7853,12.5071ZM12.4129,10.7701C12.5664,10.8578 12.7151,10.9345 12.8574,10.9997C13.2975,11.2014 13.6268,11.2704 13.8267,11.2586C13.9207,11.253 13.9578,11.2314 13.9662,11.2254C13.9663,11.2253 13.9665,11.2253 13.9666,11.2252C13.9692,11.2236 13.9798,11.2169 13.9901,11.179C14.0062,11.1199 13.9981,11.0979 13.9971,11.0954L13.997,11.0952C13.9959,11.092 13.9869,11.0676 13.9346,11.0287C13.8138,10.9392 13.5527,10.8409 13.1007,10.7952C12.8961,10.7746 12.666,10.766 12.4129,10.7701Z" />
|
||||
android:pathData="M11.4887,5.9706C11.7504,5.9482 11.9848,6.1321 12.0253,6.3916C12.3671,8.5807 12.9037,10.118 13.7707,11.2789C14.6328,12.4331 15.8595,13.2656 17.6807,13.9713C17.9231,14.0652 18.0531,14.3293 17.9797,14.5787C17.9063,14.8281 17.654,14.9796 17.3993,14.9273C15.468,14.5303 13.8846,14.4732 12.328,14.8347C10.7672,15.1971 9.1917,15.99 7.2923,17.3588C7.078,17.5133 6.7804,17.4743 6.613,17.2697C6.4457,17.0652 6.4664,16.7658 6.6603,16.5863C8.3702,15.0028 9.4691,13.5642 10.1388,11.9951C10.8083,10.4263 11.0658,8.6876 11.0313,6.4766C11.0272,6.2139 11.227,5.9929 11.4887,5.9706ZM11.8214,9.7276C11.6655,10.6689 11.4178,11.5459 11.0585,12.3877C10.7143,13.1941 10.2714,13.9598 9.7184,14.7128C10.5239,14.3265 11.3089,14.0447 12.1017,13.8606C12.9798,13.6567 13.8571,13.575 14.7706,13.5974C14.0636,13.1082 13.4681,12.5448 12.9695,11.8773C12.4995,11.2481 12.1241,10.5373 11.8214,9.7276Z" />
|
||||
</vector>
|
||||
|
|
18
core-ui/src/main/res/drawable/ic_mime_presentation.xml
Normal file
18
core-ui/src/main/res/drawable/ic_mime_presentation.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#F55522"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M12,11.9892C12,11.9892 12,8.0654 12,5.9697C15.3137,5.9697 18,8.6647 18,11.9892C14.4,11.9892 12,11.9892 12,11.9892Z" />
|
||||
<path
|
||||
android:fillAlpha="0.7"
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M11,6.0142C8.1623,6.4918 6,8.9678 6,11.9504C6,15.2749 8.6863,17.9699 12,17.9699C14.954,17.9699 17.4093,15.8283 17.9077,13.0083H11V6.0142Z"
|
||||
android:strokeAlpha="0.7" />
|
||||
</vector>
|
27
core-ui/src/main/res/drawable/ic_mime_table.xml
Normal file
27
core-ui/src/main/res/drawable/ic_mime_table.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#5DD400"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,11h4v2h-4z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M13,11h4v2h-4z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,7h4v2h-4z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M13,7h4v2h-4z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,15h4v2h-4z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M13,15h4v2h-4z" />
|
||||
</vector>
|
21
core-ui/src/main/res/drawable/ic_mime_text.xml
Normal file
21
core-ui/src/main/res/drawable/ic_mime_text.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#2AA7EE"
|
||||
android:pathData="M6,3L18,3A3,3 0,0 1,21 6L21,18A3,3 0,0 1,18 21L6,21A3,3 0,0 1,3 18L3,6A3,3 0,0 1,6 3z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,7h10v1h-10z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,10h10v1h-10z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,13h10v1h-10z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M7,16h7.5v1h-7.5z" />
|
||||
</vector>
|
12
core-ui/src/main/res/drawable/ic_mime_video.xml
Normal file
12
core-ui/src/main/res/drawable/ic_mime_video.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#2AA7EE"
|
||||
android:pathData="M6,2.978L18,2.978A3,3 0,0 1,21 5.978L21,17.978A3,3 0,0 1,18 20.978L6,20.978A3,3 0,0 1,3 17.978L3,5.978A3,3 0,0 1,6 2.978z" />
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M16.9688,11.9476L9.5469,7.6626V16.2326L16.9688,11.9476Z" />
|
||||
</vector>
|
|
@ -10,21 +10,21 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/fileIcon"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:contentDescription="@string/content_description_file_icon"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:background="@color/orange" />
|
||||
tools:background="@drawable/ic_mime_image" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/filename"
|
||||
style="@style/BlockFileFilenameContentStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/fileSize"
|
||||
|
|
|
@ -8,13 +8,18 @@ object MimeTypes {
|
|||
"image/jpeg"
|
||||
)
|
||||
|
||||
private val TEXTS = listOf(
|
||||
"text/plain"
|
||||
)
|
||||
|
||||
enum class Category {
|
||||
IMAGE, PDF, PICTURE, DOC, AUDIO, VIDEO, ZIP, OTHER
|
||||
IMAGE, PDF, TEXT, AUDIO, VIDEO, ARCHIVE, OTHER, TABLE, PRESENTATION
|
||||
}
|
||||
|
||||
fun category(mime: String): Category = when {
|
||||
mime == PDF -> Category.PDF
|
||||
IMAGES.contains(mime) -> Category.IMAGE
|
||||
TEXTS.contains(mime) -> Category.TEXT
|
||||
else -> Category.OTHER
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue