Copy internal link

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-05-29 16:42:24 +02:00
parent a69d2b7d35
commit 6bc9484db4
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
7 changed files with 99 additions and 3 deletions

View file

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 16 16" width="16" height="16">
<path
d="M7.452 1.62l2.38 2.256-3.57 3.386L8.64 9.52l3.57-3.387 2.38 2.257V1.618h-7.14zM2.69 2.746c-.66 0-1.19.504-1.19 1.13v9.028c0 .625.53 1.128 1.19 1.128h9.522c.66 0 1.19-.503 1.19-1.128V9.52l-1.19-1.13v4.515h-9.52v-9.03h4.76l-1.19-1.128H2.69z" />
</svg>

After

Width:  |  Height:  |  Size: 369 B

View file

@ -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())) {

View file

@ -0,0 +1,9 @@
<vector android:height="24dp"
android:viewportHeight="16"
android:viewportWidth="16"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#FF000000"
android:pathData="M7.452,1.62l2.38,2.256 -3.57,3.386L8.64,9.52l3.57,-3.387 2.38,2.257V1.618h-7.14zM2.69,2.746c-0.66,0 -1.19,0.504 -1.19,1.13v9.028c0,0.625 0.53,1.128 1.19,1.128h9.522c0.66,0 1.19,-0.503 1.19,-1.128V9.52l-1.19,-1.13v4.515h-9.52v-9.03h4.76l-1.19,-1.128H2.69z" />
</vector>

View file

@ -153,13 +153,14 @@
android:src="@drawable/ic_dots_vertical"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/shareUsersList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="@drawable/divider"
android:dividerHeight="1dp"/>
android:dividerHeight="1dp" />
<TextView
android:id="@+id/shareNoUsers"
@ -169,7 +170,56 @@
android:paddingTop="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding"
android:text="@string/share_no_users"
android:textSize="16sp"/>
android:textSize="16sp" />
<LinearLayout
android:id="@+id/copy_internal_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_margin"
android:orientation="horizontal">
<ImageView
android:id="@+id/copy_internal_link_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/share"
android:src="@drawable/ic_external"
android:paddingTop="@dimen/copy_internal_link_padding"
android:paddingRight="@dimen/copy_internal_link_padding"
android:paddingEnd="@dimen/copy_internal_link_padding"
android:paddingBottom="@dimen/copy_internal_link_padding"
android:paddingLeft="@dimen/copy_internal_link_padding"
android:paddingStart="@dimen/copy_internal_link_padding"
android:layout_marginBottom="@dimen/standard_half_margin"
android:layout_marginEnd="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginTop="@dimen/standard_half_margin"
android:background="@drawable/round_bgnd" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/copyInternalLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:text="@string/copy_internal_link" />
<TextView
android:id="@+id/copyInternalLinkSubline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/copy_internal_link_subline" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -40,6 +40,7 @@
<color name="standard_grey">#757575</color>
<color name="elementFallbackColor">#555555</color>
<color name="grey_200">#EEEEEE</color>
<color name="grey_db">#dbdbdb</color>
<!-- standard material color definitions -->

View file

@ -141,4 +141,5 @@
<dimen name="permission_dialog_text_size">18sp</dimen>
<dimen name="button_corner_radius">24dp</dimen>
<integer name="media_grid_width">4</integer>
<dimen name="copy_internal_link_padding">10dp</dimen>
</resources>

View file

@ -868,4 +868,7 @@
<string name="retrieving_file">Retrieving file…</string>
<string name="associated_account_not_found">Associated account not found!</string>
<string name="error_retrieving_file">Error retrieving file</string>
<string name="could_not_retrieve_url">Could not retrieve url</string>
<string name="copy_internal_link">Copy internal link</string>
<string name="copy_internal_link_subline">Only works for users with access to this folder</string>
</resources>