Merge pull request #2808 from nextcloud/codacy

Codacy
This commit is contained in:
Andy Scherzinger 2018-07-12 15:51:48 +02:00 committed by GitHub
commit 9c1c2d7f50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 162 additions and 256 deletions

View file

@ -545,7 +545,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
mAuthTokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);
if (mAuthTokenType == null) {
if (mAccount != null) {
boolean oAuthRequired = (mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null);
boolean oAuthRequired = mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null;
boolean samlWebSsoRequired = (
mAccountMgr.getUserData
(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null

View file

@ -91,7 +91,7 @@ public abstract class AuthenticatorUrlUtils {
normalizedUrl = normalizeUrlSuffix(normalizedUrl);
}
return (normalizedUrl != null ? normalizedUrl : "");
return normalizedUrl != null ? normalizedUrl : "";
}
public static String trimWebdavSuffix(String url) {

View file

@ -222,8 +222,6 @@ public class FilesystemDataProvider {
return crc.getValue();
} catch (FileNotFoundException e) {
return -1;
} catch (IOException e) {
return -1;
}

View file

@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author LukeOwncloud
@ -401,8 +401,8 @@ public class OCUpload implements Parcelable {
mRemotePath = source.readString();
mAccountName = source.readString();
mLocalAction = source.readInt();
mForceOverwrite = (source.readInt() == 1);
mIsCreateRemoteFolder = (source.readInt() == 1);
mForceOverwrite = source.readInt() == 1;
mIsCreateRemoteFolder = source.readInt() == 1;
try {
mUploadStatus = UploadStatus.valueOf(source.readString());
} catch (IllegalArgumentException x) {
@ -415,8 +415,8 @@ public class OCUpload implements Parcelable {
mLastResult = UploadResult.UNKNOWN;
}
mCreatedBy = source.readInt();
mIsUseWifiOnly = (source.readInt() == 1);
mIsWhileChargingOnly = (source.readInt() == 1);
mIsUseWifiOnly = source.readInt() == 1;
mIsWhileChargingOnly = source.readInt() == 1;
mFolderUnlockToken = source.readString();
}

View file

@ -134,7 +134,7 @@ public class FileDownloader extends Service
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
.setColor(ThemeUtils.primaryColor(getApplicationContext(), true));
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
}
@ -528,7 +528,7 @@ public class FileDownloader extends Service
new File(download.getSavePath()).getName())
);
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
}

View file

@ -469,7 +469,7 @@ public class FileUploader extends Service
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
.setColor(ThemeUtils.primaryColor(getApplicationContext(), true));
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
}
@ -601,7 +601,7 @@ public class FileUploader extends Service
files[i] = UploadFileOperation.obtainNewOCFileToUpload(
remotePaths[i],
localPaths[i],
((mimeTypes != null) ? mimeTypes[i] : null)
mimeTypes != null ? mimeTypes[i] : null
);
if (files[i] == null) {
Log_OC.e(TAG, "obtainNewOCFileToUpload() returned null for remotePaths[i]:" + remotePaths[i]
@ -612,13 +612,13 @@ public class FileUploader extends Service
}
// at this point variable "OCFile[] files" is loaded correctly.
String uploadKey = null;
UploadFileOperation newUpload = null;
String uploadKey;
UploadFileOperation newUpload;
try {
for (int i = 0; i < files.length; i++) {
for (OCFile file : files) {
OCUpload ocUpload = new OCUpload(files[i], account);
ocUpload.setFileSize(files[i].getFileLength());
OCUpload ocUpload = new OCUpload(file, account);
ocUpload.setFileSize(file.getFileLength());
ocUpload.setForceOverwrite(forceOverwrite);
ocUpload.setCreateRemoteFolder(isCreateRemoteFolder);
ocUpload.setCreatedBy(createdBy);
@ -630,7 +630,7 @@ public class FileUploader extends Service
newUpload = new UploadFileOperation(
account,
files[i],
file,
ocUpload,
forceOverwrite,
localAction,
@ -649,7 +649,7 @@ public class FileUploader extends Service
Pair<String, String> putResult = mPendingUploads.putIfAbsent(
account.name,
files[i].getRemotePath(),
file.getRemotePath(),
newUpload
);
if (putResult != null) {
@ -1153,7 +1153,7 @@ public class FileUploader extends Service
String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName())
);
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
}
@ -1223,7 +1223,7 @@ public class FileUploader extends Service
String content;
// check credentials error
boolean needsToUpdateCredentials = (ResultCode.UNAUTHORIZED.equals(uploadResult.getCode()));
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(uploadResult.getCode());
tickerId = (needsToUpdateCredentials) ?
R.string.uploader_upload_failed_credentials_error : tickerId;

View file

@ -60,7 +60,7 @@ public class NotificationJob extends Job {
@NonNull
@Override
protected Result onRunJob(Params params) {
protected Result onRunJob(@NonNull Params params) {
Context context = getContext();
PersistableBundleCompat persistableBundleCompat = getParams().getExtras();
@ -68,7 +68,6 @@ public class NotificationJob extends Job {
String signature = persistableBundleCompat.getString(KEY_NOTIFICATION_SIGNATURE, "");
if (!TextUtils.isEmpty(subject) && !TextUtils.isEmpty(signature)) {
try {
byte[] base64DecodedSubject = Base64.decode(subject, Base64.DEFAULT);
byte[] base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT);
@ -92,14 +91,10 @@ public class NotificationJob extends Job {
if (!decryptedPushMessage.getApp().equals("spreed")) {
sendNotification(decryptedPushMessage.getSubject(), signatureVerification.getAccount());
}
}
} catch (NoSuchAlgorithmException e1) {
Log.d(TAG, "No proper algorithm to decrypt the message " + e1.getLocalizedMessage());
} catch (NoSuchPaddingException e1) {
Log.d(TAG, "No proper padding to decrypt the message " + e1.getLocalizedMessage());
} catch (InvalidKeyException e1) {
Log.d(TAG, "Invalid private key " + e1.getLocalizedMessage());
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e1) {
Log.d(TAG, "Error decrypting message " + e1.getClass().getName()
+ " " + e1.getLocalizedMessage());
}
} catch (Exception exception) {
Log.d(TAG, "Something went very wrong" + exception.getLocalizedMessage());
@ -127,7 +122,7 @@ public class NotificationJob extends Job {
.setAutoCancel(true)
.setContentIntent(pendingIntent);
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_PUSH);
}
@ -136,5 +131,4 @@ public class NotificationJob extends Job {
notificationManager.notify(0, notificationBuilder.build());
}
}

View file

@ -470,27 +470,9 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
mWifiLock.release();
}
} catch (SecurityException e) {
Log_OC.e(TAG, "SecurityException playing " + mAccount.name + mFile.getRemotePath(), e);
Toast.makeText(this, String.format(getString(R.string.media_err_security_ex), mFile.getFileName()),
Toast.LENGTH_LONG).show();
processStopRequest(true);
} catch (IOException e) {
Log_OC.e(TAG, "IOException playing " + mAccount.name + mFile.getRemotePath(), e);
Toast.makeText(this, String.format(getString(R.string.media_err_io_ex), mFile.getFileName()),
Toast.LENGTH_LONG).show();
processStopRequest(true);
} catch (IllegalStateException e) {
Log_OC.e(TAG, "IllegalStateException " + mAccount.name + mFile.getRemotePath(), e);
Toast.makeText(this, String.format(getString(R.string.media_err_unexpected), mFile.getFileName()),
Toast.LENGTH_LONG).show();
processStopRequest(true);
} catch (IllegalArgumentException e) {
Log_OC.e(TAG, "IllegalArgumentException " + mAccount.name + mFile.getRemotePath(), e);
Toast.makeText(this, String.format(getString(R.string.media_err_unexpected), mFile.getFileName()),
} catch (SecurityException | IOException | IllegalStateException | IllegalArgumentException e) {
Log_OC.e(TAG, e.getClass().getSimpleName() + " playing " + mAccount.name + mFile.getRemotePath(), e);
Toast.makeText(this, String.format(getString(R.string.media_err_playing), mFile.getFileName()),
Toast.LENGTH_LONG).show();
processStopRequest(true);
}
@ -556,7 +538,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
mNotificationBuilder.setContentTitle(ticker);
mNotificationBuilder.setContentText(content);
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MEDIA);
}
@ -593,7 +575,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
mNotificationBuilder.setContentTitle(ticker);
mNotificationBuilder.setContentText(content);
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MEDIA);
}

