Monday, May 24, 2010

Eclipse plugin installation with Proxoid on G1

I had figured I'd just be browsing via the tether but then I discovered that I needed another Eclipse plugin. Setting Eclipse to use the proxy was simple enough. I use Proxoid on the G1 and adb on my computer just like I did in my previous tethering post. Rather than start Eclipse with a proxy configured, I adjusted the Eclipse preferences to use the proxy. The risk of adjusting the preferences is that when I'm in the office, I'll forget that I had configured the proxy - my memory for trivial stuff is really that bad.

Eclipse -> Preferences... | General -> Network Connections

You have to change the drop-down the Manual before you can edit the HTTP and HTTPS proxies. Since I have adb mapping 8080 for the proxy, that's what I am using in this proxy. Once the proxy is set in Network Connections, plugins installed through regular means.

Good Stuff.

Network Connections for All
I had to install the 1.6 platform so I could create a new app for my phone. Since the Android plugin manages the platform and API installations, I wasn't real confident that the Network Connections proxy would get used. I was pleased to find that Network Connections does affect the ADT properly - I'm somewhere in Iowa between Des Moines and Council Bluffs and getting the platform.

tethered via G1, Proxoid, and Chrome

It is great to hear that tethering will be part of the OS on future phones. For now, tethering isn't too bad - the worst bit is getting the Android SDK installed if you don't have it already.

Proxoid app on G1
My G1 is using Android OS 1.6 and I doubt it will ever get the 2.x line. There are probably a bunch of tethering apps but the one I downloaded was Proxoid. When you open Proxoid, there is basically just an option to change ports and then a start / stop button. It crashed once but otherwise it appears reliable. When I was to tether my computer, I open Proxoid and click Start.

Android SDK
I assume that all tethering is the same: you start the proxy app on the phone and then use adb from the Android SDK to forward some TCP port on the computer to a port on the phone. Download and install the latest Android SDK and then add the tools directory to your PATH.

I forward TCP port 8080 on my computer to port 8080 on the phone. Port 8080 is currently the default port that Proxoid uses on the phone.
adb forward tcp:8080 tcp:8080

Chrome browsing
It isn't necessary to use Chrome but it is easy to open Chrome using a proxy and not have to change any settings. You could easily do this with FF or Safari if there is a command-line option to use a proxy or if you find the proper configuration settings.

/Applications/Google\\ Chrome --proxy-server=localhost:8080

Tuesday, May 04, 2010

touchstart and touchmove

For the most part, HTML5 apps test comparably in Safari and on the iPad. One difference that really jumps out is the touch events that the iPad / iPhone implements. My application initially bound events to the click event but I noticed a delay in the iPad so I switched over to the touchstart event. When the application is running in iPad / iPhone, the whole canvas is draggable and looks crappy.

From reading blogs and SO, it seems like the delay in onClick is intentional in iPhone / iPad because the browser (UIWebView, in this case) is waiting to see if there is going to be a gesture. That makes sense to me so any cases where I had a .click I changed to a .bind(clickevent. I set clickevent = click by default but override with clickevent = touchstart when on iPhone / iPad.

In the image below, you can see a big gray space - thats from clicking and dragging the screen down. After implementing the event.preventDefault the view can no longer be dragged down.

$ git diff HTML/main.js
diff --git a/HTML/main.js b/HTML/main.js
index 4e7661b..5bceab2 100644
--- a/HTML/main.js
+++ b/HTML/main.js
@@ -23,6 +23,14 @@ if(window.Touch) {
clickevent = 'touchstart';

+// TODO - can combine with other iPad / iPhone checks but keeping separate
+// for now just to make it stand out
+if(window.Touch) {
+ document.ontouchmove = function(event) {
+ event.preventDefault();
+ }
beforeSend: function(xhr) { xhr.setRequestHeader("Emsauthtoken",localStorag
cache: false,