protected override void OnPause() { SDLActivity.OnPause(); // Reflection <UrhoSurface>: Urho.Application.HandlePause(); var handleResume = typeof(Urho.Application).GetMethod("HandlePause", BindingFlags.NonPublic | BindingFlags.Static); handleResume.Invoke(default, default);
public async Task <Application> Show(Type appType, ApplicationOptions options = null, bool finishActivityOnExit = false) { await Stop(); if (SDLSurface != null) { RemoveView(SDLSurface); } SDLSurface = SDLActivity.CreateSurface(Context as Activity); AddView(SDLSurface, ViewGroup.LayoutParams.MatchParent); var tcs = new TaskCompletionSource <Application>(); Action startedHandler = null; startedHandler = () => { Application.Started -= startedHandler; tcs.TrySetResult(Application.Current); }; Application.Started += startedHandler; UrhoSurface.SetSdlMain(() => Application.CreateInstance(appType, options), finishActivityOnExit, SDLSurface); return(await tcs.Task); }
/// <summary> /// Creates a view (SurfaceView) that can be added anywhere /// </summary> public static SDLSurface CreateSurface(Activity activity, Func <Application> applicationFactory, bool finishActivtiyOnExit = false) { var surface = SDLActivity.CreateSurface(activity); SetSdlMain(applicationFactory, finishActivtiyOnExit, surface); return(surface); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); requestedOrientation = (ApplicationOptions.OrientationType)Intent.GetIntExtra(nameof(ApplicationOptions.OrientationType), 0); switch (requestedOrientation) { case ApplicationOptions.OrientationType.Landscape: RequestedOrientation = ScreenOrientation.SensorLandscape; break; case ApplicationOptions.OrientationType.Portrait: RequestedOrientation = ScreenOrientation.SensorPortrait; break; case ApplicationOptions.OrientationType.LandscapeAndPortrait: RequestedOrientation = ScreenOrientation.Unspecified; break; } SDLSurface surface = SDLActivity.CreateSurface(this); FrameLayout layout = new FrameLayout(this); layout.AddView(surface); SetContentView(layout); }
public bool OnKey(View v, Keycode keyCode, KeyEvent e) { // This handles the hardware keyboard input if (e.IsPrintingKey) { if (e.Action == KeyEventActions.Down) { ic.CommitText(Java.Lang.String.ValueOf(e.GetUnicodeChar(0)), 1); } return(true); } if (e.Action == KeyEventActions.Down) { SDLActivity.onNativeKeyDown(keyCode); return(true); } else if (e.Action == KeyEventActions.Up) { SDLActivity.onNativeKeyUp(keyCode); return(true); } return(false); }
/// <summary> /// Creates a view (SurfaceView) that can be added anywhere /// </summary> public static SDLSurface CreateSurface(Activity activity, bool finishActivtiyOnExit = false, Type appDelegateType = null) { AndroidSDLSurface.appDelegateType = appDelegateType; var surface = SDLActivity.CreateSurface(activity); SetSDLEntryCallback(finishActivtiyOnExit, surface); return(surface); }
protected override void OnElementChanged(ElementChangedEventArgs <UrhoSurface> e) { SDLActivity.OnResume(); var surface = new AndroidUrhoSurface(Context); e.NewElement.UrhoApplicationLauncher = surface.Launcher; SetNativeControl(surface); base.OnElementChanged(e); }
public override bool DispatchKeyEvent(KeyEvent e) { if (!SDLActivity.DispatchKeyEvent(e)) { return(false); } if (e.KeyCode == Keycode.Back) { Finish(); } return(base.DispatchKeyEvent(e)); }
internal async Task <Urho.Application> Launcher(Type type, ApplicationOptions options) { await launcherSemaphore.WaitAsync(); SDLActivity.OnDestroy(); applicationTaskSource = new TaskCompletionSource <Application>(); Urho.Application.Started += UrhoApplicationStarted; var surfaceView = Urho.Droid.UrhoSurface.CreateSurface((Activity)Context, type, options); SDLActivity.OnResume(); surfaceViewPlaceholder.AddView(surfaceView); return(await applicationTaskSource.Task); }
protected override void OnElementChanged(ElementChangedEventArgs <Urho.Forms.UrhoSurface> e) { SDLActivity.OnResume(); var surface = new AndroidUrhoSurface(Context); if (e.NewElement == null) { return; } e.NewElement.RegisterRunner(surface.Launcher); SetNativeControl(surface); base.OnElementChanged(e); }
public async Task <Application> Show(Type appType, ApplicationOptions options = null, bool finishActivityOnExit = false) { Stop(); launching = true; if (SDLSurface != null) { RemoveView(SDLSurface); } SDLSurface = SDLActivity.CreateSurface(Context as Activity); AddView(SDLSurface, ViewGroup.LayoutParams.MatchParent); // Reflection <UrhoSurfacePlaceholder>: Urho.Application.CurrentSurface = new WeakReference(SDLSurface); var currentSurface = typeof(Application).GetProperty(nameof(Application.CurrentSurface), BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty); currentSurface.SetValue(default, new WeakReference(SDLSurface));
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e) { // As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event // FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639 // FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not // FIXME: A more effective solution would be to change our Layout from AbsoluteLayout to Relative or Linear // FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android // FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :) if (e.Action == KeyEventActions.Up && keyCode == Keycode.Back) { if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.Visibility == ViewStates.Visible) { SDLActivity.onNativeKeyboardFocusLost(); } } return(base.OnKeyPreIme(keyCode, e)); }
public override bool SendKeyEvent(KeyEvent e) { var keyCode = e.KeyCode; if (e.Action == KeyEventActions.Down) { if (e.IsPrintingKey) { CommitText(Java.Lang.String.ValueOf(e.GetUnicodeChar(0)), 1); } SDLActivity.onNativeKeyDown(keyCode); return(true); } else if (e.Action == KeyEventActions.Up) { SDLActivity.onNativeKeyUp(keyCode); return(true); } return(base.SendKeyEvent(e)); }
public bool OnGenericMotion(View v, MotionEvent e) { return(SDLActivity.handleJoystickMotionEvent(e)); }
public static void OnWindowFocusChanged(bool focus) { SDLActivity.OnWindowFocusChanged(focus); }
public static bool DispatchKeyEvent(KeyEvent keyEvent) { return(SDLActivity.DispatchKeyEvent(keyEvent)); }
public static void OnDestroy() { SDLActivity.OnDestroy(); }
public static void OnLowMemory() { SDLActivity.OnLowMemory(); }
public static void OnPause() { SDLActivity.OnPause(); }
public override void OnLowMemory() { base.OnLowMemory(); SDLActivity.OnLowMemory(); }
/// <summary> /// Creates a view (SurfaceView) that can be added anywhere /// </summary> public static SDLSurface CreateSurface(Activity activity, Type applicationType, ApplicationOptions options = null) { RegisterSdlLauncher(contextPtr => Application.CreateInstance(applicationType, options).Run()); return(SDLActivity.CreateSurface(activity)); }
protected override void OnResume() { base.OnResume(); SDLActivity.OnResume(); }
protected override void OnPause() { base.OnPause(); SDLActivity.OnPause(); }
/// <summary> /// Creates a view (SurfaceView) that can be added anywhere /// </summary> public static SDLSurface CreateSurface(Activity activity) => SDLActivity.CreateSurface(activity);
protected override void OnDestroy() { base.OnDestroy(); SDLActivity.OnDestroy(); }
public static void OnResume() { SDLActivity.OnResume(); Urho.Application.HandleResume(); }
public static void OnResume() { SDLActivity.OnResume(); }
public static void OnPause() { SDLActivity.OnPause(); Urho.Application.HandlePause(); }
public override void OnWindowFocusChanged(bool hasFocus) { base.OnWindowFocusChanged(hasFocus); SDLActivity.OnWindowFocusChanged(hasFocus); }