1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00
Commit graph

371 commits

Author SHA1 Message Date
Peter Oliver
8099dc6e3a Provide an Android version code derived from the Emacs version
The version code is intended to be an integer that increments
for each Android package release
(https://developer.android.com/studio/publish/versioning#versioningsettings).

If we keep this updated under version control, then F-Droid (a
third-party Android package repository), can watch for that, and
use it to automatically build Emacs packages for Android each
time a new Emacs release is tagged
(https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckData).

* admin/admin.el (set-version): Update version code in
java/incrementing-version-code
* java/incrementing-version-code: New file containing an Android
version code corresponding to the current Emacs version.
(bug#75809)
2025-03-05 14:58:18 +08:00
Po Lu
ded77fefff Fix remaining Android bugs reported over the past months
* java/org/gnu/emacs/EmacsActivity.java (attachWindow):
Guarantee that child windows promoted to toplevels receive
layout parameters that direct them to receive their parents'
dimensions.  Otherwise, the size of the window as a child is
retained on Huawei HarmonyOS 4.2 and possibly other Android
distributions.

* java/org/gnu/emacs/EmacsService.java (updateCursorAnchorInfo):
Run anchor updates on the UI thread, as
`InputMethodManager#updateCursorAnchorInfo' is liable to call
`View#requestLayout'.

* java/org/gnu/emacs/EmacsView.java (onMeasure): Always call
`measureChildren', or child frames' onLayout handlers might not
be invoked after they request a layout cycle and are duly
processed in `onLayout'.
(swapBuffers): Delete erroneous commentary.

* java/org/gnu/emacs/EmacsWindow.java (viewLayout): If
overrideRedirect, don't inadvertently clear rect.left and
rect.top by recording the window's WM window-relative position.
Fix typos.
(reparentTo): Invalidate focus after transferring frame.
(translateCoordinates): Account for override-redirect windows.
Mostly important for mouse-drag-and-drop-region.
2025-02-19 20:40:12 +08:00
Po Lu
e97be722d3 Properly move existing tooltips on Android
* java/org/gnu/emacs/EmacsWindow.java (requestViewLayout): If an
override redirect window, additionally notify the window manager
of layout changes.
2025-02-19 15:34:51 +08:00
Po Lu
e3dc0ea254 Fix crash in frame deletion on Android
* java/org/gnu/emacs/EmacsWindow.java (destroyHandle):
Invalidate the input focus in the UI thread, as is proper.
2025-02-17 11:33:50 +08:00
Stefan Kangas
7fa975adbc Update copyright year to 2025
Run "TZ=UTC0 admin/update-copyright".
2025-01-02 18:39:42 +01:00
Po Lu
16462b1a62 Register for more Intents actions on Android
* java/AndroidManifest.xml.in <EmacsOpenActivity>: Register
for SEND Intents with mailto URIs.

* java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): Use
Intent constants rather than string literals.
2024-08-09 10:11:51 +08:00
Stefan Kangas
a6cab228d4 ; Fix typos 2024-07-18 11:46:50 +02:00
Po Lu
34882d5243 Port better to Android 3.0
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Use the
old getPackageInfo calling convention if it exists rather than
on Android 2.3.3 and earlier.
2024-07-18 13:34:55 +08:00
Po Lu
b00fc31dd1 Do not set LD_LIBRARY_PATH during Android initialization
* doc/emacs/android.texi (Android Environment): Adjust
documentation to match.

* java/org/gnu/emacs/EmacsNoninteractive.java (main1): New
function.  Remove initialization of EmacsNative hither.
(main): Acquire an ApplicationInfo or LoadedApk, as the case may
be on the host system, derive a ClassLoader from the result, and
load and call `main1' from within this class loader.

* src/android-emacs.c (main):

* src/android.c (setEmacsParams): Do not override
LD_LIBRARY_PATH or set EMACS_LD_LIBRARY_PATH.  This enables
Emacs to execute subprocesses in certain "fortified" Android
systems, amongst other things.
2024-07-14 12:46:23 +08:00
Po Lu
e0b271e279 Take precautions against ill-formed content URIs
* java/org/gnu/emacs/EmacsService.java (openContentUri)
(checkContentUri): Verify that URIs derived from user-provided
file names can be parsed before attempting to open them.
2024-07-11 11:38:41 +08:00
Po Lu
67f291ddae Correct conditions for iconification on Android
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity)
<isPaused>: Rename to <isStopped>.
(attachWindow): Adjust to match.
(onPause): Delete function.
(onStop): Deem frames iconified after calls to onStop instead.
2024-07-08 15:43:22 +08:00
Po Lu
ae38579420 * java/res/mipmap-v26/emacs_icon.xml: Define monospace icon. 2024-07-01 11:22:18 +08:00
Po Lu
64851d101a Improve Android "adaptive icon"
* java/res/drawable/emacs_background.xml:

* java/res/drawable/emacs_foreground.xml: Transform borders and
gradient colors to better align with the original.
2024-06-30 23:11:19 +08:00
Po Lu
860840621a Prevent crashes and related issues if initial activity is destroyed on Android
* java/org/gnu/emacs/EmacsWindow.java
(EmacsWindow) <initialWindowCreated>: New variable.
(EmacsWindow): If the initial frame has not yet been created,
set attachmentToken to -1.

* java/org/gnu/emacs/EmacsWindowManager.java (registerWindow):
When the window's attachment token is -1 (i.e., it is the
default window), start EmacsActivity rather than
EmacsMultitaskActivity.  Catch exceptions around startActivity.
2024-06-27 11:07:38 +08:00
Po Lu
73a58329a6 Fix omission of updates to child frames on Android
* java/org/gnu/emacs/EmacsView.java (onAttachedFromWindow):
Force a layout cycle rather than report exposure immediately.
(prepareForLayout): Delete function.

* java/org/gnu/emacs/EmacsWindow.java (mapWindow): Remove
redundant calls to prepareForLayout.

* src/androidterm.c (handle_one_android_event): Do not swap
buffers when exposure is registered by a frame only partially
updated.
2024-06-24 12:04:05 +08:00
Po Lu
5fceb53856 Avoid races between the tooltip and compositor on X and Android
* java/org/gnu/emacs/EmacsView.java (onLayout): Don't send
exposure events when the window is still to be attached.

* src/androidfns.c (Fx_show_tip):

* src/xfns.c (Fx_show_tip): Block async input around initial
frame update.
2024-06-19 10:57:07 +08:00
Po Lu
fb04a51894 Fix window class of Android tooltips
* java/org/gnu/emacs/EmacsWindow.java (getWindowLayoutParams):
Declare as a panel, rather than an attached dialog.
2024-06-18 15:53:18 +08:00
Po Lu
3c2df93e06 * java/Makefile.in (emacs.apk-in): Don't compress *.gz files on SDK 8. 2024-06-18 10:11:51 +08:00
Po Lu
82f0014273 Reinforce bitmap reconfiguration on Android
* java/org/gnu/emacs/EmacsView.java (EmacsView) <unswapped>: New
field in which to record whether the back buffer has received
contents beyond those present at the last buffer swap.
<dimensionsLock>: Delete field.
(onAttachedToWindow, onLayout, handleDirtyBitmap)
(prepareForLayout): Rather, synchronize window dimensions with
the view.
(getCanvas, getBitmap): Do not reconfigure the back buffer
bitmap if such outstanding data exists.
(postSwapBuffers): New function.
(swapBuffers): If such outstanding data exists and the back
bufferis pending reconfiguration, recreate the back buffer and
report exposure.

* src/androidterm.c (handle_one_android_event): Fix indentation.
2024-06-17 17:45:48 +08:00
Stefan Kangas
c0eefebabf ; Fix typos 2024-06-16 22:38:26 +02:00
Po Lu
a39f6480ea Minor adjustments to battery.el on Android
* src/android.c (android_query_battery):

* java/org/gnu/emacs/EmacsService.java (queryBattery19)
(queryBattery): Reorder items in value for consistency with
Fandroid_query_battery.

* lisp/battery.el (battery-status-function): Select
battery-android only when android-query-battery is present.
(battery-android): Return temperature and correct values of
power source constants.
2024-06-16 15:28:54 +08:00
Po Lu
8d60b6bab8 Simplify bitmap reallocation on Android
* java/org/gnu/emacs/EmacsView.java: Update outdated commentary.
(handleDirtyBitmap): Don't copy contents of the previous bitmap
to the new.
(onLayout): Unconditionally expose upon layout changes.
2024-06-16 11:35:44 +08:00
Po Lu
6d64cf5ee1 Restore omitted dependency
* java/Makefile.in (install_temp): Depend on
$(libsrc)/asset-directory-tool.
2024-06-12 17:03:00 +08:00
Po Lu
02e70821b3 Restore functionality on Android 2.2
* java/Makefile.in (install_temp): Do not compress
directory-tree and generate such files in a special format that
stores file sizes.

* lib-src/asset-directory-tool.c (struct directory_tree): New
field st_size.
(need_file_size): New variable.
(main_1, main_2, main): Write file sizes before sibling offsets
if `--api-8' is specified.

* src/android-asset.h (struct android_asset_manager): New field
open.
(struct android_asset): New field name.
(AAssetManager_fromJava): Load AssetManager#open.
(AAssetManager_open): If a directory tree has already been
loaded, search for a matching asset and load its size thence, to
avoid the requirement of an AssetFileDescriptor.
(AAsset_close): Don't assume asset->fd exists.  Release
asset->name.
(AAsset_getLength): Likewise.
(android_asset_create_stream): If asset->name exists, call
AssetManager#open, in order to open compressed files.

* src/androidvfs.c (OLD_ANDROID_ASSETS): Define to 1 on API 8.
(android_extract_long, android_scan_directory_tree): Mark
arguments as const.  Adjust offsets when OLD_ANDROID_ASSETS.
(android_is_directory, android_init_assets, android_afs_readdir):
Likewise.

* src/lread.c (lread_fstat): Define to sys_fstat, not fstat.
2024-06-12 16:44:21 +08:00
Po Lu
f543ec18f4 ; * java/Makefile.in: Fix typo. 2024-06-12 13:59:08 +08:00
Po Lu
5fc75b051f Improve compression of Emacs packages on Android 2.2
* configure.ac (ZIP): Search for a `zip' executable and
substitute the same if targeting SDK 8.

* java/INSTALL: Document new requirement.

* java/Makefile.in (GZIP_PROG, ZIP): New substitutions.
(.PHONY): Delete references to directory-tree.

(install_temp): On SDK 8 and earlier, compress large *.el and
Info files with gzip, and divide install_temp into three
separate directories, with one for large files, another for
gzipped files, and one more for the remainder.
(install_temp/assets/directory-tree, install_temp/assets/version)
(install_temp/assets/build_info): Merge these rules into
install_tmp, that they may execute before the assets directory
is split.
(emacs.apk-in): Package each directory separately, accounting
for their varied compression requirements.

* lisp/term/android-win.el (input-decode-map): Define select to
return in input-decode-map.
2024-06-12 13:52:33 +08:00
Po Lu
677f082b0f Eliminate some redundant synchronization on Android
* java/org/gnu/emacs/EmacsService.java (resetIC): Return on all
versions of Android if the connection need not be reset.

* java/org/gnu/emacs/EmacsView.java (getICMode, setICMode):
Remove needless synchronization.
2024-06-11 14:40:55 +08:00
Po Lu
f1c9a32a23 Eliminate Makefile race
* java/Makefile.in (cf-stamp): Don't separately depend on
NDK_BUILD_SHARED, as this renders make liable to descend into
cross/ndk-build twice in different processes.
(clean): Don't remove nonexistent file.
2024-06-07 21:39:01 +08:00
Po Lu
43826a9109 ; * java/INSTALL (LIBRSVG): Typo. 2024-06-07 20:39:47 +08:00
Po Lu
7052654515 Document compilation of librsvg on Android
* java/INSTALL (LIBRSVG): New section.
(BUILDING WITH OLD NDK VERSIONS): Update recommended invocation
of configure in the case of a combined toolchain.
2024-06-07 20:39:46 +08:00
Po Lu
0467b756aa * java/AndroidManifest.xml.in: Revert portions of last change. 2024-06-06 09:16:03 +08:00
Paul Eggert
3dcac22dd4 Spelling fixes 2024-06-04 22:16:28 -07:00
Po Lu
2a699edbe5 Provide additional Android metadata
* java/AndroidManifest.xml.in: Enable preserving user data
beyond uninstallation, restarting activities without persiting
state, increase maximum number of simultaneously open
activities, and provide a sensible category.
2024-06-04 10:23:13 +08:00
Po Lu
d812e94dde Enable downgrading between this and future releases of Emacs
* java/AndroidManifest.xml.in: Fix `versionCode' at 30.
2024-06-04 10:03:01 +08:00
Po Lu
253b1d6ee8 Trim redundancies from EmacsTileObject
* java/org/gnu/emacs/EmacsTileObject.java (EmacsTileObject)
<colorFilter>: Delete unused field.
<paint>: Qualify as `static'.
2024-06-02 16:37:39 +08:00
Po Lu
e96e4906c8 Work around one Android bug and document another
* etc/PROBLEMS (Runtime problems specific to Android): Document
deficiency of "Android Keyboard (AOSP)."

* java/org/gnu/emacs/EmacsView.java (showOnScreenKeyboard):
Revert yesterday's change.

* java/org/gnu/emacs/EmacsWindow.java (toggleOnScreenKeyboard):
Sync with the UI thread after displaying the on-screen keyboard.
2024-05-23 17:46:48 +08:00
Po Lu
70effed88d Improve compatibility with Android's default text editor
* java/org/gnu/emacs/EmacsView.java (showOnScreenKeyboard):
Request a selection update if `inputConnection' has been
established, to more closely emulate the OS text editing widget.
(onCreateInputConnection) [EmacsService.DEBUG_IC]: Print current
selection values before reporting them.
2024-05-22 22:00:26 +08:00
Po Lu
8dc00dc222 Housekeeping around androidselect.c
* java/org/gnu/emacs/EmacsClipboard.java (setClipboard)
(getClipboard):

* java/org/gnu/emacs/EmacsSdk11Clipboard.java (setClipboard)
(getClipboard):

* java/org/gnu/emacs/EmacsSdk8Clipboard.java (setClipboard)
(getClipboard): Save and return Strings rather than byte arrays.

* src/androidselect.c (android_init_emacs_clipboard)
(Fandroid_set_clipboard, Fandroid_get_clipboard): Adjust to
match.
2024-05-18 20:45:35 +08:00
Po Lu
9443f8145e Communicate frame titles to the window manager on Android
* java/org/gnu/emacs/EmacsActivity.java (detachWindow)
(attachWindow): Call updateWmName.
(updateWmName): New function; transfer wm name from the window
attached to the task's description.

* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
<wmName>: New field.
(setWmName): New function.

* src/android.c (android_init_emacs_window): Link to new
function.
(android_set_wm_name): New function.

* src/android.h (struct android_emacs_service): Delete unused
entries.

* src/androidfns.c (android_set_name_internal, android_set_name)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_title): Port from X.

