mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
add the action in the context menu
This commit is contained in:
parent
684104ccb8
commit
f226b5f93a
3 changed files with 32 additions and 3 deletions
|
@ -40,6 +40,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
|
|||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.services.OperationsService;
|
||||
import com.owncloud.android.services.observer.FileObserverService;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.dialog.ShareLinkToDialog;
|
||||
|
||||
|
@ -224,6 +225,25 @@ public class FileOperationsHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void toggleKeepInSync(OCFile file, boolean isFavorite) {
|
||||
Log_OC.e(TAG, "KeepInSync");
|
||||
file.setKeepInSync(isFavorite);
|
||||
mFileActivity.getStorageManager().saveFile(file);
|
||||
|
||||
/// register the OCFile instance in the observer service to monitor local updates
|
||||
Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
|
||||
mFileActivity,
|
||||
file,
|
||||
mFileActivity.getAccount(),
|
||||
isFavorite);
|
||||
mFileActivity.startService(observedFileIntent);
|
||||
|
||||
/// immediate content synchronization
|
||||
if (file.keepInSync()) {
|
||||
syncFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void renameFile(OCFile file, String newFilename) {
|
||||
// RenameFile
|
||||
Intent service = new Intent(mFileActivity, OperationsService.class);
|
||||
|
|
|
@ -282,6 +282,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
|||
|
||||
|
||||
private void toggleKeepInSync() {
|
||||
Log_OC.e(TAG, "toggleKeepInSync");
|
||||
CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
|
||||
OCFile file = getFile();
|
||||
file.setKeepInSync(cb.isChecked());
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.owncloud.android.datamodel.OCFile;
|
|||
import com.owncloud.android.files.FileMenuFilter;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.services.observer.FileObserverService;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||
|
@ -341,6 +342,14 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_favorite_file:{
|
||||
mContainerActivity.getFileOperationsHelper().toggleKeepInSync(mTargetFile, true);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_unfavorite_file:{
|
||||
mContainerActivity.getFileOperationsHelper().toggleKeepInSync(mTargetFile, false);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
@ -495,5 +504,4 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue