lib/android: revamp entrypoint
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 1 May 2016 19:11:35 +0000 (15:11 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 May 2016 21:41:35 +0000 (17:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/asteronits/src/android.nit
lib/android/android.nit
lib/android/game.nit [new file with mode: 0644]
lib/android/input_events.nit
lib/app/audio.nit
lib/app/data_store.nit
lib/app/ui.nit
lib/gamnit/display_android.nit
lib/mnit/android/android_app.nit

index 4042f6d..e7ac9df 100644 (file)
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import ::android::platform
+import ::android
 import ::android::vibration
 
 import asteronits
index b5aa04f..58e296a 100644 (file)
 module android
 
 import platform
-import native_app_glue
 import dalvik
 private import log
-private import assets
-
-redef class App
-       redef fun init_window
-       do
-               super
-               on_create
-               on_restore_state
-               on_start
-       end
-
-       redef fun term_window
-       do
-               super
-               on_stop
-       end
-
-       # Is the application currently paused?
-       var paused = true
-
-       redef fun pause
-       do
-               paused = true
-               on_pause
-               super
-       end
-
-       redef fun resume
-       do
-               paused = false
-               on_resume
-               super
-       end
-
-       redef fun save_state do on_save_state
-
-       redef fun lost_focus
-       do
-               paused = true
-               super
-       end
-
-       redef fun gained_focus
-       do
-               paused = false
-               super
-       end
-
-       redef fun destroy do on_destroy
-end
diff --git a/lib/android/game.nit b/lib/android/game.nit
new file mode 100644 (file)
index 0000000..2d17054
--- /dev/null
@@ -0,0 +1,71 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Android services and implementation of app.nit for gamnit and mnit
+module game
+
+import platform
+import native_app_glue
+import dalvik
+private import log
+private import assets
+
+redef class App
+       redef fun init_window
+       do
+               super
+               on_create
+               on_restore_state
+               on_start
+       end
+
+       redef fun term_window
+       do
+               super
+               on_stop
+       end
+
+       # Is the application currently paused?
+       var paused = true
+
+       redef fun pause
+       do
+               paused = true
+               on_pause
+               super
+       end
+
+       redef fun resume
+       do
+               paused = false
+               on_resume
+               super
+       end
+
+       redef fun save_state do on_save_state
+
+       redef fun lost_focus
+       do
+               paused = true
+               super
+       end
+
+       redef fun gained_focus
+       do
+               paused = false
+               super
+       end
+
+       redef fun destroy do on_destroy
+end
index 9597eea..8aea378 100644 (file)
@@ -18,7 +18,7 @@
 module input_events
 
 import mnit::input
-import android
+import android::game
 
 in "C header" `{
        #include <android/log.h>
index 42d90ae..7f22c78 100644 (file)
@@ -27,7 +27,6 @@ import app_base
 import core::error
 
 # Platform variations
-# TODO: move on the platform once qualified names are understand in the condition
 import linux::audio is conditional(linux)
 import android::audio is conditional(android)
 
index 4db4b22..ebebe83 100644 (file)
@@ -23,7 +23,6 @@ import app_base
 import serialization
 
 # Platform variations
-# TODO: move on the platform once qualified names are understand in the condition
 import linux::data_store is conditional(linux)
 import android::data_store is conditional(android)
 import ios::data_store is conditional(ios)
index 4efbb87..0c7d524 100644 (file)
@@ -18,9 +18,8 @@ module ui
 import app_base
 
 # Platform variations
-# TODO: move on the platform once qualified names are understand in the condition
 import linux::ui is conditional(linux)
-import android::ui is conditional(android) # FIXME it should be conditional to `android::platform`
+import android::ui is conditional(android)
 import ios::ui is conditional(ios)
 
 redef class App
index 3997c4a..c412e9f 100644 (file)
@@ -21,7 +21,7 @@ module display_android is
        android_manifest """<uses-feature android:glEsVersion="0x00020000"/>"""
 end
 
-import ::android
+import ::android::game
 intrude import android::load_image
 
 private import gamnit::egl
index c8f02e3..e78da16 100644 (file)
@@ -22,7 +22,7 @@ module android_app is android_manifest_activity """
 
 import mnit
 import mnit::opengles1
-import ::android
+import ::android::game
 intrude import ::android::input_events
 
 in "C" `{