From: Alexis Laferrière Date: Mon, 26 Jan 2015 11:58:56 +0000 (-0500) Subject: examples/calculator: update Android UI to latest API X-Git-Tag: v0.7.3~21^2~3 X-Git-Url: http://nitlanguage.org examples/calculator: update Android UI to latest API Signed-off-by: Alexis Laferrière --- diff --git a/examples/calculator/src/calculator_android.nit b/examples/calculator/src/calculator_android.nit index e1792bf..9b79886 100644 --- a/examples/calculator/src/calculator_android.nit +++ b/examples/calculator/src/calculator_android.nit @@ -20,10 +20,8 @@ module calculator_android is app_version(0, 1, git_revision) java_package "org.nitlanguage.calculator" - # Use a translucent background and lock in portrait mode - android_manifest_activity """ - android:theme="@android:style/Theme.Holo.Wallpaper" - android:screenOrientation="portrait"""" + # Lock in portrait mode + android_manifest_activity """android:screenOrientation="portrait"""" end # FIXME the next line should import `android` only when it uses nit_activity @@ -32,7 +30,9 @@ import android::ui import calculator_logic -redef class App +redef class Activity + super EventCatcher + private var context = new CalculatorContext # The main display, at the top of the screen @@ -44,7 +44,7 @@ redef class App # Has this window been initialized? private var inited = false - redef fun init_window + redef fun on_start do super @@ -52,8 +52,7 @@ redef class App inited = true # Setup UI - var context = native_activity - var layout = new NativeLinearLayout(context) + var layout = new NativeLinearLayout(native) layout.set_vertical # Display screen @@ -70,12 +69,13 @@ redef class App ["="]] for line in ops do - var buts_layout = new NativeLinearLayout(context) + var buts_layout = new NativeLinearLayout(native) buts_layout.set_horizontal layout.add_view_with_weight(buts_layout, 1.0) for op in line do var but = new Button + but.event_catcher = self but.text = op but.text_size = 40 buts_layout.add_view_with_weight(but.native, 1.0) @@ -83,7 +83,7 @@ redef class App end end - context.content_view = layout + native.content_view = layout end redef fun catch_event(event)