View file

@ -57,12 +57,10 @@ public class MediaServiceBinder extends Binder implements MediaController.MediaP
mService = service;
}
public boolean isPlaying(OCFile mFile) {
return (mFile != null && mFile.equals(mService.getCurrentFile()));
return mFile != null && mFile.equals(mService.getCurrentFile());
}
@Override
public boolean canPause() {
return true;

View file

@ -126,7 +126,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT);
delete.getResponseBodyAsString(); // exhaust the response, although not interesting
result = new RemoteOperationResult((delete.succeeded() || status == HttpStatus.SC_NOT_FOUND), delete);
result = new RemoteOperationResult(delete.succeeded() || status == HttpStatus.SC_NOT_FOUND, delete);
Log_OC.i(TAG, "Remove " + remotePath + ": " + result.getLogMessage());
// remove file from metadata

View file

@ -46,8 +46,6 @@ public class RenameFileOperation extends SyncOperation {
private String mRemotePath;
private String mNewName;
private String mNewRemotePath;
/**
* Constructor
@ -114,7 +112,7 @@ public class RenameFileOperation extends SyncOperation {
} catch (IOException e) {
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ?
mNewName : mNewRemotePath) + ": " +
((result!= null) ? result.getLogMessage() : ""), e);
(result!= null ? result.getLogMessage() : ""), e);
}
return result;
@ -184,7 +182,7 @@ public class RenameFileOperation extends SyncOperation {
Log_OC.i(TAG, "Test for validity of name " + mNewName + " in the file system failed");
return false;
}
boolean result = (testFile.exists() && testFile.isFile());
boolean result = testFile.exists() && testFile.isFile();
// cleaning ; result is ignored, since there is not much we could do in case of failure,
// but repeat and repeat...
@ -192,5 +190,4 @@ public class RenameFileOperation extends SyncOperation {
return result;
}
}

View file

@ -210,7 +210,7 @@ public class SynchronizeFileOperation extends SyncOperation {
serverChanged = mServerFile.getModificationTimestamp() !=
mLocalFile.getModificationTimestampAtLastSyncForData();
} else {
serverChanged = (!mServerFile.getEtag().equals(mLocalFile.getEtag()));
serverChanged = !mServerFile.getEtag().equals(mLocalFile.getEtag());
}
boolean localChanged = (
mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()

View file

@ -331,7 +331,7 @@ public class OperationsService extends Service {
* in process.
*/
public boolean isPerformingBlockingOperation() {
return (!mServiceHandler.mPendingOperations.isEmpty());
return !mServiceHandler.mPendingOperations.isEmpty();
}

View file

@ -51,7 +51,6 @@ class SyncFolderHandler extends Handler {
private static final String TAG = SyncFolderHandler.class.getSimpleName();
private OperationsService mService;
private IndexedForest<SynchronizeFolderOperation> mPendingOperations = new IndexedForest<>();
@ -69,7 +68,6 @@ class SyncFolderHandler extends Handler {
mService = service;
}
/**
* Returns True when the folder located in 'remotePath' in the ownCloud account 'account', or any of its
* descendants, is being synchronized (or waiting for it).
@ -81,10 +79,9 @@ class SyncFolderHandler extends Handler {
if (account == null || remotePath == null) {
return false;
}
return (mPendingOperations.contains(account.name, remotePath));
return mPendingOperations.contains(account.name, remotePath);
}
@Override
public void handleMessage(Message msg) {
Pair<Account, String> itemSyncKey = (Pair<Account, String>) msg.obj;

View file

@ -525,7 +525,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
NotificationManager notificationManager = ((NotificationManager) getContext().
getSystemService(Context.NOTIFICATION_SERVICE));
if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_FILE_SYNC);
}

View file

@ -71,7 +71,7 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void onRestart() {
Log_OC.v(TAG, "onRestart() start");
super.onRestart();
boolean validAccount = (mCurrentAccount != null && AccountUtils.exists(mCurrentAccount, this));
boolean validAccount = mCurrentAccount != null && AccountUtils.exists(mCurrentAccount, this);
if (!validAccount) {
swapToDefaultAccount();
}

View file

@ -384,7 +384,7 @@ public abstract class FileActivity extends DrawerActivity
}
OwnCloudClient client;
OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
client = (OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(ocAccount));
client = OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(ocAccount);
if (client != null) {
OwnCloudCredentials cred = client.getCredentials();
if (cred != null) {

View file

@ -1322,8 +1322,8 @@ public class FileDisplayActivity extends HookActivity
setFile(currentFile);
}
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) &&
synchResult != null && !synchResult.isSuccess()) {
@ -1410,8 +1410,8 @@ public class FileDisplayActivity extends HookActivity
String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME);
boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name);
OCFile currentDir = getCurrentDir();
boolean isDescendant = (currentDir != null) && (uploadedRemotePath != null) &&
(uploadedRemotePath.startsWith(currentDir.getRemotePath()));
boolean isDescendant = currentDir != null && uploadedRemotePath != null &&
uploadedRemotePath.startsWith(currentDir.getRemotePath());
if (sameAccount && isDescendant) {
String linkedToRemotePath =
@ -2266,7 +2266,7 @@ public class FileDisplayActivity extends HookActivity
String activityName) {
mWaitingToSend = file;
requestForDownload(mWaitingToSend, downloadBehaviour, packageName, activityName);
boolean hasSecondFragment = (getSecondFragment() != null);
boolean hasSecondFragment = getSecondFragment() != null;
updateFragmentsVisibility(hasSecondFragment);
}

View file

@ -379,7 +379,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
boolean atRoot = (currentDir == null || currentDir.getParentId() == 0);
boolean atRoot = currentDir == null || currentDir.getParentId() == 0;
actionBar.setDisplayHomeAsUpEnabled(!atRoot);
actionBar.setHomeButtonEnabled(!atRoot);

View file

@ -295,19 +295,13 @@ public class NotificationsActivity extends FileActivity {
// show error
runOnUiThread(() -> setEmptyContent(noResultsHeadline, getString(R.string.account_not_found)));
}
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Account not found", e);
} catch (IOException e) {
Log_OC.e(TAG, "IO error", e);
} catch (OperationCanceledException e) {
Log_OC.e(TAG, "Operation has been canceled", e);
} catch (AuthenticatorException e) {
Log_OC.e(TAG, "Authentication Exception", e);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException |
OperationCanceledException | AuthenticatorException e) {
Log_OC.e(TAG, "Error fetching notification data", e);
}
});
t.start();
}
private void hideRefreshLayoutLoader() {

View file

@ -99,10 +99,8 @@ public abstract class ToolbarActivity extends BaseActivity {
boolean inRoot;
// choose the appropriate title
inRoot = (
chosenFile == null ||
(chosenFile.isFolder() && chosenFile.getParentId() == FileDataStorageManager.ROOT_PARENT_ID)
);
inRoot = chosenFile == null ||
(chosenFile.isFolder() && chosenFile.getParentId() == FileDataStorageManager.ROOT_PARENT_ID);
if (!inRoot) {
title = chosenFile.getFileName();
}

View file

@ -321,7 +321,7 @@ public class UploadFilesActivity extends FileActivity implements
return false;
} else {
View mSearchEditFrame = mSearchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE);
return mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE;
}
}

View file

@ -61,10 +61,7 @@ public class ProgressListener implements OnDatatransferProgressListener {
public boolean isWrapping(ProgressBar progressBar) {
ProgressBar wrappedProgressBar = mProgressBar.get();
return (
wrappedProgressBar != null &&
wrappedProgressBar == progressBar // on purpose; don't replace with equals
);
return wrappedProgressBar != null && wrappedProgressBar == progressBar; // on purpose; don't replace with equals
}
public OCUpload getUpload() {

View file

@ -38,12 +38,11 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi
//private final static String TAG = SslCertificateViewAdapter.class.getSimpleName();
private SslCertificate mCertificate;
/**
* Constructor
*
* @param
* @param certificate the SSL certificate
*/
public SslCertificateViewAdapter(SslCertificate certificate) {
mCertificate = certificate;
@ -51,7 +50,7 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi
@Override
public void updateCertificateView(View dialogView) {
TextView nullCerView = (TextView) dialogView.findViewById(R.id.null_cert);
TextView nullCerView = dialogView.findViewById(R.id.null_cert);
if (mCertificate != null) {
nullCerView.setVisibility(View.GONE);
showSubject(mCertificate.getIssuedTo(), dialogView);
@ -65,8 +64,8 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi
}
private void showValidity(Date notBefore, Date notAfter, View dialogView) {
TextView fromView = ((TextView)dialogView.findViewById(R.id.value_validity_from));
TextView toView = ((TextView)dialogView.findViewById(R.id.value_validity_to));
TextView fromView = dialogView.findViewById(R.id.value_validity_from);
TextView toView = dialogView.findViewById(R.id.value_validity_to);
DateFormat dateFormat = DateFormat.getDateInstance();
fromView.setText(dateFormat.format(notBefore));
toView.setText(dateFormat.format(notAfter));
@ -74,55 +73,53 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi
private void showSubject(SslCertificate.DName subject, View dialogView) {
TextView cnView = ((TextView)dialogView.findViewById(R.id.value_subject_CN));
TextView cnView = dialogView.findViewById(R.id.value_subject_CN);
cnView.setText(subject.getCName());
cnView.setVisibility(View.VISIBLE);
TextView oView = ((TextView)dialogView.findViewById(R.id.value_subject_O));
TextView oView = dialogView.findViewById(R.id.value_subject_O);
oView.setText(subject.getOName());
oView.setVisibility(View.VISIBLE);
TextView ouView = ((TextView)dialogView.findViewById(R.id.value_subject_OU));
TextView ouView = dialogView.findViewById(R.id.value_subject_OU);
ouView.setText(subject.getUName());
ouView.setVisibility(View.VISIBLE);
// SslCertificates don't offer this information
((TextView)dialogView.findViewById(R.id.value_subject_C)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_subject_ST)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_subject_L)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_subject_C)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_subject_ST)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_subject_L)).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_subject_C).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_subject_ST).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_subject_L).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_subject_C).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_subject_ST).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_subject_L).setVisibility(View.GONE);
}
private void showIssuer(SslCertificate.DName issuer, View dialogView) {
TextView cnView = ((TextView)dialogView.findViewById(R.id.value_issuer_CN));
TextView cnView = dialogView.findViewById(R.id.value_issuer_CN);
cnView.setText(issuer.getCName());
cnView.setVisibility(View.VISIBLE);
TextView oView = ((TextView)dialogView.findViewById(R.id.value_issuer_O));
TextView oView = dialogView.findViewById(R.id.value_issuer_O);
oView.setText(issuer.getOName());
oView.setVisibility(View.VISIBLE);
TextView ouView = ((TextView)dialogView.findViewById(R.id.value_issuer_OU));
TextView ouView = dialogView.findViewById(R.id.value_issuer_OU);
ouView.setText(issuer.getUName());
ouView.setVisibility(View.VISIBLE);
// SslCertificates don't offer this information
((TextView)dialogView.findViewById(R.id.value_issuer_C)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_issuer_ST)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_issuer_L)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_issuer_C)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_issuer_ST)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_issuer_L)).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_issuer_C).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_issuer_ST).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_issuer_L).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_issuer_C).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_issuer_ST).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_issuer_L).setVisibility(View.GONE);
}
private void hideSignature(View dialogView) {
((TextView)dialogView.findViewById(R.id.label_signature)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.label_signature_algorithm)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_signature_algorithm)).setVisibility(View.GONE);
((TextView)dialogView.findViewById(R.id.value_signature)).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_signature).setVisibility(View.GONE);
dialogView.findViewById(R.id.label_signature_algorithm).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_signature_algorithm).setVisibility(View.GONE);
dialogView.findViewById(R.id.value_signature).setVisibility(View.GONE);
}
}

