Archives for Aug,2010

You are browsing the site archives by date.

Nexus one 2600mAh high capacity battery replacement

I have a nexus one which has comparatively decent battery life to other smart phones, lasting about 1 day with casual usage. The battery that comes with the nexus one is 1400mAh, but I noticed dealextreme are selling a 2600mAh replacement battery.

Nexus one high capacity battery (2600mAh)

Nexus one high capacity battery (2600mAh)

The battery costs $14.00 (£8.81) which will give an extra 85% increase in charge. This means the that my nexus one should last closer to 2 days with casual use now, I have ordered one and will update with some benchmarks when it arrives (unfortunately not in time for my camping weekend).

Read More

Making Prettier Buttons in android; XML (rollover,selection & focus effects), 9patch images and transparency

Alot of the soundboards out there on the market look a little bit ugly by using the default android buttons in conjunction with a background (no offense to developers of these, perhaps they can learn from this); this mini-tutorial explains how to use xml to create a customised nice looking button thing.

Ugly Buttons:
Below is show the example I will use to demonstrate the default buttons in use with a background image (It’s a picture of me hugging the android statue!)

"Ugly" default buttons in android

Button States

There are four images you will need to create (you can use less if you want); one for each of the following states:

state_focused state_pressed What this means
true false Button highlighted (selected with trackpad)
true true Button foussed and pressed
false true Button pressed
false false Normal state of button

I recommend creating a nine-patch png for the button image, this way your image can be stretched to fit the button size as needed. Also soundboards look rather snazzy if you include a background image, and then you can use transparency in your png so that your buttons don’t obscure it.

draw9patch tool button android

Using draw9patch tool to make a 9patch png for use as a strechable button

XML Code

button.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="https://schemas.android.com/apk/res/android">
    <item android:state_focused="true"
	android:state_pressed="false" 
	android:drawable="@drawable/button_selected" />
    <item android:state_focused="true" 
    	  android:state_pressed="true"
    	  android:drawable="@drawable/button_focus" />
    <item android:state_focused="false" 
    	  android:state_pressed="true"
	  android:drawable="@drawable/button_pressed" />  
    <item android:drawable="@drawable/button_normal" />
</selector>

main.xml
An example usage of how to use this newly created xml button in your layout file.

<Button
android:id="@+id/mysexynewbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textStyle="bold"
android:text="Stealthcopter FTW"
android:background="@drawable/button" />

Results
Now you should have some nice sexy customised buttons that change depending on thier state. Which makes our example now look like this (I increased the padding and margins of the buttons slightly):

Pretty Buttons with transparency using 9patch png and xml

Pretty Buttons with transparency using 9patch png and xml

Below are a few examples of my work with some nice transparent buttons:

Example 9 patch image

button.9.png

button.9.png

Read More

Android: Soundpool vs MediaPlayer (focus on soundboards and memory problems)

I get a fair few emails asking for help on making soundboards because I have a few out on the market currently, so this is one of a few mini-tutorials I am creating to explain some of the difficulties to overcome.

So there are two methods for playing sounds in android SoundPool and MediaPlayer.

SoundPool

SoundPool is designed for short clips which can be kept in memory decompressed for quick access, this is best suited for sound effects in apps or games. Using this method with soundboards is a bad idea as you will be loading lots of “medium” sized sounds into the memory and you may exceed your limit (16Mb) and get an OutOfMemoryException.

MediaPlayer

MediaPlayer is designed for longer sound files or streams, this is best suited for music files or larger files. The files will be loaded from disk each time create is called, this will save on memory space but introduce a small delay (not really noticeable).

So lets have a look how to use Media Player instead of SoundPool

MediaPlayer Usage

MediaPlayer mp = MediaPlayer.create(ClassName.this, R.raw.sound);
mp.start();

Where ClassName.this should be the name of your class (Hint: this should be the name of the java file you are editing)

You can pause the sound playing and then use start to start the sound playing again.

mp.pause(); // Stop
mp.start();   // Start from place paused

