import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
-import android.widget.Toast;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.CreateShareWithShareeOperation;
-import com.owncloud.android.operations.UnshareOperation;
-import com.owncloud.android.ui.fragment.SearchFragment;
+import com.owncloud.android.ui.fragment.SearchShareesFragment;
import com.owncloud.android.ui.fragment.ShareFileFragment;
import com.owncloud.android.utils.GetShareWithUsersAsyncTask;
*/
public class ShareActivity extends FileActivity
- implements GetShareWithUsersAsyncTask.OnGetSharesWithUsersTaskListener,
- ShareFileFragment.OnShareFragmentInteractionListener,
- SearchFragment.OnSearchFragmentInteractionListener {
+ implements ShareFileFragment.OnShareFragmentInteractionListener,
+ SearchShareesFragment.OnSearchFragmentInteractionListener {
private static final String TAG = ShareActivity.class.getSimpleName();
private static final String DIALOG_WAIT_LOAD_DATA = "DIALOG_WAIT_LOAD_DATA";
private ShareFileFragment mShareFileFragment;
- private SearchFragment mSearchFragment;
+ private SearchShareesFragment mSearchFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ onAccountSet(false);
setContentView(R.layout.share_activity);
mShareFileFragment = (ShareFileFragment) getSupportFragmentManager().
getFragment(savedInstanceState, TAG_SHARE_FRAGMENT);
- mSearchFragment = (SearchFragment) getSupportFragmentManager().
+ mSearchFragment = (SearchShareesFragment) getSupportFragmentManager().
getFragment(savedInstanceState, TAG_SEARCH_FRAGMENT);
if (mShareFileFragment != null){
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,
}
@Override
- public void showSearchUsersAndGroups(ArrayList<OCShare> shares) {
+ public void showSearchUsersAndGroups() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
- mSearchFragment = SearchFragment.newInstance(getFile(), getAccount(), shares);
+ mSearchFragment = SearchShareesFragment.newInstance(getFile(), getAccount());
ft.hide(mShareFileFragment);
ft.add(R.id.share_fragment_container, mSearchFragment, TAG_SEARCH_FRAGMENT);
ft.addToBackStack(TAG_SEARCH_FRAGMENT);
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();
- }
- }
-
- @Override
- public void onGetDataShareWithFinish(RemoteOperationResult result) {
- // Remove loading
- dismissLoadingDialog();
- if (result != null && result.isSuccess()) {
- Log_OC.d(TAG, "Get Data Share With finishes sucessfully");
- } else {
- Toast.makeText(this, result.getLogMessage(), Toast.LENGTH_SHORT).show();
+ if (result.isSuccess()) {
+ refreshUsersInLists();
+ if (operation instanceof CreateShareWithShareeOperation) {
+ // Clean action
+ getIntent().setAction(null);
+ }
}
- // Data is on Database
- refreshUsersInLists();
}
private void refreshUsersInLists(){