+ return view;
+ }
+
+ /**
+ * 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.
+ */
+ private void initPasswordListener(View shareView) {
+ mOnPasswordInteractionListener = new OnPasswordInteractionListener();
+ Switch shareViaLinkPasswordSwitch = (Switch) shareView.findViewById(R.id.shareViaLinkPasswordSwitch);
+ shareViaLinkPasswordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener);
+ TextView shareViaLinkPasswordLabel = (TextView) shareView.findViewById(R.id.shareViaLinkPasswordLabel);
+ shareViaLinkPasswordLabel.setOnClickListener(mOnPasswordInteractionListener);
+ TextView shareViaLinkPasswordValue = (TextView) shareView.findViewById(R.id.shareViaLinkPasswordValue);
+ shareViaLinkPasswordValue.setOnClickListener(mOnPasswordInteractionListener);
+ }
+
+
+ /**
+ * Listener for user actions that start any update on a password for the public link.
+ */
+ private class OnPasswordInteractionListener
+ implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (!isResumed()) {
+ // very important, setCheched(...) is called automatically during
+ // Fragment recreation on device rotations
+ return;
+ }
+ if (isChecked) {
+ ((FileActivity) getActivity()).getFileOperationsHelper().
+ requestPasswordForShareViaLink(mFile);
+ } else {
+ ((FileActivity) getActivity()).getFileOperationsHelper().
+ setPasswordToShareViaLink(mFile, ""); // "" clears