summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2013-09-04 22:15:37 -0500
committerDavid Barksdale <amatus@amatus.name>2013-09-04 22:15:37 -0500
commite9cf8195c63e25dbefdb6aec5a9b6d912f070a92 (patch)
treef5af06aeff7b12089a6fda9d2141415f9b3ff9ad
parent237be1fc4a9aa5763efb364b8c8441f276c06eef (diff)
Add "Sign in" button with AsyncTask doing the work.
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/clojure/io/cons/carddav_sync/authenticator_activity.clj40
2 files changed, 37 insertions, 4 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c915956..703c511 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5,5 +5,6 @@
<string name="prompt_user">User</string>
<string name="prompt_password">Password</string>
<string name="prompt_url">URL</string>
+ <string name="button_sign_in">Sign in</string>
</resources>
diff --git a/src/clojure/io/cons/carddav_sync/authenticator_activity.clj b/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
index 8956b26..1c8535a 100644
--- a/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
+++ b/src/clojure/io/cons/carddav_sync/authenticator_activity.clj
@@ -1,5 +1,6 @@
(ns io.cons.carddav_sync.authenticator_activity
- (:use [neko.activity :only [defactivity set-content-view!]]
+ (:use io.cons.carddav_sync.log
+ [neko.activity :only [defactivity set-content-view!]]
[neko.resource :only [get-resource]]
[neko.threading :only [on-ui]]
[neko.ui :only [make-ui]]
@@ -10,6 +11,32 @@
:extends android.app.Activity
:exposes-methods {onCreate superOnCreate}))
+(gen-class
+ :name io.cons.carddav_sync.login_task
+ :extends android.os.AsyncTask
+ :prefix "login-")
+
+(defn login-onPreExecute
+ [this]
+ (log-i "onPreExecute"))
+
+(defn login-doInBackground
+ [this args]
+ (let [[user password url] args]
+ (log-i (str "doInBackground " user " " password " " url))))
+
+(declare ^android.widget.EditText user)
+(declare ^android.widget.EditText password)
+(declare ^android.widget.EditText url)
+
+(defn login
+ [_]
+ (let [user (.toString (.getText user))
+ password (.toString (.getText password))
+ url (.toString (.getText url))]
+ (.execute (io.cons.carddav_sync.login_task.)
+ (into-array Object [user password url]))))
+
(defelement :frame-layout
:classname android.widget.FrameLayout
:inherits :view-group)
@@ -25,13 +52,18 @@
(set-content-view! this
(make-ui [:scroll-view {}
[:linear-layout {:orientation :vertical}
- [:edit-text {:hint (get-resource :string :prompt-user)}]
- [:edit-text {:hint (get-resource :string :prompt-password)
+ [:edit-text {:def 'io.cons.carddav_sync.authenticator_activity/user
+ :hint (get-resource :string :prompt-user)}]
+ [:edit-text {:def 'io.cons.carddav_sync.authenticator_activity/password
+ :hint (get-resource :string :prompt-password)
:input-type
(bit-or InputType/TYPE_CLASS_TEXT
InputType/TYPE_TEXT_VARIATION_PASSWORD)}]
- [:edit-text {:hint (get-resource :string :prompt-url)
+ [:edit-text {:def 'io.cons.carddav_sync.authenticator_activity/url
+ :hint (get-resource :string :prompt-url)
:input-type
(bit-or InputType/TYPE_CLASS_TEXT
InputType/TYPE_TEXT_VARIATION_URI)}]
+ [:button {:text (get-resource :string :button-sign-in)
+ :on-click login}]
]]))))