app

package
v0.0.0-...-3cc54d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 13 Imported by: 39

Documentation

Overview

Package app implements a NativeActivity glue layer required to properly handle the startup process and the native activity events.

Import this package into your Go application to make it Android-compatible.

Index

Constants

This section is empty.

Variables

View Source
var LogInputEvents = func(ev *android.InputEvent) {
	switch android.InputEventGetType(ev) {
	case android.InputEventTypeKey:
		key := android.KeyEventGetKeyCode(ev)
		log.Printf("key event [%d]", key)
	case android.InputEventTypeMotion:
		str := "motion event "
		fingers := android.MotionEventGetPointerCount(ev)
		for i := uint32(0); i < fingers; i++ {
			x := android.MotionEventGetX(ev, i)
			y := android.MotionEventGetY(ev, i)
			pressure := android.MotionEventGetPressure(ev, i)
			str += fmt.Sprintf("[%.0f; %.0f; %.2f]", x, y, pressure)
		}
		log.Println(str)
	}
}
View Source
var SkipInputEvents = func(ev *android.InputEvent) {}

Functions

func HandleInputQueues

func HandleInputQueues(queueChan <-chan *android.InputQueue, onProcessed func(),
	evHandler func(ev *android.InputEvent))

func Main

func Main(fn func(app NativeActivity))

func SetLogTag

func SetLogTag(tag string)

Types

type ActivityEvent

type ActivityEvent struct {
	Activity *android.NativeActivity
	Kind     ActivityEventKind
}

type ActivityEventKind

type ActivityEventKind string
const (
	OnConfigurationChanged ActivityEventKind = "onConfigurationChanged"
	OnLowMemory            ActivityEventKind = "onLowMemory"
)

type AssetReader

type AssetReader struct {
	// contains filtered or unexported fields
}

AssetReader represents an asset opened for reading

func (*AssetReader) Close

func (r *AssetReader) Close() error

Close frees the resources associated with the AssetReader, rendering it unusable. It always returns nil.

func (*AssetReader) Read

func (r *AssetReader) Read(b []byte) (n int, err error)

Read reads up to len(b) bytes from the AssetReader. It returns the number of bytes read and or any error encountered. At end of the asset, Read returns 0, io.EOF.

type ContentRectEvent

type ContentRectEvent struct {
	Activity *android.NativeActivity
	Rect     *android.Rect
}

type InputQueueEvent

type InputQueueEvent struct {
	Activity *android.NativeActivity
	Queue    *android.InputQueue
	Kind     InputQueueEventKind
}

type InputQueueEventKind

type InputQueueEventKind string
const (
	QueueCreated   InputQueueEventKind = "queueCreated"
	QueueDestroyed InputQueueEventKind = "queueDestroyed"
)

type LifecycleEvent

type LifecycleEvent struct {
	Activity *android.NativeActivity
	Kind     LifecycleEventKind
}

type LifecycleEventKind

type LifecycleEventKind string
const (
	OnCreate  LifecycleEventKind = "onCreate"
	OnDestroy LifecycleEventKind = "onDestroy"
	OnStart   LifecycleEventKind = "onStart"
	OnStop    LifecycleEventKind = "onStop"
	OnPause   LifecycleEventKind = "onPause"
	OnResume  LifecycleEventKind = "onResume"
)

type NativeActivity

type NativeActivity interface {
	InitDone()
	NativeWindowRedrawDone()
	InputQueueHandled()
	NativeActivity() *android.NativeActivity
	LifecycleEvents() <-chan LifecycleEvent
	HandleSaveInstanceState(fn SaveStateFunc)
	HandleWindowFocusEvents(out chan<- WindowFocusEvent)
	HandleNativeWindowEvents(out chan<- NativeWindowEvent)
	HandleInputQueueEvents(out chan<- InputQueueEvent)
	HandleContentRectEvents(out chan<- ContentRectEvent)
	HandleActivityEvents(out chan<- ActivityEvent)
	GetAsset(name string) ([]byte, error)
	OpenAsset(name string) (*AssetReader, error)
}

type NativeWindowEvent

type NativeWindowEvent struct {
	Activity *android.NativeActivity
	Window   *android.NativeWindow
	Kind     NativeWindowEventKind
}

type NativeWindowEventKind

type NativeWindowEventKind string
const (
	NativeWindowCreated      NativeWindowEventKind = "nativeWindowCreated"
	NativeWindowRedrawNeeded NativeWindowEventKind = "nativeWindowRedrawNeeded"
	NativeWindowDestroyed    NativeWindowEventKind = "nativeWindowDestroyed"
)

type SaveStateFunc

type SaveStateFunc func(activity *android.NativeActivity, size uintptr) unsafe.Pointer

type Signal

type Signal struct{}

type WindowFocusEvent

type WindowFocusEvent struct {
	Activity *android.NativeActivity
	HasFocus bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL