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;
}
});
+ if (allFiles == null)
+ return;
+
/* Now try to find the right dump file. */
for (i = 0; i < allFiles.length; ++i)
{
};
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;
}
item name. */
public EmacsContextMenu
- addSubmenu (String itemName, String title, String tooltip)
+ addSubmenu (String itemName, String tooltip)
{
EmacsContextMenu submenu;
Item item;
item.itemID = 0;
item.itemName = itemName;
item.tooltip = tooltip;
- item.subMenu = createContextMenu (title);
+ item.subMenu = createContextMenu ();
item.subMenu.parent = this;
menuItems.add (item);
final EmacsHolder<Boolean> rc;
rc = new EmacsHolder<Boolean> ();
+ rc.thing = false;
runnable = new Runnable () {
@Override
getNotificationUri (File file)
{
Uri updatedUri;
- Context context;
- context = getContext ();
updatedUri
= buildChildDocumentsUri ("org.gnu.emacs",
file.getAbsolutePath ());
{
MatrixCursor result;
File directory;
+ File[] files;
Context context;
if (projection == null)
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 ();
{
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 ();
Paint maskPaint, paint;
Canvas maskCanvas;
Bitmap maskBitmap;
- Rect rect;
Rect maskRect, dstRect;
Canvas canvas;
Bitmap clipBitmap;
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
/* 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,
+ 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
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,
cache = getCacheDir ();
file = new File (cache, "emacsclient.log");
- what = "";
+ builder = new StringBuilder ();
+ reader = null;
try
{
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 ());
}
/* 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);
}
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 ();
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
{
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;
{
super (view.getContext ());
- this.view = view;
this.bitmap = new WeakReference<Bitmap> (null);
}
/* The damage region. */
public Region damageRegion;
- /* The paint. */
- public Paint paint;
-
/* The associated surface view. */
private EmacsSurfaceView surfaceView;
this.window = window;
this.damageRegion = new Region ();
- this.paint = new Paint ();
setFocusable (true);
setFocusableInTouchMode (true);
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. */
}
}
- public void
+ public synchronized void
unmapWindow ()
{
if (!isMapped)
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 ();
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)
public synchronized void
setDontAcceptFocus (final boolean dontAcceptFocus)
{
- this.dontAcceptFocus = dontAcceptFocus;
-
/* Update the view's focus state. */
EmacsService.SERVICE.runOnUiThread (new Runnable () {
@Override
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 ();
public void destroy ();
};
+ /* List of currently attached window consumers. */
public List<WindowConsumer> consumers;
+
+ /* List of currently attached windows. */
public List<EmacsWindow> windows;
public
eassert (menu_class.c_name);
FIND_METHOD_STATIC (create_context_menu, "createContextMenu",
- "(Ljava/lang/String;)"
- "Lorg/gnu/emacs/EmacsContextMenu;");
+ "()Lorg/gnu/emacs/EmacsContextMenu;");
FIND_METHOD (add_item, "addItem", "(ILjava/lang/String;ZZZ"
"Ljava/lang/String;Z)V");
FIND_METHOD (add_submenu, "addSubmenu", "(Ljava/lang/String;"
- "Ljava/lang/String;Ljava/lang/String;)"
+ "Ljava/lang/String;)"
"Lorg/gnu/emacs/EmacsContextMenu;");
FIND_METHOD (add_pane, "addPane", "(Ljava/lang/String;)V");
FIND_METHOD (parent, "parent", "()Lorg/gnu/emacs/EmacsContextMenu;");
android_push_local_frame ();
/* Push the first local frame for the context menu. */
- title_string = (!NILP (title)
- ? (jobject) android_build_string (title)
- : NULL);
method = menu_class.create_context_menu;
current_context_menu = context_menu
= (*android_java_env)->CallStaticObjectMethod (android_java_env,
menu_class.class,
- method,
- title_string);
-
- if (title_string)
- ANDROID_DELETE_LOCAL_REF (title_string);
+ method);
/* Push the second local frame for temporaries. */
count1 = SPECPDL_INDEX ();
= (*android_java_env)->CallObjectMethod (android_java_env,
current_context_menu,
menu_class.add_submenu,
- title_string, NULL,
+ title_string,
help_string);
android_exception_check ();