* src/androidterm.c (android_term_init): Compute default frame
title.

* src/androidterm.h (struct android_display_info) <x_id_name>:
New field.
2024-05-13 14:42:35 +08:00
Po Lu
ea98a6af2f Additional changes to processing of Num Lock on Android
* java/org/gnu/emacs/EmacsView.java (onKeyDown, onKeyMultiple)
(onKeyDown): Disregard Num and Scroll Lock keys, and return
value of window functions to the system.

* java/org/gnu/emacs/EmacsWindow.java (eventModifiers): Return
normalized meta state, not only those bits the system considers
modifiers.
(onKeyDown, onKeyUp): Ignore numpad keys to which no base
characters are assigned, so that the system may generate the
proper action keys instead.
2024-05-12 15:49:53 +08:00
Po Lu
af6df8e045 Correct earlier changes to processing of Num Lock on Android
* java/org/gnu/emacs/EmacsWindow.java (onKeyDown, onKeyUp):
Cease stripping META_NUM_LOCK_ON and META_SCROLL_LOCK_ON from
meta masks reported to getUnicodeChar.
2024-05-12 15:49:53 +08:00
Po Lu
3ff83246c8 Delete unused functions
* java/org/gnu/emacs/EmacsNative.java (dup, close):

* src/android.c (dup, close): Delete functions no longer
referenced.
2024-05-11 14:34:32 +08:00
Po Lu
ea2b251ab2 Remove redundant encoding of strings in androidvfs.c
* java/org/gnu/emacs/EmacsService.java (getDocumentTrees):
Accept PROVIDER as a String.

