jackpal/Android-Terminal-Emulator — pull request #113 by steven676 (2012-05-13 05:53:59+00:00)
Title: EmulatorView library bugfixes and API improvements, focus bugfixes

This patch series contains a number of fixes to bugs in the EmulatorView library and improvements in the API uncovered by the work on the sample library-using app, and also a small fix to input focus in the main Terminal Emulator app.

Patches 1 and 2 address input focus bugs in Android Terminal Emulator on Honeycomb and later when the action bar is showing.

Patches 3-5 make the library API match the documentation, allowing the use of EmulatorView and TermSession without calling setColorScheme() first and allowing the initialization of EmulatorView and TermSession at different times.

Patch 6 makes EmulatorView request input focus when clicked on by default. Previously, there was no way for the user to have EmulatorView request focus -- not a problem when EmulatorView is the only view visible (as in Android Terminal Emulator), but more of a problem with more complex layouts.

Patch 7 scales the default font size with screen density, to avoid the problem of needing to call setTextSize() to get reasonably-sized text on high-density displays.

Patches 8-10 deal with the I/O threads, and together probably carry the most risk to the main Terminal Emulator app. Patch 8 moves writes to the terminal OutputStream in TermSession off the main thread, to allow use of network sockets as OutputStreams on Honeycomb and later. Patch 9 renames the threads so that users looking at the VM can easily identify them as ours, and patch 10 ensures that the reader and writer threads shut down when finish() is called (by closing the attached InputStream and OutputStream).

Patches 11-13 make changes in the API of TermSession to make it easier to use. They provide processInput() and write(byte, int, int) methods which function as placeholders which subclasses can override to easily modify the stream of bytes coming into and out of the terminal, and clarify the function of the existing appendToEmulator() API to distinguish it from processInput().

Patch 14 rips out code in TerminalEmulator which writes directly to the terminal OutputStream and replaces it with calls to TermSession's write() instead, ensuring that subclass implementations of write() see this data.

Patch 15 improves the documentation of TermSession, noting the use of threads and offering a few additional hints on the use of the class.

Patch 16 updates the generated HTML documentation for the library.

Tested on the 1.5, 2.0, 2.2, 2.3.7/x86, 3.0/arm and 4.0.3/arm emulators and on a Nexus S running 4.0.3. The threading changes could really use some testing on a multi-core device, though.