FileDetailSharingFragment.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Andy Scherzinger
  5. * Copyright (C) 2018 Andy Scherzinger
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  9. * License as published by the Free Software Foundation; either
  10. * version 3 of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public
  18. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. package com.owncloud.android.ui.fragment;
  21. import android.accounts.Account;
  22. import android.accounts.AccountManager;
  23. import android.app.SearchManager;
  24. import android.content.Context;
  25. import android.content.res.Resources;
  26. import android.graphics.drawable.Drawable;
  27. import android.os.Bundle;
  28. import android.text.TextUtils;
  29. import android.view.LayoutInflater;
  30. import android.view.Menu;
  31. import android.view.MenuItem;
  32. import android.view.View;
  33. import android.view.ViewGroup;
  34. import android.widget.ImageView;
  35. import android.widget.LinearLayout;
  36. import android.widget.PopupMenu;
  37. import android.widget.TextView;
  38. import com.google.android.material.snackbar.Snackbar;
  39. import com.nextcloud.client.account.UserAccountManager;
  40. import com.nextcloud.client.di.Injectable;
  41. import com.owncloud.android.R;
  42. import com.owncloud.android.authentication.AccountUtils;
  43. import com.owncloud.android.datamodel.FileDataStorageManager;
  44. import com.owncloud.android.datamodel.OCFile;
  45. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  46. import com.owncloud.android.lib.resources.shares.OCShare;
  47. import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder;
  48. import com.owncloud.android.lib.resources.shares.ShareType;
  49. import com.owncloud.android.lib.resources.status.OCCapability;
  50. import com.owncloud.android.ui.activity.FileActivity;
  51. import com.owncloud.android.ui.activity.FileDisplayActivity;
  52. import com.owncloud.android.ui.adapter.UserListAdapter;
  53. import com.owncloud.android.ui.decoration.SimpleListItemDividerDecoration;
  54. import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
  55. import com.owncloud.android.ui.dialog.NoteDialogFragment;
  56. import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
  57. import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
  58. import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
  59. import com.owncloud.android.ui.helpers.FileOperationsHelper;
  60. import com.owncloud.android.utils.ClipboardUtil;
  61. import com.owncloud.android.utils.DisplayUtils;
  62. import com.owncloud.android.utils.ThemeUtils;
  63. import java.util.List;
  64. import javax.inject.Inject;
  65. import androidx.annotation.NonNull;
  66. import androidx.annotation.Nullable;
  67. import androidx.appcompat.widget.AppCompatCheckBox;
  68. import androidx.appcompat.widget.SearchView;
  69. import androidx.fragment.app.Fragment;
  70. import androidx.recyclerview.widget.LinearLayoutManager;
  71. import androidx.recyclerview.widget.RecyclerView;
  72. import butterknife.BindView;
  73. import butterknife.ButterKnife;
  74. import butterknife.OnClick;
  75. import butterknife.Unbinder;
  76. public class FileDetailSharingFragment extends Fragment implements UserListAdapter.ShareeListAdapterListener,
  77. DisplayUtils.AvatarGenerationListener, Injectable {
  78. private static final String ARG_FILE = "FILE";
  79. private static final String ARG_ACCOUNT = "ACCOUNT";
  80. // to show share with users/groups info
  81. private List<OCShare> shares;
  82. private OCFile file;
  83. private Account account;
  84. private OCCapability capabilities;
  85. private OCShare publicShare;
  86. private FileOperationsHelper fileOperationsHelper;
  87. private FileDisplayActivity fileDisplayActivity;
  88. private FileDataStorageManager fileDataStorageManager;
  89. private Unbinder unbinder;
  90. @BindView(R.id.searchView)
  91. SearchView searchView;
  92. @BindView(R.id.shareUsersList)
  93. RecyclerView usersList;
  94. @BindView(R.id.shareNoUsers)
  95. TextView noList;
  96. @BindView(R.id.share_by_link)
  97. AppCompatCheckBox shareByLink;
  98. @BindView(R.id.share_link_copy_icon)
  99. ImageView shareLinkCopyIcon;
  100. @BindView(R.id.overflow_menu_share_link)
  101. ImageView overflowMenuShareLink;
  102. @BindView(R.id.share_by_link_allow_editing)
  103. AppCompatCheckBox shareByLinkAllowEditing;
  104. @BindView(R.id.share_by_link_container)
  105. LinearLayout shareByLinkContainer;
  106. @BindView(R.id.shared_with_you_container)
  107. LinearLayout sharedWithYouContainer;
  108. @BindView(R.id.shared_with_you_avatar)
  109. ImageView sharedWithYouAvatar;
  110. @BindView(R.id.shared_with_you_username)
  111. TextView sharedWithYouUsername;
  112. @BindView(R.id.shared_with_you_note)
  113. TextView sharedWithYouNote;
  114. @Inject UserAccountManager accountManager;
  115. public static FileDetailSharingFragment newInstance(OCFile file, Account account) {
  116. FileDetailSharingFragment fragment = new FileDetailSharingFragment();
  117. Bundle args = new Bundle();
  118. args.putParcelable(ARG_FILE, file);
  119. args.putParcelable(ARG_ACCOUNT, account);
  120. fragment.setArguments(args);
  121. return fragment;
  122. }
  123. @Override
  124. public void onCreate(@Nullable Bundle savedInstanceState) {
  125. super.onCreate(savedInstanceState);
  126. if (savedInstanceState != null) {
  127. file = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
  128. account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
  129. } else {
  130. Bundle arguments = getArguments();
  131. if (arguments != null) {
  132. file = getArguments().getParcelable(ARG_FILE);
  133. account = getArguments().getParcelable(ARG_ACCOUNT);
  134. }
  135. }
  136. if (file == null) {
  137. throw new IllegalArgumentException("File may not be null");
  138. }
  139. if (account == null) {
  140. throw new IllegalArgumentException("Account may not be null");
  141. }
  142. fileDisplayActivity = (FileDisplayActivity) getActivity();
  143. if (fileDisplayActivity == null) {
  144. throw new IllegalArgumentException("FileActivity may not be null");
  145. }
  146. fileOperationsHelper = fileDisplayActivity.getFileOperationsHelper();
  147. fileDataStorageManager = fileDisplayActivity.getStorageManager();
  148. }
  149. @Override
  150. public void onActivityCreated(Bundle savedInstanceState) {
  151. super.onActivityCreated(savedInstanceState);
  152. refreshCapabilitiesFromDB();
  153. refreshPublicShareFromDB();
  154. }
  155. @Override
  156. public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  157. View view = inflater.inflate(R.layout.file_details_sharing_fragment, container, false);
  158. unbinder = ButterKnife.bind(this, view);
  159. if (fileDataStorageManager == null) {
  160. fileDataStorageManager = new FileDataStorageManager(account, fileDisplayActivity.getContentResolver());
  161. }
  162. setupView();
  163. return view;
  164. }
  165. @Override
  166. public void onDestroy() {
  167. super.onDestroy();
  168. unbinder.unbind();
  169. }
  170. @Override
  171. public void onAttach(Context context) {
  172. super.onAttach(context);
  173. if (!(getActivity() instanceof FileActivity)) {
  174. throw new IllegalArgumentException("Calling activity must be of type FileActivity");
  175. }
  176. }
  177. private void setupView() {
  178. setShareWithYou();
  179. if (file.canReshare()) {
  180. setShareByLinkInfo(file.isSharedViaLink());
  181. setShareWithUserInfo();
  182. FileDetailSharingFragmentHelper.setupSearchView(
  183. (SearchManager) fileDisplayActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
  184. fileDisplayActivity.getComponentName());
  185. ThemeUtils.themeSearchView(getContext(), searchView, false);
  186. } else {
  187. searchView.setVisibility(View.GONE);
  188. shareByLinkContainer.setVisibility(View.GONE);
  189. noList.setText(R.string.reshare_not_allowed);
  190. }
  191. }
  192. /**
  193. * Updates Share by link UI
  194. *
  195. * @param isShareByLink flag is share by link is enable
  196. */
  197. public void setShareByLinkInfo(boolean isShareByLink) {
  198. shareByLink.setChecked(isShareByLink);
  199. if (isShareByLink) {
  200. shareLinkCopyIcon.setVisibility(View.VISIBLE);
  201. } else {
  202. shareLinkCopyIcon.setVisibility(View.INVISIBLE);
  203. }
  204. int accentColor = ThemeUtils.primaryAccentColor(getContext());
  205. ThemeUtils.tintCheckbox(shareByLink, accentColor);
  206. ThemeUtils.tintCheckbox(shareByLinkAllowEditing, accentColor);
  207. setLinkDetailVisible(isShareByLink);
  208. }
  209. private void setLinkDetailVisible(boolean visible) {
  210. if (visible) {
  211. shareByLinkAllowEditing.setVisibility(View.VISIBLE);
  212. overflowMenuShareLink.setVisibility(View.VISIBLE);
  213. } else {
  214. shareByLinkAllowEditing.setVisibility(View.INVISIBLE);
  215. overflowMenuShareLink.setVisibility(View.INVISIBLE);
  216. }
  217. }
  218. /**
  219. * Update Share With data
  220. */
  221. public void setShareWithUserInfo() {
  222. // Get Users and Groups
  223. shares = fileDataStorageManager.getSharesWithForAFile(file.getRemotePath(), account.name);
  224. // Update list of users/groups
  225. updateListOfUserGroups();
  226. }
  227. private void setShareWithYou() {
  228. if (accountManager.accountOwnsFile(file, account)) {
  229. sharedWithYouContainer.setVisibility(View.GONE);
  230. } else {
  231. sharedWithYouUsername.setText(
  232. String.format(getString(R.string.shared_with_you_by), file.getOwnerDisplayName()));
  233. DisplayUtils.setAvatar(account, file.getOwnerId(), this, getResources().getDimension(
  234. R.dimen.file_list_item_avatar_icon_radius), getResources(), sharedWithYouAvatar,
  235. getContext());
  236. sharedWithYouAvatar.setVisibility(View.VISIBLE);
  237. String note = file.getNote();
  238. if (!TextUtils.isEmpty(note)) {
  239. sharedWithYouNote.setText(file.getNote());
  240. sharedWithYouNote.setVisibility(View.VISIBLE);
  241. } else {
  242. sharedWithYouNote.setVisibility(View.GONE);
  243. }
  244. }
  245. }
  246. private void updateListOfUserGroups() {
  247. // TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
  248. if (shares.size() > 0) {
  249. AccountManager accountManager = AccountManager.get(getContext());
  250. String userId = accountManager.getUserData(account,
  251. com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
  252. usersList.setVisibility(View.VISIBLE);
  253. usersList.setAdapter(new UserListAdapter(fileDisplayActivity.getSupportFragmentManager(),
  254. fileDisplayActivity, shares, account, file, this, userId));
  255. usersList.setLayoutManager(new LinearLayoutManager(getContext()));
  256. usersList.addItemDecoration(new SimpleListItemDividerDecoration(getContext()));
  257. noList.setVisibility(View.GONE);
  258. } else {
  259. usersList.setVisibility(View.GONE);
  260. noList.setVisibility(View.VISIBLE);
  261. }
  262. }
  263. @OnClick(R.id.share_by_link)
  264. public void toggleShareByLink() {
  265. if (shareByLink.isChecked()) {
  266. createShareLink();
  267. } else {
  268. fileOperationsHelper.unshareFileViaLink(file);
  269. }
  270. }
  271. private void createShareLink() {
  272. if (capabilities != null && (capabilities.getFilesSharingPublicPasswordEnforced().isTrue() ||
  273. capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue())) {
  274. // password enforced by server, request to the user before trying to create
  275. requestPasswordForShareViaLink(true,
  276. capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
  277. } else {
  278. // create without password if not enforced by server or we don't know if enforced;
  279. fileOperationsHelper.shareFileViaLink(file, null);
  280. }
  281. }
  282. private void showSendLinkTo() {
  283. if (file.isSharedViaLink()) {
  284. if (TextUtils.isEmpty(file.getPublicLink())) {
  285. fileOperationsHelper.getFileWithLink(file);
  286. } else {
  287. FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file.getPublicLink());
  288. }
  289. }
  290. }
  291. @OnClick({R.id.share_link_copy_icon})
  292. public void copyLinkToClipboard() {
  293. if (file.isSharedViaLink()) {
  294. if (TextUtils.isEmpty(file.getPublicLink())) {
  295. fileOperationsHelper.getFileWithLink(file);
  296. } else {
  297. ClipboardUtil.copyToClipboard(getActivity(), file.getPublicLink());
  298. }
  299. }
  300. }
  301. @OnClick(R.id.share_by_link_allow_editing)
  302. public void toggleShareLinkAllowEditing() {
  303. if (file.isSharedViaLink()) {
  304. fileOperationsHelper.setUploadPermissionsToShare(file, shareByLinkAllowEditing.isChecked());
  305. }
  306. }
  307. @OnClick(R.id.overflow_menu_share_link)
  308. public void showLinkOverflowMenu() {
  309. Context context = getContext();
  310. if (context != null && ThemeUtils.themingEnabled(context)) {
  311. // use grey as fallback for elements where custom theming is not available
  312. context.getTheme().applyStyle(R.style.FallbackThemingTheme, true);
  313. } else {
  314. context = getActivity();
  315. }
  316. PopupMenu popup = new PopupMenu(context, overflowMenuShareLink);
  317. popup.inflate(R.menu.file_detail_sharing_link_menu);
  318. prepareOptionsMenu(popup.getMenu());
  319. popup.setOnMenuItemClickListener(this::optionsItemSelected);
  320. popup.show();
  321. }
  322. private void prepareOptionsMenu(Menu menu) {
  323. Resources res = getResources();
  324. SharingMenuHelper.setupHideFileListingMenuItem(
  325. menu.findItem(R.id.action_hide_file_listing),
  326. file.isFolder(),
  327. shareByLinkAllowEditing.isChecked(),
  328. publicShare.getPermissions()
  329. );
  330. SharingMenuHelper.setupHideFileDownload(menu.findItem(R.id.action_hide_file_download),
  331. publicShare.isHideFileDownload(), capabilities);
  332. SharingMenuHelper.setupPasswordMenuItem(
  333. menu.findItem(R.id.action_password),
  334. publicShare.isPasswordProtected()
  335. );
  336. SharingMenuHelper.setupExpirationDateMenuItem(
  337. menu.findItem(R.id.action_share_expiration_date),
  338. publicShare.getExpirationDate(),
  339. res
  340. );
  341. menu.findItem(R.id.action_share_send_note).setVisible(capabilities.getVersion().isNoteOnShareSupported());
  342. }
  343. private boolean optionsItemSelected(MenuItem item) {
  344. switch (item.getItemId()) {
  345. case R.id.action_hide_file_listing: {
  346. item.setChecked(!item.isChecked());
  347. if (capabilities.getFilesFileDrop().isTrue()) {
  348. setHideFileListingPermissionsToShare(publicShare, item.isChecked());
  349. } else {
  350. // not supported in ownCloud
  351. showNotSupportedByOcMessage();
  352. }
  353. return true;
  354. }
  355. case R.id.action_hide_file_download:
  356. item.setChecked(!item.isChecked());
  357. setHideFileDownloadPermissionToShare(file, item.isChecked());
  358. return true;
  359. case R.id.action_password: {
  360. requestPasswordForShareViaLink(false,
  361. capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
  362. return true;
  363. }
  364. case R.id.action_share_expiration_date: {
  365. ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment.newInstance(file, -1);
  366. dialog.show(
  367. fileDisplayActivity.getSupportFragmentManager(),
  368. ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
  369. );
  370. return true;
  371. }
  372. case R.id.action_share_send_link: {
  373. if(shareByLink.isChecked() && file.isSharedViaLink() && !TextUtils.isEmpty(file.getPublicLink())) {
  374. FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file.getPublicLink());
  375. } else {
  376. showSendLinkTo();
  377. }
  378. return true;
  379. }
  380. case R.id.action_share_send_note:
  381. NoteDialogFragment dialog = NoteDialogFragment.newInstance(publicShare);
  382. dialog.show(fileDisplayActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
  383. return true;
  384. default:
  385. return super.onOptionsItemSelected(item);
  386. }
  387. }
  388. @Override
  389. public void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing) {
  390. fileOperationsHelper.setHideFileListingPermissionsToShare(share, hideFileListing);
  391. }
  392. @Override
  393. public void setHideFileDownloadPermissionToShare(OCFile file, boolean hideFileDownload) {
  394. fileOperationsHelper.setHideFileDownloadPermissionsToShare(file, hideFileDownload);
  395. }
  396. @Override
  397. public void showNotSupportedByOcMessage() {
  398. if (getView() != null) {
  399. Snackbar.make(getView(), R.string.files_drop_not_supported, Snackbar.LENGTH_LONG)
  400. .setAction(R.string.learn_more, v ->
  401. DisplayUtils.startLinkIntent(requireActivity(), R.string.url_server_install))
  402. .show();
  403. }
  404. }
  405. /**
  406. * Updates the UI after the result of an update operation on the edited {@link OCFile}.
  407. *
  408. * @param result {@link RemoteOperationResult} of an update on the edited {@link OCFile} sharing information.
  409. * @param file the edited {@link OCFile}
  410. */
  411. public void onUpdateShareInformation(RemoteOperationResult result, OCFile file) {
  412. this.file = file;
  413. if (result.isSuccess()) {
  414. refreshUiFromDB();
  415. } else {
  416. setupView();
  417. }
  418. }
  419. /**
  420. * Get {@link OCShare} instance from DB and updates the UI.
  421. */
  422. private void refreshUiFromDB() {
  423. if (publicShare != null) {
  424. // Get edited shared by link
  425. publicShare = fileDataStorageManager.getShareById(publicShare.getId());
  426. }
  427. // Updates UI with new state
  428. setupView();
  429. }
  430. @Override
  431. public void unshareWith(OCShare share) {
  432. fileOperationsHelper.unshareFileWithUserOrGroup(file, share.getShareType(), share.getShareWith());
  433. }
  434. @Override
  435. public int updatePermissionsToShare(OCShare share, boolean canReshare, boolean canEdit, boolean canEditCreate,
  436. boolean canEditChange, boolean canEditDelete) {
  437. SharePermissionsBuilder spb = new SharePermissionsBuilder();
  438. spb.setSharePermission(canReshare);
  439. if (file.isFolder()) {
  440. spb.setUpdatePermission(canEditChange)
  441. .setCreatePermission(canEditCreate)
  442. .setDeletePermission(canEditDelete);
  443. } else {
  444. spb.setUpdatePermission(canEdit);
  445. }
  446. int permissions = spb.build();
  447. fileOperationsHelper.setPermissionsToShare(share, permissions);
  448. return permissions;
  449. }
  450. @Override
  451. public void updateNoteToShare(OCShare share, String note) {
  452. fileOperationsHelper.updateNoteToShare(share, note);
  453. }
  454. /**
  455. * Starts a dialog that requests a password to the user to protect a share link.
  456. *
  457. * @param createShare When 'true', the request for password will be followed by the creation of a new public
  458. * link; when 'false', a public share is assumed to exist, and the password is bound to it.
  459. * @param askForPassword if true, password is optional
  460. */
  461. public void requestPasswordForShareViaLink(boolean createShare, boolean askForPassword) {
  462. SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(file,
  463. createShare,
  464. askForPassword);
  465. dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
  466. }
  467. @Override
  468. public void requestPasswordForShare(OCShare share) {
  469. SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(share);
  470. dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
  471. }
  472. /**
  473. * Get known server capabilities from DB
  474. */
  475. public void refreshCapabilitiesFromDB() {
  476. capabilities = fileDataStorageManager.getCapability(account.name);
  477. }
  478. /**
  479. * Get public link from the DB to fill in the "Share link" section in the UI.
  480. *
  481. * Takes into account server capabilities before reading database.
  482. */
  483. public void refreshPublicShareFromDB() {
  484. if (FileDetailSharingFragmentHelper.isPublicShareDisabled(capabilities) || !file.canReshare()) {
  485. shareByLinkContainer.setVisibility(View.GONE);
  486. } else {
  487. // Get public share
  488. publicShare = fileDataStorageManager.getFirstShareByPathAndType(file.getRemotePath(),
  489. ShareType.PUBLIC_LINK, "");
  490. // Update public share section
  491. updatePublicShareSection();
  492. }
  493. }
  494. /**
  495. * Updates in the UI the section about public share with the information
  496. * in the current public share bound to, if any.
  497. */
  498. private void updatePublicShareSection() {
  499. if (publicShare != null && ShareType.PUBLIC_LINK.equals(publicShare.getShareType())) {
  500. shareByLink.setChecked(true);
  501. if (publicShare.getPermissions() > OCShare.READ_PERMISSION_FLAG) {
  502. shareByLinkAllowEditing.setChecked(true);
  503. } else {
  504. shareByLinkAllowEditing.setChecked(false);
  505. }
  506. setShareByLinkInfo(true);
  507. } else {
  508. setShareByLinkInfo(false);
  509. }
  510. }
  511. @Override
  512. public void onSaveInstanceState(@NonNull Bundle outState) {
  513. super.onSaveInstanceState(outState);
  514. outState.putParcelable(FileActivity.EXTRA_FILE, file);
  515. outState.putParcelable(FileActivity.EXTRA_ACCOUNT, account);
  516. }
  517. @Override
  518. public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
  519. sharedWithYouAvatar.setImageDrawable(avatarDrawable);
  520. }
  521. @Override
  522. public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
  523. return false;
  524. }
  525. }