* src/android.c (android_init_emacs_service):

* src/androidvfs.c (android_saf_root_opendir): Adjust to match.
2024-05-10 11:42:37 +08:00
Po Lu
c900c707e8 Fix earlier change to content URI resolution on Android
* java/org/gnu/emacs/EmacsService.java (openContentUri): Return
-1 if fd be NULL.

* src/androidvfs.c (android_authority_open): Detect
SecurityException and suchlike.
(android_vfs_init): Initialize exception classes on Android 4.4.
2024-05-10 09:05:54 +08:00
Po Lu
e020f4e9ce Fix hang after failed yank-media on Android
* java/org/gnu/emacs/EmacsClipboard.java (getClipboardTargets)
(getClipboardData):

* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(getClipboardTargets, getClipboardData):

* java/org/gnu/emacs/EmacsSdk8Clipboard.java
(getClipboardTargets, getClipboardData): Return string data as
Strings rather than byte arrays.

* src/androidselect.c (android_init_emacs_clipboard)
(Fandroid_get_clipboard_targets): Adjust to match.
(extract_fd_offsets): Remove duplicated semicolon.
(Fandroid_get_clipboard_data): Call unblock_input before
returning if extract_fd_offsets fails.
2024-05-08 16:03:49 +08:00
Po Lu
5bf4ff806b ; * java/org/gnu/emacs/EmacsTileObject.java: Fix copyright dates. 2024-05-06 17:23:57 +08:00
Po Lu
2f36fc1b4f Optimize stipples on Android
* java/org/gnu/emacs/EmacsGC.java (EmacsGC) <tileObject>:
Change type to EmacsTileObject.
(markDirty): Create an EmacsTileObject rather than a
BitmapDrawable.

