Pages

Monday, September 26, 2011

TravAlert Premium is finally launched!

I'm very pleased to say that the Premium version of TravAlert finally has hit the market. You can now monitor all your travian accounts and keep focus on whatever you do when you are not in front of the computer ;)

Don't miss the new widget that quickly switches the service on/off.


TravAlert Premium on Android Market

Using git + dropbox + eclipse on windows

Some time ago I suffered a hardware crash, and even more recently I thought I lost my computer. Two incidents that both kept me up all night thinking of what content I might have lost and what impact they may have.

Realizing I have some android-projects (like TravAlertLite and Premium) using git for version control, but only using local repo i.e. no back-up what so ever. I promise myself to make some backups the very next day or even better - use a remote repository to push to. But I don't have  a server.. Hey - why not use dropbox?
(signup using my referal invite and we both get 250MB bonus space)

So - let's get to the point..

  • you are using windows
  • you are using eclipse with egit
  • you have local repo of existing project
  • you have dropbox account (default install ~/Dropbox)


  1. Open dropbox folder and create suitable directory, say 'git/private_projects/'
  2. Open the bash in your local repo and
    $ git clone --bare . ~/Dropbox/git/private_projects/my_project.git
  3. Add this new clone as remote called 'dropbox'
    $ git remote add dropbox ~/Dropbox/git/private_projecs/my_project.git
  4. Open eclipse and you are now able to push from menu team>remote

Disclaimer
I have not fully tested this setup but it seem to work just fine for simple personal use, this is not a preferred professional setup.
I think it would work just fine among smaller teams where simultaneous pushes are less likely and also easily avoided.

I do not guarantee that this works nor do I take responsibility for consequences. I'm just sharing my thoughts and experimental experiences.

Tuesday, April 12, 2011

Android Launcher Icons Color Palette for Incscape

Since we are 'forced' to submit a 512x512 launcher icon when publishing apps I guess I'm not the only one thinking that a master vector icon would be handy.

I've made  a color palette for Inkscape with the recommended colors for launcher icons. Simply copy/paste this and save as Android.gpl and move it to your palette folder in Inkscape and it will be loaded as a selectable palette next time you start.

GIMP Palette
Name: Android Launcher Icons
Columns: 3
#
255 255 255     White (#FFFFFF)
  0   0   0    Black (#000000)
 64  64  64   Dark Gray (#404040)
128 128 128    Medium Gray (#808080)
191 191 191     Light Gray (#BFBFBF)
102 153 255     Light Blue (#6699FF)
 51 102 204    Medium Blue (#3366CC)
  0  51 153     Dark Blue (#003399)
153 204  51     Light Green (#99CC33)
  0 204   0     Medium Green (#00CC00)
102 153   0     Dark Green (#669900)
255 204   0     Light Orange (#FFCC00)
255 153   0     Medium Orange (#FF9900)
255 102   0     Dark Orange (#FF6600)
204   0   0     Red (#CC0000)



New vector based icon for TravAlert

Wednesday, April 6, 2011

In-app billing - first impressions

So finally Google has released in-app billing for the android market. It is also documented and bundled with a sample app to use for testing, learning and as a demo.

Here is my two cents on what I want to see in next in-app billing updade:

1:st cent Make it easier to test for the developer!

I have spent a night or three browsing the sample code (Dungeons!) and trying to make it work for me, only to be slapped by INTERNAL_SERVICE_ERROR each time I tried to buy something.

The error was far from internal and service related - in fact - it was I who had foreseen this little sentence:

"You cannot use your developer account to test the complete in-app purchase process because Google Checkout does not let you buy items from yourself."


So to be able to actually try the in-app billing I need to factory reset my phone - hook it to a different Google account - register VISA-credentials (Google checkout). Then - I can install my apk and try this new feature. Puh..

Now that I've done all this - I'll have to make a refund from the merchant account - or I've lost 30% to Google. This leads to ...

2:nd cent: Give us micro payments!
Minimum price is same as for apps: $.99 | .50€ | SEK 7:-
Thats pretty much for in-app payments - VISA can handle cents, it must be possible to divide in to 30% - so theoretically $.03 | €.03 | SEK 0:03 could be minimum -

Yeah, I'm ready to give Google that extra 3% for this ;)

Sunday, March 20, 2011

Including QR-reader in your app

Thanks to android intents, it is easy to include functionality from other apps to you own. Say for example you have an app that should be able to read QR-codes. You could easily call a barcode scanner to do the dirty work for you and just bother about the result.

Create a button that will launch Barcode Scanner from Zxing:
public Button.OnClickListener mScan = new Button.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.setPackage("com.google.zxing.client.android");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        startActivityForResult(intent, 0);
    }
};

Handle the callback for result:
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            // Handle successful scan
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
}

This is a raw copy/paste from the ZXING-project. Nothing that I can take credit for, but I have tested it and it works as a charm.

Yes, it requires the user to have the Barcode Scanner installed. This can be handled smoothly by calling url instead - if the barcoder is installed - it will launch - otherwise launch a web browser (with a install guide of course). Very nice!

Wednesday, March 16, 2011

Extract HTML from Android webview

Having a webview in android and wanting to fiddle with the HTML?

Injecting javascript in android webview

Its easy, make sure you have javascript enabled and simply load url containing javascript:
mBrowser = new WebView(context);
mBrowser.getSettings().setJavaScriptEnabled(true);
mBrowser.loadUrl("javascript:getElementById('ad_container').style.display='none');");

In most cases, you first want to load the actual web page, then inject the javascript - this is done by using a WebViewClient which overrides onPageFinished.

mBrowser.setWebViewClient(new WebViewClient() {
   @Override
   public void onPageFinished(WebView view, String url) {
      // check url
      if (SOME_WEBPAGE.equals(url) {
        loadUrl(JAVASCRIPT_CODE);
      }
   }
});
mBrowser.loadUrl(SOME_WEBPAGE);

Extracting HTML from Android webview

Taking it one step further - let's get HTML from a page and use it in our program. This is accomplished by using a JavascriptInterface with our webview.

mBrowser.getSettings().setJavaScriptEnabled();
// add javascript interface with example method
mBrowser.addJavaScriptInterface(new JavaScriptInterface() {
   public void setTitle(String html) {
      mTitle = html;
   }
}, "MY_JS");
// add webview client that calls javascript interface when page is loaded
mBrowser.addWebViewClient(new WebViewClient() {
   @Override
   public void onPageFinished(WebView view, String url) {
       view.loadUrl("javascript:window.MY_JS.setTitle(document.getElementsByTagName('title')[0].innerHTML);");
   }

mBrowser.loadUrl(SOME_WEBPAGE);

That's it - using the combination of WebVievClient and JavascriptInterface is very powerful - drawback is that I have not found an easy way of debugging javascript - if your javascript fails it will fail silent.

Nice thing is you can test your javascript on Firefox using Firebug on your main computer before adding code to your android project.