remote folder can now be changed, all config changes for a synced folder are now saved

This commit is contained in:
AndyScherzinger 2016-10-09 23:27:30 +02:00
parent 5214659b05
commit b557b0762c
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
8 changed files with 293 additions and 79 deletions

View file

@ -31,8 +31,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/folder_sync_preferences"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:visibility="gone"/>
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
<ScrollView
android:id="@+id/details_scroll"
@ -78,7 +77,7 @@
android:id="@+id/local_folder_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prefs_instant_upload_path_title"
android:text="@string/prefs_folder_sync_local_path_title"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="?android:attr/textAppearanceListItem"/>
@ -97,7 +96,18 @@
</LinearLayout>
<TextView
android:id="@+id/settings_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:paddingTop="@dimen/standard_padding"
android:text="@string/folder_sync_settings"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/color_accent"/>
<LinearLayout
android:id="@+id/remote_folder_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@ -121,7 +131,7 @@
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="16dip"
@ -131,7 +141,7 @@
android:id="@+id/remote_folder_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prefs_instant_upload_path_title"
android:text="@string/prefs_folder_sync_remote_path_title"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="?android:attr/textAppearanceListItem"/>
@ -150,16 +160,6 @@
</LinearLayout>
<TextView
android:id="@+id/settings_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:paddingTop="@dimen/standard_padding"
android:text="@string/folder_sync_settings"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/color_accent"/>
<LinearLayout
android:id="@+id/setting_instant_upload_on_wifi_container"
android:layout_width="match_parent"
@ -311,6 +311,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/setting_instant_behaviour_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"

View file

@ -316,6 +316,8 @@
<string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local folder</string>
<string name="prefs_instant_upload_path_title">Instant upload folder</string>
<string name="prefs_folder_sync_local_path_title">Local folder</string>
<string name="prefs_folder_sync_remote_path_title">Remote folder</string>
<string name="prefs_instant_upload_path_use_subfolders_title">Use subfolders</string>
<string name="prefs_instant_upload_path_use_subfolders_summary">Store in subfolders based on year and month</string>
@ -495,6 +497,7 @@
<string name="participate_contribute_github_text">Contribute as a developer, see &lt;a href="https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md">CONTRIBUTING.md&lt;/a> for details</string>
<string name="move_to">Move to&#8230;</string>
<string name="copy_to">Copy to&#8230;</string>
<string name="choose_remote_folder">Choose folder&#8230;</string>
<string name="folder_sync_loading_folders">Loading folders&#8230;</string>
<string name="folder_sync_no_results">No results</string>
<string name="folder_sync_preferences">Folder Sync Preferences</string>

View file

