X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c6edcab5a2f81773f05b8f796f2c356c2c2aeb4d..6cb184ab6377431383d7a6b30da30c3c4b02d8d7:/src/com/owncloud/android/ui/preview/PreviewImageFragment.java diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index eb8af268..aa2a6b36 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -1,5 +1,5 @@ /* ownCloud Android client application - * Copyright (C) 2012-2014 ownCloud Inc. + * Copyright (C) 2012-2013 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -17,8 +17,6 @@ package com.owncloud.android.ui.preview; import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; import android.accounts.Account; @@ -46,6 +44,8 @@ import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.files.FileMenuFilter; +import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.Log_OC; @@ -77,8 +77,6 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { private boolean mIgnoreFirstSavedState; - private FileFragment.ContainerActivity mContainerActivity; - /** * Creates a fragment to preview an image. @@ -161,22 +159,20 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { if (savedInstanceState != null) { if (!mIgnoreFirstSavedState) { OCFile file = (OCFile)savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_FILE); - setFile(file); mAccount = savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_ACCOUNT); -// TODO remove this code: update file no needed -// // Update the file -//// if (mAccount!= null) { -// OCFile updatedFile = -// mContainerActivity.getStorageManager().getFileByPath(file.getRemotePath()); -// if (updatedFile != null) { -// setFile(updatedFile); -// } else { -// setFile(file); -// } -// } else { -// setFile(file); -// } - + + // Update the file + if (mAccount!= null) { + OCFile updatedFile = ((FileActivity) getSherlockActivity()). + getStorageManager().getFileByPath(file.getRemotePath()); + if (updatedFile != null) { + setFile(updatedFile); + } else { + setFile(file); + } + } else { + setFile(file); + } } else { mIgnoreFirstSavedState = false; } @@ -220,35 +216,7 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - inflater.inflate(R.menu.file_actions_menu, menu); - List toHide = new ArrayList(); - - MenuItem item = null; - toHide.add(R.id.action_cancel_download); - toHide.add(R.id.action_cancel_upload); - toHide.add(R.id.action_download_file); - toHide.add(R.id.action_rename_file); // by now - - // Options shareLink - if (!getFile().isShareByLink()) { - toHide.add(R.id.action_unshare_file); - } - - // Send file - boolean sendEnabled = getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on"); - if (!sendEnabled) { - toHide.add(R.id.action_send_file); - } - - for (int i : toHide) { - item = menu.findItem(i); - if (item != null) { - item.setVisible(false); - item.setEnabled(false); - } - } - } /** @@ -258,16 +226,21 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - MenuItem item = menu.findItem(R.id.action_unshare_file); - // Options shareLink - if (!getFile().isShareByLink()) { + FileMenuFilter mf = new FileMenuFilter( + getFile(), + mContainerActivity.getStorageManager().getAccount(), + mContainerActivity, + getSherlockActivity() + ); + mf.filter(menu); + + // additional restriction for this fragment + // TODO allow renaming in PreviewImageFragment + MenuItem item = menu.findItem(R.id.action_rename_file); + if (item != null) { item.setVisible(false); item.setEnabled(false); - } else { - item.setVisible(true); - item.setEnabled(true); } - } @@ -302,6 +275,10 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); return true; } + case R.id.action_sync_file: { + mContainerActivity.getFileOperationsHelper().syncFile(getFile()); + return true; + } default: return false; @@ -369,7 +346,7 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { public void onConfirmation(String callerTag) { FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); if (storageManager.getFileById(getFile().getFileId()) != null) { // check that the file is still there; - mContainerActivity.getFileOperationsHelper().removeFile(getFile(), true); + mContainerActivity.getFileOperationsHelper().removeFile(getFile(), false); } } @@ -380,8 +357,9 @@ ConfirmationDialogFragment.ConfirmationDialogFragmentListener { @Override public void onNeutral(String callerTag) { OCFile file = getFile(); - mContainerActivity.getStorageManager().removeFile(file, false, true); // TODO perform in background task / new thread - finish(); + mContainerActivity.getFileOperationsHelper().removeFile(file, true); + //mContainerActivity.getStorageManager().removeFile(file, false, true); // TODO perform in background task / new thread + //finish(); } /**