1.[代码][Java]代码
/*
* Copyright (C) 2013 Simple Explorer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.dnielfe.manager.preview;
import android.webkit.MimeTypeMap;
import com.dnielfe.manager.R;
import com.dnielfe.manager.utils.SimpleUtils;
import java.io.File;
import java.util.HashMap;
import java.util.Locale;
import java.util.regex.Pattern;
public final class MimeTypes {
public static final String ALL_MIME_TYPES = "*/*";
private static final HashMap EXT_ICONS = new HashMap<>();
private static final HashMap MIME_TYPES = new HashMap<>();
static {
// BINARY
EXT_ICONS.put("a", R.drawable.type_unknown);
EXT_ICONS.put("bin", R.drawable.type_unknown);
EXT_ICONS.put("class", R.drawable.type_unknown);
EXT_ICONS.put("com", R.drawable.type_unknown);
EXT_ICONS.put("dex", R.drawable.type_unknown);
EXT_ICONS.put("dump", R.drawable.type_unknown);
EXT_ICONS.put("exe", R.drawable.type_unknown);
EXT_ICONS.put("dat", R.drawable.type_unknown);
EXT_ICONS.put("dll", R.drawable.type_unknown);
EXT_ICONS.put("lib", R.drawable.type_unknown);
EXT_ICONS.put("o", R.drawable.type_unknown);
EXT_ICONS.put("obj", R.drawable.type_unknown);
EXT_ICONS.put("pyc", R.drawable.type_unknown);
EXT_ICONS.put("pyo", R.drawable.type_unknown);
EXT_ICONS.put("ser", R.drawable.type_unknown);
EXT_ICONS.put("swf", R.drawable.type_unknown);
EXT_ICONS.put("so", R.drawable.type_unknown);
// Shell
EXT_ICONS.put("bar", R.drawable.type_unknown);
EXT_ICONS.put("csh", R.drawable.type_unknown);
EXT_ICONS.put("ksh", R.drawable.type_unknown);
EXT_ICONS.put("sh", R.drawable.type_unknown);
// TEXT
EXT_ICONS.put("csv", R.drawable.type_note);
EXT_ICONS.put("diff", R.drawable.type_note);
EXT_ICONS.put("in", R.drawable.type_note);
EXT_ICONS.put("list", R.drawable.type_note);
EXT_ICONS.put("log", R.drawable.type_note);
EXT_ICONS.put("rc", R.drawable.type_note);
EXT_ICONS.put("text", R.drawable.type_note);
EXT_ICONS.put("txt", R.drawable.type_note);
EXT_ICONS.put("tsv", R.drawable.type_note);
// Properties
EXT_ICONS.put("properties", R.drawable.type_config);
EXT_ICONS.put("conf", R.drawable.type_config);
EXT_ICONS.put("config", R.drawable.t