* java/org/gnu/emacs/EmacsTileObject.java: New file,
significantly leaner than BitmapDrawable.
2024-05-06 12:09:21 +08:00
Po Lu
51791fd178 Fix inadvertent removal in EmacsWindow
* java/org/gnu/emacs/EmacsWindow.java (onKeyUp): Send KeyPress
events upon deferred KEYCODE_BACK.
2024-05-05 09:03:57 +08:00
Po Lu
41dd78cd36 Simplify handling of command-line arguments on Android
* java/org/gnu/emacs/EmacsActivity.java
(EXTRA_STARTUP_ARGUMENTS): New constant.
(onCreate): Read a string array, not a string extra from the
intent with this key.

* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
<fileToOpen>: Delete field.
(onCreate): Provide file name as a command line argument when
starting the Emacs service.

* java/org/gnu/emacs/EmacsPreferencesActivity.java (startEmacsQ)
(startEmacsDebugInit): In like manner, replace ad-hoc
command-line argument extra with a proper array.

* java/org/gnu/emacs/EmacsService.java (EmacsService): Rename
extraStartupArgument to extraStartupArguments, and change its
type to a string array.
(onCreate): Adjust to match.

* java/org/gnu/emacs/EmacsThread.java (EmacsThread)
<extraStartupArguments>: Ditto.
<fileToOpen>: Delete field.
(run): Adjust correspondingly.
2024-05-04 16:13:24 +08:00
Po Lu
139931fefb Simplify management of Android handle IDs
* java/org/gnu/emacs/EmacsCursor.java (EmacsCursor):

* java/org/gnu/emacs/EmacsGC.java (EmacsGC):

* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
Remove HANDLE argument to constructor.

* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):

* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow):

* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection) <windowHandle>: Change type to long.

* java/org/gnu/emacs/EmacsNative.java (EmacsNative)
(sendConfigureNotify, sendKeyPress, sendKeyRelease, sendFocusIn)
(sendFocusOut, sendWindowAction, sendEnterNotify)
(sendLeaveNotify, sendMotionNotify, sendButtonPress)
(sendButtonRelease, sendTouchDown, sendTouchUp, sendTouchMove)
(sendWheel, sendIconified, sendDeiconified, sendContextMenu)
(sendExpose, sendDndDrag, sendDndUri, sendDndText)
(beginBatchEdit, commitCompletion, endBatchEdit, commitText)
(deleteSurroundingText, finishComposingText, replaceText)
(getSelectedText, getTextAfterCursor, getTextBeforeCursor)
(setComposingText, setComposingRegion, setSelection)
(performEditorAction, performContextMenuAction, getExtractedText)
(requestSelectionUpdate, requestCursorUpdates, clearInputFlags)
(getSurroundingText, takeSnapshot, getSelection): Accept handles
as longs, rather than shorts.  All callers changed.

* java/org/gnu/emacs/EmacsService.java (queryTree): Return
handles as longs rather than shorts.
(viewGetSelection): Take long WINDOW, not short.

