Merge pull request #4384 from nextcloud/codacy

Codacy
This commit is contained in:
Andy Scherzinger 2019-08-23 09:41:29 +02:00 committed by GitHub
commit 753b4591db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 166 additions and 165 deletions

View file

@ -113,7 +113,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
/**
* Main Application of the project
* <p>
*
* Contains methods to build the "static" strings. These strings were before constants in different classes
*/
public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@ -122,6 +122,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
private static final String TAG = MainApp.class.getSimpleName();
public static final String DOT = ".";
private static Context mContext;
@ -233,11 +234,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
insertConscrypt();
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
.setEnableDebugLogging(BuildConfig.DEBUG)
.build();
securityKeyManager.init(this, config);
initSecurityKeyManager();
registerActivityLifecycleCallbacks(new ActivityInjector());
@ -307,7 +304,10 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
.build()
.schedule();
// register global protection with pass code
registerGlobalPassCodeProtection();
}
private void registerGlobalPassCodeProtection() {
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
@ -350,6 +350,14 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
});
}
private void initSecurityKeyManager() {
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
.setEnableDebugLogging(BuildConfig.DEBUG)
.build();
securityKeyManager.init(this, config);
}
public static void initContactsBackup(UserAccountManager accountManager) {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(mContext.getContentResolver());
Account[] accounts = accountManager.getAccounts();
@ -368,9 +376,9 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
Conscrypt.Version version = Conscrypt.version();
Log_OC.i(TAG, "Using Conscrypt/"
+ version.major()
+ "."
+ DOT
+ version.minor()
+ "." + version.patch()
+ DOT + version.patch()
+ " for TLS");
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
Log_OC.i(TAG, "Enabled protocols: " + Arrays.toString(engine.getEnabledProtocols()) + " }");

View file

@ -54,6 +54,8 @@ import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeType;
import com.owncloud.android.utils.MimeTypeUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@ -81,6 +83,7 @@ public class FileDataStorageManager {
private static final String EXCEPTION_MSG = "Exception in batch of operations ";
public static final int ROOT_PARENT_ID = 0;
public static final String NULL_STRING = "null";
private ContentResolver contentResolver;
private ContentProviderClient contentProviderClient;
@ -999,7 +1002,7 @@ public class FileDataStorageManager {
String sharees = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_SHAREES));
if (sharees == null || "null".equals(sharees) || sharees.isEmpty()) {
if (sharees == null || NULL_STRING.equals(sharees) || sharees.isEmpty()) {
file.setSharees(new ArrayList<>());
} else {
try {
@ -1920,66 +1923,7 @@ public class FileDataStorageManager {
public OCCapability saveCapabilities(OCCapability capability) {
// Prepare capabilities data
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, account.name);
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, capability.getVersionMayor());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, capability.getVersionMinor());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
cv.put(ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT, capability.getExtendedSupport().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollInterval());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
capability.getFilesSharingPublicEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED,
capability.getFilesSharingPublicPasswordEnforced().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD,
capability.getFilesSharingPublicAskForOptionalPassword().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED,
capability.getFilesSharingPublicExpireDateEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS,
capability.getFilesSharingPublicExpireDateDays());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED,
capability.getFilesSharingPublicExpireDateEnforced().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL,
capability.getFilesSharingPublicSendMail().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD,
capability.getFilesSharingPublicUpload().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL,
capability.getFilesSharingUserSendMail().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_RESHARING, capability.getFilesSharingResharing().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING,
capability.getFilesSharingFederationOutgoing().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING,
capability.getFilesSharingFederationIncoming().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING, capability.getFilesBigFileChunking().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_UNDELETE, capability.getFilesUndelete().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_VERSIONING, capability.getFilesVersioning().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_DROP, capability.getFilesFileDrop().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS, capability.getExternalLinks().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_NAME, capability.getServerName());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_COLOR, capability.getServerColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_TEXT_COLOR, capability.getServerTextColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_ELEMENT_COLOR, capability.getServerElementColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL, capability.getServerBackground());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN, capability.getServerSlogan());
cv.put(ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION, capability.getEndToEndEncryption().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT, capability.getServerBackgroundDefault()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, capability.getServerBackgroundPlain()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, capability.getActivity().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsOptionalMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName());
ContentValues cv = createContentValues(account.name, capability);
if (capabilityExists(account.name)) {
if (getContentResolver() != null) {
@ -2019,6 +1963,71 @@ public class FileDataStorageManager {
return capability;
}
@NotNull
private ContentValues createContentValues(String accountName, OCCapability capability) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, accountName);
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, capability.getVersionMayor());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, capability.getVersionMinor());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
cv.put(ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT, capability.getExtendedSupport().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollInterval());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
capability.getFilesSharingPublicEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED,
capability.getFilesSharingPublicPasswordEnforced().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD,
capability.getFilesSharingPublicAskForOptionalPassword().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED,
capability.getFilesSharingPublicExpireDateEnabled().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS,
capability.getFilesSharingPublicExpireDateDays());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED,
capability.getFilesSharingPublicExpireDateEnforced().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL,
capability.getFilesSharingPublicSendMail().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD,
capability.getFilesSharingPublicUpload().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL,
capability.getFilesSharingUserSendMail().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_RESHARING, capability.getFilesSharingResharing().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING,
capability.getFilesSharingFederationOutgoing().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING,
capability.getFilesSharingFederationIncoming().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING, capability.getFilesBigFileChunking().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_UNDELETE, capability.getFilesUndelete().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_VERSIONING, capability.getFilesVersioning().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_FILES_DROP, capability.getFilesFileDrop().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS, capability.getExternalLinks().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_NAME, capability.getServerName());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_COLOR, capability.getServerColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_TEXT_COLOR, capability.getServerTextColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_ELEMENT_COLOR, capability.getServerElementColor());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL, capability.getServerBackground());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN, capability.getServerSlogan());
cv.put(ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION, capability.getEndToEndEncryption().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT, capability.getServerBackgroundDefault()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, capability.getServerBackgroundPlain()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, capability.getActivity().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsOptionalMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName());
return cv;
}
private boolean capabilityExists(String accountName) {
Cursor c = getCapabilityCursorForAccount(accountName);
boolean exists = false;

View file

@ -39,7 +39,7 @@ import com.owncloud.android.lib.resources.shares.ShareeUser;
import com.owncloud.android.utils.MimeType;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
@ -57,7 +57,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
private static final String TAG = OCFile.class.getSimpleName();
@Getter @Setter private long fileId; // android internal ID of the file
@Getter @Setter private long fileId; // android internal ID of the file
@Getter @Setter private long parentId;
@Getter @Setter private long fileLength;
@Getter @Setter private long creationTimestamp; // UNIX timestamp of the time the file was created
@ -90,7 +90,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
@Getter @Setter private String ownerId;
@Getter @Setter private String ownerDisplayName;
@Getter @Setter String note;
@Getter @Setter private ArrayList<ShareeUser> sharees;
@Getter @Setter private List<ShareeUser> sharees;
/**
* URI to the local path of the file contents, if stored in the device; cached after first call

View file

@ -78,8 +78,6 @@ public class ContactsBackupJob extends Job {
protected Result onRunJob(@NonNull Params params) {
PersistableBundleCompat bundle = params.getExtras();
boolean force = bundle.getBoolean(FORCE, false);
final Account account = accountManager.getAccountByName(bundle.getString(ACCOUNT, ""));
if (account == null) {
@ -87,9 +85,9 @@ public class ContactsBackupJob extends Job {
}
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
Long lastExecution = arbitraryDataProvider.getLongValue(account,
PREFERENCE_CONTACTS_LAST_BACKUP);
Long lastExecution = arbitraryDataProvider.getLongValue(account, PREFERENCE_CONTACTS_LAST_BACKUP);
boolean force = bundle.getBoolean(FORCE, false);
if (force || (lastExecution + 24 * 60 * 60 * 1000) < Calendar.getInstance().getTimeInMillis()) {
Log_OC.d(TAG, "start contacts backup job");

View file

@ -675,24 +675,7 @@ public class UploadFileOperation extends SyncOperation {
result = new RemoteOperationResult(ResultCode.UNKNOWN_ERROR);
}
if (result.isSuccess()) {
Log_OC.i(TAG, "Upload of " + mFile.getStoragePath() + " to " + mFile.getRemotePath() + ": " +
result.getLogMessage());
} else {
if (result.getException() != null) {
if (result.isCancelled()) {
Log_OC.w(TAG, "Upload of " + mFile.getStoragePath() + " to " + mFile.getRemotePath() +
": " + result.getLogMessage());
} else {
Log_OC.e(TAG, "Upload of " + mFile.getStoragePath() + " to " + mFile.getRemotePath() +
": " + result.getLogMessage(), result.getException());
}
} else {
Log_OC.e(TAG, "Upload of " + mFile.getStoragePath() + " to " + mFile.getRemotePath() +
": " + result.getLogMessage());
}
}
logResult(result, mFile.getStoragePath(), mFile.getRemotePath());
}
if (result.isSuccess()) {
@ -886,23 +869,7 @@ public class UploadFileOperation extends SyncOperation {
result = new RemoteOperationResult(ResultCode.UNKNOWN_ERROR);
}
if (result.isSuccess()) {
Log_OC.i(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath + ": " +
result.getLogMessage());
} else {
if (result.getException() != null) {
if (result.isCancelled()) {
Log_OC.w(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath +
": " + result.getLogMessage());
} else {
Log_OC.e(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath +
": " + result.getLogMessage(), result.getException());
}
} else {
Log_OC.e(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath +
": " + result.getLogMessage());
}
}
logResult(result, mOriginalStoragePath, mRemotePath);
}
if (result.isSuccess()) {
@ -919,6 +886,24 @@ public class UploadFileOperation extends SyncOperation {
return result;
}
private void logResult(RemoteOperationResult result, String sourcePath, String targetPath) {
if (result.isSuccess()) {
Log_OC.i(TAG, "Upload of " + sourcePath + " to " + targetPath + ": " + result.getLogMessage());
} else {
if (result.getException() != null) {
if (result.isCancelled()) {
Log_OC.w(TAG, "Upload of " + sourcePath + " to " + targetPath + ": "
+ result.getLogMessage());
} else {
Log_OC.e(TAG, "Upload of " + sourcePath + " to " + targetPath + ": "
+ result.getLogMessage(), result.getException());
}
} else {
Log_OC.e(TAG, "Upload of " + sourcePath + " to " + targetPath + ": " + result.getLogMessage());
}
}
}
private RemoteOperationResult copyFile(File originalFile, String expectedPath) throws OperationCancelledException,
IOException {
if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY && !mOriginalStoragePath.equals(expectedPath)) {

View file

@ -29,6 +29,7 @@ package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerFuture;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@ -396,30 +397,7 @@ public abstract class DrawerActivity extends ToolbarActivity
setDrawerMenuItemChecked(menuItem.getItemId());
if (menuItem.getGroupId() == R.id.drawer_menu_accounts) {
switch (menuItem.getItemId()) {
case R.id.drawer_menu_account_add:
boolean isProviderOrOwnInstallationVisible = getResources()
.getBoolean(R.bool.show_provider_or_own_installation);
if (isProviderOrOwnInstallationVisible) {
Intent firstRunIntent = new Intent(getApplicationContext(), FirstRunActivity.class);
firstRunIntent.putExtra(FirstRunActivity.EXTRA_ALLOW_CLOSE, true);
startActivity(firstRunIntent);
} else {
createAccount(false);
}
break;
case R.id.drawer_menu_account_manage:
Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
break;
default:
accountClicked(menuItem.getItemId());
break;
}
handleAccountItemClick(menuItem);
return;
}
@ -459,39 +437,28 @@ public abstract class DrawerActivity extends ToolbarActivity
showFiles(true);
break;
case R.id.nav_uploads:
Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class);
uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(uploadListIntent);
startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_trashbin:
Intent trashbinIntent = new Intent(getApplicationContext(), TrashbinActivity.class);
trashbinIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(trashbinIntent);
startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_activity:
Intent activityIntent = new Intent(getApplicationContext(), ActivitiesActivity.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(activityIntent);
startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
case R.id.nav_notifications:
Intent notificationsIntent = new Intent(getApplicationContext(), NotificationsActivity.class);
startActivity(notificationsIntent);
startActivity(NotificationsActivity.class);
break;
case R.id.nav_synced_folders:
Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class);
startActivity(syncedFoldersIntent);
startActivity(SyncedFoldersActivity.class);
break;
case R.id.nav_contacts:
Intent contactsIntent = new Intent(getApplicationContext(), ContactsPreferenceActivity.class);
startActivity(contactsIntent);
startActivity(ContactsPreferenceActivity.class);
break;
case R.id.nav_settings:
Intent settingsIntent = new Intent(getApplicationContext(), SettingsActivity.class);
startActivity(settingsIntent);
startActivity(SettingsActivity.class);
break;
case R.id.nav_participate:
Intent participateIntent = new Intent(getApplicationContext(), ParticipateActivity.class);
startActivity(participateIntent);
startActivity(ParticipateActivity.class);
break;
case R.id.nav_logout:
mCheckedMenuItem = -1;
@ -522,6 +489,42 @@ public abstract class DrawerActivity extends ToolbarActivity
}
}
private void startActivity(Class<? extends Activity> activity) {
startActivity(new Intent(getApplicationContext(), activity));
}
private void startActivity(Class<? extends Activity> activity, int flags) {
Intent intent = new Intent(getApplicationContext(), activity);
intent.setFlags(flags);
startActivity(intent);
}
private void handleAccountItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.drawer_menu_account_add:
boolean isProviderOrOwnInstallationVisible = getResources()
.getBoolean(R.bool.show_provider_or_own_installation);
if (isProviderOrOwnInstallationVisible) {
Intent firstRunIntent = new Intent(getApplicationContext(), FirstRunActivity.class);
firstRunIntent.putExtra(FirstRunActivity.EXTRA_ALLOW_CLOSE, true);
startActivity(firstRunIntent);
} else {
createAccount(false);
}
break;
case R.id.drawer_menu_account_manage:
Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
break;
default:
accountClicked(menuItem.getItemId());
break;
}
}
private void startPhotoSearch(MenuItem menuItem) {
SearchEvent searchEvent = new SearchEvent("image/%",
SearchRemoteOperation.SearchType.PHOTO_SEARCH,

View file

@ -363,7 +363,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
itemViewHolder.sharedAvatars.removeAllViews();
String fileOwner = file.getOwnerId();
ArrayList<ShareeUser> sharees = file.getSharees();
List<ShareeUser> sharees = file.getSharees();
// use fileOwner if not oneself, then add at first
ShareeUser fileOwnerSharee = new ShareeUser(fileOwner, file.getOwnerDisplayName(), ShareType.USER);

View file

@ -218,11 +218,10 @@ public class ExtendedListFragment extends Fragment implements
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)
&& !(getActivity() instanceof UploadFilesActivity)) {
setFabVisible(!hasFocus);
if (!(getActivity() instanceof UploadFilesActivity)) {
setFabVisible(!hasFocus);
}
}
}
}, 100);

View file

@ -170,11 +170,10 @@ public class PhotoFragment extends OCFileListFragment {
int totalItemCount = gridLayoutManager.getItemCount();
int firstVisibleItem = gridLayoutManager.findFirstCompletelyVisibleItemPosition();
if ((totalItemCount - visibleItemCount) <= (firstVisibleItem + MAX_ITEMS_PER_ROW)) {
if ((totalItemCount - visibleItemCount) <= (firstVisibleItem + MAX_ITEMS_PER_ROW)
&& (totalItemCount - visibleItemCount) > 0) {
// Almost reached the end, continue to load new photos
if ((totalItemCount - visibleItemCount) > 0) {
searchAndDisplay();
}
searchAndDisplay();
}
}
}

View file

@ -636,7 +636,7 @@ public final class ThemeUtils {
public static void setEditTextCursorColor(EditText editText, int color) {
try {
// Get the cursor resource id
if (Build.VERSION.SDK_INT >= 28) {//set differently in Android P (API 28)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//set differently in Android P (API 28)
Field field = TextView.class.getDeclaredField("mCursorDrawableRes");
field.setAccessible(true);
int drawableResId = field.getInt(editText);