View file

@ -303,14 +303,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
fakeFileToCheatThumbnailsCacheManagerInterface.setStoragePath(item.getLocalPath());
fakeFileToCheatThumbnailsCacheManagerInterface.setMimetype(item.getMimeType());
boolean allowedToCreateNewThumbnail = (ThumbnailsCacheManager.cancelPotentialThumbnailWork(
fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.thumbnail)
boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(
fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.thumbnail
);
// TODO this code is duplicated; refactor to a common place
if ((MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)
if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)
&& fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null &&
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED)) {
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
// Thumbnail in Cache?
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId())

View file

@ -70,7 +70,7 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
}
private byte[] getDigest(String algorithm, byte[] message) {
MessageDigest md = null;
MessageDigest md;
try {
md = MessageDigest.getInstance(algorithm);
@ -82,10 +82,10 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
}
private void showSignature(View dialogView) {
byte[] cert = null;
byte[] cert;
TextView certFingerprintView = ((TextView) dialogView.findViewById(R.id.value_certificate_fingerprint));
TextView algorithmView = ((TextView) dialogView.findViewById(R.id.value_signature_algorithm));
TextView certFingerprintView = dialogView.findViewById(R.id.value_certificate_fingerprint);
TextView algorithmView = dialogView.findViewById(R.id.value_signature_algorithm);
try {
cert = mCertificate.getEncoded();
@ -103,15 +103,12 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
algorithmView.setText(mCertificate.getSigAlgName());
}
} catch (CertificateEncodingException e) {
Log.e(TAG, "Problem while trying to decode the certificate.");
}
}
private final String getDigestHexBytesWithColonsAndNewLines(View dialogView, final String digestType, final byte [] cert) {
private String getDigestHexBytesWithColonsAndNewLines(View dialogView, final String digestType, final byte [] cert) {
final byte[] rawDigest;
final String newLine = System.getProperty("line.separator");
@ -134,8 +131,8 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
}
private void showValidity(Date notBefore, Date notAfter, View dialogView) {
TextView fromView = ((TextView)dialogView.findViewById(R.id.value_validity_from));
TextView toView = ((TextView)dialogView.findViewById(R.id.value_validity_to));
TextView fromView = dialogView.findViewById(R.id.value_validity_from);
TextView toView = dialogView.findViewById(R.id.value_validity_to);
DateFormat dateFormat = DateFormat.getDateInstance();
fromView.setText(dateFormat.format(notBefore));
toView.setText(dateFormat.format(notAfter));
@ -143,12 +140,12 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
private void showSubject(X500Principal subject, View dialogView) {
Map<String, String> s = parsePrincipal(subject);
TextView cnView = ((TextView)dialogView.findViewById(R.id.value_subject_CN));
TextView oView = ((TextView)dialogView.findViewById(R.id.value_subject_O));
TextView ouView = ((TextView)dialogView.findViewById(R.id.value_subject_OU));
TextView cView = ((TextView)dialogView.findViewById(R.id.value_subject_C));
TextView stView = ((TextView)dialogView.findViewById(R.id.value_subject_ST));
TextView lView = ((TextView)dialogView.findViewById(R.id.value_subject_L));
TextView cnView = dialogView.findViewById(R.id.value_subject_CN);
TextView oView = dialogView.findViewById(R.id.value_subject_O);
TextView ouView = dialogView.findViewById(R.id.value_subject_OU);
TextView cView = dialogView.findViewById(R.id.value_subject_C);
TextView stView = dialogView.findViewById(R.id.value_subject_ST);
TextView lView = dialogView.findViewById(R.id.value_subject_L);
if (s.get("CN") != null) {
cnView.setText(s.get("CN"));
@ -190,12 +187,12 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
private void showIssuer(X500Principal issuer, View dialogView) {
Map<String, String> s = parsePrincipal(issuer);
TextView cnView = ((TextView)dialogView.findViewById(R.id.value_issuer_CN));
TextView oView = ((TextView)dialogView.findViewById(R.id.value_issuer_O));
TextView ouView = ((TextView)dialogView.findViewById(R.id.value_issuer_OU));
TextView cView = ((TextView)dialogView.findViewById(R.id.value_issuer_C));
TextView stView = ((TextView)dialogView.findViewById(R.id.value_issuer_ST));
TextView lView = ((TextView)dialogView.findViewById(R.id.value_issuer_L));
TextView cnView = dialogView.findViewById(R.id.value_issuer_CN);
TextView oView = dialogView.findViewById(R.id.value_issuer_O);
TextView ouView = dialogView.findViewById(R.id.value_issuer_OU);
TextView cView = dialogView.findViewById(R.id.value_issuer_C);
TextView stView = dialogView.findViewById(R.id.value_issuer_ST);
TextView lView = dialogView.findViewById(R.id.value_issuer_L);
if (s.get("CN") != null) {
cnView.setText(s.get("CN"));
@ -237,18 +234,17 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif
private Map<String, String> parsePrincipal(X500Principal principal) {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<>();
String toParse = principal.getName();
String[] pieces = toParse.split(",");
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
for (int i=0; i < pieces.length ; i++) {
for (int j=0; j<tokens.length; j++) {
if (pieces[i].startsWith(tokens[j] + "=")) {
result.put(tokens[j], pieces[i].substring(tokens[j].length()+1));
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
for (String piece : pieces) {
for (String token : tokens) {
if (piece.startsWith(token + "=")) {
result.put(token, piece.substring(token.length() + 1));
}
}
}
return result;
}
}

View file

@ -29,6 +29,7 @@ package com.owncloud.android.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
@ -70,16 +71,15 @@ implements ConfirmationDialogFragmentListener {
// choose message for a single file
OCFile file = files.get(0);
messageStringId = (file.isFolder()) ?
messageStringId = file.isFolder() ?
R.string.confirmation_remove_folder_alert :
R.string.confirmation_remove_file_alert;
} else {
// choose message for more than one file
messageStringId = (containsFolder) ?
messageStringId = containsFolder ?
R.string.confirmation_remove_folders_alert :
R.string.confirmation_remove_files_alert;
}
int localRemoveButton = (!containsFavorite && (containsFolder || containsDown)) ?
@ -124,7 +124,8 @@ implements ConfirmationDialogFragmentListener {
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(color);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
@ -157,4 +158,4 @@ implements ConfirmationDialogFragmentListener {
public void onNeutral(String callerTag) {
// nothing to do here
}
}
}

View file

@ -211,12 +211,7 @@ public class SslUntrustedCertDialog extends DialogFragment {
try {
NetworkUtils.addCertToKnownServersStore(m509Certificate, activity); // TODO make this asynchronously, it can take some time
((OnSslUntrustedCertListener)activity).onSavedCertificate();
} catch (GeneralSecurityException e) {
((OnSslUntrustedCertListener)activity).onFailedSavingCertificate();
Log_OC.e(TAG, "Server certificate could not be saved in the known-servers trust store ", e);
} catch (IOException e) {
} catch (GeneralSecurityException | IOException e) {
((OnSslUntrustedCertListener)activity).onFailedSavingCertificate();
Log_OC.e(TAG, "Server certificate could not be saved in the known-servers trust store ", e);
}
@ -239,5 +234,4 @@ public class SslUntrustedCertDialog extends DialogFragment {
public interface CertificateViewAdapter {
void updateCertificateView(View mView);
}
}

View file

@ -89,7 +89,6 @@ public class SslValidatorDialog extends Dialog {
mListener = listener;
}
/**
* {@inheritDoc}
*/
@ -161,25 +160,23 @@ public class SslValidatorDialog extends Dialog {
/// refresh
if (mException.getCertPathValidatorException() != null) {
((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
mView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.VISIBLE);
}
if (mException.getCertificateExpiredException() != null) {
((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
mView.findViewById(R.id.reason_cert_expired).setVisibility(View.VISIBLE);
}
if (mException.getCertificateNotYetValidException() != null) {
((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
mView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.VISIBLE);
}
if (mException.getSslPeerUnverifiedException() != null ) {
((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
mView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.VISIBLE);
}
showCertificateData(mException.getServerCertificate());
}
}
private void showCertificateData(X509Certificate cert) {
@ -197,8 +194,8 @@ public class SslValidatorDialog extends Dialog {
}
private void showSignature(X509Certificate cert) {
TextView sigView = ((TextView)mView.findViewById(R.id.value_signature));
TextView algorithmView = ((TextView)mView.findViewById(R.id.value_signature_algorithm));
TextView sigView = mView.findViewById(R.id.value_signature);
TextView algorithmView = mView.findViewById(R.id.value_signature_algorithm);
sigView.setText(getHex(cert.getSignature()));
algorithmView.setText(cert.getSigAlgName());
}
@ -219,20 +216,20 @@ public class SslValidatorDialog extends Dialog {
@SuppressWarnings("deprecation")
private void showValidity(Date notBefore, Date notAfter) {
TextView fromView = ((TextView)mView.findViewById(R.id.value_validity_from));
TextView toView = ((TextView)mView.findViewById(R.id.value_validity_to));
TextView fromView = mView.findViewById(R.id.value_validity_from);
TextView toView = mView.findViewById(R.id.value_validity_to);
fromView.setText(notBefore.toLocaleString());
toView.setText(notAfter.toLocaleString());
}
private void showSubject(X500Principal subject) {
Map<String, String> s = parsePrincipal(subject);
TextView cnView = ((TextView)mView.findViewById(R.id.value_subject_CN));
TextView oView = ((TextView)mView.findViewById(R.id.value_subject_O));
TextView ouView = ((TextView)mView.findViewById(R.id.value_subject_OU));
TextView cView = ((TextView)mView.findViewById(R.id.value_subject_C));
TextView stView = ((TextView)mView.findViewById(R.id.value_subject_ST));
TextView lView = ((TextView)mView.findViewById(R.id.value_subject_L));
TextView cnView = mView.findViewById(R.id.value_subject_CN);
TextView oView = mView.findViewById(R.id.value_subject_O);
TextView ouView = mView.findViewById(R.id.value_subject_OU);
TextView cView = mView.findViewById(R.id.value_subject_C);
TextView stView = mView.findViewById(R.id.value_subject_ST);
TextView lView = mView.findViewById(R.id.value_subject_L);
if (s.get("CN") != null) {
cnView.setText(s.get("CN"));
@ -274,12 +271,12 @@ public class SslValidatorDialog extends Dialog {
private void showIssuer(X500Principal issuer) {
Map<String, String> s = parsePrincipal(issuer);
TextView cnView = ((TextView)mView.findViewById(R.id.value_issuer_CN));
TextView oView = ((TextView)mView.findViewById(R.id.value_issuer_O));
TextView ouView = ((TextView)mView.findViewById(R.id.value_issuer_OU));
TextView cView = ((TextView)mView.findViewById(R.id.value_issuer_C));
TextView stView = ((TextView)mView.findViewById(R.id.value_issuer_ST));
TextView lView = ((TextView)mView.findViewById(R.id.value_issuer_L));
TextView cnView = mView.findViewById(R.id.value_issuer_CN);
TextView oView = mView.findViewById(R.id.value_issuer_O);
TextView ouView = mView.findViewById(R.id.value_issuer_OU);
TextView cView = mView.findViewById(R.id.value_issuer_C);
TextView stView = mView.findViewById(R.id.value_issuer_ST);
TextView lView = mView.findViewById(R.id.value_issuer_L);
if (s.get("CN") != null) {
cnView.setText(s.get("CN"));
@ -321,7 +318,7 @@ public class SslValidatorDialog extends Dialog {
private Map<String, String> parsePrincipal(X500Principal principal) {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<>();
String toParse = principal.getName();
String[] pieces = toParse.split(",");
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
@ -341,11 +338,9 @@ public class SslValidatorDialog extends Dialog {
NetworkUtils.addCertToKnownServersStore(mException.getServerCertificate(), getContext());
}
}
public interface OnSslValidatorListener {
public void onSavedCertificate();
public void onFailedSavingCertificate();
}
}

View file

@ -156,7 +156,7 @@ public class EditShareFragment extends Fragment {
*/
public void refreshCapabilitiesFromDB() {
if (getActivity() instanceof FileActivity) {
FileActivity fileActivity = ((FileActivity) getActivity());
FileActivity fileActivity = (FileActivity) getActivity();
if (fileActivity.getStorageManager() != null) {
mCapabilities = fileActivity.getStorageManager().getCapability(mAccount.name);
}
@ -202,26 +202,24 @@ public class EditShareFragment extends Fragment {
// from checking when iOS is ready
AppCompatCheckBox checkBox = editShareView.findViewById(R.id.canEditCreateCheckBox);
checkBox.setChecked((sharePermissions & OCShare.CREATE_PERMISSION_FLAG) > 0);
checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE);
ThemeUtils.tintCheckbox(checkBox, accentColor);
checkBox = editShareView.findViewById(R.id.canEditChangeCheckBox);
checkBox.setChecked((sharePermissions & OCShare.UPDATE_PERMISSION_FLAG) > 0);
checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE);
ThemeUtils.tintCheckbox(checkBox, accentColor);
checkBox = editShareView.findViewById(R.id.canEditDeleteCheckBox);
checkBox.setChecked((sharePermissions & OCShare.DELETE_PERMISSION_FLAG) > 0);
checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE);
checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE);
ThemeUtils.tintCheckbox(checkBox, accentColor);
}
setPermissionsListening(editShareView, true);
}
}
/**
* Binds or unbinds listener for user actions to enable or disable a permission on the edited share
* to the views receiving the user events.

View file

@ -342,17 +342,11 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
}
hideRefreshLayoutLoader(activity);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Account not found", e);
} catch (IOException e) {
Log_OC.e(TAG, "IO error", e);
} catch (OperationCanceledException e) {
Log_OC.e(TAG, "Operation has been canceled", e);
} catch (AuthenticatorException e) {
Log_OC.e(TAG, "Authentication Exception", e);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException |
OperationCanceledException | AuthenticatorException e) {
Log_OC.e(TAG, "Error fetching file details activities", e);
}
}
);
});
t.start();
}

View file

@ -457,7 +457,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
* @return True when the fragment was created with the empty layout.
*/
public boolean isEmpty() {
return (layout == R.layout.empty_list || getFile() == null || account == null);
return layout == R.layout.empty_list || getFile() == null || account == null;
}
/**

View file

@ -1332,14 +1332,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
mAdapter.setFavoriteAttributeForItemID(event.remoteId, event.shouldFavorite);
}
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Account not found", e);
} catch (AuthenticatorException e) {
Log_OC.e(TAG, "Authentication failed", e);
} catch (IOException e) {
Log_OC.e(TAG, "IO error", e);
} catch (OperationCanceledException e) {
Log_OC.e(TAG, "Operation has been canceled", e);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | AuthenticatorException
| IOException | OperationCanceledException e) {
Log_OC.e(TAG, "Error processing event", e);
}
}

View file

@ -695,9 +695,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
* @return 'True' when public share is disabled in the server
*/
private boolean isPublicShareDisabled() {
return (mCapabilities != null &&
mCapabilities.getFilesSharingPublicEnabled().isFalse()
);
return mCapabilities != null && mCapabilities.getFilesSharingPublicEnabled().isFalse();
}
/**

View file

@ -361,7 +361,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
// check permissions
if ((PermissionUtil.checkSelfPermission(contactsPreferenceActivity, Manifest.permission.READ_CONTACTS))) {
if (PermissionUtil.checkSelfPermission(contactsPreferenceActivity, Manifest.permission.READ_CONTACTS)) {
return true;
} else {
// Check if we should show an explanation

View file

@ -71,6 +71,6 @@ public class FileDetailSharingFragmentHelper {
* @return 'True' when public share is disabled in the server.
*/
public static boolean isPublicShareDisabled(OCCapability capabilities) {
return (capabilities != null && capabilities.getFilesSharingPublicEnabled().isFalse());
return capabilities != null && capabilities.getFilesSharingPublicEnabled().isFalse();
}
}

View file

@ -424,18 +424,13 @@ public class PreviewImageActivity extends FileActivity implements
} else {
Log_OC.d(TAG, "Download finished, but the fragment is offscreen");
}
}
removeStickyBroadcast(intent);
}
}
public boolean getSystemUIVisible() {
if (getSupportActionBar() != null) {
return (getSupportActionBar().isShowing());
}
return true;
return getSupportActionBar() == null || getSupportActionBar().isShowing();
}
public void toggleFullScreen() {

View file

@ -697,10 +697,9 @@ public class PreviewImageFragment extends FileFragment {
* @return 'True' if the file can be handled by the fragment.
*/
public static boolean canBePreviewed(OCFile file) {
return (file != null && MimeTypeUtil.isImage(file));
return file != null && MimeTypeUtil.isImage(file);
}
/**
* Finishes the preview
*/
@ -741,14 +740,12 @@ public class PreviewImageFragment extends FileFragment {
}
}
private static int convertDpToPixel(float dp, Context context) {
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
return (int) (dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
}
public PhotoView getImageView() {
return mImageView;
}
@ -763,7 +760,5 @@ public class PreviewImageFragment extends FileFragment {
this.drawable = drawable;
this.ocFile = ocFile;
}
}
}

View file

@ -58,7 +58,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class PreviewTextFragment extends FileFragment {
public class PreviewTextFragment extends FileFragment {
private static final String EXTRA_FILE = "FILE";
private static final String EXTRA_ACCOUNT = "ACCOUNT";
private static final String TAG = PreviewTextFragment.class.getSimpleName();
@ -402,10 +402,9 @@ public class PreviewTextFragment extends FileFragment {
unsupportedTypes.add("text/vnd.rn-realtext");
unsupportedTypes.add("text/vnd.wap.wml");
unsupportedTypes.add("text/vnd.wap.wmlscript");
return (file != null && file.isDown() && MimeTypeUtil.isText(file) &&
return file != null && file.isDown() && MimeTypeUtil.isText(file) &&
!unsupportedTypes.contains(file.getMimeType()) &&
!unsupportedTypes.contains(MimeTypeUtil.getMimeTypeFromPath(file.getRemotePath()))
);
!unsupportedTypes.contains(MimeTypeUtil.getMimeTypeFromPath(file.getRemotePath()));
}
/**

View file

@ -91,9 +91,7 @@ public class ConnectivityUtils {
Log_OC.e(TAG, "Error checking internet connection", e);
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Log_OC.e(TAG, "Account not found", e);
} catch (OperationCanceledException e) {
Log_OC.e(TAG, e.getMessage());
} catch (AuthenticatorException e) {
} catch (OperationCanceledException | AuthenticatorException e) {
Log_OC.e(TAG, e.getMessage());
}
} else if (!Device.getNetworkType(context).equals(JobRequest.NetworkType.ANY)) {

View file

@ -266,7 +266,7 @@ public class DisplayUtils {
hostEnd = (hostEnd == -1 ? urlNoDots.length() : hostStart + hostEnd);
String host = urlNoDots.substring(hostStart, hostEnd);
host = (toASCII ? IDN.toASCII(host) : IDN.toUnicode(host));
host = toASCII ? IDN.toASCII(host) : IDN.toUnicode(host);
return dots + urlNoDots.substring(0, hostStart) + host + urlNoDots.substring(hostEnd);
}

View file

@ -113,7 +113,6 @@ public class FilesSyncHelper {
} else {
try {
if (dryRun) {
arbitraryDataProvider.storeOrUpdateKeyValue(GLOBAL, syncedFolderInitiatedKey,
currentTimeString);
@ -157,7 +156,7 @@ public class FilesSyncHelper {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver);
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
if ((syncedFolder.isEnabled()) && ((MediaFolderType.CUSTOM != syncedFolder.getType()) || !skipCustom)) {
if (syncedFolder.isEnabled() && (MediaFolderType.CUSTOM != syncedFolder.getType() || !skipCustom)) {
insertAllDBEntriesForSyncedFolder(syncedFolder);
}
}

View file

@ -282,11 +282,10 @@ public class MimeTypeUtil {
* @return 'True' if the file is simple text (e.g. not application-dependent, like .doc or .docx)
*/
public static boolean isText(OCFile file) {
return (MimeTypeUtil.isText(file.getMimeType())
|| MimeTypeUtil.isText(getMimeTypeFromPath(file.getRemotePath())));
return MimeTypeUtil.isText(file.getMimeType())
|| MimeTypeUtil.isText(getMimeTypeFromPath(file.getRemotePath()));
}
/**
* @param file the file to be analyzed
* @return 'True' if the file is a vcard

View file

@ -231,9 +231,7 @@
<string name="media_err_timeout">Attempt to play file timed out</string>
<string name="media_err_invalid_progressive_playback">The media file can not be streamed</string>
<string name="media_err_unknown">The built-in media player is unable to play the media file</string>
<string name="media_err_security_ex">A security error was encountered trying to play %1$s</string>
<string name="media_err_io_ex">Input error while trying to play %1$s</string>
<string name="media_err_unexpected">Unexpected error while trying to play %1$s</string>
<string name="media_err_playing">Unexpected error while trying to play %1$s</string>
<string name="media_rewind_description">Rewind button</string>
<string name="media_play_pause_description">Play or pause button</string>
<string name="media_forward_description">Fast forward button</string>