SDL  2.0
org.libsdl.app.SDLActivity.SDLCommandHandler Class Reference
+ Inheritance diagram for org.libsdl.app.SDLActivity.SDLCommandHandler:
+ Collaboration diagram for org.libsdl.app.SDLActivity.SDLCommandHandler:

Public Member Functions

void handleMessage (Message msg)
 

Detailed Description

A Handler class for Messages from native SDL applications. It uses current Activities as target (e.g. for the title). static to prevent implicit references to enclosing object.

Definition at line 556 of file SDLActivity.java.

Member Function Documentation

◆ handleMessage()

void org.libsdl.app.SDLActivity.SDLCommandHandler.handleMessage ( Message  msg)
inline

Definition at line 558 of file SDLActivity.java.

References button, context, sort_controllers.filename, org.libsdl.app.SDL.getContext(), org.libsdl.app.SDLActivity.getContext(), org.libsdl.app.SDLActivity.mFullscreenModeActive, org.libsdl.app.SDLActivity.nativeGetHint(), org.libsdl.app.SDLActivity.nativeLowMemory(), org.libsdl.app.SDLActivity.nativePause(), org.libsdl.app.SDLActivity.nativeQuit(), org.libsdl.app.SDLActivity.nativeResume(), org.libsdl.app.SDLActivity.nativeRunMain(), org.libsdl.app.SDLActivity.nativeSetenv(), org.libsdl.app.SDLActivity.nativeSetupJNI(), org.libsdl.app.SDLActivity.onNativeAccel(), org.libsdl.app.SDLActivity.onNativeClipboardChanged(), org.libsdl.app.SDLActivity.onNativeDropFile(), org.libsdl.app.SDLActivity.onNativeKeyboardFocusLost(), org.libsdl.app.SDLActivity.onNativeKeyDown(), org.libsdl.app.SDLActivity.onNativeKeyUp(), org.libsdl.app.SDLActivity.onNativeMouse(), org.libsdl.app.SDLActivity.onNativeOrientationChanged(), org.libsdl.app.SDLActivity.onNativeResize(), org.libsdl.app.SDLActivity.onNativeSurfaceChanged(), org.libsdl.app.SDLActivity.onNativeSurfaceDestroyed(), org.libsdl.app.SDLActivity.onNativeTouch(), and org.libsdl.app.SDLActivity.onUnhandledMessage().

558  {
559  Context context = SDL.getContext();
560  if (context == null) {
561  Log.e(TAG, "error handling message, getContext() returned null");
562  return;
563  }
564  switch (msg.arg1) {
565  case COMMAND_CHANGE_TITLE:
566  if (context instanceof Activity) {
567  ((Activity) context).setTitle((String)msg.obj);
568  } else {
569  Log.e(TAG, "error handling message, getContext() returned no Activity");
570  }
571  break;
572  case COMMAND_CHANGE_WINDOW_STYLE:
573  if (Build.VERSION.SDK_INT < 19) {
574  // This version of Android doesn't support the immersive fullscreen mode
575  break;
576  }
577  if (context instanceof Activity) {
578  Window window = ((Activity) context).getWindow();
579  if (window != null) {
580  if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
581  int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
582  View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
583  View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
584  View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
585  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
586  View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
587  window.getDecorView().setSystemUiVisibility(flags);
588  window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
589  window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
590  SDLActivity.mFullscreenModeActive = true;
591  } else {
592  int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
593  window.getDecorView().setSystemUiVisibility(flags);
594  window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
595  window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
596  SDLActivity.mFullscreenModeActive = false;
597  }
598  }
599  } else {
600  Log.e(TAG, "error handling message, getContext() returned no Activity");
601  }
602  break;
603  case COMMAND_TEXTEDIT_HIDE:
604  if (mTextEdit != null) {
605  // Note: On some devices setting view to GONE creates a flicker in landscape.
606  // Setting the View's sizes to 0 is similar to GONE but without the flicker.
607  // The sizes will be set to useful values when the keyboard is shown again.
608  mTextEdit.setLayoutParams(new RelativeLayout.LayoutParams(0, 0));
609 
610  InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
611  imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
612 
613  mScreenKeyboardShown = false;
614  }
615  break;
616  case COMMAND_SET_KEEP_SCREEN_ON:
617  {
618  if (context instanceof Activity) {
619  Window window = ((Activity) context).getWindow();
620  if (window != null) {
621  if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
622  window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
623  } else {
624  window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
625  }
626  }
627  }
628  break;
629  }
630  default:
631  if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
632  Log.e(TAG, "error handling message, command is " + msg.arg1);
633  }
634  }
635  }
static final String TAG
static screen_context_t context
Definition: video.c:25
boolean onUnhandledMessage(int command, Object param)
GLbitfield flags
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
static boolean mScreenKeyboardShown

The documentation for this class was generated from the following file: