mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-06 11:50:51 -08:00
Update Android port
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): * java/org/gnu/emacs/EmacsApplication.java (findDumpFile): * java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu) (addSubmenu, display): * java/org/gnu/emacs/EmacsDocumentsProvider.java (getNotificationUri, queryChildDocuments, deleteDocument): * java/org/gnu/emacs/EmacsDrawRectangle.java (perform): * java/org/gnu/emacs/EmacsFillRectangle.java (perform): * java/org/gnu/emacs/EmacsOpenActivity.java (readEmacsClientLog) (checkReadableOrCopy): * java/org/gnu/emacs/EmacsSdk7FontDriver.java (EmacsSdk7FontDriver): * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): * java/org/gnu/emacs/EmacsView.java (EmacsView): * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, onKeyUp): * java/org/gnu/emacs/EmacsWindowAttachmentManager.java (EmacsWindowAttachmentManager): Remove various unused arguments and variables, dead stores, and make minor cleanups and performance improvements. * src/androidmenu.c (FIND_METHOD_STATIC, android_menu_show): Adjust accordingly.
This commit is contained in:
parent
7f0342a1bd
commit
377a3ebbb5
13 changed files with 73 additions and 60 deletions
|
|
@ -55,7 +55,7 @@ public class EmacsActivity extends Activity
|
|||
private FrameLayout layout;
|
||||
|
||||
/* List of activities with focus. */
|
||||
public static List<EmacsActivity> focusedActivities;
|
||||
public static final List<EmacsActivity> focusedActivities;
|
||||
|
||||
/* The last activity to have been focused. */
|
||||
public static EmacsActivity lastFocusedActivity;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ public final class EmacsApplication extends Application
|
|||
}
|
||||
});
|
||||
|
||||
if (allFiles == null)
|
||||
return;
|
||||
|
||||
/* Now try to find the right dump file. */
|
||||
for (i = 0; i < allFiles.length; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -131,20 +131,18 @@ public final class EmacsContextMenu
|
|||
};
|
||||
|
||||
public List<Item> menuItems;
|
||||
public String title;
|
||||
private EmacsContextMenu parent;
|
||||
|
||||
/* Create a context menu with no items inside and the title TITLE,
|
||||
which may be NULL. */
|
||||
|
||||
public static EmacsContextMenu
|
||||
createContextMenu (String title)
|
||||
createContextMenu ()
|
||||
{
|
||||
EmacsContextMenu menu;
|
||||
|
||||
menu = new EmacsContextMenu ();
|
||||
menu.menuItems = new ArrayList<Item> ();
|
||||
menu.title = title;
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
|
@ -197,7 +195,7 @@ public final class EmacsContextMenu
|
|||
item name. */
|
||||
|
||||
public EmacsContextMenu
|
||||
addSubmenu (String itemName, String title, String tooltip)
|
||||
addSubmenu (String itemName, String tooltip)
|
||||
{
|
||||
EmacsContextMenu submenu;
|
||||
Item item;
|
||||
|
|
@ -206,7 +204,7 @@ public final class EmacsContextMenu
|
|||
item.itemID = 0;
|
||||
item.itemName = itemName;
|
||||
item.tooltip = tooltip;
|
||||
item.subMenu = createContextMenu (title);
|
||||
item.subMenu = createContextMenu ();
|
||||
item.subMenu.parent = this;
|
||||
|
||||
menuItems.add (item);
|
||||
|
|
@ -334,6 +332,7 @@ public final class EmacsContextMenu
|
|||
final EmacsHolder<Boolean> rc;
|
||||
|
||||
rc = new EmacsHolder<Boolean> ();
|
||||
rc.thing = false;
|
||||
|
||||
runnable = new Runnable () {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -131,9 +131,7 @@ public final class EmacsDocumentsProvider extends DocumentsProvider
|
|||
getNotificationUri (File file)
|
||||
{
|
||||
Uri updatedUri;
|
||||
Context context;
|
||||
|
||||
context = getContext ();
|
||||
updatedUri
|
||||
= buildChildDocumentsUri ("org.gnu.emacs",
|
||||
file.getAbsolutePath ());
|
||||
|
|
@ -294,6 +292,7 @@ public final class EmacsDocumentsProvider extends DocumentsProvider
|
|||
{
|
||||
MatrixCursor result;
|
||||
File directory;
|
||||
File[] files;
|
||||
Context context;
|
||||
|
||||
if (projection == null)
|
||||
|
|
@ -305,9 +304,15 @@ public final class EmacsDocumentsProvider extends DocumentsProvider
|
|||
requested. */
|
||||
directory = new File (parentDocumentId);
|
||||
|
||||
/* Now add each child. */
|
||||
for (File child : directory.listFiles ())
|
||||
queryDocument1 (result, child);
|
||||
/* Look up each child. */
|
||||
files = directory.listFiles ();
|
||||
|
||||
if (files != null)
|
||||
{
|
||||
/* Now add each child. */
|
||||
for (File child : files)
|
||||
queryDocument1 (result, child);
|
||||
}
|
||||
|
||||
context = getContext ();
|
||||
|
||||
|
|
@ -406,12 +411,10 @@ public final class EmacsDocumentsProvider extends DocumentsProvider
|
|||
{
|
||||
File file, parent;
|
||||
File[] children;
|
||||
Context context;
|
||||
|
||||
/* Java makes recursively deleting a file hard. File name
|
||||
encoding issues also prevent easily calling into C... */
|
||||
|
||||
context = getContext ();
|
||||
file = new File (documentId);
|
||||
parent = file.getParentFile ();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ public final class EmacsDrawRectangle
|
|||
Paint maskPaint, paint;
|
||||
Canvas maskCanvas;
|
||||
Bitmap maskBitmap;
|
||||
Rect rect;
|
||||
Rect maskRect, dstRect;
|
||||
Canvas canvas;
|
||||
Bitmap clipBitmap;
|
||||
|
|
@ -52,7 +51,6 @@ public final class EmacsDrawRectangle
|
|||
|
||||
paint = gc.gcPaint;
|
||||
paint.setStyle (Paint.Style.STROKE);
|
||||
rect = new Rect (x, y, x + width, y + height);
|
||||
|
||||
if (gc.clip_mask == null)
|
||||
/* Use canvas.drawRect with a RectF. That seems to reliably
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public final class EmacsFillRectangle
|
|||
/* Drawing with a clip mask involves calculating the
|
||||
intersection of the clip mask with the dst rect, and
|
||||
extrapolating the corresponding part of the src rect. */
|
||||
|
||||
clipBitmap = gc.clip_mask.bitmap;
|
||||
dstRect = new Rect (x, y, x + width, y + height);
|
||||
maskRect = new Rect (gc.clip_x_origin,
|
||||
|
|
@ -69,7 +70,6 @@ public final class EmacsFillRectangle
|
|||
+ clipBitmap.getWidth ()),
|
||||
(gc.clip_y_origin
|
||||
+ clipBitmap.getHeight ()));
|
||||
clipBitmap = gc.clip_mask.bitmap;
|
||||
|
||||
if (!maskRect.setIntersect (dstRect, maskRect))
|
||||
/* There is no intersection between the clip mask and the
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ public final class EmacsOpenActivity extends Activity
|
|||
FileReader reader;
|
||||
char[] buffer;
|
||||
int rc;
|
||||
String what;
|
||||
StringBuilder builder;
|
||||
|
||||
/* Because the ProcessBuilder functions necessary to redirect
|
||||
process output are not implemented on Android 7 and earlier,
|
||||
|
|
@ -160,7 +160,8 @@ public final class EmacsOpenActivity extends Activity
|
|||
|
||||
cache = getCacheDir ();
|
||||
file = new File (cache, "emacsclient.log");
|
||||
what = "";
|
||||
builder = new StringBuilder ();
|
||||
reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -168,13 +169,25 @@ public final class EmacsOpenActivity extends Activity
|
|||
buffer = new char[2048];
|
||||
|
||||
while ((rc = reader.read (buffer, 0, 2048)) != -1)
|
||||
what += String.valueOf (buffer, 0, 2048);
|
||||
builder.append (buffer, 0, rc);
|
||||
|
||||
reader.close ();
|
||||
return what;
|
||||
return builder.toString ();
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
/* Close the reader if it's already been opened. */
|
||||
|
||||
try
|
||||
{
|
||||
if (reader != null)
|
||||
reader.close ();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
/* Not sure what to do here. */
|
||||
}
|
||||
|
||||
return ("Couldn't read emacsclient.log: "
|
||||
+ exception.toString ());
|
||||
}
|
||||
|
|
@ -248,11 +261,16 @@ public final class EmacsOpenActivity extends Activity
|
|||
/* inFile is now the file being written to. */
|
||||
inFile = new File (getCacheDir (), inFile.getName ());
|
||||
buffer = new byte[4098];
|
||||
outStream = new FileOutputStream (inFile);
|
||||
stream = new FileInputStream (fd.getFileDescriptor ());
|
||||
|
||||
/* Initialize both streams to NULL. */
|
||||
outStream = null;
|
||||
stream = null;
|
||||
|
||||
try
|
||||
{
|
||||
outStream = new FileOutputStream (inFile);
|
||||
stream = new FileInputStream (fd.getFileDescriptor ());
|
||||
|
||||
while ((read = stream.read (buffer)) >= 0)
|
||||
outStream.write (buffer, 0, read);
|
||||
}
|
||||
|
|
@ -263,8 +281,12 @@ public final class EmacsOpenActivity extends Activity
|
|||
Keep in mind that execution is transferred to ``finally''
|
||||
even if an exception happens inside the while loop
|
||||
above. */
|
||||
stream.close ();
|
||||
outStream.close ();
|
||||
|
||||
if (stream != null)
|
||||
stream.close ();
|
||||
|
||||
if (outStream != null)
|
||||
outStream.close ();
|
||||
}
|
||||
|
||||
return inFile.getCanonicalPath ();
|
||||
|
|
|
|||
|
|
@ -252,6 +252,10 @@ public class EmacsSdk7FontDriver extends EmacsFontDriver
|
|||
systemFontsDirectory = new File ("/system/fonts");
|
||||
|
||||
fontFamilyList = systemFontsDirectory.list ();
|
||||
|
||||
/* If that returned null, replace it with an empty array. */
|
||||
fontFamilyList = new String[0];
|
||||
|
||||
typefaceList = new Sdk7Typeface[fontFamilyList.length + 3];
|
||||
|
||||
/* It would be nice to avoid opening each and every font upon
|
||||
|
|
|
|||
|
|
@ -39,10 +39,6 @@ public final class EmacsSurfaceView extends View
|
|||
{
|
||||
private static final String TAG = "EmacsSurfaceView";
|
||||
|
||||
/* The EmacsView representing the window that this surface is
|
||||
displaying. */
|
||||
private EmacsView view;
|
||||
|
||||
/* The complete buffer contents at the time of the last draw. */
|
||||
private Bitmap frontBuffer;
|
||||
|
||||
|
|
@ -71,7 +67,6 @@ public final class EmacsSurfaceView extends View
|
|||
{
|
||||
super (view.getContext ());
|
||||
|
||||
this.view = view;
|
||||
this.bitmap = new WeakReference<Bitmap> (null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ public final class EmacsView extends ViewGroup
|
|||
/* The damage region. */
|
||||
public Region damageRegion;
|
||||
|
||||
/* The paint. */
|
||||
public Paint paint;
|
||||
|
||||
/* The associated surface view. */
|
||||
private EmacsSurfaceView surfaceView;
|
||||
|
||||
|
|
@ -128,7 +125,6 @@ public final class EmacsView extends ViewGroup
|
|||
|
||||
this.window = window;
|
||||
this.damageRegion = new Region ();
|
||||
this.paint = new Paint ();
|
||||
|
||||
setFocusable (true);
|
||||
setFocusableInTouchMode (true);
|
||||
|
|
|
|||
|
|
@ -103,11 +103,10 @@ public final class EmacsWindow extends EmacsHandleObject
|
|||
public int lastButtonState, lastModifiers;
|
||||
|
||||
/* Whether or not the window is mapped. */
|
||||
private boolean isMapped;
|
||||
private volatile boolean isMapped;
|
||||
|
||||
/* Whether or not to ask for focus upon being mapped, and whether or
|
||||
not the window should be focusable. */
|
||||
private boolean dontFocusOnMap, dontAcceptFocus;
|
||||
/* Whether or not to ask for focus upon being mapped. */
|
||||
private boolean dontFocusOnMap;
|
||||
|
||||
/* Whether or not the window is override-redirect. An
|
||||
override-redirect window always has its own system window. */
|
||||
|
|
@ -464,7 +463,7 @@ public final class EmacsWindow extends EmacsHandleObject
|
|||
}
|
||||
}
|
||||
|
||||
public void
|
||||
public synchronized void
|
||||
unmapWindow ()
|
||||
{
|
||||
if (!isMapped)
|
||||
|
|
@ -618,7 +617,7 @@ public final class EmacsWindow extends EmacsHandleObject
|
|||
onKeyUp (int keyCode, KeyEvent event)
|
||||
{
|
||||
int state, state_1;
|
||||
long time, serial;
|
||||
long time;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
state = event.getModifiers ();
|
||||
|
|
@ -645,12 +644,11 @@ public final class EmacsWindow extends EmacsHandleObject
|
|||
state_1
|
||||
= state & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK);
|
||||
|
||||
serial
|
||||
= EmacsNative.sendKeyRelease (this.handle,
|
||||
event.getEventTime (),
|
||||
state, keyCode,
|
||||
getEventUnicodeChar (event,
|
||||
state_1));
|
||||
EmacsNative.sendKeyRelease (this.handle,
|
||||
event.getEventTime (),
|
||||
state, keyCode,
|
||||
getEventUnicodeChar (event,
|
||||
state_1));
|
||||
lastModifiers = state;
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
|
||||
|
|
@ -1155,8 +1153,6 @@ public final class EmacsWindow extends EmacsHandleObject
|
|||
public synchronized void
|
||||
setDontAcceptFocus (final boolean dontAcceptFocus)
|
||||
{
|
||||
this.dontAcceptFocus = dontAcceptFocus;
|
||||
|
||||
/* Update the view's focus state. */
|
||||
EmacsService.SERVICE.runOnUiThread (new Runnable () {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -53,9 +53,11 @@ import android.util.Log;
|
|||
|
||||
public final class EmacsWindowAttachmentManager
|
||||
{
|
||||
public static EmacsWindowAttachmentManager MANAGER;
|
||||
private final static String TAG = "EmacsWindowAttachmentManager";
|
||||
|
||||
/* The single window attachment manager ``object''. */
|
||||
public static final EmacsWindowAttachmentManager MANAGER;
|
||||
|
||||
static
|
||||
{
|
||||
MANAGER = new EmacsWindowAttachmentManager ();
|
||||
|
|
@ -69,7 +71,10 @@ public final class EmacsWindowAttachmentManager
|
|||
public void destroy ();
|
||||
};
|
||||
|
||||
/* List of currently attached window consumers. */
|
||||
public List<WindowConsumer> consumers;
|
||||
|
||||
/* List of currently attached windows. */
|
||||
public List<EmacsWindow> windows;
|
||||
|
||||
public
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue