diff --git a/src/com/owncloud/android/MainApp.java b/src/com/owncloud/android/MainApp.java index 9c8a8ffd93..18dd6b80a6 100644 --- a/src/com/owncloud/android/MainApp.java +++ b/src/com/owncloud/android/MainApp.java @@ -67,6 +67,7 @@ public class MainApp extends Application { private static boolean mOnlyOnDevice = false; private static SyncedFolderObserverService mObserverService; + @SuppressWarnings("unused") private boolean mBound; diff --git a/src/com/owncloud/android/datamodel/MediaProvider.java b/src/com/owncloud/android/datamodel/MediaProvider.java index 5fd5499dc1..7ee9f1df5a 100644 --- a/src/com/owncloud/android/datamodel/MediaProvider.java +++ b/src/com/owncloud/android/datamodel/MediaProvider.java @@ -40,7 +40,6 @@ public class MediaProvider { private static final Uri MEDIA_URI = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI; private static final String[] FILE_PROJECTION = new String[]{MediaStore.MediaColumns.DATA}; private static final String FILE_SELECTION = MediaStore.Images.Media.BUCKET_ID + "="; - private static final Uri uri1 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; private static final String[] FOLDER_PROJECTION = { "Distinct " + MediaStore.Images.Media.BUCKET_ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME }; private static final String FOLDER_SORT_ORDER = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " ASC"; diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index cb0d13c220..cbca4ff575 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -132,7 +132,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { new FileUploader.UploadRequester(); int behaviour = getUploadBehaviour(context); - Boolean subfolderByDate = com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context); + Boolean subfolderByDate = PreferenceManager.instantPictureUploadPathUseSubfolders(context); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); diff --git a/src/com/owncloud/android/services/observer/FolderObserver.java b/src/com/owncloud/android/services/observer/FolderObserver.java index 4e6c398cee..8c045be301 100644 --- a/src/com/owncloud/android/services/observer/FolderObserver.java +++ b/src/com/owncloud/android/services/observer/FolderObserver.java @@ -20,10 +20,6 @@ package com.owncloud.android.services.observer; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - import android.accounts.Account; import android.content.Context; import android.content.Intent; @@ -37,6 +33,10 @@ import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.ui.activity.ConflictsResolveActivity; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + /** * Observer watching a folder to request the synchronization of kept-in-sync files * inside it. @@ -111,17 +111,16 @@ public class FolderObserver extends FileObserver { synchronized(mObservedChildren) { if (path != null && path.length() > 0 && mObservedChildren.containsKey(path)) { - if ( ((event & FileObserver.MODIFY) != 0) || + if ( (((event & FileObserver.MODIFY) != 0) || ((event & FileObserver.ATTRIB) != 0) || - ((event & FileObserver.MOVED_TO) != 0) ) { - - if (mObservedChildren.get(path) != true) { - mObservedChildren.put(path, Boolean.valueOf(true)); - } + ((event & FileObserver.MOVED_TO) != 0)) && + !mObservedChildren.get(path)) { + + mObservedChildren.put(path, Boolean.TRUE); } if ((event & FileObserver.CLOSE_WRITE) != 0 && mObservedChildren.get(path)) { - mObservedChildren.put(path, Boolean.valueOf(false)); + mObservedChildren.put(path, Boolean.FALSE); shouldSynchronize = true; } } @@ -134,7 +133,6 @@ public class FolderObserver extends FileObserver { (path == null || path.length() == 0)) { Log_OC.d(TAG, "Stopping the observance on " + mPath); } - } @@ -146,7 +144,7 @@ public class FolderObserver extends FileObserver { public void startWatching(String fileName) { synchronized (mObservedChildren) { if (!mObservedChildren.containsKey(fileName)) { - mObservedChildren.put(fileName, Boolean.valueOf(false)); + mObservedChildren.put(fileName, Boolean.FALSE); } } @@ -212,5 +210,4 @@ public class FolderObserver extends FileObserver { // or maybe just toast them; // or nothing, very strange fails } - } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index ed66c22d28..2c82023c1d 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -248,45 +248,44 @@ public class FileDisplayActivity extends HookActivity */ private void upgradeNotificationForInstantUpload() { // check for Android 5+ if legacy instant upload is activated --> disable + show info - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (PreferenceManager.instantPictureUploadEnabled(this) || PreferenceManager.instantPictureUploadEnabled - (this)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && + (PreferenceManager.instantPictureUploadEnabled(this) || + PreferenceManager.instantPictureUploadEnabled(this))) { - // remove legacy shared preferences - SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); - editor.remove("instant_uploading") - .remove("instant_video_uploading") - .remove("instant_upload_path") - .remove("instant_upload_path_use_subfolders") - .remove("instant_upload_on_wifi") - .remove("instant_upload_on_charging") - .remove("instant_video_upload_path") - .remove("instant_video_upload_path_use_subfolders") - .remove("instant_video_upload_on_wifi") - .remove("instant_video_uploading") - .remove("instant_video_upload_on_charging") - .remove("prefs_instant_behaviour").apply(); + // remove legacy shared preferences + SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); + editor.remove("instant_uploading") + .remove("instant_video_uploading") + .remove("instant_upload_path") + .remove("instant_upload_path_use_subfolders") + .remove("instant_upload_on_wifi") + .remove("instant_upload_on_charging") + .remove("instant_video_upload_path") + .remove("instant_video_upload_path_use_subfolders") + .remove("instant_video_upload_on_wifi") + .remove("instant_video_uploading") + .remove("instant_video_upload_on_charging") + .remove("prefs_instant_behaviour").apply(); - // show info pop-up - new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog) - .setTitle(R.string.drawer_folder_sync) - .setMessage(R.string.folder_sync_new_info) - .setPositiveButton(R.string.drawer_open, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - // show instant upload - Intent folderSyncIntent = new Intent(getApplicationContext(), FolderSyncActivity.class); - dialog.dismiss(); - startActivity(folderSyncIntent); - } - }) - .setNegativeButton(R.string.drawer_close, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }) - .setIcon(R.drawable.ic_cloud_upload) - .show(); - } + // show info pop-up + new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog) + .setTitle(R.string.drawer_folder_sync) + .setMessage(R.string.folder_sync_new_info) + .setPositiveButton(R.string.drawer_open, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + // show instant upload + Intent folderSyncIntent = new Intent(getApplicationContext(), FolderSyncActivity.class); + dialog.dismiss(); + startActivity(folderSyncIntent); + } + }) + .setNegativeButton(R.string.drawer_close, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }) + .setIcon(R.drawable.ic_cloud_upload) + .show(); } } diff --git a/src/com/owncloud/android/ui/activity/FolderSyncActivity.java b/src/com/owncloud/android/ui/activity/FolderSyncActivity.java index dcb891ba0b..20fba35aef 100644 --- a/src/com/owncloud/android/ui/activity/FolderSyncActivity.java +++ b/src/com/owncloud/android/ui/activity/FolderSyncActivity.java @@ -121,7 +121,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte * @param perFolderMediaItemLimit the amount of media items to be loaded/shown per media folder */ private void load(final int perFolderMediaItemLimit) { - if (mAdapter.getItemCount() > 0) return; + if (mAdapter.getItemCount() > 0) { + return; + } setListShown(false); final Handler mHandler = new Handler(); new Thread(new Runnable() { @@ -354,7 +356,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte @Override public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) { SyncedFolderDisplayItem item = syncFolderItems.get(syncedFolder.getSection()); - boolean dirty = !(item.isEnabled() == syncedFolder.getEnabled()); + boolean dirty = item.isEnabled() != syncedFolder.getEnabled(); item = updateSyncedFolderItem(item, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(), syncedFolder .getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder .getUploadAction(), syncedFolder.getEnabled()); diff --git a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java index 3c13c0d07f..55ef54e77a 100644 --- a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java +++ b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java @@ -23,10 +23,12 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.FileProvider; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; @@ -148,11 +150,18 @@ public class LogHistoryActivity extends ToolbarActivity { ArrayList uris = new ArrayList(); // Convert from paths to Android friendly Parcelable Uri's - for (String file : Log_OC.getLogFileNames()) - { + for (String file : Log_OC.getLogFileNames()) { File logFile = new File(mLogPath, file); if (logFile.exists()) { - uris.add(Uri.fromFile(logFile)); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { + uris.add(Uri.fromFile(logFile)); + } else { + uris.add(FileProvider.getUriForFile( + this, + getString(R.string.file_provider_authority), + logFile + )); + } } } diff --git a/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java b/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java index a9c84f1ac1..df6de99ca8 100644 --- a/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java @@ -157,13 +157,13 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter