Use file extension based on MIME type

It uses the most common extension for the given MIME type.

Test: Manual

Change-Id: I3d4aea85fcd42088ed19898054db7225954d3401
Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
This commit is contained in:
Taesu Lee
2020-02-03 11:04:15 +09:00
parent 3bd7b79daa
commit 0770975c8a
3 changed files with 23 additions and 13 deletions

View File

@@ -21,7 +21,6 @@ import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import com.android.messaging.Factory;
import com.android.messaging.R;
@@ -62,9 +61,7 @@ public class FileUtil {
* actually creating the file.
*/
public static File getNewFile(File directory, String contentType) throws IOException {
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String fileExtension = mimeTypeMap.getExtensionFromMimeType(contentType);
String fileExtension = ContentType.getExtensionFromMimeType(contentType);
final Context context = Factory.get().getApplicationContext();
String fileNameFormat = context.getString(ContentType.isImageType(contentType)
? R.string.new_image_file_name_format : R.string.new_file_name_format);