mView = inflater.inflate(mLayout, null);
if (mLayout == R.layout.file_details_fragment) {
- mView.findViewById(R.id.fdKeepInSync).setOnClickListener(this);
+ mView.findViewById(R.id.fdFavorite).setOnClickListener(this);
ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.fdProgressBar);
+ DisplayUtils.colorPreLollipopHorizontalProgressBar(progressBar);
mProgressListener = new ProgressListener(progressBar);
mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this);
}
}
return true;
}
+ case R.id.action_favorite_file:{
+ mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), true);
+ return true;
+ }
+ case R.id.action_unfavorite_file:{
+ mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false);
+ return true;
+ }
default:
return false;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
- case R.id.fdKeepInSync: {
- toggleKeepInSync();
+ case R.id.fdFavorite: {
+ CheckBox cb = (CheckBox) getView().findViewById(R.id.fdFavorite);
+ mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(),cb.isChecked());
break;
}
case R.id.fdCancelBtn: {
Log_OC.e(TAG, "Incorrect view clicked!");
}
}
-
-
- private void toggleKeepInSync() {
- CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
- OCFile file = getFile();
- file.setKeepInSync(cb.isChecked());
- mContainerActivity.getStorageManager().saveFile(file);
-
- /// register the OCFile instance in the observer service to monitor local updates
- Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
- getActivity(),
- file,
- mAccount,
- cb.isChecked());
- getActivity().startService(observedFileIntent);
-
- /// immediate content synchronization
- if (file.keepInSync()) {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
- }
- }
+
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
setTimeModified(file.getModificationTimestamp());
- CheckBox cb = (CheckBox)getView().findViewById(R.id.fdKeepInSync);
- cb.setChecked(file.keepInSync());
+ CheckBox cb = (CheckBox)getView().findViewById(R.id.fdFavorite);
+ cb.setChecked(file.isFavorite());
// configure UI for depending upon local state of the file
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
private void setButtonsForTransferring() {
if (!isEmpty()) {
// let's protect the user from himself ;)
- getView().findViewById(R.id.fdKeepInSync).setEnabled(false);
+ getView().findViewById(R.id.fdFavorite).setEnabled(false);
// show the progress bar for the transfer
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
*/
private void setButtonsForDown() {
if (!isEmpty()) {
- getView().findViewById(R.id.fdKeepInSync).setEnabled(true);
+ getView().findViewById(R.id.fdFavorite).setEnabled(true);
// hides the progress bar
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
*/
private void setButtonsForRemote() {
if (!isEmpty()) {
- getView().findViewById(R.id.fdKeepInSync).setEnabled(true);
+ getView().findViewById(R.id.fdFavorite).setEnabled(true);
// hides the progress bar
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);