Friday, November 25, 2011

Android 2.3.7 on HTC myTouch3G

After a lot of time I could compile the cyanogenmod 7 for my phone (HTC myTouch 3G). It may be buggy or slow, but as a true nerd I do not care. It is something that you do because you can. So I am happy now.
Oh.. just saying is not perfect but anyhow I'm happy.
The video is very slow because video is captured through the adb. When the phone disconnected to the screen capture software it is "faster".

My broken droid

For all of you that have tried to compile the Android source code and run into a LOT OF ERRORS. Somehow "fix it" then another arises, "fix again" and then another.... And of course most of the fixes are commenting a line or skipping building certain module.
After searching the Internet, there are a lot of people that runs in same problems that i do. Some shows success after a while others (like me) decided to join forces between the head and the keyboard to see what comes out of it. Most of the time this solution only produces a headache.
Anyhow in the name of all us nerds that have very old phones and just for the fun of it want to port the latest version of Android to it. Please make the source building process a little easier. I have no solution since I am no expert so do not know what can be done. But there are smart people out there that can make this better and easier.
If you are like me trying to build this yourself for your phone, go ahead continue trying. I believe there is a small chance of success and you can achieve it.
Finished this post, lets get back to my crusade and see what's comes out of it.

Thursday, November 17, 2011

Trouble downloading Android Source code

After a lot of time without being unable to sync any git repository, with a unable to get https helper error message. I encountered with a blog post that suggested to upgrade git. So look no more on the web, update and build from source your git. After retry, if problem is not fixed then start searching again on the web. Check out this link to upgrade your git http://www.barregren.se/blog/how-install-git-source-ubuntu I have Ubuntu and had the git from the Ubuntu repository (you know the one you get with apt-get) well forget about it. Go ahead get the version directly from source and build/install. It is better that way, at least in my case it fixed it all. Now I am a happy camper, trying to build android from source for my old phone, oh yes!

Tuesday, November 8, 2011

How to use a WebView and navigate inside it

As you may know Android provides the WebView control that allows you to show a web page inside your activity very nice. Just drag & drop from the "designer" into your Activity and that's it.
Ok, but after placing your WebView you notice that when you click in one link it opens the default web browser and bye bye your app.
Well to keep the navigation in your app. Check this snipped.

public class WebActivity extends Activity {
 public final static String URL = "URL";
 private WebView mWebClient;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.web_navigation);

  mWebClient = (WebView)this.findViewById(R.id.webViewSpace);

  Bundle bundle = this.getIntent().getExtras();
  String url = bundle.getString(URL);
  
//Next line to make continue navigating inside our WebView
  mWebClient.setWebViewClient(new WebViewClient(){

   @Override
   public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
   }
  });  

  mWebClient.loadUrl(url);
 }
}

To avoid loading the page in other activity just neeeeds to extends a WebViewClient, in here I just created an anonymous class cause I'm lazzy but you may extend in a formal class and do stuff like filter only your site trafic, and any other let the browser manage.


Saturday, October 29, 2011

QR URL - Mi primer Chrome Extension

Nuevo dia, nueva aplicación. Me pregunte, que hago? que quiero aprender? Hacia tiempo estaba curioso con las extensiones de Chrome. Pues dije: "Sabes que seria bueno, un boton al lado del URL que cuando le de vea un QR code de la dirección que tengo en pantalla". Que tal, luego de algunas busquedas atravez del todo sabio Google, me encontre con que esto no era algo complejo. Así que ni corto ni perezoso emprendí manos a la obra. Al cabo de un ratito ya funcionaba y sin mas ni menos lo publique en el WebStore de Chrome. La extensión se llama QR URL y puedes encontrarlo en el siguiente link: https://chrome.google.com/webstore/detail/nppbdeifhmhjlahlcplebmeklianffba?hl=en&gl=001

Ahora para los blogueros curiosos como yo, aquí el como funciona.
En el web hay muchos tutoriales y ejempos de como se hace una extensión para Chrome y la complejidad depende mucho de cuanto quieres hacer. No tengo el conocimiento suficiente como para escribir un tutorial así que mejor lo dejo los que saben. Por ahora la meta es romper el hielo en esto de las extensiones de Chrome así que vamos poco a poco.
Requerimientos:
1. Boton en el lado de la barra con la direccion web de chrome que cuando le de con el boton muestre un QR code con la direccion de la pagina actual.

Herramientas:
1. API publico para generar QR Codes disponible en http://zxing.appspot.com/generator/
2. Cualquier editor de texto.

Componentes:
Una extensión de chrome cuenta al menos de un archivo, en este caso son tres. Todo va a depender de la funcionalidad y la organizacion que desees.
Listado de archivos:
1. Icon.png ==> Imagen de 19x19 que se ve en el browser)
2. manifest.json ==> Contiene la información básica de la extensión así como el nombre del archivo para usar como icono y el nombre del archivo html que se encarga de mostrar el QR Code.
2. popup.html ==> Codigo en html que lee la dirección web actual y muestra la imagen.

Para crear esta extensión crear archivo manifest.json con el siguiente contenido. Como puedes ver es solo una descripción, los permisos y el icono que muestra.
manifest.json

{
  "name": "QR URL",
  "version": "1.0",
  "description": "Show current web URL as a QRCode so you may scan with your mobile device.",
  "browser_action": {
    "default_icon": "icon.png",
    "popup": "popup.html"
  },
  "permissions": [
    "http://chart.apis.google.com/",
    "tabs"
  ]
}


