mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
OC-2834: Access to unshare link from PreviewMediaFragment
This commit is contained in:
parent
ffdd188f06
commit
3f701c5bb8
4 changed files with 38 additions and 14 deletions
|
@ -250,4 +250,5 @@
|
||||||
<string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your administrator.</string>
|
<string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your administrator.</string>
|
||||||
<string name="share_link_file_no_exist">Unable to share this file or folder. Please, make sure it exists</string>
|
<string name="share_link_file_no_exist">Unable to share this file or folder. Please, make sure it exists</string>
|
||||||
<string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
|
<string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
|
||||||
|
<string name="unshare_link_file_error">An error occurred while trying to unshare this file or folder</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.owncloud.android.lib.operations.common.RemoteOperation;
|
||||||
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
|
||||||
import com.owncloud.android.operations.CreateShareOperation;
|
import com.owncloud.android.operations.CreateShareOperation;
|
||||||
|
import com.owncloud.android.operations.UnshareLinkOperation;
|
||||||
|
|
||||||
import com.owncloud.android.ui.dialog.LoadingDialog;
|
import com.owncloud.android.ui.dialog.LoadingDialog;
|
||||||
import com.owncloud.android.utils.Log_OC;
|
import com.owncloud.android.utils.Log_OC;
|
||||||
|
@ -353,6 +354,10 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
|
||||||
Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the FileActivities ");
|
Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the FileActivities ");
|
||||||
if (operation instanceof CreateShareOperation) {
|
if (operation instanceof CreateShareOperation) {
|
||||||
onCreateShareOperationFinish((CreateShareOperation) operation, result);
|
onCreateShareOperationFinish((CreateShareOperation) operation, result);
|
||||||
|
|
||||||
|
} else if (operation instanceof UnshareLinkOperation) {
|
||||||
|
onUnshareLinkOperationFinish((UnshareLinkOperation)operation, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +367,7 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
|
||||||
Intent sendIntent = operation.getSendIntent();
|
Intent sendIntent = operation.getSendIntent();
|
||||||
startActivity(sendIntent);
|
startActivity(sendIntent);
|
||||||
|
|
||||||
} else if (result.getCode() == ResultCode.FILE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
} else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
|
||||||
Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG);
|
Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG);
|
||||||
t.show();
|
t.show();
|
||||||
} else { // Generic error
|
} else { // Generic error
|
||||||
|
@ -373,6 +378,17 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
|
||||||
|
dismissLoadingDialog();
|
||||||
|
|
||||||
|
if (!result.isSuccess()){ // Generic error
|
||||||
|
// Show a Message, operation finished without success
|
||||||
|
Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_error), Toast.LENGTH_LONG);
|
||||||
|
t.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show loading dialog
|
* Show loading dialog
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1315,17 +1315,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
|
|
||||||
if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
|
|
||||||
// Show a Message
|
|
||||||
Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG);
|
|
||||||
t.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
refeshListOfFilesFragment();
|
|
||||||
|
|
||||||
dismissLoadingDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
|
private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
|
@ -1334,6 +1323,13 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
|
||||||
|
if (result.isSuccess()) {
|
||||||
|
refeshListOfFilesFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the view associated to the activity after the finish of an operation trying to remove a
|
* Updates the view associated to the activity after the finish of an operation trying to remove a
|
||||||
* file.
|
* file.
|
||||||
|
|
|
@ -316,6 +316,10 @@ public class PreviewMediaFragment extends FileFragment implements
|
||||||
shareFileWithLink();
|
shareFileWithLink();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case R.id.action_unshare_file: {
|
||||||
|
unshareFileWithLink();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case R.id.action_open_file_with: {
|
case R.id.action_open_file_with: {
|
||||||
openFile();
|
openFile();
|
||||||
return true;
|
return true;
|
||||||
|
@ -334,6 +338,8 @@ public class PreviewMediaFragment extends FileFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -342,6 +348,11 @@ public class PreviewMediaFragment extends FileFragment implements
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unshareFileWithLink() {
|
||||||
|
stopPreview(false);
|
||||||
|
FileActivity activity = (FileActivity)((FileFragment.ContainerActivity)getActivity());
|
||||||
|
activity.getFileOperationsHelper().unshareFileWithLink(getFile(), activity);
|
||||||
|
}
|
||||||
|
|
||||||
private void shareFileWithLink() {
|
private void shareFileWithLink() {
|
||||||
stopPreview(false);
|
stopPreview(false);
|
||||||
|
|
Loading…
Reference in a new issue