+ public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
+ }
+ };
+
+ // Set listener for user actions on switch for sharing/unsharing via link
+ initShareViaLinkListener(view);
+
+ // Set listener for user actions on expiration date
+ initExpirationListener(view);
+
+ // Set listener for user actions on password
+ initPasswordListener(view);
+
+ return view;
+ }
+
+
+ /**
+ * Binds listener for user actions to create or delete a public share
+ * to the views receiving the user events.
+ *
+ * @param shareView Root view in the fragment.
+ */
+ private void initShareViaLinkListener(View shareView) {
+ mOnShareViaLinkSwitchCheckedChangeListener = new OnShareViaLinkListener();
+ Switch shareViaLinkSwitch = (Switch) shareView.findViewById(R.id.shareViaLinkSectionSwitch);
+ shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
+ }
+
+ /**
+ * Listener for user actions that create or delete a public share.
+ */
+ private class OnShareViaLinkListener
+ implements CompoundButton.OnCheckedChangeListener {
+
+ /**
+ * Called by R.id.shareViaLinkSectionSwitch to create or delete a public link.
+ *
+ * @param switchView {@link Switch} toggled by the user, R.id.shareViaLinkSectionSwitch
+ * @param isChecked New switch state.
+ */
+ @Override
+ public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
+ if (!isResumed()) {
+ // very important, setCheched(...) is called automatically during
+ // Fragment recreation on device rotations
+ return;
+ }
+ if (isChecked) {
+ if (mCapabilities != null &&
+ mCapabilities.getFilesSharingPublicPasswordEnforced().isTrue()) {
+ // password enforced by server, request to the user before trying to create