Crear archivo de popup.html (puedes cambiar el nombre solo recuerda cambiar la referencia a en el manifest.json. Como puedes ver en este archivo es simplemente leer el URL que esta en la pagina actual, concatenarle el link del web API que genera la imagen y cambiar la fuentre de la imagen definida en el <body> para que apunte a la imagen del QR Code generado por el web API.
Es una pagina html cualquiera donde tiene al principio unos estilos definidos para body y img. Pudieran crear un style sheet para esto si desean pero como es tan simple por que hacerlo. Ademas tome la idea de uno de los ejemplos y lo tenia ahí así que se quedo ahí con un cambio mínimo.
En la parte de <script> es que esta la acción. la función chrome.tabs.getSelected es la que nos permite traer la dirección actual. El primer argumento se deja null ya que queremos la ventana actual y el segundo argumento es una función que se usa como callback donde en el parámetro nos llega el "tab" que esta actualmente activo. De este "tab" es de donde obtenemos la direccion llamando tab.url. Luego solamente concatenas la dirección del web API a este url y se materializa una imagen con el QRCode. 
popup.html

<style>

body {

  min-width:150px;  

  overflow-x:hidden;

}

img {

  margin:5px;

  border:0px solid black;

  vertical-align:middle;

}

</style>

<script>

  chrome.tabs.getSelected(null, function(tab) { 

    var myTabUrl = tab.url; 

    document.getElementById("qrImage").src = buildQRCode(myTabUrl);

  });

function buildQRCode(linkURL) {

  return "http://chart.apis.google.com/chart?cht=qr&chs=230x230&chl=" + linkURL;

}

</script>

<body>

<center><img src="" id="qrImage" />

QR code for Current web address</center>

</body>




Una extensión de Chrome bien simple pero cumple el propósito de experimentar algo nuevo. Espero que les sirva de alguna utilidad esta información y despierte su curiosidad.

Mas información sobre los API de chrome están disponibles aquí http://code.google.com/chrome/extensions/api_index.html

Tuesday, October 18, 2011

Mi primer App

Una noche nueva y un programa nuevo. En esta ocasión se me presenta la oportunidad de colaborar con un 10K local (Maraton de Navidad de Camuy). Como todo un buen nerdito me dedico a utilizar la tecnología para "ayudar" a los corredores.

Ya que el mundo esta lleno de teléfonos Android pues que mejor manera que haciendo un Android App para la carrera.
Este app es llamado Marathon Pacer y simplemente calcula a que paso debes correr para llegar en el tiempo deseado a la meta. Este tiempo luego le puedes dar Share y compartirlo por email. Un app bien simple pero útil a la vez.
Ya el app esta puesta en el marketplace y la puedes bajar desde este link o desde el QR Code
https://market.android.com/details?id=com.maratonnavidad.pacerapp&feature=search_result&hl=es
Si interesas bajar el app apunta tu Android a este QR code y adelante.
Pronto el código estará disponible en http://github.com/soynerdito/MarathonPacer
Cualquier comentario sobre el app o si desean un "how to" de alguna parte del App dejen un comentario.









Sunday, October 16, 2011

Upgrade Ubuntu to 11.something

Months ago (after an epic battle with windows 7) I decided to switched full force at home from Windows 7 to a Linux distro. Ubuntu became the weapon of choice and have no regrets.
Now, happy with Ubuntu 10 but version 11.something is out, so what the heck. Lets Updagrade!! Discovered a nice feature that it is posible to update Ubuntu from within the Update Manager. Lets give it a try!

Step one: Click Update Manager. It said that a new version of Ubuntu is available. All happy and curious could it be a full OS upgrade done with a mouse point and click? (like apple? or Android?). I live for risks like this, so lets click away and see what happen.
Well it seems to be going well, a few warning message about a lot that will be removed and so but nothing too critical to abort mission.
I can tell you that estimated time is really estimated time, it took a while more. During the upgrade process I cleaned the apartment floor, did laundry and watch one and a half movies on streaming. Yes the streaming may affected the download time, but who are you to judge.

Anyhow, after a blink of the eyes (3+ hours) this message showed up:
"Your system could be in an unusable state" WT#*#&!@@!!!@#@!!!!@#(& ... 
Ok deep breath and clicked Close. It kept doing something and and "Upgrade complete with errors" message showed up.

I decided to dismiss all warning messages an restart my PC (by using "sudo shotdown -h" because the menu option did nothing).
However for my surprice it rebooted into Ubuntu 11.something, so it seems that it really did the upgrade. A few wifi auto connect settings missing, but overall it seems to be running. I did reboot the machine three more times into Gnome and KDE to see what is new.

Now I switched from KDE back to the new Gnome since the upgrade may had change what I did not liked before. Now it might be time to end my love affair with KDE and switch forever to Gnome, time will tell.

Overall I grade this process a B+. The upgrade completed and I did not loose any data at all. I do recommend anyone with Ubuntu 10.something to try it. Could be better yes, but this is something that I never thought possible in my days of installing RedHat in a fast Pentium 75Mhz with blazing 16Mb of RAM.
Happy with my Ubuntu, and somehow sad at the same time. Some of the new Gnome features that I like might be copied out from Mac (since Apple had them forever). I am not a Mac fan but even I have to admit somethings they do really good.
So lets resume with my nerdy afternoon clicking away and searching for new "features" on the Ubuntu 11.something. See you!