Created
January 29, 2013 12:14
-
-
Save stevedonovan/4663812 to your computer and use it in GitHub Desktop.
Simple Android Activity in MoonScript using AndroLua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'android' | |
require 'android.intents' -- needed for creating an email.. | |
feedback_email = 'appfeedback@yourappsite.com' | |
_M = android.new! | |
with _M | |
-- compare to this more standard implementation: | |
--http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-forms/ | |
.create = (me) -> | |
me.title = me\textView text:'Enter feedback details to developer:',size:'25sp' | |
me.name = me\editText text:'Your Name',inputType:'textPersonName' | |
me.email = me\editText text:'Your Email',inputType:'textEmailAddress' | |
me.kind = me\spinner | |
prompt:'Enter feedback type', | |
options:{'Praise','Gripe','Suggestion','Bug'} | |
me.details = me\editText | |
text:'Feedback Details...' | |
inputType:'textMultiLine',minLines:5,gravity:'top|left' | |
me.emailResponse = me\checkBox 'Would you like an email response?' | |
get_text = (v) -> v\getText!\toString! | |
send_feedback = -> | |
name = get_text me.name | |
email = get_text me.email | |
details = get_text me.details | |
gripe = me.kind\getSelectedItem! | |
if name=='' or email=='' | |
me\alert 'Problem!','ok','Must fill in name and email address!' | |
return | |
body = 'To: The Gripe Department\n\n'..details..'\n\n'..name..'('..email..')' | |
if me.emailResponse\isChecked! | |
body = body .. '\nRequires a response' | |
me\send_message 'Application Feedback ('..gripe..')',body,feedback_email | |
me\vbox{ | |
scrollable:true, | |
me.title, | |
me.name, | |
me.email, | |
me.kind, | |
me.details, | |
me.emailResponse, | |
me\button 'Send Feedback',send_feedback, | |
me\button 'Test Values',-> | |
me.name\setText 'Patsy Stone' | |
me.email\setText 'patsy@fabulous.org' | |
me.details\setText 'too slow darling!' | |
} | |
return _M | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment