An activity, a single, focused thing a user can do on Android

Introduced properties

fun content_view=(layout: NativeViewGroup)

android :: NativeActivity :: content_view=

Set the main layout of this activity
fun finish

android :: NativeActivity :: finish

Notify the OS that this activity is done and should be closed
private fun insert_root_layout(root_layout_id: Int)

android :: NativeActivity :: insert_root_layout

Insert a single layout as the root of the activity window
fun run_on_ui_thread(task: Task)

android :: NativeActivity :: run_on_ui_thread

Execute task.main on the UI thread when possible
private fun show_fragment(root_layout_id: Int, native_fragment: Android_app_Fragment)

android :: NativeActivity :: show_fragment

Replace the currently visible fragment, if any, with native_fragment

Redefined properties

redef type SELF: NativeActivity

android $ NativeActivity :: SELF

Type of this instance, automatically specialized in every class
redef fun new_global_ref: SELF

android $ NativeActivity :: new_global_ref

HACK for bug #845

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun address_is_null: Bool

core :: Pointer :: address_is_null

Is the address behind this Object at NULL?
private fun assets: NativeAssetManager

android :: NativeContext :: assets

Get the native AssetsManager of the application, used to initialize the nit's AssetManager
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun content_view=(layout: NativeViewGroup)

android :: NativeActivity :: content_view=

Set the main layout of this activity
fun delete_global_ref

jvm :: JavaObject :: delete_global_ref

Delete this global reference
fun delete_local_ref

jvm :: JavaObject :: delete_local_ref

Delete this local reference
fun finish

android :: NativeActivity :: finish

Notify the OS that this activity is done and should be closed
fun free

core :: Pointer :: free

Free the memory pointed by this pointer
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

private fun insert_root_layout(root_layout_id: Int)

android :: NativeActivity :: insert_root_layout

Insert a single layout as the root of the activity window
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_java_null: Bool

jvm :: JavaObject :: is_java_null

Is self null in Java?
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
private fun native_equals(o: Pointer): Bool

core :: Pointer :: native_equals

fun new_global_ref: SELF

jvm :: JavaObject :: new_global_ref

Returns a global reference to the Java object behind this reference
init nul: Pointer

core :: Pointer :: nul

C NULL pointer
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
private fun package_name: JavaString

android :: NativeContext :: package_name

Get the package name of the application
fun pop_from_local_frame: SELF

jvm :: JavaObject :: pop_from_local_frame

Pops the current local reference frame and return a valid reference to self
protected fun pop_from_local_frame_with_env(jni_env: JniEnv): SELF

jvm :: JavaObject :: pop_from_local_frame_with_env

Java implementation of pop_from_local_frame
private fun premultiply_alpha(width: Int, height: Int)

core :: Pointer :: premultiply_alpha

Multiply RGB values by their alpha value
private fun resources: NativeResources

android :: NativeContext :: resources

Get the native ResourceManager of the application, used to initialize the nit's ResourceManager
fun run_on_ui_thread(task: Task)

android :: NativeActivity :: run_on_ui_thread

Execute task.main on the UI thread when possible
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun show_fragment(root_layout_id: Int, native_fragment: Android_app_Fragment)

android :: NativeActivity :: show_fragment

Replace the currently visible fragment, if any, with native_fragment
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_java_string: JavaString

jvm :: JavaObject :: to_java_string

JavaString representation of self using Java's toString
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun wifi_manager: NativeWifiManager

android :: NativeContext :: wifi_manager

Handle to the WiFi system service
package_diagram android::NativeActivity NativeActivity android::NativeContextWrapper NativeContextWrapper android::NativeActivity->android::NativeContextWrapper android::NativeContext NativeContext android::NativeContextWrapper->android::NativeContext ...android::NativeContext ... ...android::NativeContext->android::NativeContext android::NativeNativeActivity NativeNativeActivity android::NativeNativeActivity->android::NativeActivity android::NativeNitActivity NativeNitActivity android::NativeNitActivity->android::NativeActivity

Ancestors

extern class JavaObject

jvm :: JavaObject

Represens a jni jobject
extern class NativeContext

android :: NativeContext

An Android activity context
interface Object

core :: Object

The root of the class hierarchy.
extern class Pointer

core :: Pointer

Pointer classes are used to manipulate extern C structures.

Parents

extern class NativeContextWrapper

android :: NativeContextWrapper

A wrapper of context

Children

extern class NativeNativeActivity

android :: NativeNativeActivity

Android SDK's android.app.NativeActivity.
extern class NativeNitActivity

android :: NativeNitActivity

Wrapper to our Java NitActivity

Class definitions

android $ NativeActivity
# An activity, a single, focused thing a user can do on Android
extern class NativeActivity in "Java" `{ android.app.Activity `}
	super NativeContextWrapper

	# HACK for bug #845
	redef fun new_global_ref: SELF import sys, Sys.jni_env `{
		Sys sys = NativeActivity_sys(self);
		JNIEnv *env = Sys_jni_env(sys);
		return (*env)->NewGlobalRef(env, self);
	`}

	# Notify the OS that this activity is done and should be closed
	fun finish in "Java" `{ self.finish(); `}

	# Execute `task.main` on the UI thread when possible
	fun run_on_ui_thread(task: Task) import Task.main in "Java" `{
		final nit.app.NitObject final_task = task;
		Runnable runnable = new Runnable() {
			@Override
			public void run() {
				Task_main(final_task);
			}
		};
		self.runOnUiThread(runnable);
	`}
end
lib/android/activities.nit:30,1--55,3

android :: native_ui $ NativeActivity
redef extern class NativeActivity

	# Set the main layout of this activity
	fun content_view=(layout: NativeViewGroup) in "Java" `{
		self.setContentView(layout);
	`}
end
lib/android/ui/native_ui.nit:40,1--46,3

android :: ui $ NativeActivity
redef class NativeActivity

	private fun remove_title_bar in "Java" `{
		self.requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
	`}

	# Insert a single layout as the root of the activity window
	private fun insert_root_layout(root_layout_id: Int)
	in "Java" `{
		android.widget.FrameLayout layout = new android.widget.FrameLayout(self);
		layout.setId((int)root_layout_id);
		self.setContentView(layout);
	`}

	# Replace the currently visible fragment, if any, with `native_fragment`
	private fun show_fragment(root_layout_id: Int, native_fragment: Android_app_Fragment)
	in "Java" `{
		android.app.FragmentTransaction transaction = self.getFragmentManager().beginTransaction();
		transaction.replace((int)root_layout_id, native_fragment);
		transaction.commit();
	`}
end
lib/android/ui/ui.nit:43,1--64,3

gamnit :: gamnit_android $ NativeActivity
redef class NativeActivity

	private fun window_height: Int in "Java" `{
		android.view.View view = self.getWindow().getDecorView();
		return view.getBottom() - view.getTop();
	`}

	private fun window_width: Int in "Java" `{
		android.view.View view = self.getWindow().getDecorView();
		return view.getRight() - view.getLeft();
	`}

	private fun orientation: Int in "Java" `{
		return self.getResources().getConfiguration().orientation;
	`}
end
lib/gamnit/gamnit_android.nit:292,1--307,3