Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ea293d0 authored by Danny Baumann's avatar Danny Baumann
Browse files

Fix a number of default locale issues.

See http://elliotth.blogspot.com/2012/01/beware-convenience-methods.html

Change-Id: I1f1e8dba6bbe862fcefc4bbde7d3eb0dfaf15982
parent 7a197395
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.cyanogenmod.filemanager.util.StorageHelper;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * An activity for show bookmarks and links.
@@ -549,7 +550,7 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
            StorageVolume[] volumes = StorageHelper.getStorageVolumes(getApplication());
            int cc = volumes.length;
            for (int i = 0; i < cc ; i++) {
                if (volumes[i].getPath().toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$
                if (volumes[i].getPath().toLowerCase(Locale.ROOT).indexOf("usb") != -1) { //$NON-NLS-1$
                    bookmarks.add(
                            new Bookmark(
                                    BOOKMARK_TYPE.USB,
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Locale;

/**
 * A class for calculate MD5 and SHA-1 checksums of a file system object.<br />
@@ -241,7 +242,8 @@ public class ChecksumCommand extends Program implements ChecksumExecutable {
            checkCancelled();

            // Finally digest
            this.mChecksums[type.ordinal()] = HexDump.toHexString(md.digest()).toLowerCase();
            this.mChecksums[type.ordinal()] =
                    HexDump.toHexString(md.digest()).toLowerCase(Locale.ROOT);
            checkCancelled();
            if (this.mAsyncResultListener != null) {
                this.mAsyncResultListener.onPartialResult(this.mChecksums[type.ordinal()]);
+30 −41
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.cyanogenmod.filemanager.model.SystemFile;
import java.io.File;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

@@ -246,7 +247,7 @@ public final class MimeTypeHelper {
        //Get the extension and delivery
        String ext = FileHelper.getExtension(fso);
        if (ext != null) {
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase(Locale.ROOT));
            if (mimeTypeInfo != null) {
                // Create a new drawable
                if (!TextUtils.isEmpty(mimeTypeInfo.mDrawable)) {
@@ -298,15 +299,7 @@ public final class MimeTypeHelper {
        }

        //Get the extension and delivery
        String ext = FileHelper.getExtension(fso);
        if (ext != null) {
            //Load from the database of mime types
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            if (mimeTypeInfo != null) {
                return mimeTypeInfo.mMimeType;
            }
        }
        return null;
        return getMimeTypeFromExtension(fso);
    }

    /**
@@ -347,15 +340,27 @@ public final class MimeTypeHelper {
        }

        //Get the extension and delivery
        String mime = getMimeTypeFromExtension(fso);
        if (mime != null) {
            return mime;
        }

        return res.getString(R.string.mime_unknown);
    }

    private static final String getMimeTypeFromExtension(final FileSystemObject fso) {
        String ext = FileHelper.getExtension(fso);
        if (ext != null) {
            //Load from the database of mime types
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            if (mimeTypeInfo != null) {
                return mimeTypeInfo.mMimeType;
        if (ext == null) {
            return null;
        }

        //Load from the database of mime types
        MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase(Locale.ROOT));
        if (mimeTypeInfo == null) {
            return null;
        }
        return res.getString(R.string.mime_unknown);

        return mimeTypeInfo.mMimeType;
    }

    /**
@@ -377,7 +382,7 @@ public final class MimeTypeHelper {
        }
        if (ext != null) {
            //Load from the database of mime types
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase(Locale.ROOT));
            if (mimeTypeInfo != null) {
                return mimeTypeInfo.mCategory;
            }
@@ -411,17 +416,7 @@ public final class MimeTypeHelper {
        }

        //Get the extension and delivery
        String ext = FileHelper.getExtension(file.getName());
        if (ext != null) {
            //Load from the database of mime types
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            if (mimeTypeInfo != null) {
                return mimeTypeInfo.mCategory;
            }
        }

        // No category
        return MimeTypeCategory.NONE;
        return getCategoryFromExt(context, FileHelper.getExtension(file.getName()));
    }

    /**
@@ -451,21 +446,15 @@ public final class MimeTypeHelper {
        }

        //Get the extension and delivery
        String ext = FileHelper.getExtension(fso);
        if (ext != null) {
            //Load from the database of mime types
            MimeTypeInfo mimeTypeInfo = sMimeTypes.get(ext.toLowerCase());
            if (mimeTypeInfo != null) {
                return mimeTypeInfo.mCategory;
            }
        }
        final MimeTypeCategory category = getCategoryFromExt(context,
                FileHelper.getExtension(fso));

        // Check  system file
        if (fso instanceof SystemFile) {
        if (category == MimeTypeCategory.NONE && fso instanceof SystemFile) {
            return MimeTypeCategory.SYSTEM;
        }

        // No category
        return MimeTypeCategory.NONE;
        return category;
    }

    /**
@@ -481,7 +470,7 @@ public final class MimeTypeHelper {
            return "-";  //$NON-NLS-1$
        }
        try {
            String id = "category_" + category.toString().toLowerCase(); //$NON-NLS-1$
            String id = "category_" + category.toString().toLowerCase(Locale.ROOT); //$NON-NLS-1$
            int resid = ResourcesHelper.getIdentifier(
                    context.getResources(), "string", id); //$NON-NLS-1$
            return context.getString(resid);
+3 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.cyanogenmod.filemanager.model.SearchResult;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -68,8 +69,8 @@ public final class SearchHelper {
        }

        //Convert the string to lower and upper
        final String lowerCase = q.toLowerCase();
        final String upperCase = q.toUpperCase();
        final String lowerCase = q.toLowerCase(Locale.ROOT);
        final String upperCase = q.toUpperCase(Locale.ROOT);

        //Create the regular expression filter
        StringBuffer sb = new StringBuffer();
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.cyanogenmod.filemanager.R;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

import java.util.Locale;

/**
 * A helper class with useful methods for deal with storages.
@@ -60,7 +60,7 @@ public final class StorageHelper {
                    File externalStorage = Environment.getExternalStorageDirectory();
                    String path = externalStorage.getCanonicalPath();
                    String description = null;
                    if (path.toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$
                    if (path.toLowerCase(Locale.ROOT).indexOf("usb") != -1) { //$NON-NLS-1$
                        description = ctx.getString(R.string.usb_storage);
                    } else {
                        description = ctx.getString(R.string.external_storage);