import android.util.Log;
import android.view.Menu;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.widget.FrameLayout;
public class EmacsActivity extends Activity
- implements EmacsWindowAttachmentManager.WindowConsumer
+ implements EmacsWindowAttachmentManager.WindowConsumer,
+ ViewTreeObserver.OnGlobalLayoutListener
{
public static final String TAG = "EmacsActivity";
{
FrameLayout.LayoutParams params;
Intent intent;
+ View decorView;
+ ViewTreeObserver observer;
/* See if Emacs should be started with -Q. */
intent = getIntent ();
/* Add this activity to the list of available activities. */
EmacsWindowAttachmentManager.MANAGER.registerWindowConsumer (this);
+ /* Start observing global layout changes between Jelly Bean and Q.
+ This is required to restore the fullscreen state whenever the
+ on screen keyboard is displayed, as there is otherwise no way
+ to determine when the on screen keyboard becomes visible. */
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
+ && Build.VERSION.SDK_INT < Build.VERSION_CODES.R)
+ {
+ decorView = getWindow ().getDecorView ();
+ observer = decorView.getViewTreeObserver ();
+ observer.addOnGlobalLayoutListener (this);
+ }
+
super.onCreate (savedInstanceState);
}
+ @Override
+ public final void
+ onGlobalLayout ()
+ {
+ syncFullscreenWith (window);
+ }
+
@Override
public final void
onDestroy ()
if (isFullscreen)
{
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
- /* This flag means that Emacs will be full screen, but
- the system will cancel the full screen state upon
- switching to another program. */
- view.setSystemUiVisibility (View.SYSTEM_UI_FLAG_FULLSCREEN);
- else
+ flags = 0;
+ flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
/* These flags means that Emacs will be full screen as
long as the state flag is set. */
- flags = 0;
- flags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE;
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
- view.setSystemUiVisibility (flags);
}
+
+ /* Apply the given flags. */
+ view.setSystemUiVisibility (flags);
}
else
view.setSystemUiVisibility (View.SYSTEM_UI_FLAG_VISIBLE);
return -1;
}
+/* Like Fselect_window. However, if WINDOW is a mini buffer window
+ but not the active minibuffer window, select its frame's selected
+ window instead. */
+
+static void
+select_window (Lisp_Object window, Lisp_Object norecord)
+{
+ struct window *w;
+
+ w = XWINDOW (window);
+
+ if (MINI_WINDOW_P (w)
+ && WINDOW_LIVE_P (window)
+ && !EQ (window, Factive_minibuffer_window ()))
+ window = WINDOW_XFRAME (w)->selected_window;
+
+ Fselect_window (window, norecord);
+}
+
/* Perform the text conversion operation specified in QUERY and return
the results.
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window ((WINDOW_LIVE_P (f->old_selected_window)
- ? f->old_selected_window
- : f->selected_window), Qt);
+ select_window ((WINDOW_LIVE_P (f->old_selected_window)
+ ? f->old_selected_window
+ : f->selected_window), Qt);
/* Now find the appropriate text bounds for QUERY. First, move
point QUERY->position steps forward or backwards. */
restore_selected_window (Lisp_Object window)
{
/* FIXME: not sure what to do if WINDOW has been deleted. */
- Fselect_window (window, Qt);
+ select_window (window, Qt);
}
/* Commit the given text in the composing region. If there is no
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
/* Now detect whether or not there is a composing region.
If there is, then replace it with TEXT. Don't do that
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
w = XWINDOW (f->old_selected_window);
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
/* Now set up the composition region if necessary. */
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
/* Now set up the composition region if necessary. */
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
/* Figure out where to start deleting from. */
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
if (point == PT)
{
/* Temporarily switch to F's selected window at the time of the last
redisplay. */
- Fselect_window (f->old_selected_window, Qt);
+ select_window (f->old_selected_window, Qt);
buffer = NULL;
/* Figure out the bounds of the text to return. */