|
@@ -47,12 +47,12 @@ fun SharedPreferences.put(key: String, value: Boolean) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fun Context.createImageFile(): File {
|
|
|
+fun Context.createFile(suffix: String): File {
|
|
|
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
|
|
|
- val imageFileName = "IMG_" + timeStamp + "_"
|
|
|
+ val imageFileName = "FL_" + timeStamp + "_"
|
|
|
return File.createTempFile(
|
|
|
imageFileName,
|
|
|
- ".jpeg",
|
|
|
+ suffix,
|
|
|
filesDir
|
|
|
)
|
|
|
}
|
|
@@ -70,6 +70,11 @@ fun Uri.getFileName(context: Context): String? {
|
|
|
|
|
|
fun Context.getMimeType(uri: Uri): String {
|
|
|
Log.d(tag, "getMimeType:uri:$uri")
|
|
|
+ val mimeType = contentResolver.getType(uri) ?: ""
|
|
|
+ Log.d(tag, "getMimeType:$mimeType")
|
|
|
+ if (mimeType.isNotEmpty()) {
|
|
|
+ return mimeType
|
|
|
+ }
|
|
|
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(uri.toString())
|
|
|
if (!fileExtension.isNullOrEmpty()) {
|
|
|
Log.d(tag, "getMimeType:fileExtension:$fileExtension")
|
|
@@ -79,9 +84,7 @@ fun Context.getMimeType(uri: Uri): String {
|
|
|
return it
|
|
|
}
|
|
|
}
|
|
|
- val mimeType = contentResolver.getType(uri) ?: ""
|
|
|
- Log.d(tag, "getMimeType:$mimeType")
|
|
|
- return mimeType
|
|
|
+ return ""
|
|
|
}
|
|
|
|
|
|
fun String.toMD5(): String {
|