Improved navigation after errors due to removal of shares, files or users from a separate client

This commit is contained in:
David A. Velasco 2016-01-25 11:08:28 +01:00
parent 6ac53bc1ba
commit 2681f8c22b
5 changed files with 60 additions and 44 deletions

View file

@ -46,6 +46,7 @@ import com.owncloud.android.ui.dialog.ShareLinkToDialog;
import com.owncloud.android.ui.fragment.EditShareFragment;
import com.owncloud.android.ui.fragment.SearchShareesFragment;
import com.owncloud.android.ui.fragment.ShareFileFragment;
import com.owncloud.android.ui.fragment.ShareFragmentListener;
import com.owncloud.android.utils.GetShareWithUsersAsyncTask;
import org.apache.http.protocol.HTTP;
@ -56,8 +57,7 @@ import org.apache.http.protocol.HTTP;
*/
public class ShareActivity extends FileActivity
implements ShareFileFragment.OnShareFragmentInteractionListener,
SearchShareesFragment.OnSearchFragmentInteractionListener {
implements ShareFragmentListener {
private static final String TAG = ShareActivity.class.getSimpleName();

View file

@ -271,8 +271,10 @@ public class EditShareFragment extends Fragment {
}
updatePermissionsToShare(); // see (1)
}
} else {
updatePermissionsToShare();
}
// updatePermissionsToShare()
// updatePermissionsToShare() // see (1)
// (1) These modifications result in an exceptional UI behaviour for the case
// where the switch 'can edit' is enabled for a *reshared folder*; if the same
// behaviour was applied than for owned folder, and the user did not have full
@ -357,6 +359,14 @@ public class EditShareFragment extends Fragment {
public void onUpdateSharePermissionsFinished(RemoteOperationResult result) {
if (result.isSuccess()) {
refreshUiFromDB(getView());
} else if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND) {
// share or file was deleted from other client before completing the operation
int backStackCount = getFragmentManager().getBackStackEntryCount();
for (int i=0; i<backStackCount; i++) {
getFragmentManager().popBackStack();
}
((ShareFragmentListener)getActivity()).
refreshUsersOrGroupsListFromServer();
} else {
refreshUiFromState(getView());
}
@ -469,5 +479,4 @@ public class EditShareFragment extends Fragment {
return (CheckBox) getView().findViewById(R.id.canEditDeleteCheckBox);
}
}

View file

@ -40,7 +40,6 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.ShareActivity;
import com.owncloud.android.ui.adapter.ShareUserListAdapter;
import java.util.ArrayList;
@ -51,7 +50,7 @@ import java.util.ArrayList;
* A simple {@link Fragment} subclass.
*
* Activities that contain this fragment must implement the
* {@link SearchShareesFragment.OnSearchFragmentInteractionListener} interface
* {@link ShareFragmentListener} interface
* to handle interaction events.
*
* Use the {@link SearchShareesFragment#newInstance} factory method to
@ -71,7 +70,7 @@ public class SearchShareesFragment extends Fragment implements ShareUserListAdap
// other members
private ArrayList<OCShare> mShares;
private ShareUserListAdapter mUserGroupsAdapter = null;
private OnSearchFragmentInteractionListener mListener;
private ShareFragmentListener mListener;
/**
@ -198,7 +197,7 @@ public class SearchShareesFragment extends Fragment implements ShareUserListAdap
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnSearchFragmentInteractionListener) activity;
mListener = (ShareFragmentListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
@ -239,20 +238,4 @@ public class SearchShareesFragment extends Fragment implements ShareUserListAdap
mListener.showEditShare(share);
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnSearchFragmentInteractionListener {
void showEditShare(OCShare share);
void unshareWith(OCShare share);
}
}

View file

@ -66,7 +66,7 @@ import java.util.Date;
* A simple {@link Fragment} subclass.
*
* Activities that contain this fragment must implement the
* {@link ShareFileFragment.OnShareFragmentInteractionListener} interface
* {@link ShareFragmentListener} interface
* to handle interaction events.
*
* Use the {@link ShareFileFragment#newInstance} factory method to
@ -91,7 +91,7 @@ public class ShareFileFragment extends Fragment
private Account mAccount;
/** Reference to parent listener */
private OnShareFragmentInteractionListener mListener;
private ShareFragmentListener mListener;
/** List of private shares bound to the file */
private ArrayList<OCShare> mPrivateShares;
@ -454,7 +454,7 @@ public class ShareFileFragment extends Fragment
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnShareFragmentInteractionListener) activity;
mListener = (ShareFragmentListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnShareFragmentInteractionListener");
@ -739,21 +739,4 @@ public class ShareFileFragment extends Fragment
listView.requestLayout();
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnShareFragmentInteractionListener {
void showSearchUsersAndGroups();
void showEditShare(OCShare share);
void refreshUsersOrGroupsListFromServer();
void unshareWith(OCShare share);
}
}

View file

@ -0,0 +1,41 @@
/**
* ownCloud Android client application
*
* @author masensio
* @author David A. Velasco
* Copyright (C) 2015 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,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.owncloud.android.ui.fragment;
import com.owncloud.android.lib.resources.shares.OCShare;
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in fragments handling {@link OCShare}s
* to be communicated to the parent activity and potentially other fragments
* contained in that activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface ShareFragmentListener {
void showSearchUsersAndGroups();
void showEditShare(OCShare share);
void refreshUsersOrGroupsListFromServer();
void unshareWith(OCShare share);
}