gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] branch master updated: [wallet] add option to ente


From: gnunet
Subject: [taler-taler-android] branch master updated: [wallet] add option to enter URI manually by long pressing scan button
Date: Fri, 22 May 2020 19:43:56 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

The following commit(s) were added to refs/heads/master by this push:
     new 882c2c5  [wallet] add option to enter URI manually by long pressing 
scan button
882c2c5 is described below

commit 882c2c50c878215c380ee1cfd132030a0b0c80f8
Author: Torsten Grote <address@hidden>
AuthorDate: Fri May 22 14:43:36 2020 -0300

    [wallet] add option to enter URI manually by long pressing scan button
---
 .../src/main/java/net/taler/wallet/MainFragment.kt |  4 ++
 .../main/java/net/taler/wallet/UriInputFragment.kt | 68 ++++++++++++++++++++
 wallet/src/main/res/drawable/ic_content_paste.xml  |  9 +++
 wallet/src/main/res/layout/fragment_uri_input.xml  | 75 ++++++++++++++++++++++
 wallet/src/main/res/navigation/nav_graph.xml       |  9 +++
 wallet/src/main/res/values/strings.xml             |  5 ++
 6 files changed, 170 insertions(+)

diff --git a/wallet/src/main/java/net/taler/wallet/MainFragment.kt 
b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
index 26c5a90..a735987 100644
--- a/wallet/src/main/java/net/taler/wallet/MainFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
@@ -62,6 +62,10 @@ class MainFragment : Fragment() {
         mainFab.setOnClickListener {
             scanQrCode(requireActivity())
         }
+        mainFab.setOnLongClickListener {
+            findNavController().navigate(R.id.action_nav_main_to_nav_uri_input)
+            true
+        }
     }
 
     override fun onStart() {
diff --git a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt 
b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt
new file mode 100644
index 0000000..eaa6d16
--- /dev/null
+++ b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt
@@ -0,0 +1,68 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under 
the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+ * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.wallet
+
+import android.content.ClipboardManager
+import android.content.Intent
+import android.content.Intent.ACTION_VIEW
+import android.net.Uri
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Toast
+import android.widget.Toast.LENGTH_LONG
+import androidx.fragment.app.Fragment
+import kotlinx.android.synthetic.main.fragment_uri_input.*
+
+class UriInputFragment : Fragment() {
+
+    override fun onCreateView(
+        inflater: LayoutInflater,
+        container: ViewGroup?,
+        savedInstanceState: Bundle?
+    ): View? {
+        return inflater.inflate(R.layout.fragment_uri_input, container, false)
+    }
+
+    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+        val clipboard = 
requireContext().getSystemService(ClipboardManager::class.java)!!
+
+        pasteButton.setOnClickListener {
+            val item = clipboard.primaryClip?.getItemAt(0)
+            if (item?.text != null) {
+                uriView.setText(item.text)
+            } else {
+                if (item?.uri != null) {
+                    uriView.setText(item.uri.toString())
+                } else {
+                    Toast.makeText(requireContext(), R.string.paste_invalid, 
LENGTH_LONG).show()
+                }
+            }
+        }
+        okButton.setOnClickListener {
+            if (uriView.text?.startsWith("taler://") == true) {
+                uriLayout.error = null
+                val i = Intent(ACTION_VIEW, Uri.parse(uriView.text.toString()))
+                startActivity(i)
+            } else {
+                uriLayout.error = getString(R.string.uri_invalid)
+            }
+        }
+    }
+
+}
diff --git a/wallet/src/main/res/drawable/ic_content_paste.xml 
b/wallet/src/main/res/drawable/ic_content_paste.xml
new file mode 100644
index 0000000..40235c2
--- /dev/null
+++ b/wallet/src/main/res/drawable/ic_content_paste.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android";
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M19,2h-4.18C14.4,0.84 13.3,0 12,0c-1.3,0 -2.4,0.84 
-2.82,2L5,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 
2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM12,2c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 
-1,-1 0.45,-1 1,-1zM19,20L5,20L5,4h2v3h10L17,4h2v16z" />
+</vector>
diff --git a/wallet/src/main/res/layout/fragment_uri_input.xml 
b/wallet/src/main/res/layout/fragment_uri_input.xml
new file mode 100644
index 0000000..60155e3
--- /dev/null
+++ b/wallet/src/main/res/layout/fragment_uri_input.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  ~ This file is part of GNU Taler
+  ~ (C) 2020 Taler Systems S.A.
+  ~
+  ~ GNU Taler is free software; you can redistribute it and/or modify it under 
the
+  ~ terms of the GNU General Public License as published by the Free Software
+  ~ Foundation; either version 3, or (at your option) any later version.
+  ~
+  ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT 
ANY
+  ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+  ~ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License along 
with
+  ~ GNU Taler; see the file COPYING.  If not, see 
<http://www.gnu.org/licenses/>
+  -->
+
+<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android";
+    xmlns:app="http://schemas.android.com/apk/res-auto";
+    xmlns:tools="http://schemas.android.com/tools";
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <com.google.android.material.textfield.TextInputLayout
+        android:id="@+id/uriLayout"
+        
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_margin="16dp"
+        android:hint="@string/enter_uri"
+        app:boxBackgroundMode="outline"
+        app:endIconMode="clear_text"
+        app:endIconTint="?attr/colorControlNormal"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <com.google.android.material.textfield.TextInputEditText
+            android:id="@+id/uriView"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:inputType="textUri" />
+
+    </com.google.android.material.textfield.TextInputLayout>
+
+    <Button
+        android:id="@+id/pasteButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="16dp"
+        android:layout_marginEnd="16dp"
+        android:layout_weight="1"
+        android:drawableLeft="@drawable/ic_content_paste"
+        android:drawableTint="?attr/colorOnPrimarySurface"
+        android:text="@string/paste"
+        app:layout_constraintEnd_toStartOf="@+id/okButton"
+        app:layout_constraintHorizontal_chainStyle="spread_inside"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/uriLayout"
+        tools:ignore="RtlHardcoded" />
+
+    <Button
+        android:id="@+id/okButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="16dp"
+        android:layout_marginEnd="16dp"
+        android:backgroundTint="@color/green"
+        android:text="@string/ok"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toEndOf="@+id/pasteButton"
+        app:layout_constraintTop_toBottomOf="@+id/uriLayout" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/wallet/src/main/res/navigation/nav_graph.xml 
b/wallet/src/main/res/navigation/nav_graph.xml
index a06abad..d5ce657 100644
--- a/wallet/src/main/res/navigation/nav_graph.xml
+++ b/wallet/src/main/res/navigation/nav_graph.xml
@@ -34,6 +34,9 @@
         <action
             android:id="@+id/action_nav_main_to_nav_transactions"
             app:destination="@id/nav_transactions" />
+        <action
+            android:id="@+id/action_nav_main_to_nav_uri_input"
+            app:destination="@id/nav_uri_input" />
     </fragment>
 
     <fragment
@@ -123,6 +126,12 @@
         android:label="@string/nav_history"
         tools:layout="@layout/fragment_transactions" />
 
+    <fragment
+        android:id="@+id/nav_uri_input"
+        android:name="net.taler.wallet.UriInputFragment"
+        android:label="@string/enter_uri"
+        tools:layout="@layout/fragment_uri_input" />
+
     <fragment
         android:id="@+id/errorFragment"
         android:name="net.taler.wallet.withdraw.ErrorFragment"
diff --git a/wallet/src/main/res/values/strings.xml 
b/wallet/src/main/res/values/strings.xml
index 167ab53..3da30f9 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -45,6 +45,11 @@ GNU Taler is immune against many types of fraud, such as 
phishing of credit card
 
     <string name="button_back">Go Back</string>
     <string name="button_scan_qr_code">Scan Taler QR Code</string>
+    <string name="enter_uri">Enter Taler URI</string>
+    <string name="paste">Paste</string>
+    <string name="paste_invalid">Clipboard contains an invalid data 
type</string>
+    <string name="uri_invalid">Not a valid Taler URI</string>
+    <string name="ok">OK</string>
     <string name="search">Search</string>
 
     <string name="menu_settings">Settings</string>

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]