To stop the sound playing use stop, using start now will start playing the sound again from the beginning

mp.stop();    // Stop sound
mp.start();   // Start from beginning

To reset the media player so it can be reinitialised with a another sound

mp.reset();
mp = MediaPlayer.create(ClassName.this, R.raw.sound2);

To release the resources once you are finished media player (free memory)

mp.release();
Read More

Nexus Revamped Pro Live Wallpaper 1.1.11 update

With version 1.1.11 I’ve brought it up to 27 revisions since the original wallpaper by issuing another update (This follows from my previous updates in this post)

Whats new?
I have now added a changelog to the application, viewable by clicking on the version number, so now there is no mystery to what the update contains!

  • Added changelog
  • Added reset to defaults button
  • Moved reaction to battery level to a new submenu ‘Reactions’, more coming soon!
  • Changed default value of maximum particles to 100 to make application more responsive to people who like spamming the screen
  • Renamed ‘Static background’ to ‘Static foreground’ to more accurately reflect it’s purpose. This has also been moved to the particle settings menu and changed it’s default value to true to improve performance.

Video

I am still planning on posting a video soon (when I get some free time) to demonstrate the app as it has improved significantly since the firstvideo.

Android Market Links
Either click the following android market links (in android phone) or search the market for nexus revamped.
Pro Version
Nexus Revamped Pro Live Wallpaper (com.stealthcopter.nexusrevampedpro)

qr

Free Version

Nexus Revamped Live Wallpaper (com.stealthcopter.nexusrevamped)

Download link

qr

Future
I have plans and ideas for the future of this application, please complete the poll below to indicate what you’d like to see in this app or leave feedback (comment) if you have any.

[poll id=”10″]

Read More

Nexus Revamped Pro update v1.1.10 (google android live wallpaper)

I have issued a MASSIVE update for my Nexus Revamped Live Wallpaper Pro (This follows from my previous updates in this post)

Images

The gallery below first shows the options avaliable, some examples, and then some examples used with launcherpro. Click on each image to see a larger version, as these images are cropped.

I will post a video soon to demonstrate the app as it has improved significantly since the first video I have made.

New Features
This version includes some very exciting and highly demanded features:

  • Custom particle colors: Use a color wheel to select custom colors for each of the particles
  • Performance options: You can now adjust the desired FPS (frames per second) of the live wallpaper, this means that you can save battery life and increase responsiveness of your home screen. To find the optimum FPS I recommend that you try reducing the frame-rate until the point where you start to notice some jittering then increase it slightly.
  • Custom background images: Select a custom image to be used for the background.
  • Speed Deviation: You can now set how much the speed will deviate on a per-particle basis. A low setting will mean all particles travel at similar speeds whereas a high setting will mean there is a large amount of variance in speed (particles will overtake each other)
  • Reaction to battery level: Selecting this will cause the particles speed to represent the battery life of your phone. The less power your phone has the slower the particles will move.
  • Seekbar settings: Many of the settings (Speed, Speed Deviation, Tail length, FPS, and Saturation) which previously had a list to choose the values have been replaced with seekbar to allow improved customisation
  • New themes: please email me with more theme requests
  • Many bug fixes: Especially one that stopped custom background from working when rebooting the phone (reset settings to defaults), this was because the SD card isn’t ready when the live wallpaper starts.

I have also also pushed most of the updates down to the free version of this application, but some options are left out to reward the paying customers (custom background images, and custom particle colors)

Android Market Links
Either click the following android market links (in android phone) or search the market for nexus revamped.
Pro Version
Nexus Revamped Pro Live Wallpaper (com.stealthcopter.nexusrevampedpro)

qr

Free Version

Nexus Revamped Live Wallpaper (com.stealthcopter.nexusrevamped)

Download link

qr

Future
I have plans and ideas for the future of this application, please complete the poll below to indicate what you’d like to see in this app or leave feedback (comment) if you have any.

[poll id=”10″]

Read More