summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2022-07-25 15:05:33 +0200
committerAlbin <albin@mullvad.net>2022-07-25 15:07:51 +0200
commit7896855db010377fbdfc64900ca7d7a790a87523 (patch)
tree84df54acfbef352cb9267c545b32e49ba8e65132 /android/app/src
parent81414c799c5ea89feed0ea92552285ba3e2757d6 (diff)
downloadmullvadvpn-7896855db010377fbdfc64900ca7d7a790a87523.tar.xz
mullvadvpn-7896855db010377fbdfc64900ca7d7a790a87523.zip
Add copy icon/button to account view
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt7
-rw-r--r--android/app/src/main/res/drawable/icon_copy.xml8
-rw-r--r--android/app/src/main/res/layout/account.xml3
-rw-r--r--android/app/src/main/res/layout/information_view.xml9
-rw-r--r--android/app/src/main/res/values/strings.xml1
5 files changed, 27 insertions, 1 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt
index a3f43fbac2..e19edc9d34 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/CopyableInformationView.kt
@@ -4,6 +4,8 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.util.AttributeSet
+import android.view.View
+import android.widget.ImageButton
import android.widget.Toast
import net.mullvad.mullvadvpn.R
@@ -38,6 +40,11 @@ class CopyableInformationView : InformationView {
init {
onClick = { copyToClipboard() }
+
+ findViewById<ImageButton>(R.id.copy_button).apply {
+ visibility = View.VISIBLE
+ setOnClickListener { copyToClipboard() }
+ }
}
private fun loadAttributes(attributes: AttributeSet) {
diff --git a/android/app/src/main/res/drawable/icon_copy.xml b/android/app/src/main/res/drawable/icon_copy.xml
new file mode 100644
index 0000000000..4a919a00b8
--- /dev/null
+++ b/android/app/src/main/res/drawable/icon_copy.xml
@@ -0,0 +1,8 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path android:pathData="M15.789,2.737L5.684,2.737A1.689,1.689 0,0 0,4 4.421v11.79a0.749,0.749 0,0 0,0.829 0.736,0.812 0.812,0 0,0 0.855,-0.736L5.684,4.421h10.105a0.9,0.9 0,0 0,0.832 -0.825,0.91 0.91,0 0,0 -0.832,-0.859zM18.315,6.105L9.053,6.105a1.689,1.689 0,0 0,-1.685 1.685v11.789a1.689,1.689 0,0 0,1.684 1.684h9.263A1.689,1.689 0,0 0,20 19.579L20,7.79a1.689,1.689 0,0 0,-1.684 -1.685zM18.315,19.579L9.053,19.579L9.053,7.79h9.263z"
+ android:fillColor="@android:color/white" />
+</vector>
diff --git a/android/app/src/main/res/layout/account.xml b/android/app/src/main/res/layout/account.xml
index 7f2e2fb598..225ef71cc0 100644
--- a/android/app/src/main/res/layout/account.xml
+++ b/android/app/src/main/res/layout/account.xml
@@ -57,7 +57,8 @@
mullvad:clipboardLabel="@string/mullvad_account_number"
mullvad:copiedToast="@string/copied_mullvad_account_number"
mullvad:description="@string/account_number"
- mullvad:whenMissing="hide" />
+ mullvad:whenMissing="hide"
+ android:descendantFocusability="afterDescendants" />
<net.mullvad.mullvadvpn.ui.widget.InformationView android:id="@+id/account_expiry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/android/app/src/main/res/layout/information_view.xml b/android/app/src/main/res/layout/information_view.xml
index 366d204b35..c4c5d5144a 100644
--- a/android/app/src/main/res/layout/information_view.xml
+++ b/android/app/src/main/res/layout/information_view.xml
@@ -31,6 +31,15 @@
android:indeterminateOnly="true"
android:visibility="visible"
android:layout_alignParentStart="true" />
+ <ImageButton android:id="@+id/copy_button"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_alignParentEnd="true"
+ android:background="@drawable/icon_copy"
+ android:visibility="gone"
+ android:clickable="true"
+ android:focusable="true"
+ android:contentDescription="@string/copy_account_number" />
</RelativeLayout>
</LinearLayout>
</merge>
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 8a04ad5bb9..312c20ca6e 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -195,4 +195,5 @@
<string name="failed_to_fetch_devices">Failed to fetch list of devices</string>
<string name="port_removal_notice">This will delete all forwarded ports. Local settings will be
saved.</string>
+ <string name="copy_account_number">Copy account number</string>
</resources>