1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-28 08:11:05 -08:00

Update Android port

* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity)
(onCreate): Add view tree observer.
(onGlobalLayout): Sync fullscreen state.
(syncFullscreenWith): Improve visibility flag setting.

* src/textconv.c (select_window): New function.
(textconv_query):
(restore_selected_window):
(really_commit_text):
(really_set_composing_text):
(really_set_composing_region):
(really_delete_surrounding_text):
(really_set_point_and_mark):
(get_extracted_text): Call it instead of Fselect_window
to avoid selecting the mini window if it is no longer active.
This commit is contained in:
Po Lu 2023-03-03 15:23:21 +08:00
parent bf93380c1c
commit bc9239eb51
2 changed files with 61 additions and 20 deletions

View file

@ -31,6 +31,7 @@ import android.os.Bundle;
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;
@ -38,7 +39,8 @@ import android.widget.FrameLayout.LayoutParams;
import android.widget.FrameLayout;
public class EmacsActivity extends Activity
implements EmacsWindowAttachmentManager.WindowConsumer
implements EmacsWindowAttachmentManager.WindowConsumer,
ViewTreeObserver.OnGlobalLayoutListener
{
public static final String TAG = "EmacsActivity";
@ -180,6 +182,8 @@ public class EmacsActivity extends Activity
{
FrameLayout.LayoutParams params;
Intent intent;
View decorView;
ViewTreeObserver observer;
/* See if Emacs should be started with -Q. */
intent = getIntent ();
@ -203,9 +207,29 @@ public class EmacsActivity extends Activity
/* 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 ()
@ -348,22 +372,20 @@ public class EmacsActivity extends Activity
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);