Tuesday, July 17, 2012

Mini Bluetooth Keyboard Android FIx

Hey all,

I've just bought a mini bluetooth keyboard off the internet. It's supposedly compatible with Android devices. I MUD (Multi User Dungeon, I call it the grandfather of MMOs) and seeing the possibility to MUD on the go without an entire computer, I was enticed to buy it.

Just a brief description:

It's a 49 key small keyboard, not the full QWERTY design but it's working well enough.
I bought it off Qoo10, though you can find it on places like Amazon as well.



***WARNING***
This item will not be easy to set up for the non tech savvy.

But for the rest who are frustrated, here's how I got it working.

Summary
1) Pair up keyboard
2) Connect keyboard
3) To reuse after turning off

Steps
1) Pair up keyboard
-Go into Android, Settings, Wireless & Networks, Turn on Bluetooth, Bluetooth Settings.
-Turn on keyboard, it will glow blue (top right) for about 2 seconds.
-Click the button next to the blue LED, it should start flashing, this is the pairing mode.
-On phone, you should get "Bluetooth Keyboard, Pair with this device", click it.
***IMPORTANT STEP***
-When it asks for a PIN code, enter 0000, click 'OK' (on phone) and then on the keyboard, press 0000 and then the enter key. This will pair it up.

If you take too long and the keyboard stops flashing, press and hold the pairing button until it flashes again.

***Step 1 done***

2) Connect keyboard
-You will need an app called BlueKeyboard JP by Elbrain. Download it off the Play Store.
-Start up the program, you should end up in the Language & Keyboard Settings. You can get here again by going from Android, Settings, Language & Keyboard Settings.
-Check BlueKeyboard JP, read through warning and click 'OK' if you're acceptable with it.
-Click BlueKeyboard JP to edit the settings or you can click the BlueKeyboard JP program from the app list.
-You will arrive at 'BlueKeyboard Settings'.
-Click 'Selected keyboard' and select the only option, which should be 'Bluetooth keyboard'.
-Make sure 'Connecting process' is checked.
-Go to any text input app, for example, SMS.
-Long press on the text input, choose 'Input Method' and select 'BlueKeyboard JP'
-Type something on the bluetooth keyboard, there should be a message prompt on the screen saying something similar to 'Connecting to keyboard, change keyboard state to pairing mode'. Press and hold the pairing button on the mini bluetooth keyboard.
-There should be a notification on top that says 'Connected. Bluetooth keyboard etc'.

***Congratulations, your mini bluetooth keyboard is usable now!***

3) To reuse after turning off
-To go back to normal usage, turn off keyboard and long press on text input and select back 'International keyboard' or whichever keyboard you were using.
-To go back to using the mini bluetooth keyboard again, turn on keyboard. Long press text input and change to to BlueKeyboard JP. It will show a 'Connecting' notification. Press and hold the pairing button on keyboard.
-Once it shows 'Connected', you're back to typing!

***If this post has helped you, you can help me in return. Click on one of the Google Ads on the side :) ***

Tuesday, May 22, 2012

HTML To PDF

Hey all, just a quick post.

I found a .exe file that converts html to pdf. Kind of nifty. Now I need to try integrating this into a web app to see if I can churn PDFs on the fly.

If you are interested in it as well, here's the link:
http://code.google.com/p/wkhtmltopdf/

Wednesday, May 9, 2012

Dynamically creating QML objects via Javascript

Hey all, Now in the midst of work so this is going to be a quick post. I needed to create QML Objects on the fly and needed to do it via Javascript. So how do I do it? Here's the quick and dirty, read it yourself!

// Variables
ListModel {
    id: listModelData
}

function splitStringToArray(stringToSplit) {

    var stringArray = stringToSplit.split(';');

    console.log("Length: " + stringArray.length)

    for(var i = 0; i < stringArray.length; i++) {
        var splitStr = stringArray[i]
        var model = Qt.createQmlObject('import QtQuick 1.1; ListModel {}', parentQMLObject);
        model.append({"name":"test"});

        listModelData.append({"model":model})
        console.log("Test model: " + model.get(0).name)
        console.log("Test listModelData: " + listModelData.get(0).model.get(0).name)
    }
}
There!

Have fun!

Friday, March 9, 2012

Tough day at work

