mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
rewrite for icon determination with refactoring into its own class + fixed a typo
This commit is contained in:
parent
8c19d0fa50
commit
fa12c619b0
5 changed files with 441 additions and 160 deletions
|
@ -55,6 +55,7 @@ import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
|||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimetypeIconUtil;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -329,7 +330,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
|
||||
|
||||
} else {
|
||||
fileIcon.setImageResource(DisplayUtils.getFileTypeIconId(file.getMimetype(),
|
||||
fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.getMimetype(),
|
||||
file.getFileName()));
|
||||
}
|
||||
|
||||
|
@ -344,7 +345,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
fileIcon.setImageResource(R.drawable.folder_public);
|
||||
} else {
|
||||
fileIcon.setImageResource(
|
||||
DisplayUtils.getFileTypeIconId(file.getMimetype(), file.getFileName())
|
||||
MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.owncloud.android.R;
|
|||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimetypeIconUtil;
|
||||
|
||||
/**
|
||||
* This Adapter populates a ListView with all files and directories contained
|
||||
|
@ -159,7 +160,7 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
fileIcon.setImageResource(DisplayUtils.getFileTypeIconId(null, file.getName()));
|
||||
fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(null, file.getName()));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.owncloud.android.ui.activity.FileDisplayActivity;
|
|||
import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimetypeIconUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
|
@ -403,7 +404,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
|||
}
|
||||
ImageView iv = (ImageView) getView().findViewById(R.id.fdIcon);
|
||||
if (iv != null) {
|
||||
iv.setImageResource(DisplayUtils.getFileTypeIconId(mimetype, filename));
|
||||
iv.setImageResource(MimetypeIconUtil.getFileTypeIconId(mimetype, filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,26 +22,14 @@
|
|||
|
||||
package com.owncloud.android.utils;
|
||||
|
||||
import java.net.IDN;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Build;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.Display;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
|
@ -49,73 +37,39 @@ import com.owncloud.android.MainApp;
|
|||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
||||
import java.net.IDN;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A helper class for some string operations.
|
||||
*/
|
||||
public class DisplayUtils {
|
||||
|
||||
private static final String OWNCLOUD_APP_NAME = "ownCloud";
|
||||
|
||||
//private static String TAG = DisplayUtils.class.getSimpleName();
|
||||
|
||||
private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
|
||||
private static HashMap<String, String> mimeType2HUmanReadable;
|
||||
static {
|
||||
mimeType2HUmanReadable = new HashMap<String, String>();
|
||||
// images
|
||||
mimeType2HUmanReadable.put("image/jpeg", "JPEG image");
|
||||
mimeType2HUmanReadable.put("image/jpg", "JPEG image");
|
||||
mimeType2HUmanReadable.put("image/png", "PNG image");
|
||||
mimeType2HUmanReadable.put("image/bmp", "Bitmap image");
|
||||
mimeType2HUmanReadable.put("image/gif", "GIF image");
|
||||
mimeType2HUmanReadable.put("image/svg+xml", "JPEG image");
|
||||
mimeType2HUmanReadable.put("image/tiff", "TIFF image");
|
||||
// music
|
||||
mimeType2HUmanReadable.put("audio/mpeg", "MP3 music file");
|
||||
mimeType2HUmanReadable.put("application/ogg", "OGG music file");
|
||||
private static Map<String, String> mimeType2HumanReadable;
|
||||
|
||||
static {
|
||||
mimeType2HumanReadable = new HashMap<String, String>();
|
||||
// images
|
||||
mimeType2HumanReadable.put("image/jpeg", "JPEG image");
|
||||
mimeType2HumanReadable.put("image/jpg", "JPEG image");
|
||||
mimeType2HumanReadable.put("image/png", "PNG image");
|
||||
mimeType2HumanReadable.put("image/bmp", "Bitmap image");
|
||||
mimeType2HumanReadable.put("image/gif", "GIF image");
|
||||
mimeType2HumanReadable.put("image/svg+xml", "JPEG image");
|
||||
mimeType2HumanReadable.put("image/tiff", "TIFF image");
|
||||
// music
|
||||
mimeType2HumanReadable.put("audio/mpeg", "MP3 music file");
|
||||
mimeType2HumanReadable.put("application/ogg", "OGG music file");
|
||||
}
|
||||
|
||||
private static final String TYPE_APPLICATION = "application";
|
||||
private static final String TYPE_AUDIO = "audio";
|
||||
private static final String TYPE_IMAGE = "image";
|
||||
private static final String TYPE_TXT = "text";
|
||||
private static final String TYPE_VIDEO = "video";
|
||||
|
||||
private static final String SUBTYPE_PDF = "pdf";
|
||||
private static final String SUBTYPE_XML = "xml";
|
||||
private static final String[] SUBTYPES_DOCUMENT = {
|
||||
"msword",
|
||||
"vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"vnd.oasis.opendocument.text",
|
||||
"rtf",
|
||||
"javascript"
|
||||
};
|
||||
private static Set<String> SUBTYPES_DOCUMENT_SET = new HashSet<String>(Arrays.asList(SUBTYPES_DOCUMENT));
|
||||
private static final String[] SUBTYPES_SPREADSHEET = {
|
||||
"msexcel",
|
||||
"vnd.ms-excel",
|
||||
"vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"vnd.oasis.opendocument.spreadsheet"
|
||||
};
|
||||
private static Set<String> SUBTYPES_SPREADSHEET_SET = new HashSet<String>(Arrays.asList(SUBTYPES_SPREADSHEET));
|
||||
private static final String[] SUBTYPES_PRESENTATION = {
|
||||
"mspowerpoint",
|
||||
"vnd.ms-powerpoint",
|
||||
"vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"vnd.oasis.opendocument.presentation"
|
||||
};
|
||||
private static Set<String> SUBTYPES_PRESENTATION_SET = new HashSet<String>(Arrays.asList(SUBTYPES_PRESENTATION));
|
||||
private static final String[] SUBTYPES_COMPRESSED = {"x-tar", "x-gzip", "zip"};
|
||||
private static final Set<String> SUBTYPES_COMPRESSED_SET = new HashSet<String>(Arrays.asList(SUBTYPES_COMPRESSED));
|
||||
private static final String SUBTYPE_OCTET_STREAM = "octet-stream";
|
||||
private static final String EXTENSION_RAR = "rar";
|
||||
private static final String EXTENSION_RTF = "rtf";
|
||||
private static final String EXTENSION_3GP = "3gp";
|
||||
private static final String EXTENSION_PY = "py";
|
||||
private static final String EXTENSION_JS = "js";
|
||||
|
||||
/**
|
||||
* Converts the file size in bytes to human readable output.
|
||||
*
|
||||
|
@ -141,100 +95,14 @@ public class DisplayUtils {
|
|||
* @return A human friendly version of the MIME type
|
||||
*/
|
||||
public static String convertMIMEtoPrettyPrint(String mimetype) {
|
||||
if (mimeType2HUmanReadable.containsKey(mimetype)) {
|
||||
return mimeType2HUmanReadable.get(mimetype);
|
||||
if (mimeType2HumanReadable.containsKey(mimetype)) {
|
||||
return mimeType2HumanReadable.get(mimetype);
|
||||
}
|
||||
if (mimetype.split("/").length >= 2)
|
||||
return mimetype.split("/")[1].toUpperCase() + " file";
|
||||
return "Unknown type";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the resource identifier of an image to use as icon associated to a known MIME type.
|
||||
*
|
||||
* @param mimetype MIME type string; if NULL, the method tries to guess it from the extension in filename
|
||||
* @param filename Name, with extension.
|
||||
* @return Identifier of an image resource.
|
||||
*/
|
||||
public static int getFileTypeIconId(String mimetype, String filename) {
|
||||
|
||||
if (mimetype == null) {
|
||||
String fileExtension = getExtension(filename);
|
||||
mimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
|
||||
if (mimetype == null) {
|
||||
mimetype = TYPE_APPLICATION + "/" + SUBTYPE_OCTET_STREAM;
|
||||
}
|
||||
}
|
||||
|
||||
if ("DIR".equals(mimetype)) {
|
||||
return R.drawable.ic_menu_archive;
|
||||
|
||||
} else {
|
||||
String [] parts = mimetype.split("/");
|
||||
String type = parts[0];
|
||||
String subtype = (parts.length > 1) ? parts[1] : "";
|
||||
|
||||
if(TYPE_TXT.equals(type)) {
|
||||
return R.drawable.file_doc;
|
||||
|
||||
} else if(TYPE_IMAGE.equals(type)) {
|
||||
return R.drawable.file_image;
|
||||
|
||||
} else if(TYPE_VIDEO.equals(type)) {
|
||||
return R.drawable.file_movie;
|
||||
|
||||
} else if(TYPE_AUDIO.equals(type)) {
|
||||
return R.drawable.file_sound;
|
||||
|
||||
} else if(TYPE_APPLICATION.equals(type)) {
|
||||
|
||||
if (SUBTYPE_PDF.equals(subtype)) {
|
||||
return R.drawable.file_pdf;
|
||||
|
||||
} else if (SUBTYPE_XML.equals(subtype)) {
|
||||
return R.drawable.file_doc;
|
||||
|
||||
} else if (SUBTYPES_DOCUMENT_SET.contains(subtype)) {
|
||||
return R.drawable.file_doc;
|
||||
|
||||
} else if (SUBTYPES_SPREADSHEET_SET.contains(subtype)) {
|
||||
return R.drawable.file_xls;
|
||||
|
||||
} else if (SUBTYPES_PRESENTATION_SET.contains(subtype)) {
|
||||
return R.drawable.file_ppt;
|
||||
|
||||
} else if (SUBTYPES_COMPRESSED_SET.contains(subtype)) {
|
||||
return R.drawable.file_zip;
|
||||
|
||||
} else if (SUBTYPE_OCTET_STREAM.equals(subtype) ) {
|
||||
if (getExtension(filename).equalsIgnoreCase(EXTENSION_RAR)) {
|
||||
return R.drawable.file_zip;
|
||||
|
||||
} else if (getExtension(filename).equalsIgnoreCase(EXTENSION_RTF)) {
|
||||
return R.drawable.file_doc;
|
||||
|
||||
} else if (getExtension(filename).equalsIgnoreCase(EXTENSION_3GP)) {
|
||||
return R.drawable.file_movie;
|
||||
|
||||
} else if ( getExtension(filename).equalsIgnoreCase(EXTENSION_PY) ||
|
||||
getExtension(filename).equalsIgnoreCase(EXTENSION_JS)) {
|
||||
return R.drawable.file_doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default icon
|
||||
return R.drawable.file;
|
||||
}
|
||||
|
||||
|
||||
private static String getExtension(String filename) {
|
||||
String extension = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Unix time to human readable format
|
||||
* @param milliseconds that have passed since 01/01/1970
|
||||
|
@ -246,7 +114,6 @@ public class DisplayUtils {
|
|||
return df.format(date);
|
||||
}
|
||||
|
||||
|
||||
public static int getSeasonalIconId() {
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_YEAR) >= 354 &&
|
||||
MainApp.getAppContext().getString(R.string.app_name).equals(OWNCLOUD_APP_NAME)) {
|
||||
|
|
411
src/com/owncloud/android/utils/MimetypeIconUtil.java
Normal file
411
src/com/owncloud/android/utils/MimetypeIconUtil.java
Normal file
|
@ -0,0 +1,411 @@
|
|||
package com.owncloud.android.utils;
|
||||
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Helper class for detecting the right icon for a file, based on its mimen type and/or file extension.
|
||||
*/
|
||||
public class MimetypeIconUtil {
|
||||
|
||||
private static final Map<String, Integer> MIMETYPE_TO_ICON_MAPPING = new HashMap<String, Integer>();
|
||||
private static final Map<String, Integer> MAINMIMETYPE_TO_ICON_MAPPING = new HashMap<String, Integer>();
|
||||
private static final Map<String, List<String>> FILE_EXTENSION_TO_MIMETYPE_MAPPING =
|
||||
new HashMap<String, List<String>>();
|
||||
|
||||
static {
|
||||
populateFileExtensionMimeTypeMapping();
|
||||
populateMimeTypeIconMapping();
|
||||
populateMainMimeTypeMapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource identifier of an image to use as icon associated to a known MIME type.
|
||||
*
|
||||
* @param mimetype MIME type string; if NULL, the method tries to guess it from the extension in filename
|
||||
* @param filename Name, with extension.
|
||||
* @return Identifier of an image resource.
|
||||
*/
|
||||
public static int getFileTypeIconId(String mimetype, String filename) {
|
||||
List<String> possibleMimeTypes;
|
||||
if (mimetype == null) {
|
||||
possibleMimeTypes = determineMimeTypesByFilename(filename);
|
||||
} else {
|
||||
possibleMimeTypes = Collections.singletonList(mimetype);
|
||||
}
|
||||
|
||||
return determineIconIdByMimeTypeList(possibleMimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* determines the icon based on the mime type.
|
||||
*
|
||||
* @param mimetypes the mimetypes
|
||||
* @return the icon id, R.drawable.file if the mime type could not be matched at all or was {@code null}
|
||||
*/
|
||||
private static int determineIconIdByMimeTypeList(List<String> mimetypes) {
|
||||
// no mime type leads to file
|
||||
if (mimetypes == null || mimetypes.size() < 1) {
|
||||
return R.drawable.file;
|
||||
} else {
|
||||
|
||||
// search for full mime type mapping
|
||||
for (String mimetype : mimetypes) {
|
||||
Integer iconId = MIMETYPE_TO_ICON_MAPPING.get(mimetype);
|
||||
|
||||
if (iconId != null) {
|
||||
return iconId;
|
||||
}
|
||||
}
|
||||
|
||||
// fallback to main mime type part mapping
|
||||
for (String mimetype : mimetypes) {
|
||||
String mainMimetypePart = mimetype.split("/")[0];
|
||||
|
||||
Integer iconId = MAINMIMETYPE_TO_ICON_MAPPING.get(mainMimetypePart);
|
||||
if (iconId != null) {
|
||||
return iconId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no match found at all, falling back to file
|
||||
return R.drawable.file;
|
||||
}
|
||||
|
||||
/**
|
||||
* determines the list of possible mime types for the given file, based on its extension.
|
||||
*
|
||||
* @param filename the file name
|
||||
* @return list of possible mime types (ordered), empty list in case no mime types found
|
||||
*/
|
||||
private static List<String> determineMimeTypesByFilename(String filename) {
|
||||
String fileExtension = getExtension(filename);
|
||||
|
||||
// try detecting the mimetype based on the web app logic equivalent
|
||||
List<String> mimeTypeList = FILE_EXTENSION_TO_MIMETYPE_MAPPING.get(fileExtension);
|
||||
if (mimeTypeList != null && mimeTypeList.size() > 0) {
|
||||
return mimeTypeList;
|
||||
} else {
|
||||
// try detecting the mime type via android itself
|
||||
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
|
||||
if (mimeType != null) {
|
||||
return Collections.singletonList(mimeType);
|
||||
} else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getExtension(String filename) {
|
||||
String extension = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* populates the mapping list: full mime type --> icon.
|
||||
*/
|
||||
private static void populateMimeTypeIconMapping() {
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/coreldraw", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/epub+zip", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/font-sfnt", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/font-woff", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/illustrator", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/javascript", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/json", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/msaccess", R.drawable.file);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/msexcel", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/mspowerpoint", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/msword", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/octet-stream", R.drawable.file);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/postscript", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/pdf", R.drawable.file_pdf);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/rss+xml", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/rtf", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.android.package-archive", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.addin.macroEnabled.12", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.sheet.binary.macroEnabled.12", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.sheet.macroEnabled.12", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.template.macroEnabled.12", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-fontobject", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.addin.macroEnabled.12", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.presentation.macroEnabled.12", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.slideshow.macroEnabled.12", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.template.macroEnabled.12", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-word.document.macroEnabled.12", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-word.template.macroEnabled.12", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.presentation", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.presentation-template", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.spreadsheet", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.spreadsheet-template", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-master", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-template", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.text-web", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.presentation", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.slideshow", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.presentationml.template", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.template", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.template", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-7z-compressed", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-cbr", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-compressed", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-dcraw", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-deb", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-font", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-gimp", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-gzip", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-ms-dos-executable", R.drawable.file_application);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-msi", R.drawable.file_application);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-iwork-numbers-sffnumbers", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-iwork-keynote-sffkey", R.drawable.file_ppt);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-iwork-pages-sffpages", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-perl", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-photoshop", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-php", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-rar-compressed", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-shockwave-flash", R.drawable.file_application);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-tar", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/x-tex", R.drawable.file_doc);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/xml", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/yaml", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("application/zip", R.drawable.file_zip);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("database", R.drawable.file);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("httpd/unix-directory", R.drawable.ic_menu_archive);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("image/svg+xml", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("image/vector", R.drawable.file_image);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/calendar", R.drawable.file_calendar);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/css", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/csv", R.drawable.file_xls);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/html", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/vcard", R.drawable.file_vcard);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/x-c", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/x-c++src", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/x-h", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/x-python", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("text/x-shellscript", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("web", R.drawable.file_code);
|
||||
MIMETYPE_TO_ICON_MAPPING.put("DIR", R.drawable.ic_menu_archive);
|
||||
}
|
||||
|
||||
/**
|
||||
* populates the mapping list: main mime type --> icon.
|
||||
*/
|
||||
private static void populateMainMimeTypeMapping() {
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("audio", R.drawable.file_sound);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("database", R.drawable.file);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("httpd", R.drawable.file_zip);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("image", R.drawable.file_image);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("text", R.drawable.file_doc);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("video", R.drawable.file_movie);
|
||||
MAINMIMETYPE_TO_ICON_MAPPING.put("web", R.drawable.file_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* populates the mapping list: file extension --> mime type.
|
||||
*/
|
||||
private static void populateFileExtensionMimeTypeMapping() {
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("3gp", Collections.singletonList("video/3gpp"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("7z", Collections.singletonList("application/x-7z-compressed"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("accdb", Collections.singletonList("application/msaccess"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ai", Collections.singletonList("application/illustrator"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("apk", Collections.singletonList("application/vnd.android.package-archive"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("arw", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("avi", Collections.singletonList("video/x-msvideo"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bash", Collections.singletonList("text/x-shellscript"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("blend", Collections.singletonList("application/x-blender"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bin", Collections.singletonList("application/x-bin"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bmp", Collections.singletonList("image/bmp"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bpg", Collections.singletonList("image/bpg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cb7", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cba", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbr", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbt", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbtc", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbz", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cc", Collections.singletonList("text/x-c"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cdr", Collections.singletonList("application/coreldraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cnf", Collections.singletonList("text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("conf", Collections.singletonList("text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cpp", Collections.singletonList("text/x-c++src"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cr2", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("css", Collections.singletonList("text/css"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("csv", Collections.singletonList("text/csv"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cvbdl", Collections.singletonList("application/x-cbr"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("c", Collections.singletonList("text/x-c"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("c++", Collections.singletonList("text/x-c++src"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dcr", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("deb", Collections.singletonList("application/x-deb"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dng", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("doc", Collections.singletonList("application/msword"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docm", Collections.singletonList("application/vnd.ms-word.document.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("docx", Collections.singletonList("application/vnd.openxmlformats-officedocument.wordprocessingml.document"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dot", Collections.singletonList("application/msword"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dotx", Collections.singletonList("application/vnd.openxmlformats-officedocument.wordprocessingml.template"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("dv", Collections.singletonList("video/dv"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("eot", Collections.singletonList("application/vnd.ms-fontobject"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("epub", Collections.singletonList("application/epub+zip"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("eps", Collections.singletonList("application/postscript"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("erf", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("exe", Collections.singletonList("application/x-ms-dos-executable"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("flac", Collections.singletonList("audio/flac"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("flv", Collections.singletonList("video/x-flv"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gif", Collections.singletonList("image/gif"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gz", Collections.singletonList("application/x-gzip"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gzip", Collections.singletonList("application/x-gzip"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("h", Collections.singletonList("text/x-h"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("hh", Collections.singletonList("text/x-h"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("html", Arrays.asList("text/html", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("htm", Arrays.asList("text/html", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ical", Collections.singletonList("text/calendar"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ics", Collections.singletonList("text/calendar"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("iiq", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("impress", Collections.singletonList("text/impress"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jpeg", Collections.singletonList("image/jpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jpg", Collections.singletonList("image/jpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jps", Collections.singletonList("image/jpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("js", Arrays.asList("application/javascript", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("json", Arrays.asList("application/json", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("k25", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kdc", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("key", Collections.singletonList("application/x-iwork-keynote-sffkey"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("keynote", Collections.singletonList("application/x-iwork-keynote-sffkey"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kra", Collections.singletonList("application/x-krita"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m4v", Collections.singletonList("video/mp4"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("markdown", Collections.singletonList("text/markdown"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mdown", Collections.singletonList("text/markdown"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("md", Collections.singletonList("text/markdown"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mdb", Collections.singletonList("application/msaccess"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mdwn", Collections.singletonList("text/markdown"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mkd", Collections.singletonList("text/markdown"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mef", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mkv", Collections.singletonList("video/x-matroska"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mobi", Collections.singletonList("application/x-mobipocket-ebook"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mov", Collections.singletonList("video/quicktime"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mp3", Collections.singletonList("audio/mpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mp4", Collections.singletonList("video/mp4"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mpeg", Collections.singletonList("video/mpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mpg", Collections.singletonList("video/mpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mpo", Collections.singletonList("image/jpeg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("msi", Collections.singletonList("application/x-msi"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mts", Collections.singletonList("video/MP2T"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mt2s", Collections.singletonList("video/MP2T"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("nef", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("numbers", Collections.singletonList("application/x-iwork-numbers-sffnumbers"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odf", Collections.singletonList("application/vnd.oasis.opendocument.formula"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odg", Collections.singletonList("application/vnd.oasis.opendocument.graphics"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odp", Collections.singletonList("application/vnd.oasis.opendocument.presentation"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ods", Collections.singletonList("application/vnd.oasis.opendocument.spreadsheet"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("odt", Collections.singletonList("application/vnd.oasis.opendocument.text"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("oga", Collections.singletonList("audio/ogg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogg", Collections.singletonList("audio/ogg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogv", Collections.singletonList("video/ogg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("opus", Collections.singletonList("audio/ogg"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("orf", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("otf", Collections.singletonList("application/font-sfnt"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pages", Collections.singletonList("application/x-iwork-pages-sffpages"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pdf", Collections.singletonList("application/pdf"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pfb", Collections.singletonList("application/x-font"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pef", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("php", Collections.singletonList("application/x-php"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pl", Collections.singletonList("application/x-perl"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("png", Collections.singletonList("image/png"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pot", Collections.singletonList("application/vnd.ms-powerpoint"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potm", Collections.singletonList("application/vnd.ms-powerpoint.template.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.template"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppa", Collections.singletonList("application/vnd.ms-powerpoint"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppam", Collections.singletonList("application/vnd.ms-powerpoint.addin.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pps", Collections.singletonList("application/vnd.ms-powerpoint"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsm", Collections.singletonList("application/vnd.ms-powerpoint.slideshow.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppsx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.slideshow"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ppt", Collections.singletonList("application/vnd.ms-powerpoint"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptm", Collections.singletonList("application/vnd.ms-powerpoint.presentation.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pptx", Collections.singletonList("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ps", Collections.singletonList("application/postscript"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("psd", Collections.singletonList("application/x-photoshop"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("py", Collections.singletonList("text/x-python"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("raf", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rar", Collections.singletonList("application/x-rar-compressed"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("reveal", Collections.singletonList("text/reveal"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rtf", Collections.singletonList("application/rtf"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rw2", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sgf", Collections.singletonList("application/sgf"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sh-lib", Collections.singletonList("text/x-shellscript"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sh", Collections.singletonList("text/x-shellscript"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("srf", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sr2", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("svg", Arrays.asList("image/svg+xml", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("swf", Arrays.asList("application/x-shockwave-flash", "application/octet-stream"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tar", Collections.singletonList("application/x-tar"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gz", Collections.singletonList("application/x-compressed"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tex", Collections.singletonList("application/x-tex"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tgz", Collections.singletonList("application/x-compressed"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tiff", Collections.singletonList("image/tiff"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tif", Collections.singletonList("image/tiff"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ttf", Collections.singletonList("application/font-sfnt"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("txt", Collections.singletonList("text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vcard", Collections.singletonList("text/vcard"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vcf", Collections.singletonList("text/vcard"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vob", Collections.singletonList("video/dvd"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wav", Collections.singletonList("audio/wav"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("webm", Collections.singletonList("video/webm"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("woff", Collections.singletonList("application/font-woff"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wmv", Collections.singletonList("video/x-ms-wmv"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xcf", Collections.singletonList("application/x-gimp"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xla", Collections.singletonList("application/vnd.ms-excel"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlam", Collections.singletonList("application/vnd.ms-excel.addin.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xls", Collections.singletonList("application/vnd.ms-excel"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsb", Collections.singletonList("application/vnd.ms-excel.sheet.binary.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsm", Collections.singletonList("application/vnd.ms-excel.sheet.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlsx", Collections.singletonList("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xlt", Collections.singletonList("application/vnd.ms-excel"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltm", Collections.singletonList("application/vnd.ms-excel.template.macroEnabled.12"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xltx", Collections.singletonList("application/vnd.openxmlformats-officedocument.spreadsheetml.template"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xml", Arrays.asList("application/xml", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xrf", Collections.singletonList("image/x-dcraw"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("yaml", Arrays.asList("application/yaml", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("yml", Arrays.asList("application/yaml", "text/plain"));
|
||||
FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("zip", Collections.singletonList("application/zip"));
|
||||
}
|
||||
|
||||
/**
|
||||
public static void main(String[] args) {
|
||||
Iterator<String> fileExtensions = FILE_EXTENSION_TO_MIMETYPE_MAPPING.keySet().iterator();
|
||||
String extension;
|
||||
List<String> mimeTypes;
|
||||
Map<Integer, String> iconTextMap = new HashMap<Integer, String>();
|
||||
iconTextMap.put(R.drawable.file, "file");
|
||||
iconTextMap.put(R.drawable.file_application, "app");
|
||||
iconTextMap.put(R.drawable.file_calendar, "calendar");
|
||||
iconTextMap.put(R.drawable.file_code, "code");
|
||||
iconTextMap.put(R.drawable.file_doc, "document");
|
||||
iconTextMap.put(R.drawable.file_image, "image");
|
||||
iconTextMap.put(R.drawable.file_movie, "movie");
|
||||
iconTextMap.put(R.drawable.file_pdf, "pdf");
|
||||
iconTextMap.put(R.drawable.file_ppt, "presentation");
|
||||
iconTextMap.put(R.drawable.file_sound, "sound");
|
||||
iconTextMap.put(R.drawable.file_vcard, "vcard");
|
||||
iconTextMap.put(R.drawable.file_xls, "spreadsheet");
|
||||
iconTextMap.put(R.drawable.file_zip, "archive");
|
||||
while (fileExtensions.hasNext()) {
|
||||
extension = fileExtensions.next();
|
||||
System.out.println(extension + " / " + iconTextMap.get(getFileTypeIconId(null, "test." + extension)));
|
||||
}
|
||||
|
||||
System.out.println("notExistingExtension" + " / " + iconTextMap.get(getFileTypeIconId(null, "test." + "notExistingExtension")));
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in a new issue