Merge remote-tracking branch 'origin/syncedFolders' into syncedFolders2

This commit is contained in:
tobiasKaminsky 2016-11-10 21:50:43 +01:00
commit fb4fe4663e
10 changed files with 75 additions and 67 deletions

View file

@ -67,6 +67,7 @@ public class MainApp extends Application {
private static boolean mOnlyOnDevice = false;
private static SyncedFolderObserverService mObserverService;
@SuppressWarnings("unused")
private boolean mBound;

View file

@ -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";

View file

@ -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);

View file

@ -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
}
}

View file

@ -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();
}
}

View file

@ -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());

View file

@ -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<Uri> uris = new ArrayList<Uri>();
// 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
));
}
}
}

View file

@ -157,13 +157,13 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
}
static class MainViewHolder extends RecyclerView.ViewHolder {
final ImageView image;
final TextView title;
final ImageButton menuButton;
final ImageButton syncStatusButton;
final LinearLayout counterBar;
final TextView counterValue;
final ImageView thumbnailDarkener;
private final ImageView image;
private final TextView title;
private final ImageButton menuButton;
private final ImageButton syncStatusButton;
private final LinearLayout counterBar;
private final TextView counterValue;
private final ImageView thumbnailDarkener;
private MainViewHolder(View itemView) {
super(itemView);

View file

@ -264,8 +264,9 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
@Override
public void onDestroyView() {
Log_OC.d(TAG, "destroy SyncedFolderPreferencesDialogFragment view");
if (getDialog() != null && getRetainInstance())
if (getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
}
super.onDestroyView();
}

View file

@ -147,7 +147,7 @@ public class SyncedFolderParcelable implements Parcelable {
this.mChargingOnly = mChargingOnly;
}
public boolean getEnabled() {
public Boolean getEnabled() {
return mEnabled;
}