diff --git a/android-samples/Hello/.gitignore b/android-samples/Hello/.gitignore new file mode 100644 index 00000000..e45ebb9f --- /dev/null +++ b/android-samples/Hello/.gitignore @@ -0,0 +1,13 @@ +.repl_history +build +tags +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/android-samples/Hello/Rakefile b/android-samples/Hello/Rakefile new file mode 100644 index 00000000..c04d676e --- /dev/null +++ b/android-samples/Hello/Rakefile @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +$:.unshift("../../lib") +require 'motion/project/template/android' + +Motion::Project::App.setup do |app| + # Use `rake config' to see complete project settings. + app.name = 'Hello' + app.api_version = '18' + app.sdk_path = File.expand_path('~/src/android-sdk-macosx') + app.ndk_path = File.expand_path('~/src/android-ndk-r9d') +end diff --git a/android-samples/Hello/app/main_activity.rb b/android-samples/Hello/app/main_activity.rb new file mode 100644 index 00000000..d8629ad4 --- /dev/null +++ b/android-samples/Hello/app/main_activity.rb @@ -0,0 +1,25 @@ +class MainActivity < Android::App::Activity + def onCreate(savedInstanceState) + super + + @text = Android::Widget::TextView.new(self) + @text.text = 'Hello RubyMotion!' + @text.textColor = Android::Graphics::Color::WHITE + @text.textSize = 40.0 + self.contentView = @text + end + + def dispatchTouchEvent(event) + @counter ||= 0 + case event.getAction + when Android::View::MotionEvent::ACTION_UP + @counter += 1 + @text.text = "Touched #{@counter} times!" + @text.backgroundColor = Android::Graphics::Color::BLACK + when Android::View::MotionEvent::ACTION_MOVE + @text.text = "ZOMG!" + @text.backgroundColor = Android::Graphics::Color.rgb(rand(255), rand(255), rand(255)) + end + true + end +end