Man, what a tough day at work. I'm still fairly new to ASP.Net.
No idea on how to accomplish a certain task.

Tough wall to crack but I'll crack it anyhow, with a little time and patience, just not today...

Anyway, what I'm trying to accomplish is:

1) Pull 2 sets of data out from database via SQL (Done)
2) Populate 2 lists with sets of data (Done)
3) Enable user to manipulate list dynamically without postbacks (Stuck here)
4) Save changes

Still stuck at step 3. Can't think of a way to do this via ASP.Net.
If this was PHP, I would have already done it with the help of Javascript.

Sign, no idea of which web control to use. Repeater? ListView? Or some other web control which I have not heard of or used yet. What a bummer, stumped at my inexperience.

I need the ItemTemplate portion to generate possibly a span item with unique id that can be picked out from a div with unique id (list1) to another div (list2). I would also need checkboxes.

If without postbacks, does it mean I have to put scripts into the page itself rather than code behind? I'll look into in page scripts first thing on Monday.

If any of you readers have any suggestions, do feel free to throw it in the comments section, though I believe that due to the low exposure of this blog at the moment, I would have solved this by then. Do check out my next post then. I should have my solution posted :)

P.S. Looked back on some old code. Had a hard time programming it back then but since I'm touching on a higher level of code now, looking back on those old code really makes it look easy. I would probably be touching up on those old code sometime... In case of TL;DR, Programming level up!

Monday, March 5, 2012

Combine image and text in a PdfPCell

Hey all,

Was confused as to how to combine an image and text together in ASP.net C#, while using the iTextSharp PDF library. Googled a bit and found my answer.

I'm not an expert at this so I'll just list out the code that would be understandable for dabblers.

If it's too long for you to read (including my babbling), just scroll down to the code

Starting off, I use a [Document] to contain a [PdfPTable] that holds [PdfPCell]s.
Being new to this I was hard-wired to think, 1 PdfPCell, 1 item, with that item being maybe text, or just graphics alone.

However I got stumped when I was required to c
ombine text and graphics together in a cell due to formatting, like wanting to have an image next to a label. I tried two separate cells with the image aligned to the right, and text aligned to the right (I needed it to the end) but due to the Colspan and width properties, I got this.


Yeah, you see it right? I needed that round image next to the text, however due to each cell being 100 pixels and the label not using up all the space I had this ugly effect.

Now here's what you were for! A cell can have multiple elements in there.
A quick touchdown on the solution. Remember
PdfPCell? It used to hold one item, either an Image, or a Phrase or Paragraph.

But now, [PdfPcell] holds 1 [Paragraph], which holds 1 [Chunk] (image) and 1 [Phrase] (text). So I get this!
Further formatting can be done with the X and Y offset to shift the image, you'll see it in the code as (image, 0, 0).

Now here's the code:

Document doc = new Document();

doc.Open();

PdfPTable table = new PdfPTable(5);
table.TotalWidth = 500f;
table.LockedWidth = true;

...
Paragraph paragraph = new Paragraph();
paragraph .Add(new Chunk(image, 0, 0)); // x y offsets as 0 but you can edit it in your code to align the image

paragraph.Add(new Phrase("Admin CP J", timesSmallBlack));
paragraph.Alignment = 2; // This alignment affects the positioning within the cell, important!

PdfPCell cell = new PdfPCell(paragraph );
cell.Colspan = 3;
cell.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right
cell.Border = 0;
table.AddCell(cell);

...

doc.Add(table);

Now, kudos to the original post which I've found: How to get a gif in a pdfpcell to line up with trailing text

If you enjoyed my post and it has helped you and you would like to return the favour you can click any of the sponsored Google ads around the page, thank you!

First post!

First!

Nah, let's stop with that "FIRST" crap like we always see on a new forum post or Facebook picture post.

First and foremost, this is going to be my programming blog. Why blog about it when you're supposed to be doing your work?! Well, in case this information helps you readers out there, in case I forget (which I'll most likely do) and return here to read up again.

This is like a learning journal and history of the walls I have to break down and have broken down. So, if you are reading this post, I don't think you are in the right place. Google or another spider should have brought you to a relevant post. So have fun, if one of my posts has helped, do click a sponsored Google Ad or link to help out, thank you!