diff options
| author | Po Lu | 2023-03-03 15:23:21 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-03 15:23:21 +0800 |
| commit | bc9239eb51b1a346dac8a7f0f20b857143114bae (patch) | |
| tree | 550fe2442699c940ba9a055430640c9cbd849522 /java | |
| parent | bf93380c1c9a319840f89106ff6b9492faf923b4 (diff) | |
| download | emacs-bc9239eb51b1a346dac8a7f0f20b857143114bae.tar.gz emacs-bc9239eb51b1a346dac8a7f0f20b857143114bae.zip | |
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.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsActivity.java | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/java/org/gnu/emacs/EmacsActivity.java b/java/org/gnu/emacs/EmacsActivity.java index bcfee3f7080..62bef33fab3 100644 --- a/java/org/gnu/emacs/EmacsActivity.java +++ b/java/org/gnu/emacs/EmacsActivity.java | |||
| @@ -31,6 +31,7 @@ import android.os.Bundle; | |||
| 31 | import android.util.Log; | 31 | import android.util.Log; |
| 32 | import android.view.Menu; | 32 | import android.view.Menu; |
| 33 | import android.view.View; | 33 | import android.view.View; |
| 34 | import android.view.ViewTreeObserver; | ||
| 34 | import android.view.Window; | 35 | import android.view.Window; |
| 35 | import android.view.WindowInsets; | 36 | import android.view.WindowInsets; |
| 36 | import android.view.WindowInsetsController; | 37 | import android.view.WindowInsetsController; |
| @@ -38,7 +39,8 @@ import android.widget.FrameLayout.LayoutParams; | |||
| 38 | import android.widget.FrameLayout; | 39 | import android.widget.FrameLayout; |
| 39 | 40 | ||
| 40 | public class EmacsActivity extends Activity | 41 | public class EmacsActivity extends Activity |
| 41 | implements EmacsWindowAttachmentManager.WindowConsumer | 42 | implements EmacsWindowAttachmentManager.WindowConsumer, |
| 43 | ViewTreeObserver.OnGlobalLayoutListener | ||
| 42 | { | 44 | { |
| 43 | public static final String TAG = "EmacsActivity"; | 45 | public static final String TAG = "EmacsActivity"; |
| 44 | 46 | ||
| @@ -180,6 +182,8 @@ public class EmacsActivity extends Activity | |||
| 180 | { | 182 | { |
| 181 | FrameLayout.LayoutParams params; | 183 | FrameLayout.LayoutParams params; |
| 182 | Intent intent; | 184 | Intent intent; |
| 185 | View decorView; | ||
| 186 | ViewTreeObserver observer; | ||
| 183 | 187 | ||
| 184 | /* See if Emacs should be started with -Q. */ | 188 | /* See if Emacs should be started with -Q. */ |
| 185 | intent = getIntent (); | 189 | intent = getIntent (); |
| @@ -203,11 +207,31 @@ public class EmacsActivity extends Activity | |||
| 203 | /* Add this activity to the list of available activities. */ | 207 | /* Add this activity to the list of available activities. */ |
| 204 | EmacsWindowAttachmentManager.MANAGER.registerWindowConsumer (this); | 208 | EmacsWindowAttachmentManager.MANAGER.registerWindowConsumer (this); |
| 205 | 209 | ||
| 210 | /* Start observing global layout changes between Jelly Bean and Q. | ||
| 211 | This is required to restore the fullscreen state whenever the | ||
| 212 | on screen keyboard is displayed, as there is otherwise no way | ||
| 213 | to determine when the on screen keyboard becomes visible. */ | ||
| 214 | |||
| 215 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN | ||
| 216 | && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) | ||
| 217 | { | ||
| 218 | decorView = getWindow ().getDecorView (); | ||
| 219 | observer = decorView.getViewTreeObserver (); | ||
| 220 | observer.addOnGlobalLayoutListener (this); | ||
| 221 | } | ||
| 222 | |||
| 206 | super.onCreate (savedInstanceState); | 223 | super.onCreate (savedInstanceState); |
| 207 | } | 224 | } |
| 208 | 225 | ||
| 209 | @Override | 226 | @Override |
| 210 | public final void | 227 | public final void |
| 228 | onGlobalLayout () | ||
| 229 | { | ||
| 230 | syncFullscreenWith (window); | ||
| 231 | } | ||
| 232 | |||
| 233 | @Override | ||
| 234 | public final void | ||
| 211 | onDestroy () | 235 | onDestroy () |
| 212 | { | 236 | { |
| 213 | EmacsWindowAttachmentManager manager; | 237 | EmacsWindowAttachmentManager manager; |
| @@ -348,22 +372,20 @@ public class EmacsActivity extends Activity | |||
| 348 | 372 | ||
| 349 | if (isFullscreen) | 373 | if (isFullscreen) |
| 350 | { | 374 | { |
| 351 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) | 375 | flags = 0; |
| 352 | /* This flag means that Emacs will be full screen, but | 376 | flags |= View.SYSTEM_UI_FLAG_FULLSCREEN; |
| 353 | the system will cancel the full screen state upon | 377 | |
| 354 | switching to another program. */ | 378 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) |
| 355 | view.setSystemUiVisibility (View.SYSTEM_UI_FLAG_FULLSCREEN); | ||
| 356 | else | ||
| 357 | { | 379 | { |
| 358 | /* These flags means that Emacs will be full screen as | 380 | /* These flags means that Emacs will be full screen as |
| 359 | long as the state flag is set. */ | 381 | long as the state flag is set. */ |
| 360 | flags = 0; | ||
| 361 | flags |= View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
| 362 | flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | 382 | flags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 363 | flags |= View.SYSTEM_UI_FLAG_IMMERSIVE; | 383 | flags |= View.SYSTEM_UI_FLAG_IMMERSIVE; |
| 364 | flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | 384 | flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
| 365 | view.setSystemUiVisibility (flags); | ||
| 366 | } | 385 | } |
| 386 | |||
| 387 | /* Apply the given flags. */ | ||
| 388 | view.setSystemUiVisibility (flags); | ||
| 367 | } | 389 | } |
| 368 | else | 390 | else |
| 369 | view.setSystemUiVisibility (View.SYSTEM_UI_FLAG_VISIBLE); | 391 | view.setSystemUiVisibility (View.SYSTEM_UI_FLAG_VISIBLE); |