1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-29 16:41:45 -08:00
emacs/java/org/gnu/emacs/EmacsMultitaskActivity.java
Po Lu 7df66b4762 Better align Emacs window management with Android task lifecycles
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Permit
overriding by child classes.
(onDestroy): Minor stylistic adjustments.
(getAttachmentToken): New function.

* java/org/gnu/emacs/EmacsMultitaskActivity.java (onCreate)
(getAttachmentToken): New functions.

* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow):
<attachmentToken, preserve, previouslyAttached>: New variables.
(onActivityDetached): Remove redundant isFinishing argument.
(reparentTo): Reset the foregoing fields before registering with
the window manager.

* java/org/gnu/emacs/EmacsWindowManager.java
(EmacsWindowManager): Rename from EmacsWindowAttachmentManager.
(WindowConsumer): New function getAttachmentToken.
(isWindowEligible): New function.
(registerWindowConsumer, registerWindow, removeWindowConsumer)
(detachWindow): Implement a new window management strategy on
API 29 and subsequent releases where both varieties of toplevel
window are permanently, except when reparented, bound to the
activities to which they attach, and Emacs establishes at
strategic junctures whether those activities remain present.
(getTaskToken, pruneWindows): New functions.
2024-04-03 20:31:22 +08:00

57 lines
1.6 KiB
Java

/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
Copyright (C) 2023-2024 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
package org.gnu.emacs;
import android.content.Intent;
import android.os.Bundle;
/* In large measure, this class only exists because EmacsActivity is
already defined as an activity, and the system requires that every
new activity be defined by a new class. */
public final class EmacsMultitaskActivity extends EmacsActivity
{
/* Token provided by the creator. */
private long activityToken;
@Override
public final void
onCreate (Bundle savedInstanceState)
{
Intent intent;
String token;
intent = getIntent ();
token = EmacsWindowManager.ACTIVITY_TOKEN;
if (intent != null)
activityToken = intent.getLongExtra (token, -2);
super.onCreate (savedInstanceState);
}
@Override
public final long
getAttachmentToken ()
{
return activityToken;
}
};