Wednesday, June 22, 2011

How to create a Bada Widget

Widgets are those cool small applications that we see on our main screen.They are written in html just like any web page, but making them can be problematic at start (especially that there are no good tutorials for Bada Widgets). So I took some time and effort and experiment with the ones that are already in Samsung’s App Store.
As I mentioned before, widget is some sort of a web page written in html, which also takes the advantage of css styles and Java Script. But before we even start writing in html, we’ll encounter some small problems with widget packaging.


Widget usually consists of 3 base folders:
  • css (where all styles are being held),
  • js (where all Java Scripts are stacked) and
  • images (You already know what is this for – right? ;) ).
All widgets (both for Bada and Samsung Omnia) have such folder structure and it is good to keep it that way (especially if we think to later sell our creations in the App Store)
But the utmost important things are those three basic files, without which widget won’t run:
- index.htm – html structure of the widget,
- icon.png – icon which we see during widget drag ‘n drop (32bit image of size 90×90)
- config.xml – configuration file (very important)
So let’s start with the not so obvious one – config.xml. This file is used by Bada OS system during widget installation. If it contains mistakes, widget won’t be installed AT ALL. Inside this file there should be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<widget id="ExampleWidget" version="1.0" width="120" height="180" xmlns="http://www.w3.org/ns/widgets">
 <title>Example</title>
 <description>This is my example widget's description.</description>
 <icon src="icon.png"/>
 <content src="index.html"/>
 <access network="false"/>
</widget>
 
  • Id – widget identifier can be an alphanumeric value (after certification it contains number like 0×10000715, but if we write “ExampleWidget” it will run as well,
  • Version – widget version,
  • Width – widget are initial width (the yellow frame we see during widget dragging),
  • Height – widget area initial height (the yellow frame we see during widget dragging),
  • Title – widget name,
  • Description- widget short description (if it contains UTF-8 chars that whole xml file must be UFT-8 encoded or widget won’t install),
  • Icon – the path to widget main icon (can point to elsewhere – like “/images/1.png” but it’s good to do it this way),
  • Content – point’s to widget main content and must always be “index.html”,
  • Access network – true if we need to use network in our widgets, otherwise false (if it is set to true, we will be prompted to turn on WiFi or GPRS).
Those few lines are absolute minimum for widget to work and we must also remember to save this file in UTF-8 (not in Unicode or ANSI) or widget won’t install.
OK, we have prepared a config – now let’s start the html adventure! Argh!
Widgets are a bit limited in their html, css, DOM and JavaScript support. For example we have only those events in available: onClick(), onMouseUp(), onFocus(), onBlur(). So if we want to make properly behaving buttons (different graphics for pushed and released state) we need to use onClick() and onMouseUp() (there’s no onMouseDown() nor onKeyDown() event).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Example widget</title>
 <link rel="stylesheet" type="text/css" href="css/exampleWidget.css"/>
 <script src="js/exampleWidget.js" type="text/javascript"></script>
</head>
 
<body>
 <img id="logo" src="images/badaDev.png" onClick="testLogo();"/>
 <span class="logoLabel">Hello Bada!</span>
</body>
</html>
 
In example widget I’m linking to two simple external files: css/exapleWidget.css (style sheet) and js/exapleWidget.js (JavaScript code). JS code contains simple script which shows ‘Hello Bada’ alert and CSS is used to change ‘Hello Bada!’ label font and color.
// exampleWidget.js
function testLogo()
{
 alert('Hello Bada');
}
 
// exampleWidget.css
span.logoLabel
{
 top: 5px;
 font-size:20px;
 color:#FFFFFF;
}
 
But those few files and folders won’t do anything without packaging them into widget (.wgt) file. To do this we need to use any Zip packer (I used 7Zip for this purpose) with Deflate option (default) and later change extension from .zip to .wgt.
And viola! Here we have our first widget.
To install it, we simply copy .wgt file to device and press on it in ‘My files’. If everything is OK, Bada will inform us that this widget is not certified and asks us whether we want to install it anyway.



Android porting on samsung wave

ONLY The wave S8500 will be supported. other samsung bada phones aren't and will not be supported. IF you are so stupid to listing to the guy who said you can f;lash you rWave II with normal wave FW then you'll BRICK your phone

BIG UPDATE 12-6-2011
[b]Edited 12-6-2011 22:47 GMT+1 (added new button layout)
Okay firstly. I am making this guide because many people have problems installing and a lot of things changed.

What works in this version
  • Launchers
  • Market (including install)
  • Settings
  • Wi-Fi

What NOT works in this version
  • Modem (3G, Calls, etc.)
  • GPS
  • Video
  • Audio
  • Sensors (This causes the battery charge bug]

    FAQ

    My WiFi ain't working but I followed all the steps, what should I do?
    A: Download this app: http://www.mediafire.com/?edc30bp78w5ue7j put it in /data/app/ run it on your phone and turn wifi off and on again. This will work 100% guaranteed or YOU are doing something wrong

    I stay stuck at the Galaxy S logo or it boots bada
    A: I dunno, Redo all your steps (except for the flasing part)

    I want to see some proof of android running
    A: Go to http://livestream.com/ShadowAS1

    My apps wont install
    A: This is an permissions error. If you have CHMODDED everything as told and you are using the NEW zImage you should be fine.

Okay, Lets get started

What do we need?
  1. a Computer running windows
  2. VirtualBox
  3. a Ubuntu 11.04 CD
  4. Your S8500 + USB Cable
  5. Fota: http://badadroid.googlecode.com/files/kernel_boot.fota
  6. Bootfiles: http://badadroid.googlecode.com/files/S8500XXJEE_BL.zip
  7. S8500XXJL2 FW (NOT needed if you already have this one running) http://www.multiupload.com/WMGXTWKQH2
  8. NEW! zImage and SBL.bin http://www.mediafire.com/?apnvsr2qovasrxz
  9. Multiloader v5.62: http://www.mediafire.com/?ukut12kcpa5og5h
  10. Android FileSystem http://www.megaupload.com/?d=CI0QUBLY (There IS an zImage in the file, Do NOT USE IT, DELETE IT)
  11. Patience...

WARNING: If you are using this phone as your regualr phone BACK UP EVERYTHING.
WARNING2: Flashing is NOT without risk. Do NOT do this if your not completely sure it will succeed or you WILL BRICK YOUR PHONE.

Step 1: Prepearing the phone
Note: If you already are running S8500XXJL2 Skip to Step 1.2

1: Assuming you´ve already downloaded the firmware open it up and extract it somewhere.
2: Open Multiloader (run as admin on vista/7) Select: LSI and check: "Full Download"
3: Click on Boot and select the folder where your Bootfiles are located (eg. C:\s8500XXJL2\BOOTFILES\)
4: For the other buttons it's the same thing. Click them and select the appropiate file.
5: Shut down your phone (Have you backed up everything) Hold Volume down+Camera+Power button and the phone will say: Download mode
6: Connect the phone with USB to the computer and click Port search in Multiloader. If multiloader finds the phone click download.
WARNING: When flashing DO NOT Touch your phone, disconnect it or whatever. That WILL brick your phone.


Step 1.2 Flashing the BL and FOTA
Same thing here.
1. Open up multiloader, Select LSI and check full download
2. Click Boot, Navigate to your bootfiles (The folder should be called: BOOTFILES_EVTSF)
3. Click FOTA, Select the FOTA you just downloaded.
4. Boot you phone to download mode. (if you don't know how to you should not do this, Step 1.5 Describes how-to)
5. Click Port search, Download.
6. When done boot bada to make sure the phone works fine. If it does. Continue

Step 2: Installing VB, Ubuntu
Okay, I was told many people have problems with partitioning. This is how i did it and it WORKED.
In this step i will discribe how to install VirtualBox and Ubuntu, If you already done this Skip to step 3
1. Download VirtualBox from: http://download.virtualbox.org/virtu...-71778-Win.exe
2. Install it. When installing i Suggest you download and burn/mount ubuntu if you haven't yet. http://www.ubuntu.com/download/ubuntu/download
3. Make a new VM in VirtualBox. Jst follow the steps. If you have 4GB RAM I would recommend assigning 1GB to the VM
4. Install ubuntu on the VM. I'm not gonna explain how to do that, just follow the wizards.

Step 3: Installing gParted and partitioning your card
For this step you should have your phone running in bada USB connected with Mass Storage mode.
1. In your Ubuntu VM go to ubuntu software centre. Search for gParted and click install
2. In the VM window you see the menu, Click Devices -> USB Devices -> Samsung Electronincs GT-S8500 Wave. This will connect the wave to ubuntu
3. Launch gParted and wait till it's done scanning. At the right top corner you'll see a drop-down box. This will list all seperate devices. In my case /dev/sdb was the SD Card. You'll just have to look which one os yours
Note: In this case i am assuming we're using the standard samsung 2GB SD card.
4. You found your card? Great, Now first format the partition(s) and then delete them all
5. Then (assuming you're having a 2gb card) Split the card in half (that mean make 2 equal sized partitions) the FIRST partition must be FAT16 the second MUST be ext2

Step 4: Transferring Files EDITED
Okay, I've COMPLETELY re-written this part due to much changes. Goodluck

This part can ONLY be preformed on ubuntu.
In this part we'll need the galaxyboot files and the filesystem

1.Log in as root on your ubuntu box if you haven't already
2.(re-)connect your wave so it mounts the partitions.
3. Open up the filesystem and move the CONTENTS of the filesystem folder to the root of the ext 2 partition.
4. In your ext2 partition go to /system/media/audio and rename ui to uibak
5. go to /data/wifi and delete the .conf file in there.
EDIT5b. open up a terminal and navigate to the SD card (shoud be in /media) and do "chmod -R 0777 ./*"
6. Open up the internal memory of your wave and put the galaxyboot folder in there. In there you should have 2 files: zImage and sbl.bin
NEW! 7. go http://pastebin.com/exReHpFa and save this file as s3c-keypad.kl place it in /system/usr/keylayout and overwrite the existing file

7. Now you should be all ready the only thing left is to open up a terminal and type "sudo sync" (no quotes)


Step 5: First-Time run
Okay, now we're ready for first run. This does NOT mean we're done yet.
READ THIS ENTIRE STEP BEFORE STARTING
1. Remove the USB cable and shutdown bada
2. When shut down press the end call button and immideatly after that you press the start call button. Release the end call button when the screen turns on
3. When you see the Samsung GalaxyS S screen release all the buttons.
Notice: It may take up to 5 minutes for first time boot. As long as the screen stays on everything is fine.
Notice2: In case your screen turns of remove the battery and double check everything you've done.
4.Booted up? Awesome. Pass the welcome wizard. Do NOT type in the keyboard part. This will freeze the phone.
5.You passed it? Great. Now you can continue
6. The phone will ask you which launcher to use. I don't car which one you use. I've always used TwLauncher. it's up to you
7. In order to let your keypad work normal Go to settings -> Text and Locale -> Samsung keypad -> Uncheck all



This is it. Now your phone should function normally. If things go wrong for you do not hesistate to ask.

Tuesday, June 21, 2011

Samsung wave II Review(wave 2)

Here is the unboxing video of samsung wave 2 and review as well.

Unboxing

Review