Commit 7760bddc authored by Ricki Hirner's avatar Ricki Hirner

Collection info: allow copying URL to clipboard

parent 60527e83
Pipeline #25916219 passed with stages
in 7 minutes and 13 seconds
......@@ -10,9 +10,14 @@ package at.bitfire.davdroid.ui
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v7.app.AlertDialog
import android.widget.Toast
import at.bitfire.davdroid.R
import at.bitfire.davdroid.model.CollectionInfo
import kotlinx.android.synthetic.main.collection_properties.view.*
......@@ -40,6 +45,13 @@ class CollectionInfoFragment : DialogFragment() {
val view = requireActivity().layoutInflater.inflate(R.layout.collection_properties, null)
view.url.text = info.url.toString()
view.url_copy.setOnClickListener {
val clipboard = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val text = ClipData.newPlainText(info.displayName, info.url.toString())
clipboard.primaryClip = text
Toast.makeText(requireActivity(), R.string.copied_to_clipboard, Toast.LENGTH_LONG).show()
}
return AlertDialog.Builder(requireActivity())
.setTitle(info.displayName)
.setView(view)
......
<!--
~ Copyright © Ricki Hirner (bitfire web engineering).
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the GNU Public License v3.0
~ which accompanies this distribution, and is available at
~ http://www.gnu.org/licenses/gpl.html
-->
<vector android:alpha="0.54" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
</vector>
......@@ -8,24 +8,46 @@
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:text="@string/collection_properties_url"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/url"
android:id="@+id/url_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace" />
android:text="@string/collection_properties_url"
android:labelFor="@id/url" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/url"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:textSize="12sp"/>
<ImageButton
android:id="@+id/url_copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="1sp"
android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_content_copy_dark"
android:contentDescription="@string/collection_properties_copy_url" />
</LinearLayout>
</LinearLayout>
......
......@@ -13,10 +13,10 @@
android:checkable="true"
android:title="@string/collection_force_read_only"/>
<item android:id="@+id/delete_collection"
android:title="@string/delete_collection"/>
<item android:id="@+id/properties"
android:title="@string/collection_properties"/>
<item android:id="@+id/delete_collection"
android:title="@string/delete_collection"/>
</menu>
\ No newline at end of file
......@@ -16,6 +16,7 @@
<string name="account_title_address_book">DAVdroid Address book</string>
<string name="address_books_authority" translatable="false">at.bitfire.davdroid.addressbooks</string>
<string name="address_books_authority_title">Address books</string>
<string name="copied_to_clipboard">Copied to clipboard</string>
<string name="help">Help</string>
<string name="manage_accounts">Manage accounts</string>
<string name="please_wait">Please wait …</string>
......@@ -258,7 +259,8 @@
<string name="delete_collection_deleting_collection">Deleting collection</string>
<string name="collection_force_read_only">Force read-only</string>
<string name="collection_properties">Properties</string>
<string name="collection_properties_url">URL:</string>
<string name="collection_properties_url">Address (URL):</string>
<string name="collection_properties_copy_url">Copy URL</string>
<!-- ExceptionInfoFragment -->
<string name="exception">An error has occurred.</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment