Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Android Activity in MoonScript using AndroLua
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
You can’t perform that action at this time.