* src/android.c (struct android_emacs_handle): New structure.
(handle_class): New variable.
(android_init_emacs_service, android_init_emacs_pixmap)
(android_init_emacs_gc_class, android_init_emacs_cursor): Adjust
to match signature changes in constructors.
(android_init_emacs_handle): New function.
(initEmacs): Initialize the handle class, its fields and metods.
(sendConfigureNotify, sendKeyPress, sendKeyRelease, sendFocusIn)
(sendFocusOut, sendWindowAction, sendEnterNotify)
(sendLeaveNotify, sendMotionNotify, sendButtonPress)
(sendButtonRelease, sendTouchDown, sendTouchUp, sendTouchMove)
(sendWheel, sendIconified, sendDeiconified, sendContextMenu)
(sendExpose, sendDndDrag, sendDndUri, sendDndText): Update for
changes to handle type.
(android_alloc_id, android_resolve_handle)
(android_resolve_handle2): Remove functions; replace the second
with a macro that accepts one fewer argument.  All callers
changed.
(android_destroy_handle): Cease indexing the handle list for the
handle object.
(android_globalize_reference): New function.
(android_create_window, android_create_gc, android_create_pixmap)
(android_create_font_cursor): Call android_globalize_reference
to convert global references into handles.
(android_free_cursor, android_destroy_window): Cease verifying
the handle type.
(android_copy_area): Check destination object type rather than
handle entry.
(android_query_tree): Adjust for changes to return types.
(likely): Define __builtin_expect variant unconditionally.

* src/android.h (android_resolve_handle): New macro.

* src/androidgui.h (android_handle): Define to intptr_t.

* src/androidterm.c (deleteSurroundingText, finishComposingText)
(performEditorAction, performContextMenuAction, getExtractedText)
(getSelectedText, requestSelectionUpdate, requestCursorUpdates)
(clearInputFlags, getSurroundingText)
(android_get_surrounding_text_internal): Accept handles as
longs, not jshorts.
2024-05-04 11:36:09 +08:00