Merge pull request #1839 from nextcloud/locales

Fix: implicitly using the default locale is a common source of bugs
This commit is contained in:
Tobias Kaminsky 2018-01-09 11:05:52 +01:00 committed by GitHub
commit 8e57107f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 102 additions and 77 deletions

View file

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 172 warnings</span>
<span class="mdl-layout-title">Lint Report: 131 warnings</span>

View file

@ -63,6 +63,7 @@ import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Locale;
public class PushUtils {
@ -191,7 +192,7 @@ public class PushUtils {
if (!TextUtils.isEmpty(MainApp.getAppContext().getResources().getString(R.string.push_server_url)) &&
!TextUtils.isEmpty(token)) {
PushUtils.generateRsa2048KeyPair();
String pushTokenHash = PushUtils.generateSHA512Hash(token).toLowerCase();
String pushTokenHash = PushUtils.generateSHA512Hash(token).toLowerCase(Locale.ROOT);
PublicKey devicePublicKey = (PublicKey) PushUtils.readKeyFromFile(true);
if (devicePublicKey != null) {
byte[] publicKeyBytes = Base64.encode(devicePublicKey.getEncoded(), Base64.NO_WRAP);

View file

@ -130,6 +130,7 @@ import java.io.InputStream;
import java.net.URLDecoder;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -330,7 +331,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
} else {
setContentView(R.layout.account_setup_webview);
mLoginWebView = (WebView) findViewById(R.id.login_webview);
mLoginWebView = findViewById(R.id.login_webview);
initWebViewLogin(null);
}
@ -353,14 +354,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
private static String getWebLoginUserAgent() {
return Build.MANUFACTURER.substring(0, 1).toUpperCase() +
Build.MANUFACTURER.substring(1).toLowerCase() + " " + Build.MODEL;
return Build.MANUFACTURER.substring(0, 1).toUpperCase(Locale.getDefault()) +
Build.MANUFACTURER.substring(1).toLowerCase(Locale.getDefault()) + " " + Build.MODEL;
}
private void initWebViewLogin(String baseURL) {
mLoginWebView.setVisibility(View.GONE);
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.login_webview_progress_bar);
final ProgressBar progressBar = findViewById(R.id.login_webview_progress_bar);
mLoginWebView.getSettings().setAllowFileAccess(false);
mLoginWebView.getSettings().setJavaScriptEnabled(true);
@ -572,15 +573,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
* Configures elements in the user interface under direct control of the Activity.
*/
private void initOverallUi() {
mHostUrlInput = (CustomEditText) findViewById(R.id.hostUrlInput);
mUsernameInputLayout = (TextInputLayout) findViewById(R.id.input_layout_account_username);
mPasswordInputLayout = (TextInputLayout) findViewById(R.id.input_layout_account_password);
mPasswordInput = (EditText) findViewById(R.id.account_password);
mUsernameInput = (EditText) findViewById(R.id.account_username);
mAuthStatusView = (TextView) findViewById(R.id.auth_status_text);
mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
mServerStatusView = (TextView) findViewById(R.id.server_status_text);
mTestServerButton = (ImageButton) findViewById(R.id.testServerButton);
mHostUrlInput = findViewById(R.id.hostUrlInput);
mUsernameInputLayout = findViewById(R.id.input_layout_account_username);
mPasswordInputLayout = findViewById(R.id.input_layout_account_password);
mPasswordInput = findViewById(R.id.account_password);
mUsernameInput = findViewById(R.id.account_username);
mAuthStatusView = findViewById(R.id.auth_status_text);
mOAuth2Check = findViewById(R.id.oauth_onOff_check);
mServerStatusView = findViewById(R.id.server_status_text);
mTestServerButton = findViewById(R.id.testServerButton);
mOkButton = findViewById(R.id.buttonOK);
mOkButton.setOnClickListener(v -> onOkClick());
@ -603,13 +604,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
/// step 2 - set properties of UI elements (text, visibility, enabled...)
Button welcomeLink = (Button) findViewById(R.id.welcome_link);
Button welcomeLink = findViewById(R.id.welcome_link);
welcomeLink.setVisibility(mAction == ACTION_CREATE && isWelcomeLinkVisible ? View.VISIBLE : View.GONE);
welcomeLink.setText(getString(R.string.auth_register));
mTestServerButton.setVisibility(mAction == ACTION_CREATE ? View.VISIBLE : View.GONE);
TextView instructionsView = (TextView) findViewById(R.id.instructions_message);
TextView instructionsView = findViewById(R.id.instructions_message);
if (instructionsMessageText != null) {
instructionsView.setVisibility(View.VISIBLE);
instructionsView.setText(instructionsMessageText);
@ -665,7 +666,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
if (!webViewLoginMethod) {
/// step 2 - set properties of UI elements (text, visibility, enabled...)
mHostUrlInput = (CustomEditText) findViewById(R.id.hostUrlInput);
mHostUrlInput = findViewById(R.id.hostUrlInput);
// Convert IDN to Unicode
mHostUrlInput.setText(DisplayUtils.convertIdn(mServerInfo.mBaseUrl, false));
if (mAction != ACTION_CREATE) {
@ -681,7 +682,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
showRefreshButton(mServerIsChecked && !mServerIsValid &&
mWaitingForOpId > Integer.MAX_VALUE);
mServerStatusView = (TextView) findViewById(R.id.server_status_text);
mServerStatusView = findViewById(R.id.server_status_text);
showServerStatus();
/// step 3 - bind some listeners and options
@ -741,12 +742,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private void initAuthorizationPreFragment(Bundle savedInstanceState) {
/// step 0 - get UI elements in layout
mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
mOAuthAuthEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_1);
mOAuthTokenEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_2);
mUsernameInput = (EditText) findViewById(R.id.account_username);
mPasswordInput = (EditText) findViewById(R.id.account_password);
mAuthStatusView = (TextView) findViewById(R.id.auth_status_text);
mOAuth2Check = findViewById(R.id.oauth_onOff_check);
mOAuthAuthEndpointText = findViewById(R.id.oAuthEntryPoint_1);
mOAuthTokenEndpointText = findViewById(R.id.oAuthEntryPoint_2);
mUsernameInput = findViewById(R.id.account_username);
mPasswordInput = findViewById(R.id.account_password);
mAuthStatusView = findViewById(R.id.auth_status_text);
/// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
String presetUserName = null;
@ -1434,7 +1435,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
mPasswordInputLayout.setVisibility(View.GONE);
setContentView(R.layout.account_setup_webview);
mLoginWebView = (WebView) findViewById(R.id.login_webview);
mLoginWebView = findViewById(R.id.login_webview);
initWebViewLogin(mServerInfo.mBaseUrl);
} else {
// show old login
@ -1507,7 +1508,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
case OK_NO_SSL:
case OK:
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
if (mHostUrlInput.getText().toString().trim().toLowerCase(Locale.ROOT).startsWith(HTTP_PROTOCOL)) {
mServerStatusText = getResources().getString(R.string.auth_connection_established);
mServerStatusIcon = R.drawable.ic_ok;
} else {
@ -1592,7 +1593,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
case OK_NO_SSL:
case OK:
if (mHostUrlInput.getText().toString().trim().toLowerCase().startsWith(HTTP_PROTOCOL)) {
if (mHostUrlInput.getText().toString().trim().toLowerCase(Locale.ROOT).startsWith(HTTP_PROTOCOL)) {
mAuthStatusText = getResources().getString(R.string.auth_connection_established);
mAuthStatusIcon = R.drawable.ic_ok;
} else {
@ -1712,12 +1713,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
mLoginWebView.setVisibility(View.GONE);
setContentView(R.layout.account_setup);
CustomEditText serverAddressField = (CustomEditText) findViewById(R.id.hostUrlInput);
CustomEditText serverAddressField = findViewById(R.id.hostUrlInput);
serverAddressField.setText(mServerInfo.mBaseUrl);
findViewById(R.id.oauth_onOff_check).setVisibility(View.GONE);
findViewById(R.id.server_status_text).setVisibility(View.GONE);
mAuthStatusView = (TextView) findViewById(R.id.auth_status_text);
mAuthStatusView = findViewById(R.id.auth_status_text);
showAuthStatus();
}
@ -1749,7 +1750,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
} else { // authorization fail due to client side - probably wrong credentials
if (webViewLoginMethod) {
mLoginWebView = (WebView) findViewById(R.id.login_webview);
mLoginWebView = findViewById(R.id.login_webview);
initWebViewLogin(mServerInfo.mBaseUrl);
Snackbar.make(mLoginWebView, getString(R.string.auth_access_failed) + ": " + result.getLogMessage(),

View file

@ -25,6 +25,8 @@ import com.owncloud.android.MainApp;
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import java.util.Locale;
/**
* Helper class for authenticator-URL related logic.
*/
@ -75,8 +77,8 @@ public abstract class AuthenticatorUrlUtils {
if (normalizedUrl != null && normalizedUrl.length() > 0) {
normalizedUrl = normalizedUrl.trim();
if (!normalizedUrl.toLowerCase().startsWith(HTTP_PROTOCOL) &&
!normalizedUrl.toLowerCase().startsWith(HTTP_PROTOCOL)) {
if (!normalizedUrl.toLowerCase(Locale.ROOT).startsWith(HTTP_PROTOCOL) &&
!normalizedUrl.toLowerCase(Locale.ROOT).startsWith(HTTP_PROTOCOL)) {
if (sslWhenUnprefixed) {
normalizedUrl = HTTPS_PROTOCOL + normalizedUrl;
} else {
@ -110,7 +112,7 @@ public abstract class AuthenticatorUrlUtils {
}
private static String trimUrlWebdav(String url) {
if (url.toLowerCase().endsWith(WEBDAV_PATH_4_0_AND_LATER)) {
if (url.toLowerCase(Locale.ROOT).endsWith(WEBDAV_PATH_4_0_AND_LATER)) {
return url.substring(0, url.length() - WEBDAV_PATH_4_0_AND_LATER.length());
}

View file

@ -34,6 +34,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.MimeType;
import java.io.File;
import java.util.Locale;
import third_parties.daveKoeller.AlphanumComparator;
@ -563,7 +564,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
@Override
public int compareTo(OCFile another) {
if (isFolder() && another.isFolder()) {
return getRemotePath().toLowerCase().compareTo(another.getRemotePath().toLowerCase());
return getRemotePath().toLowerCase(Locale.ROOT).compareTo(another.getRemotePath().toLowerCase(Locale.ROOT));
} else if (isFolder()) {
return -1;
} else if (another.isFolder()) {

View file

@ -32,6 +32,7 @@ import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import org.apache.commons.httpclient.HttpStatus;
import java.util.ArrayList;
import java.util.Locale;
/**
* Operation to find out what authentication method requires the server to access files.
@ -101,7 +102,7 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
for (String header : authHeaders) {
// currently we only support basic auth
if (header.toLowerCase().startsWith("basic")) {
if (header.toLowerCase(Locale.ROOT).startsWith("basic")) {
authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
break;
}

View file

@ -34,6 +34,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;
import java.util.ArrayList;
import java.util.Locale;
/**
* Get basic information from an ownCloud server given its URL.
@ -119,7 +120,7 @@ public class GetServerInfoOperation extends RemoteOperation {
if (trimmedUrl.endsWith("/")) {
trimmedUrl = trimmedUrl.substring(0, trimmedUrl.length() - 1);
}
if (trimmedUrl.toLowerCase().endsWith(AuthenticatorUrlUtils.WEBDAV_PATH_4_0_AND_LATER)) {
if (trimmedUrl.toLowerCase(Locale.ROOT).endsWith(AuthenticatorUrlUtils.WEBDAV_PATH_4_0_AND_LATER)) {
trimmedUrl = trimmedUrl.substring(0,
trimmedUrl.length() - AuthenticatorUrlUtils.WEBDAV_PATH_4_0_AND_LATER.length());
}
@ -129,8 +130,8 @@ public class GetServerInfoOperation extends RemoteOperation {
private String normalizeProtocolPrefix(String url, boolean isSslConn) {
if (!url.toLowerCase().startsWith("http://") &&
!url.toLowerCase().startsWith("https://")) {
if (!url.toLowerCase(Locale.ROOT).startsWith("http://") &&
!url.toLowerCase(Locale.ROOT).startsWith("https://")) {
if (isSslConn) {
return "https://" + url;
} else {

View file

@ -51,6 +51,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
/**
@ -148,7 +149,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
MatrixCursor response = null;
String userQuery = uri.getLastPathSegment().toLowerCase();
String userQuery = uri.getLastPathSegment().toLowerCase(Locale.ROOT);
/// need to trust on the AccountUtils to get the current account since the query in the client side is not

View file

@ -33,6 +33,7 @@ import com.owncloud.android.utils.BitmapUtils;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
/**
* A Drawable object that draws text (1 character) on top of a circular/filled background.
@ -116,7 +117,8 @@ public class TextDrawable extends Drawable {
int[] hsl = BitmapUtils.calculateHSL(name);
int[] rgb = BitmapUtils.HSLtoRGB(hsl[0], hsl[1], hsl[2], 1);
return new TextDrawable(name.substring(0, 1).toUpperCase(), rgb[0], rgb[1], rgb[2], radiusInDp);
return new TextDrawable(name.substring(0, 1).toUpperCase(Locale.getDefault()), rgb[0], rgb[1], rgb[2],
radiusInDp);
}
/**

View file

@ -74,6 +74,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static android.support.design.widget.AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS;
@ -280,7 +281,8 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
} else if (f2 == null) {
return 1;
} else if (f1.isEnabled() && f2.isEnabled()) {
return f1.getFolderName().toLowerCase().compareTo(f2.getFolderName().toLowerCase());
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
} else if (f1.isEnabled()) {
return -1;
} else if (f2.isEnabled()) {
@ -291,14 +293,16 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
return -1;
} else if (f2.getFolderName() == null) {
return 1;
} else if (PRIORITIZED_FOLDER.equals(f1.getFolderName()) && PRIORITIZED_FOLDER.equals(f2.getFolderName())) {
} else if (PRIORITIZED_FOLDER.equals(f1.getFolderName()) &&
PRIORITIZED_FOLDER.equals(f2.getFolderName())) {
return 0;
} else if (PRIORITIZED_FOLDER.equals(f1.getFolderName())) {
return -1;
} else if (PRIORITIZED_FOLDER.equals(f2.getFolderName())) {
return 1;
} else {
return f1.getFolderName().toLowerCase().compareTo(f2.getFolderName().toLowerCase());
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
}
}
});

View file

@ -71,6 +71,7 @@ import com.owncloud.android.utils.ThemeUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Vector;
@ -686,7 +687,8 @@ public class FileListListAdapter extends BaseAdapter {
for (int i = 0; i < mFilesAll.size(); i++) {
OCFile currentFile = mFilesAll.get(i);
if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
currentFile.getFileName().toLowerCase(Locale.getDefault()).contains(
constraint.toString().toLowerCase(Locale.getDefault())) &&
!filteredFiles.contains(currentFile)) {
filteredFiles.add(currentFile);
}

View file

@ -47,6 +47,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
/**
@ -147,12 +148,12 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
}
if(!ViewType.GRID_IMAGE.equals(viewType)) {
TextView fileName = (TextView) view.findViewById(R.id.Filename);
TextView fileName = view.findViewById(R.id.Filename);
String name = file.getName();
fileName.setText(name);
}
ImageView fileIcon = (ImageView) view.findViewById(R.id.thumbnail);
ImageView fileIcon = view.findViewById(R.id.thumbnail);
/** Cancellation needs do be checked and done before changing the drawable in fileIcon, or
* {@link ThumbnailsCacheManager#cancelPotentialThumbnailWork} will NEVER cancel any task.
@ -166,11 +167,11 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
}
fileIcon.setTag(file.hashCode());
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);
ImageView checkBoxV = view.findViewById(R.id.custom_checkbox);
TextView fileSizeV = view.findViewById(R.id.file_size);
TextView fileSizeSeparatorV = view.findViewById(R.id.file_separator);
if (!isGridView) {
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
TextView lastModV = view.findViewById(R.id.last_mod);
lastModV.setVisibility(View.VISIBLE);
lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.lastModified()));
view.findViewById(R.id.overflow_menu).setVisibility(View.GONE);
@ -289,7 +290,8 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
}
private int compareNames(File lhs, File rhs) {
return lhs.getName().toLowerCase().compareTo(rhs.getName().toLowerCase());
return lhs.getName().toLowerCase(Locale.getDefault()).compareTo(
rhs.getName().toLowerCase(Locale.getDefault()));
}
});
@ -329,9 +331,9 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
mFiles = mFilesAll.toArray(new File[1]);
} else {
ArrayList<File> result = new ArrayList<>();
text = text.toLowerCase();
text = text.toLowerCase(Locale.getDefault());
for (File file: mFilesAll) {
if (file.getName().toLowerCase().contains(text)) {
if (file.getName().toLowerCase(Locale.getDefault()).contains(text)) {
result.add(file);
}
}

View file

@ -48,6 +48,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
/**
* Dialog showing a list activities able to resolve a given Intent,
@ -92,7 +93,7 @@ public class ShareLinkToDialog extends DialogFragment {
ResolveInfo resolveInfo;
while (it.hasNext()) {
resolveInfo = it.next();
if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())){
if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase(Locale.ROOT))) {
it.remove();
}
}
@ -169,9 +170,9 @@ public class ShareLinkToDialog extends DialogFragment {
}
private void bindView(int position, View row) {
TextView label = (TextView) row.findViewById(R.id.title);
TextView label = row.findViewById(R.id.title);
label.setText(getItem(position).loadLabel(mPackageManager));
ImageView icon = (ImageView) row.findViewById(R.id.icon);
ImageView icon = row.findViewById(R.id.icon);
icon.setImageDrawable(getItem(position).loadIcon(mPackageManager));
}
}

View file

@ -34,6 +34,7 @@ import org.apache.commons.codec.binary.Hex;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
/**
* Utility class with methods for decoding Bitmaps.
@ -277,7 +278,7 @@ public class BitmapUtils {
int lum = 68;
int modulo = 16;
String hash = name.toLowerCase().replaceAll("[^0-9a-f]", "");
String hash = name.toLowerCase(Locale.ROOT).replaceAll("[^0-9a-f]", "");
if (!hash.matches("^[0-9a-f]{32}")) {
hash = md5(hash);

View file

@ -88,6 +88,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -163,7 +164,7 @@ public class DisplayUtils {
return mimeType2HumanReadable.get(mimetype);
}
if (mimetype.split("/").length >= 2) {
return mimetype.split("/")[1].toUpperCase() + " file";
return mimetype.split("/")[1].toUpperCase(Locale.getDefault()) + " file";
}
return MIME_TYPE_UNKNOWN;
}

View file

@ -286,7 +286,7 @@ public class FileStorageUtils {
if (pos >= 0) {
extension = path.substring(pos + 1);
}
String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT));
return (result != null) ? result : "";
}

View file

@ -33,6 +33,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
@ -177,29 +178,29 @@ public class MimeTypeUtil {
* @return 'True' if the mime type defines image
*/
public static boolean isImage(String mimeType) {
return (mimeType != null && mimeType.toLowerCase().startsWith("image/") && !mimeType.toLowerCase().contains
("djvu"));
return (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("image/") &&
!mimeType.toLowerCase(Locale.ROOT).contains("djvu"));
}
/**
* @return 'True' the mime type defines video
*/
public static boolean isVideo(String mimeType) {
return (mimeType != null && mimeType.toLowerCase().startsWith("video/"));
return (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("video/"));
}
/**
* @return 'True' the mime type defines audio
*/
public static boolean isAudio(String mimeType) {
return (mimeType != null && mimeType.toLowerCase().startsWith("audio/"));
return (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("audio/"));
}
/**
* @return 'True' if mime type defines text
*/
public static boolean isText(String mimeType) {
return (mimeType != null && mimeType.toLowerCase().startsWith("text/"));
return (mimeType != null && mimeType.toLowerCase(Locale.ROOT).startsWith("text/"));
}
/**
@ -284,7 +285,7 @@ public class MimeTypeUtil {
*/
private static String extractMimeType(File file) {
Uri selectedUri = Uri.fromFile(file);
String fileExtension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString().toLowerCase());
String fileExtension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString().toLowerCase(Locale.ROOT));
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
}
@ -354,7 +355,7 @@ public class MimeTypeUtil {
if (pos >= 0) {
extension = path.substring(pos + 1);
}
String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT));
return (result != null) ? result : "";
}
@ -365,7 +366,7 @@ public class MimeTypeUtil {
* @return the file extension
*/
private static String getExtension(String filename) {
return filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
return filename.substring(filename.lastIndexOf('.') + 1).toLowerCase(Locale.ROOT);
}
/**

View file

@ -29,6 +29,7 @@ import com.owncloud.android.datamodel.OCFile;
import java.io.File;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
/*
* This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, and David Koelle
@ -86,15 +87,15 @@ public class AlphanumComparator<T> implements Comparator<T> {
}
public int compare(OCFile o1, OCFile o2) {
String s1 = o1.getRemotePath().toLowerCase();
String s2 = o2.getRemotePath().toLowerCase();
String s1 = o1.getRemotePath().toLowerCase(Locale.ROOT);
String s2 = o2.getRemotePath().toLowerCase(Locale.ROOT);
return compare(s1, s2);
}
public int compare(File f1, File f2) {
String s1 = f1.getPath().toLowerCase();
String s2 = f2.getPath().toLowerCase();
String s1 = f1.getPath().toLowerCase(Locale.ROOT);
String s2 = f2.getPath().toLowerCase(Locale.ROOT);
return compare(s1, s2);
}

View file

@ -4,6 +4,7 @@ import android.provider.ContactsContract;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import ezvcard.parameter.AddressType;
@ -164,7 +165,7 @@ public class DataMappings {
return ContactsContract.CommonDataKinds.Website.TYPE_CUSTOM;
}
type = type.toLowerCase();
type = type.toLowerCase(Locale.ROOT);
Integer value = websiteTypeMappings.get(type);
return (value == null) ? ContactsContract.CommonDataKinds.Website.TYPE_CUSTOM : value;
}
@ -180,7 +181,7 @@ public class DataMappings {
return ContactsContract.CommonDataKinds.Event.TYPE_OTHER;
}
type = type.toLowerCase();
type = type.toLowerCase(Locale.ROOT);
for (Map.Entry<String, Integer> entry : abDateMappings.entrySet()){
if (type.contains(entry.getKey())){
return entry.getValue();
@ -200,7 +201,7 @@ public class DataMappings {
return ContactsContract.CommonDataKinds.Relation.TYPE_CUSTOM;
}
type = type.toLowerCase();
type = type.toLowerCase(Locale.ROOT);
for (Map.Entry<String, Integer> entry : abRelatedNamesMappings.entrySet()){
if (type.contains(entry.getKey())){
return entry.getValue();
@ -230,7 +231,7 @@ public class DataMappings {
return ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM;
}
protocol = protocol.toLowerCase();
protocol = protocol.toLowerCase(Locale.ROOT);
Integer value = imProtocolMappings.get(protocol);
return (value == null) ? ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM : value;
}

View file

@ -63,6 +63,7 @@ import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Locale;
public class PushUtils {
@ -191,7 +192,7 @@ public class PushUtils {
if (!TextUtils.isEmpty(MainApp.getAppContext().getResources().getString(R.string.push_server_url)) &&
!TextUtils.isEmpty(token)) {
PushUtils.generateRsa2048KeyPair();
String pushTokenHash = PushUtils.generateSHA512Hash(token).toLowerCase();
String pushTokenHash = PushUtils.generateSHA512Hash(token).toLowerCase(Locale.ROOT);
PublicKey devicePublicKey = (PublicKey) PushUtils.readKeyFromFile(true);
if (devicePublicKey != null) {
byte[] publicKeyBytes = Base64.encode(devicePublicKey.getEncoded(), Base64.NO_WRAP);