Skip to content

Commit

Permalink
Start converting to version 2 of BNR book
Browse files Browse the repository at this point in the history
  • Loading branch information
darinwilson committed Aug 12, 2015
1 parent 9fd350e commit 7e266ac
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
2 changes: 2 additions & 0 deletions chapter01/GeoQuiz/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ nbproject
.sass-cache
.idea
.dat*.*
vendor/Gradle

6 changes: 3 additions & 3 deletions chapter01/GeoQuiz/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rake'
# Add your dependencies here:
gem "rake"
gem "motion-gradle"
5 changes: 5 additions & 0 deletions chapter01/GeoQuiz/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions chapter01/GeoQuiz/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion chapter01/GeoQuiz/app/quiz_activity.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class QuizActivity < Android::App::Activity
class QuizActivity < Android::Support::V7::App::AppCompatActivity
attr_accessor :true_button
attr_accessor :false_button

Expand All @@ -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
10 changes: 10 additions & 0 deletions chapter01/GeoQuiz/resources/menu/menu_quiz.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".QuizActivity">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>

3 changes: 2 additions & 1 deletion chapter01/GeoQuiz/resources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<string name="question_text">Constantinople is the largest city in Turkey.</string>
<string name="true_button">True</string>
<string name="false_button">False</string>
<string name="menu_settings">Settings</string>
<string name="correct_toast">Correct!</string>
<string name="incorrect_toast">Incorrect!</string>
<string name="action_settings">Settings</string>


</resources>

0 comments on commit 7e266ac

Please sign in to comment.