@ -22,7 +22,8 @@
package com.owncloud.android.datamodel;
public class SyncedFolder {
private long id;
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
private long id = UNPERSISTED_ID;
private String localPath;
private String remotePath;
private Boolean wifiOnly;
@ -45,38 +46,82 @@ public class SyncedFolder {
this.enabled = enabled;
}
public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled) {
this.localPath = localPath;
this.remotePath = remotePath;
this.wifiOnly = wifiOnly;
this.chargingOnly = chargingOnly;
this.subfolderByDate = subfolderByDate;
this.account = account;
this.uploadAction = uploadAction;
this.enabled = enabled;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getLocalPath() {
return localPath;
}
public void setLocalPath(String localPath) {
this.localPath = localPath;
}
public String getRemotePath() {
return remotePath;
}
public void setRemotePath(String remotePath) {
this.remotePath = remotePath;
}
public Boolean getWifiOnly() {
return wifiOnly;
}
public void setWifiOnly(Boolean wifiOnly) {
this.wifiOnly = wifiOnly;
}
public Boolean getChargingOnly() {
return chargingOnly;
}
public void setChargingOnly(Boolean chargingOnly) {
this.chargingOnly = chargingOnly;
}
public Boolean getSubfolderByDate() {
return subfolderByDate;
}
public void setSubfolderByDate(Boolean subfolderByDate) {
this.subfolderByDate = subfolderByDate;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public Integer getUploadAction() {
return uploadAction;
}
public void setUploadAction(Integer uploadAction) {
this.uploadAction = uploadAction;
}
public boolean isEnabled() {
return enabled;
}

View file

@ -27,7 +27,6 @@ import java.util.List;
* TODO javadoc
*/
public class SyncedFolderItem extends SyncedFolder {
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
private List<String> filePaths;
private String folderName;
private long numberOfFiles;

View file

@ -56,7 +56,7 @@ public class SyncedFolderProvider extends Observable {
* Stores an media folder sync object in database.
*
* @param syncedFolder synced folder to store
* @return upload id, -1 if the insert process fails.
* @return synced folder id, -1 if the insert process fails.
*/
public long storeFolderSync(SyncedFolder syncedFolder) {
Log_OC.v(TAG, "Inserting " + syncedFolder.getLocalPath() + " with enabled=" + syncedFolder.isEnabled());
@ -191,7 +191,7 @@ public class SyncedFolderProvider extends Observable {
* @param syncedFolder the synced folder to be updated.
* @return the number of rows updated.
*/
private int updateSyncFolder(SyncedFolder syncedFolder) {
public int updateSyncFolder(SyncedFolder syncedFolder) {
Log_OC.v(TAG, "Updating " + syncedFolder.getLocalPath() + " with enabled=" + syncedFolder.isEnabled());
ContentValues cv = createContentValuesFromSyncedFolder(syncedFolder);

View file

@ -40,11 +40,13 @@ import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.MediaFolder;
import com.owncloud.android.datamodel.MediaProvider;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.SyncedFolder;
import com.owncloud.android.datamodel.SyncedFolderItem;
import com.owncloud.android.datamodel.SyncedFolderProvider;
import com.owncloud.android.ui.adapter.FolderSyncAdapter;
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable;
import java.util.ArrayList;
import java.util.HashMap;
@ -52,6 +54,8 @@ import java.util.List;
import java.util.Map;
import java.util.TimerTask;
import static com.owncloud.android.datamodel.SyncedFolderItem.UNPERSISTED_ID;
/**
* Activity displaying all auto-synced folders and/or instant upload media folders.
*/
@ -66,6 +70,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
private TextView mEmpty;
private SyncedFolderProvider mSyncedFolderProvider;
private List<SyncedFolderItem> syncFolderItems;
private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -113,11 +118,11 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
syncFolderItems = mergeFolderData(mSyncedFolderProvider.getSyncedFolders(),
mediaFolders);
// TODO remove before mergeing to master, keeping it for debugging atm
// TODO remove before merging to master, keeping it for debugging atm
/**
for (MediaFolder mediaFolder : mediaFolders) {
Log.d(TAG, mediaFolder.absolutePath);
}
for (MediaFolder mediaFolder : mediaFolders) {
Log.d(TAG, mediaFolder.absolutePath);
}
*/
mHandler.post(new TimerTask() {
@ -140,7 +145,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
for (MediaFolder mediaFolder : mediaFolders) {
if (syncedFoldersMap.containsKey(mediaFolder.absolutePath)) {
SyncedFolder syncedFolder = syncedFoldersMap.get(mediaFolder.absolutePath);
result.add(createSyncedFolder(syncedFolder,mediaFolder));
result.add(createSyncedFolder(syncedFolder, mediaFolder));
} else {
result.add(createSyncedFolderFromMediaFolder(mediaFolder));
}
@ -169,7 +174,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
@NonNull
private SyncedFolderItem createSyncedFolderFromMediaFolder(@NonNull MediaFolder mediaFolder) {
return new SyncedFolderItem(
SyncedFolderItem.UNPERSISTED_ID,
UNPERSISTED_ID,
mediaFolder.absolutePath,
getString(R.string.instant_upload_path) + "/" + mediaFolder.folderName,
true,
@ -184,7 +189,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
}
@NonNull
private Map<String,SyncedFolder> createSyncedFoldersMap(List<SyncedFolder> syncFolders) {
private Map<String, SyncedFolder> createSyncedFoldersMap(List<SyncedFolder> syncFolders) {
Map<String, SyncedFolder> result = new HashMap<>();
if (syncFolders != null) {
for (SyncedFolder syncFolder : syncFolders) {
@ -237,8 +242,8 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
@Override
public void onSyncStatusToggleClick(int section, SyncedFolderItem syncedFolderItem) {
if(syncedFolderItem.getId() > SyncedFolderItem.UNPERSISTED_ID) {
mSyncedFolderProvider.updateFolderSyncEnabled(syncedFolderItem.getId(),!syncedFolderItem.isEnabled());
if (syncedFolderItem.getId() > UNPERSISTED_ID) {
mSyncedFolderProvider.updateFolderSyncEnabled(syncedFolderItem.getId(), !syncedFolderItem.isEnabled());
} else {
mSyncedFolderProvider.storeFolderSync(syncedFolderItem);
}
@ -250,12 +255,71 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(null);
SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderItem)
.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
mSyncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderItem,
section);
mSyncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
}
@Override
public void onSaveSyncedFolderPreference() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER
&& resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) {
OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath());
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
Toast.makeText(this, "onSaveSyncedFolderPreference clicked", Toast.LENGTH_SHORT).show();
SyncedFolderItem item = syncFolderItems.get(syncedFolder.getSection());
item = updateSyncedFolderItem(item, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(), syncedFolder
.getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder
.getUploadAction());
if (syncedFolder.getId() == UNPERSISTED_ID) {
// newly set up folder sync config
mSyncedFolderProvider.storeFolderSync(item);
} else {
// existing synced folder setup to be updated
mSyncedFolderProvider.updateSyncFolder(item);
}
mSyncedFolderPreferencesDialogFragment = null;
}
@Override
public void onCancelSyncedFolderPreference() {
mSyncedFolderPreferencesDialogFragment = null;
}
/**
* update given synced folder with the given values.
*
* @param item the synced folder to be updated
* @param localPath the local path
* @param remotePath the remote path
* @param wifiOnly upload on wifi only
* @param chargingOnly upload on charging only
* @param subfolderByDate created sub folders
* @param uploadAction upload action
* @return the updated item
*/
private SyncedFolderItem updateSyncedFolderItem(SyncedFolderItem item,
String localPath,
String remotePath,
Boolean wifiOnly,
Boolean chargingOnly,
Boolean subfolderByDate,
Integer uploadAction) {
item.setLocalPath(localPath);
item.setRemotePath(remotePath);
item.setWifiOnly(wifiOnly);
item.setChargingOnly(chargingOnly);
item.setSubfolderByDate(subfolderByDate);
item.setUploadAction(uploadAction);
return item;
}
}

View file

@ -22,20 +22,23 @@ package com.owncloud.android.ui.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.SyncedFolderItem;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.activity.FolderPickerActivity;
import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable;
/**
@ -46,15 +49,23 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
private final static String TAG = SyncedFolderPreferencesDialogFragment.class.getSimpleName();
public static final String SYNCED_FOLDER_PARCELABLE = "SyncedFolderParcelable";
public static final int REQUEST_CODE__SELECT_REMOTE_FOLDER = 0;
private CharSequence[] mUploadBehaviorItemStrings;
private CharSequence[] mUploadBehaviorItemValues;
protected View mView = null;
private CheckBox mUploadOnWifiCheckbox;
private CheckBox mUploadOnChargingCheckbox;
private CheckBox mUploadUseSubfoldersCheckbox;
private TextView mUploadBehaviorSummary;
private TextView mLocalFolderSummary;
private TextView mRemoteFolderSummary;
private SyncedFolderParcelable mSyncedFolder;
private int mSection;
public static SyncedFolderPreferencesDialogFragment newInstance(SyncedFolderItem syncedFolder) {
public static SyncedFolderPreferencesDialogFragment newInstance(SyncedFolderItem syncedFolder, int section) {
SyncedFolderPreferencesDialogFragment dialogFragment = new SyncedFolderPreferencesDialogFragment();
if (syncedFolder == null) {
@ -62,7 +73,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
}
Bundle args = new Bundle();
args.putParcelable(SYNCED_FOLDER_PARCELABLE, new SyncedFolderParcelable(syncedFolder));
args.putParcelable(SYNCED_FOLDER_PARCELABLE, new SyncedFolderParcelable(syncedFolder, section));
dialogFragment.setArguments(args);
return dialogFragment;
@ -72,7 +83,8 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
public void onAttach(Activity activity) {
super.onAttach(activity);
if (!(activity instanceof OnSyncedFolderPreferenceListener)) {
throw new IllegalArgumentException("The host activity must implement " + OnSyncedFolderPreferenceListener.class.getCanonicalName());
throw new IllegalArgumentException("The host activity must implement "
+ OnSyncedFolderPreferenceListener.class.getCanonicalName());
}
}
@ -82,11 +94,12 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
// keep the state of the fragment on configuration changes
setRetainInstance(true);
// TODO check UX if it shouldn't be cancelable
//setCancelable(false);
setCancelable(false);
mView = null;
mSyncedFolder = getArguments().getParcelable(SYNCED_FOLDER_PARCELABLE);
mUploadBehaviorItemStrings = getResources().getTextArray(R.array.pref_behaviour_entries);
mUploadBehaviorItemValues = getResources().getTextArray(R.array.pref_behaviour_entryValues);
}
@Override
@ -95,61 +108,128 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
mView = inflater.inflate(R.layout.folder_sync_settings_layout, container, false);
Button save = (Button) mView.findViewById(R.id.save);
save.setOnClickListener(new OnSyncedFolderSaveClickListener());
Button cancel = (Button) mView.findViewById(R.id.cancel);
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
((TextView) mView.findViewById(R.id.local_folder_summary)).setText(mSyncedFolder.getLocalPath());
((TextView) mView.findViewById(R.id.remote_folder_summary)).setText(mSyncedFolder.getRemotePath());
// TODO add all necessary listeners and fields
setupDialogElements(mView);
setupListeners(mView);
return mView;
}
/**
* find all relevant UI elements and set their values.
*
* @param view the parent view
*/
private void setupDialogElements(View view) {
// find/saves UI elements
mLocalFolderSummary = (TextView) mView.findViewById(R.id.local_folder_summary);
mRemoteFolderSummary = (TextView) mView.findViewById(R.id.remote_folder_summary);
mUploadOnWifiCheckbox = (CheckBox) mView.findViewById(R.id.setting_instant_upload_on_wifi_checkbox);
mUploadOnChargingCheckbox = (CheckBox) mView.findViewById(R.id.setting_instant_upload_on_charging_checkbox);
mUploadUseSubfoldersCheckbox = (CheckBox) mView.findViewById(R.id
.setting_instant_upload_path_use_subfolders_checkbox);
// TODO create separate setup methods to keep code easy to read
mUploadBehaviorSummary = (TextView) mView.findViewById(R.id.setting_instant_behaviour_summary);
mView.findViewById(R.id.setting_instant_upload_on_wifi_container).setOnClickListener(new OnClickListener() {
// Set values
mLocalFolderSummary.setText(mSyncedFolder.getLocalPath());
mRemoteFolderSummary.setText(mSyncedFolder.getRemotePath());
mUploadOnWifiCheckbox.setChecked(mSyncedFolder.getWifiOnly());
mUploadOnChargingCheckbox.setChecked(mSyncedFolder.getChargingOnly());
mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.getSubfolderByDate());
mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[mSyncedFolder.getUploadAction()]);
}
/**
* set (new) remote path on activity result of the folder picker activity. The result gets originally propagated
* to the underlying activity since the picker is an activity and the result can't get passed to the dialog
* fragment directly.
*
* @param path the remote path to be set
*/
public void setRemoteFolderSummary(String path) {
mSyncedFolder.setRemotePath(path);
mRemoteFolderSummary.setText(path);
}
/**
* setup all listeners.
*
* @param view the parent view
*/
private void setupListeners(View view) {
view.findViewById(R.id.save).setOnClickListener(new OnSyncedFolderSaveClickListener());
view.findViewById(R.id.cancel).setOnClickListener(new OnSyncedFolderCancelClickListener());
view.findViewById(R.id.setting_instant_upload_on_wifi_container).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setWifiOnly(!mSyncedFolder.getWifiOnly());
mUploadOnWifiCheckbox.toggle();
}
});
view.findViewById(R.id.setting_instant_upload_on_charging_container).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setChargingOnly(!mSyncedFolder.getChargingOnly());
mUploadOnChargingCheckbox.toggle();
}
});
view.findViewById(R.id.setting_instant_upload_path_use_subfolders_container).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
mSyncedFolder.setSubfolderByDate(!mSyncedFolder.getSubfolderByDate());
mUploadUseSubfoldersCheckbox.toggle();
}
});
view.findViewById(R.id.remote_folder_container).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO save checkbox state to boolean
mUploadOnWifiCheckbox.toggle();
Intent action = new Intent(getActivity(), FolderPickerActivity.class);
action.putExtra(
FolderPickerActivity.EXTRA_ACTION, getResources().getText(R.string.choose_remote_folder));
getActivity().startActivityForResult(action, REQUEST_CODE__SELECT_REMOTE_FOLDER);
}
});
mView.findViewById(R.id.setting_instant_upload_on_charging_container).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO save checkbox state to boolean
mUploadOnChargingCheckbox.toggle();
}
});
mView.findViewById(R.id.setting_instant_upload_path_use_subfolders_container).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO save checkbox state to boolean
mUploadUseSubfoldersCheckbox.toggle();
}
});
return mView;
view.findViewById(R.id.setting_instant_behaviour_container).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.prefs_instant_behaviour_dialogTitle)
.setSingleChoiceItems(getResources().getTextArray(R.array.pref_behaviour_entries),
mSyncedFolder.getUploadAction(),
new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
mSyncedFolder.setUploadAction(which);
mUploadBehaviorSummary.setText(SyncedFolderPreferencesDialogFragment
.this.mUploadBehaviorItemStrings[which]);
dialog.dismiss();
}
});
builder.create().show();
}
});
}
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.setTitle(R.string.folder_sync_preferences);
dialog.setTitle(null);
return dialog;
}
@ -165,11 +245,21 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
@Override
public void onClick(View v) {
dismiss();
((OnSyncedFolderPreferenceListener) getActivity()).onSaveSyncedFolderPreference();
((OnSyncedFolderPreferenceListener) getActivity()).onSaveSyncedFolderPreference(mSyncedFolder);
}
}
private class OnSyncedFolderCancelClickListener implements OnClickListener {
@Override
public void onClick(View v) {
dismiss();
((OnSyncedFolderPreferenceListener) getActivity()).onCancelSyncedFolderPreference();
}
}
public interface OnSyncedFolderPreferenceListener {
public void onSaveSyncedFolderPreference();
public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder);
public void onCancelSyncedFolderPreference();
}
}

