From 7e266ac8c6e4c74b40ac104d7ddb048340bce301 Mon Sep 17 00:00:00 2001 From: Darin Wilson Date: Wed, 12 Aug 2015 06:39:57 -0700 Subject: [PATCH] Start converting to version 2 of BNR book --- chapter01/GeoQuiz/.gitignore | 2 ++ chapter01/GeoQuiz/Gemfile | 6 +++--- chapter01/GeoQuiz/Gemfile.lock | 5 +++++ chapter01/GeoQuiz/Rakefile | 7 +++++-- chapter01/GeoQuiz/app/quiz_activity.rb | 13 ++++++++++++- chapter01/GeoQuiz/resources/menu/menu_quiz.xml | 10 ++++++++++ chapter01/GeoQuiz/resources/values/strings.xml | 3 ++- 7 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 chapter01/GeoQuiz/resources/menu/menu_quiz.xml diff --git a/chapter01/GeoQuiz/.gitignore b/chapter01/GeoQuiz/.gitignore index e45ebb9..faf0724 100644 --- a/chapter01/GeoQuiz/.gitignore +++ b/chapter01/GeoQuiz/.gitignore @@ -11,3 +11,5 @@ nbproject .sass-cache .idea .dat*.* +vendor/Gradle + diff --git a/chapter01/GeoQuiz/Gemfile b/chapter01/GeoQuiz/Gemfile index 764be63..92d43ce 100644 --- a/chapter01/GeoQuiz/Gemfile +++ b/chapter01/GeoQuiz/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source "https://rubygems.org" -gem 'rake' -# Add your dependencies here: +gem "rake" +gem "motion-gradle" diff --git a/chapter01/GeoQuiz/Gemfile.lock b/chapter01/GeoQuiz/Gemfile.lock index c3124de..cf2057f 100644 --- a/chapter01/GeoQuiz/Gemfile.lock +++ b/chapter01/GeoQuiz/Gemfile.lock @@ -1,10 +1,15 @@ GEM remote: https://rubygems.org/ specs: + motion-gradle (1.3.0) rake (10.4.2) PLATFORMS ruby DEPENDENCIES + motion-gradle rake + +BUNDLED WITH + 1.10.6 diff --git a/chapter01/GeoQuiz/Rakefile b/chapter01/GeoQuiz/Rakefile index 89d99fb..7b0de2b 100644 --- a/chapter01/GeoQuiz/Rakefile +++ b/chapter01/GeoQuiz/Rakefile @@ -13,6 +13,9 @@ Motion::Project::App.setup do |app| app.name = "GeoQuiz" app.package = "net.darinwilson.android.geoquiz" app.main_activity = "QuizActivity" - app.theme = "@android:style/Theme.Holo.Light" - app.development { app.archs << 'x86' } #for genymotion support + app.theme = "@style/Theme.AppCompat.Light.DarkActionBar" + app.archs = ["x86"] unless ARGV.include?("device") || ARGV.include?("release") + app.gradle do + dependency "com.android.support:appcompat-v7:22.1.0" + end end diff --git a/chapter01/GeoQuiz/app/quiz_activity.rb b/chapter01/GeoQuiz/app/quiz_activity.rb index 5703d31..71c4c65 100644 --- a/chapter01/GeoQuiz/app/quiz_activity.rb +++ b/chapter01/GeoQuiz/app/quiz_activity.rb @@ -1,4 +1,4 @@ -class QuizActivity < Android::App::Activity +class QuizActivity < Android::Support::V7::App::AppCompatActivity attr_accessor :true_button attr_accessor :false_button @@ -17,4 +17,15 @@ def onClick(view) Toast.makeText(self, message_id, Toast::LENGTH_SHORT).show() end + def onCreateOptionsMenu(menu) + getMenuInflater().inflate(R::Menu::Menu_quiz, menu) + true + end + + def onOptionsItemSelected(item) + if (item.itemId == R::Id::Section_settings) + return true + end + super + end end diff --git a/chapter01/GeoQuiz/resources/menu/menu_quiz.xml b/chapter01/GeoQuiz/resources/menu/menu_quiz.xml new file mode 100644 index 0000000..5a02c80 --- /dev/null +++ b/chapter01/GeoQuiz/resources/menu/menu_quiz.xml @@ -0,0 +1,10 @@ + + + + diff --git a/chapter01/GeoQuiz/resources/values/strings.xml b/chapter01/GeoQuiz/resources/values/strings.xml index d3df1c8..04f5de2 100644 --- a/chapter01/GeoQuiz/resources/values/strings.xml +++ b/chapter01/GeoQuiz/resources/values/strings.xml @@ -5,8 +5,9 @@ Constantinople is the largest city in Turkey. True False - Settings Correct! Incorrect! + Settings +