gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant-terminal-android] 02/02: Allow configuration Uri with ba


From: gnunet
Subject: [taler-merchant-terminal-android] 02/02: Allow configuration Uri with basic auth crentials in user info
Date: Mon, 16 Mar 2020 14:19:23 +0100

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

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

commit 17647003ccf9f32011e2580cb73330eac7b5bc2a
Author: Torsten Grote <address@hidden>
AuthorDate: Mon Mar 16 10:18:11 2020 -0300

    Allow configuration Uri with basic auth crentials in user info
    
    When such a Uri is entered and the input field loses focus or the FETCH
    button is clicked, the credentials are filled in and used for the fetch.
---
 .../taler/merchantpos/config/MerchantConfigFragment.kt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git 
a/app/src/main/java/net/taler/merchantpos/config/MerchantConfigFragment.kt 
b/app/src/main/java/net/taler/merchantpos/config/MerchantConfigFragment.kt
index fa9fc4b..aad1c93 100644
--- a/app/src/main/java/net/taler/merchantpos/config/MerchantConfigFragment.kt
+++ b/app/src/main/java/net/taler/merchantpos/config/MerchantConfigFragment.kt
@@ -16,6 +16,7 @@
 
 package net.taler.merchantpos.config
 
+import android.net.Uri
 import android.os.Bundle
 import android.text.method.LinkMovementMethod
 import android.view.LayoutInflater
@@ -54,7 +55,11 @@ class MerchantConfigFragment : Fragment() {
     }
 
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+        configUrlView.editText!!.setOnFocusChangeListener { _, hasFocus ->
+            if (!hasFocus) checkForUrlCredentials()
+        }
         okButton.setOnClickListener {
+            checkForUrlCredentials()
             val inputUrl = configUrlView.editText!!.text
             val url = if (inputUrl.startsWith("http")) {
                 inputUrl.toString()
@@ -112,6 +117,19 @@ class MerchantConfigFragment : Fragment() {
         forgetPasswordButton.visibility = if (config.hasPassword()) VISIBLE 
else GONE
     }
 
+    private fun checkForUrlCredentials() {
+        val text = configUrlView.editText!!.text.toString()
+        Uri.parse(text)?.userInfo?.let { userInfo ->
+            if (userInfo.contains(':')) {
+                val (user, pass) = userInfo.split(':')
+                val strippedUrl = text.replace("${userInfo}@", "")
+                configUrlView.editText!!.setText(strippedUrl)
+                usernameView.editText!!.setText(user)
+                passwordView.editText!!.setText(pass)
+            }
+        }
+    }
+
     /**
      * Processes updated config and returns true, if observer can be removed.
      */

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



reply via email to

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