From 6bc9484db45c2cb96456fa439b0499fa7630f1bb Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 29 May 2019 16:42:24 +0200 Subject: [PATCH] Copy internal link Signed-off-by: tobiasKaminsky --- drawable_resources/external.svg | 4 ++ .../fragment/FileDetailSharingFragment.java | 30 ++++++++++- src/main/res/drawable/ic_external.xml | 9 ++++ .../layout/file_details_sharing_fragment.xml | 54 ++++++++++++++++++- src/main/res/values/colors.xml | 1 + src/main/res/values/dims.xml | 1 + src/main/res/values/strings.xml | 3 ++ 7 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 drawable_resources/external.svg create mode 100644 src/main/res/drawable/ic_external.xml diff --git a/drawable_resources/external.svg b/drawable_resources/external.svg new file mode 100644 index 0000000000..59d4f4d1cf --- /dev/null +++ b/drawable_resources/external.svg @@ -0,0 +1,4 @@ + + + diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java index dbc5705b8a..633e643737 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java @@ -25,6 +25,7 @@ import android.accounts.AccountManager; import android.app.SearchManager; import android.content.Context; import android.content.res.Resources; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.TextUtils; @@ -42,9 +43,9 @@ import com.google.android.material.snackbar.Snackbar; import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.client.di.Injectable; import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder; @@ -136,6 +137,9 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt @BindView(R.id.shared_with_you_note) TextView sharedWithYouNote; + @BindView(R.id.copy_internal_link_icon) + ImageView internalLinkIcon; + @Inject UserAccountManager accountManager; public static FileDetailSharingFragment newInstance(OCFile file, Account account) { @@ -200,6 +204,14 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt setupView(); + // todo extract + internalLinkIcon.getBackground().setColorFilter(getResources().getColor(R.color.grey_db), + PorterDuff.Mode.SRC_IN); + internalLinkIcon.getDrawable().mutate().setColorFilter(getResources().getColor(R.color.black), + PorterDuff.Mode.SRC_IN); + + + return view; } @@ -325,6 +337,22 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt } } + @OnClick(R.id.copy_internal_container) + public void copyInternalLink() { + OwnCloudAccount account = accountManager.getCurrentOwnCloudAccount(); + + if (account == null) { + DisplayUtils.showSnackMessage(getView(), getString(R.string.could_not_retrieve_url)); + return; + } + + FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, createInternalLink(account, file)); + } + + private String createInternalLink(OwnCloudAccount account, OCFile file) { + return account.getBaseUri() + "/index.php/f/" + file.getLocalId(); + } + private void createShareLink() { if (capabilities != null && (capabilities.getFilesSharingPublicPasswordEnforced().isTrue() || capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue())) { diff --git a/src/main/res/drawable/ic_external.xml b/src/main/res/drawable/ic_external.xml new file mode 100644 index 0000000000..15e30be7c1 --- /dev/null +++ b/src/main/res/drawable/ic_external.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/layout/file_details_sharing_fragment.xml b/src/main/res/layout/file_details_sharing_fragment.xml index a69ef1e0d6..5e63b0790d 100644 --- a/src/main/res/layout/file_details_sharing_fragment.xml +++ b/src/main/res/layout/file_details_sharing_fragment.xml @@ -153,13 +153,14 @@ android:src="@drawable/ic_dots_vertical"/> + + android:dividerHeight="1dp" /> + android:textSize="16sp" /> + + + + + + + + + + + + + diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index b8397d494f..0ec8772b38 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -40,6 +40,7 @@ #757575 #555555 #EEEEEE + #dbdbdb diff --git a/src/main/res/values/dims.xml b/src/main/res/values/dims.xml index f298bc512c..0806007d95 100644 --- a/src/main/res/values/dims.xml +++ b/src/main/res/values/dims.xml @@ -141,4 +141,5 @@ 18sp 24dp 4 + 10dp diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a4d0eaab34..f4356a0cae 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -868,4 +868,7 @@ Retrieving fileā€¦ Associated account not found! Error retrieving file + Could not retrieve url + Copy internal link + Only works for users with access to this folder