View file

@ -31,18 +31,19 @@ import com.owncloud.android.datamodel.SyncedFolderItem;
public class SyncedFolderParcelable implements Parcelable {
private String mLocalPath;
private String mRemotePath;
private Boolean mWifiOnly;
private Boolean mChargingOnly;
private boolean mEnabled;
private Boolean mSubfolderByDate;
private Boolean mWifiOnly = false;
private Boolean mChargingOnly = false;
private Boolean mEnabled = false;
private Boolean mSubfolderByDate = false;
private Integer mUploadAction;
private long mId;
private String mAccount;
private int mSection;
public SyncedFolderParcelable() {
}
public SyncedFolderParcelable(SyncedFolderItem syncedFolderItem) {
public SyncedFolderParcelable(SyncedFolderItem syncedFolderItem, int section) {
mId = syncedFolderItem.getId();
mLocalPath = syncedFolderItem.getLocalPath();
mRemotePath = syncedFolderItem.getRemotePath();
@ -52,6 +53,7 @@ public class SyncedFolderParcelable implements Parcelable {
mSubfolderByDate = syncedFolderItem.getSubfolderByDate();
mAccount = syncedFolderItem.getAccount();
mUploadAction = syncedFolderItem.getUploadAction();
mSection = section;
}
public SyncedFolderParcelable(Parcel read) {
@ -64,6 +66,7 @@ public class SyncedFolderParcelable implements Parcelable {
mSubfolderByDate = read.readInt() != 0;
mAccount = read.readString();
mUploadAction = read.readInt();
mSection = read.readInt();
}
@Override
@ -77,6 +80,7 @@ public class SyncedFolderParcelable implements Parcelable {
dest.writeInt(mSubfolderByDate ? 1 : 0);
dest.writeString(mAccount);
dest.writeInt(mUploadAction);
dest.writeInt(mSection);
}
public static final Creator<SyncedFolderParcelable> CREATOR =
@ -130,7 +134,7 @@ public class SyncedFolderParcelable implements Parcelable {
this.mChargingOnly = mChargingOnly;
}
public boolean isEnabled() {
public boolean getEnabled() {
return mEnabled;
}
@ -169,4 +173,12 @@ public class SyncedFolderParcelable implements Parcelable {
public void setAccount(String mAccount) {
this.mAccount = mAccount;
}
public int getSection() {
return mSection;
}
public void setSection(int mSection) {
this.mSection = mSection;
}
}