|
@@ -82,7 +82,7 @@ public class ShareFileFragment extends Fragment
|
|
|
private static final String TAG = ShareFileFragment.class.getSimpleName();
|
|
|
|
|
|
/**
|
|
|
- * The fragment initialization parameters
|
|
|
+ * The fragment initialization parameters.
|
|
|
*/
|
|
|
private static final String ARG_FILE = "FILE";
|
|
|
private static final String ARG_ACCOUNT = "ACCOUNT";
|
|
@@ -91,66 +91,65 @@ public class ShareFileFragment extends Fragment
|
|
|
// private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
|
|
|
|
|
|
/**
|
|
|
- * File to share, received as a parameter in construction time
|
|
|
+ * File to share, received as a parameter in construction time.
|
|
|
*/
|
|
|
private OCFile mFile;
|
|
|
|
|
|
/**
|
|
|
- * OC account holding the file to share, received as a parameter in construction time
|
|
|
+ * OC account holding the file to share, received as a parameter in construction time.
|
|
|
*/
|
|
|
private Account mAccount;
|
|
|
|
|
|
/**
|
|
|
- * Reference to parent listener
|
|
|
+ * Reference to parent listener.
|
|
|
*/
|
|
|
private ShareFragmentListener mListener;
|
|
|
|
|
|
/**
|
|
|
- * List of private shares bound to the file
|
|
|
+ * List of private shares bound to the file.
|
|
|
*/
|
|
|
private ArrayList<OCShare> mPrivateShares;
|
|
|
|
|
|
/**
|
|
|
- * Capabilities of the server
|
|
|
+ * Capabilities of the server.
|
|
|
*/
|
|
|
private OCCapability mCapabilities;
|
|
|
|
|
|
/**
|
|
|
- * Adapter to show private shares
|
|
|
+ * Adapter to show private shares.
|
|
|
*/
|
|
|
private ShareUserListAdapter mUserGroupsAdapter = null;
|
|
|
|
|
|
/**
|
|
|
- * Public share bound to the file
|
|
|
+ * Public share bound to the file.
|
|
|
*/
|
|
|
private OCShare mPublicShare;
|
|
|
|
|
|
/**
|
|
|
- * Listener for changes on switch to share / unshare publicly
|
|
|
+ * Listener for changes on switch to share / unshare publicly.
|
|
|
*/
|
|
|
private CompoundButton.OnCheckedChangeListener mOnShareViaLinkSwitchCheckedChangeListener;
|
|
|
|
|
|
/**
|
|
|
- * Listener for user actions to set, update or clear password on public link
|
|
|
+ * Listener for user actions to set, update or clear password on public link.
|
|
|
*/
|
|
|
private OnPasswordInteractionListener mOnPasswordInteractionListener = null;
|
|
|
|
|
|
/**
|
|
|
- * Listener for user actions to set, update or clear expiration date on public link
|
|
|
+ * Listener for user actions to set, update or clear expiration date on public link.
|
|
|
*/
|
|
|
private OnExpirationDateInteractionListener mOnExpirationDateInteractionListener = null;
|
|
|
|
|
|
/**
|
|
|
- * Listener for user actions to set or unset edit permission on public link
|
|
|
+ * Listener for user actions to set or unset edit permission on public link.
|
|
|
*/
|
|
|
private OnEditPermissionInteractionListener mOnEditPermissionInteractionListener = null;
|
|
|
|
|
|
/**
|
|
|
- * Listener for user actions to set or unset hide file listing permission on public link
|
|
|
+ * Listener for user actions to set or unset hide file listing permission on public link.
|
|
|
*/
|
|
|
private OnHideFileListingPermissionInteractionListener mOnHideFileListingPermissionInteractionListener = null;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Public factory method to create new ShareFileFragment instances.
|
|
|
*
|
|
@@ -168,14 +167,11 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Required empty public constructor
|
|
|
+ * Required empty public constructor.
|
|
|
*/
|
|
|
public ShareFileFragment() {
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * {@inheritDoc}
|
|
|
- */
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
@@ -186,10 +182,6 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * {@inheritDoc}
|
|
|
- */
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
Bundle savedInstanceState) {
|
|
@@ -210,9 +202,11 @@ public class ShareFileFragment extends Fragment
|
|
|
icon.setImageBitmap(thumbnail);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// Name
|
|
|
TextView fileNameHeader = (TextView) view.findViewById(R.id.shareFileName);
|
|
|
fileNameHeader.setText(getResources().getString(R.string.share_file, mFile.getFileName()));
|
|
|
+
|
|
|
// Size
|
|
|
TextView size = (TextView) view.findViewById(R.id.shareFileSize);
|
|
|
if (mFile.isFolder()) {
|
|
@@ -320,7 +314,6 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Binds listener for user actions that start any update on a expiration date
|
|
|
* for the public link to the views receiving the user events.
|
|
@@ -368,8 +361,7 @@ public class ShareFileFragment extends Fragment
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
- ((FileActivity) getActivity()).getFileOperationsHelper().
|
|
|
- setExpirationDateToShareViaLink(mFile, -1);
|
|
|
+ ((FileActivity) getActivity()).getFileOperationsHelper().setExpirationDateToShareViaLink(mFile, -1);
|
|
|
}
|
|
|
|
|
|
// undo the toggle to grant the view will be correct if the dialog is cancelled
|
|
@@ -379,8 +371,8 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Called by R.id.shareViaLinkExpirationLabel or R.id.shareViaLinkExpirationValue
|
|
|
- * to change the current expiration date.
|
|
|
+ * Called by R.id.shareViaLinkExpirationLabel or R.id.shareViaLinkExpirationValue to change the current
|
|
|
+ * expiration date.
|
|
|
*
|
|
|
* @param expirationView Label or value view touched by the user.
|
|
|
*/
|
|
@@ -392,10 +384,7 @@ public class ShareFileFragment extends Fragment
|
|
|
chosenDateInMillis = mPublicShare.getExpirationDate();
|
|
|
}
|
|
|
ExpirationDatePickerDialogFragment dialog =
|
|
|
- ExpirationDatePickerDialogFragment.newInstance(
|
|
|
- mFile,
|
|
|
- chosenDateInMillis
|
|
|
- );
|
|
|
+ ExpirationDatePickerDialogFragment.newInstance(mFile, chosenDateInMillis);
|
|
|
dialog.show(
|
|
|
getActivity().getSupportFragmentManager(),
|
|
|
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
|
|
@@ -404,10 +393,9 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * Binds listener for user actions that start any update on a password for the public link
|
|
|
- * to the views receiving the user events.
|
|
|
+ * Binds listener for user actions that start any update on a password for the public link to the views receiving
|
|
|
+ * the user events.
|
|
|
*
|
|
|
* @param shareView Root view in the fragment.
|
|
|
*/
|
|
@@ -417,11 +405,9 @@ public class ShareFileFragment extends Fragment
|
|
|
((SwitchCompat) shareView.findViewById(R.id.shareViaLinkPasswordSwitch)).
|
|
|
setOnCheckedChangeListener(mOnPasswordInteractionListener);
|
|
|
|
|
|
- shareView.findViewById(R.id.shareViaLinkPasswordLabel).
|
|
|
- setOnClickListener(mOnPasswordInteractionListener);
|
|
|
+ shareView.findViewById(R.id.shareViaLinkPasswordLabel).setOnClickListener(mOnPasswordInteractionListener);
|
|
|
|
|
|
- shareView.findViewById(R.id.shareViaLinkPasswordValue).
|
|
|
- setOnClickListener(mOnPasswordInteractionListener);
|
|
|
+ shareView.findViewById(R.id.shareViaLinkPasswordValue).setOnClickListener(mOnPasswordInteractionListener);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -494,7 +480,7 @@ public class ShareFileFragment extends Fragment
|
|
|
private void initHideFileListingListener(View shareView) {
|
|
|
mOnHideFileListingPermissionInteractionListener = new OnHideFileListingPermissionInteractionListener();
|
|
|
|
|
|
- ((SwitchCompat) shareView.findViewById(R.id.shareViaLinkHideListPermissionSwitch)).
|
|
|
+ ((SwitchCompat) shareView.findViewById(R.id.shareViaLinkFileListingPermissionSwitch)).
|
|
|
setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
|
|
|
}
|
|
|
|
|
@@ -517,19 +503,13 @@ public class ShareFileFragment extends Fragment
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- ((FileActivity) getActivity()).getFileOperationsHelper().
|
|
|
- setUploadPermissionsToShare(
|
|
|
- mFile,
|
|
|
- isChecked
|
|
|
- );
|
|
|
- ;
|
|
|
+ ((FileActivity) getActivity()).getFileOperationsHelper().setUploadPermissionsToShare(mFile, isChecked);
|
|
|
|
|
|
// undo the toggle to grant the view will be correct if the dialog is cancelled
|
|
|
switchView.setOnCheckedChangeListener(null);
|
|
|
switchView.toggle();
|
|
|
switchView.setOnCheckedChangeListener(mOnEditPermissionInteractionListener);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -600,8 +580,7 @@ public class ShareFileFragment extends Fragment
|
|
|
try {
|
|
|
mListener = (ShareFragmentListener) activity;
|
|
|
} catch (ClassCastException e) {
|
|
|
- throw new ClassCastException(activity.toString()
|
|
|
- + " must implement OnShareFragmentInteractionListener");
|
|
|
+ throw new ClassCastException(activity.toString() + " must implement OnShareFragmentInteractionListener");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -619,8 +598,7 @@ public class ShareFileFragment extends Fragment
|
|
|
*/
|
|
|
public void refreshCapabilitiesFromDB() {
|
|
|
if (((FileActivity) mListener).getStorageManager() != null) {
|
|
|
- mCapabilities = ((FileActivity) mListener).getStorageManager().
|
|
|
- getCapability(mAccount.name);
|
|
|
+ mCapabilities = ((FileActivity) mListener).getStorageManager().getCapability(mAccount.name);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -686,7 +664,6 @@ public class ShareFileFragment extends Fragment
|
|
|
mListener.showEditShare(share);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Get public link from the DB to fill in the "Share link" section in the UI.
|
|
|
* <p/>
|
|
@@ -722,8 +699,8 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Updates in the UI the section about public share with the information in the current
|
|
|
- * public share bound to mFile, if any
|
|
|
+ * Updates in the UI the section about public share with the information in the current public share bound to
|
|
|
+ * mFile, if any.
|
|
|
*/
|
|
|
private void updatePublicShareSection() {
|
|
|
if (mPublicShare != null && ShareType.PUBLIC_LINK.equals(mPublicShare.getShareType())) {
|
|
@@ -745,6 +722,7 @@ public class ShareFileFragment extends Fragment
|
|
|
} else {
|
|
|
getEditPermissionSection().setVisibility(View.GONE);
|
|
|
}
|
|
|
+
|
|
|
// GetLink button
|
|
|
AppCompatButton getLinkButton = getGetLinkButton();
|
|
|
getLinkButton.setVisibility(View.VISIBLE);
|
|
@@ -778,10 +756,9 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
getExpirationDateValue().setText(R.string.empty);
|
|
|
}
|
|
|
+
|
|
|
// recover listener
|
|
|
- expirationDateSwitch.setOnCheckedChangeListener(
|
|
|
- mOnExpirationDateInteractionListener
|
|
|
- );
|
|
|
+ expirationDateSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener);
|
|
|
|
|
|
/// update state of password switch and message depending on password protection
|
|
|
SwitchCompat passwordSwitch = getPasswordSwitch();
|
|
@@ -798,10 +775,9 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
getPasswordValue().setVisibility(View.INVISIBLE);
|
|
|
}
|
|
|
+
|
|
|
// recover listener
|
|
|
- passwordSwitch.setOnCheckedChangeListener(
|
|
|
- mOnPasswordInteractionListener
|
|
|
- );
|
|
|
+ passwordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener);
|
|
|
|
|
|
/// update state of the edit permission switch
|
|
|
SwitchCompat editPermissionSwitch = getEditPermissionSwitch();
|
|
@@ -819,10 +795,9 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
getHideFileListingPermissionSection().setVisibility(View.GONE);
|
|
|
}
|
|
|
+
|
|
|
// recover listener
|
|
|
- editPermissionSwitch.setOnCheckedChangeListener(
|
|
|
- mOnEditPermissionInteractionListener
|
|
|
- );
|
|
|
+ editPermissionSwitch.setOnCheckedChangeListener(mOnEditPermissionInteractionListener);
|
|
|
|
|
|
/// update state of the hide file listing permission switch
|
|
|
SwitchCompat hideFileListingPermissionSwitch = getHideFileListingPermissionSwitch();
|
|
@@ -896,11 +871,11 @@ public class ShareFileFragment extends Fragment
|
|
|
}
|
|
|
|
|
|
private SwitchCompat getHideFileListingPermissionSwitch() {
|
|
|
- return (SwitchCompat) getView().findViewById(R.id.shareViaLinkHideListPermissionSwitch);
|
|
|
+ return (SwitchCompat) getView().findViewById(R.id.shareViaLinkFileListingPermissionSwitch);
|
|
|
}
|
|
|
|
|
|
private View getHideFileListingPermissionSection() {
|
|
|
- return getView().findViewById(R.id.shareViaLinkHideListPermissionSection);
|
|
|
+ return getView().findViewById(R.id.shareViaLinkHideFileListingPermissionSection);
|
|
|
}
|
|
|
|
|
|
private AppCompatButton getGetLinkButton() {
|
|
@@ -956,7 +931,8 @@ public class ShareFileFragment extends Fragment
|
|
|
|
|
|
/**
|
|
|
* Hide share features sections that are not enabled
|
|
|
- * @param view
|
|
|
+ *
|
|
|
+ * @param view share file view
|
|
|
*/
|
|
|
private void hideNotEnabledShareSections(View view) {
|
|
|
LinearLayout shareWithUsersSection = (LinearLayout) view.findViewById(R.id.shareWithUsersSection);
|
|
@@ -975,5 +951,4 @@ public class ShareFileFragment extends Fragment
|
|
|
shareWithUsersSection.setVisibility(View.GONE);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|