import com.owncloud.android.operations.UnshareOperation;
import com.owncloud.android.ui.fragment.SearchFragment;
import com.owncloud.android.ui.fragment.ShareFileFragment;
+import com.owncloud.android.utils.ErrorMessageAdapter;
import com.owncloud.android.utils.GetShareWithUsersAsyncTask;
import java.util.ArrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ onAccountSet(false);
setContentView(R.layout.share_activity);
if (mSearchFragment != null){
ft.hide(mShareFileFragment);
ft.add(R.id.share_fragment_container, mSearchFragment, TAG_SEARCH_FRAGMENT);
- ft.addToBackStack(TAG_SEARCH_FRAGMENT);
}
ft.commit();
}
handleIntent(getIntent());
- onAccountSet(false);
+
}
}
private void doShareWith(String shareeName, boolean isGroup) {
- if (isGroup) {
- Toast.makeText(this, "You want to SHARE with GROUP [" + shareeName + "]", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(this, "You want to SHARE with USER [" + shareeName + "]", Toast.LENGTH_SHORT).show();
- }
getFileOperationsHelper().shareFileWithSharee(
getFile(),
shareeName,
public void onBackPressed() {
super.onBackPressed();
if (mSearchFragment != null){
- getSupportFragmentManager().popBackStackImmediate();
mSearchFragment = null;
+ getSupportFragmentManager().popBackStackImmediate();
mShareFileFragment.refreshUsersOrGroupsListFromDB();
}
}
@Override
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
super.onRemoteOperationFinish(operation, result);
- if (operation instanceof UnshareOperation) {
- refreshUsersInLists();
- } else if(operation instanceof CreateShareWithShareeOperation){
- refreshUsersInLists();
+ if (operation instanceof UnshareOperation ||
+ operation instanceof CreateShareWithShareeOperation) {
+
+ if (result.isSuccess()) {
+ refreshUsersInLists();
+ if (operation instanceof CreateShareWithShareeOperation) {
+ // Clean action
+ getIntent().setAction(null);
+ }
+ } else {
+ Toast.makeText(
+ this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG
+ ).show();
+ }
+
+ /*} else if (operation instanceof GetSharesForFileOperation) {
+ onGetSharesForFileOperationFinish((GetSharesForFileOperation) operation, result);*/
}
}