[Android Themes] taboo5200:
Modified version

Based on the .smalis in this post, I've reconstructed the source code in Java as accurately as possible (right down to the line number) - see the Traffic_Reconstructed.java attachment (only of interest to those who build from source). However, because the .smalis have evidently been modified before, things may not match up 100% though these differences are fairly trivial and do not actually affect the way the code executes. To compile it, grab my Eclipse/ADT project and replace the Traffic.java file with the reconstructed one. Things should just work (I hope?).

Name mappings (again, only of interest to those who build from source and are curious about the reconstruction):

[B]Traffic_Reconstructed.java (compiled and smali-ed) ↔ TRAFFIC.zip[/B]
Traffic$Receiver.smali ↔ Traffic$1.smali
Traffic$1.smali ↔ Traffic$2.smali
Traffic$Task.smali ↔ Traffic$3.smali
Traffic$SettingsObserver.smali ↔ Traffic$SettingsObserver.smali
Traffic.smali ↔ Traffic.smali

From the reconstructed code, I've modified it to remove unnecessary code and make it more efficient and (hopefully) less memory hungry. The changes are as follows:

Dynamically switches between the download and upload rates depending on whichever is higher

Text colorization depending on which rate is being displayed (green for download and red for upload, adjustable)

Dynamically hides the counter if the rate is below a configurable value to save space (defaults to 18 bytes/second)

Supports poll rate adjustments (defaults to once every two seconds)

Favors displaying smaller units of measurement (e.g. 999B/s instead of 0.99K/s, 999.00K/s instead of 0.99M/s)

Bytes are displayed as integers (whole numbers), kibibytes and mebibytes are displayed as decimal fractions accurate to two decimal places

Removed unnecessary code and SettingsObserver subclass

Previews:

Sounds good? There's (unfortunately) a catch: the abovementioned customizability means that manual linking has to be done. The integration instructions further below will guide you through the process.

Disclaimer: This has only been tested with an Xperia go on Gingerbread 2.3.7. Your mileage may vary, though I don't see any reason why it shouldn't work for any newer version. Try out the test app I've attached to this post to see it in action for yourself and to determine if it will work for you before taking the plunge.

traffic_demo.apk, SHA-1 hash: 531F02DC710EA41E059E2C0F654AA5E1EACE2C78 | source code and Eclipse/ADT project

Integration procedure [brace yourself, it's long]:

(these instructions supercede those given in the OP since they are specific to my version)

0. Common sense dictates that you should have a working backup before meddling around with things, and I'd recommend you to heed its advice

Decompile SystemUI.apk

Extract the four .smali files from traffic_rw_smali.zip and copy them to smali/com/android/systemui/statusbar/policy

Edit res/layout/status_bar.xml and insert the following line (preferably within the LinearLayout containing android:id="@id/icons"):

<com.android.systemui.statusbar.policy.Traffic android:textAppearance="@style/TextAppearance.StatusBar.Traffic" android:gravity="left|center" android:id="@id/traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" />

Edit res/values/ids.xml and add the following line:

<item type="id" name="traffic">false</item>

Edit res/values/styles.xml and add the following lines (alter textSize and/or typeface if desired):

<style name="TextAppearance.StatusBar.Traffic" parent="@*android:style/TextAppearance.StatusBar.Icon">
<item name="android:textColor">@color/traffic_text_color_default</item>
<item name="android:textSize">10sp</item>
<item name="android:typeface">monospace</item>
</style>

Edit res/values/colors.xml and add the following lines (and adjust the colors if desired):

<color name="traffic_text_color_default">#ffd0d0d0</color>
<color name="traffic_text_color_download">#ffbeffbe</color>
<color name="traffic_text_color_upload">#ffffbebe</color>

Edit res/values/integers.xml and add the following lines (changing the values if desired):

[COLOR="SeaGreen"]<!-- The counter will only be shown if transfer rates exceed this amount in bytes per second. Set to -1 to always show -->[/COLOR]
<integer name="minimum_threshold_bps">18</integer>
[COLOR="SeaGreen"]<!-- This determines the interval in seconds between consecutive polls (updates). The smaller the value, the more accurate it
will be, but the more power it will consume. Clamped to a minimum of 1 (i.e. once per second) -->[/COLOR]
<integer name="poll_rate">2</integer>

Edit res/values/public.xml and add the following lines (please first verify that the id= values do not already exist, otherwise change them to something else if they do clash AND keep track of them - we'll need to fix them up again in step 9)*:

<public type="color" name="traffic_text_color_default" id="0x7f0c0000" />
<public type="color" name="traffic_text_color_download" id="0x7f0c0001" />
<public type="color" name="traffic_text_color_upload" id="0x7f0c0002" />
<public type="integer" name="minimum_threshold_bps" id="0x7f060001" />
<public type="integer" name="poll_rate" id="0x7f060002" />

Edit smali/com/android/systemui/statusbar/policy/Traffic.smali and perform the following changes (and read the green text for further details):

Line 155, change from:

const/high16 v2, 0x7f04

to:

const v2, 0x7f0c0000	[COLOR="SeaGreen"]# <- Change this to match whatever [I]id=[/I] value was set in step 8 for [B]traffic_text_color_default[/B] [U]IF[/U] there was a clash[/COLOR]

Line 170, change from:

const v2, 0x7f040001

to:

const v2, 0x7f0c0001	[COLOR="SeaGreen"]# <- Change this to match whatever [I]id=[/I] value was set in step 8 for [B]traffic_text_color_download[/B] [U]IF[/U] there was a clash[/COLOR]

Line 185, change from:

const v2, 0x7f040002

to:

const v2, 0x7f0c0002	[COLOR="SeaGreen"]# <- Change this to match whatever [I]id=[/I] value was set in step 8 for [B]traffic_text_color_upload[/B] [U]IF[/U] there was a clash[/COLOR]

Line 213, change from:

const/high16 v1, 0x7f06

to:

const v1, 0x7f060001	[COLOR="SeaGreen"]# <- Change this to match whatever [I]id=[/I] value was set in step 8 for [B]minimum_threshold_bps[/B] [U]IF[/U] there was a clash[/COLOR]

Line 226, change from:

const v1, 0x7f060001

to:

const v1, 0x7f060002	[COLOR="SeaGreen"]# <- Change this to match whatever [I]id=[/I] value was set in step 8 for [B]poll_rate[/B] [U]IF[/U] there was a clash[/COLOR]

Recompile SystemUI, paste the signature back in and install as usual

*: When dealing with id clashes, first check if there are any entries that share the same type= value. For example, if the following line:

<public type="integer" name="minimum_threshold_bps" id="[COLOR="DarkRed"]0x7f060000[/COLOR]" />

clashes with another line (observe that their ids are identical):

<public type="integer" name="config_clock_am_pm_style" id="[COLOR="DarkRed"]0x7f060000[/COLOR]" />

then the line to be added (i.e. minimum_threshold_bps) should have its id adjusted to the largest value + 1. In this case, there is only one other entry, so the line is changed to become:

<public type="integer" name="minimum_threshold_bps" id="[COLOR="DarkRed"]0x7f060001[/COLOR]" />

On the other hand, if there are no other entries that share the same type= value, then (assuming the list of entries have their ids in ascending order) take the id of the last entry and modify it to create your own type code. This is mandatory, or aapt will complain with an error along the lines of "res\values\public.xml:205: error: Public resource color/traffic_text_color_download has conflicting type codes for its public identifiers (0x4 vs 0xc)". For example, the following entries represent the contents of the res/values/public.xml file:

<public type="layout" name="status_bar_tracking" id="0x7f030005" />
<public type="[COLOR="DarkRed"]xml[/COLOR]" name="bookmarks" id="[COLOR="DarkRed"]0x7f040000[/COLOR]" />
<public type="bool" name="config_hspa_data_distinguishable" id="0x7f050000" />
...
<public type="id" name="content" id="0x7f0b0014" />
<public type="id" name="close" id="0x7f0b0015" />

The following line is to be added to the above list:

<public type="[COLOR="DarkRed"]color[/COLOR]" name="traffic_text_color_default" id="[COLOR="DarkRed"]0x7f040000[/COLOR]" />

The first issue is that the id= value clashes (with bookmarks). Unfortunately, it isn't as easy as simply using 0x7f040001 instead because aapt will complain that the type codes are the same (0x4) since one is an xml and the other is a color. To fix this, look at the id for close (0x7f0b0015, focus on the b within that number). Obviously, we can't use 0x7f0b0016 because we'd run into the exact same error again. Instead, increment b by one (it's in hexadecimal, so the number after that is c. If this makes no sense to you, I suggest you start learning it before proceeding) and reset the four digits after it to 0. The resultant value: 0x7f0c0000. Now the entry can be added to the list, like so:

<public type="layout" name="status_bar_tracking" id="0x7f030005" />
<public type="xml" name="bookmarks" id="0x7f040000" />
<public type="bool" name="config_hspa_data_distinguishable" id="0x7f050000" />
...
<public type="id" name="content" id="0x7f0b0014" />
<public type="id" name="close" id="0x7f0b0015" />
<public type="color" name="traffic_text_color_default" id="[COLOR="DarkRed"]0x7f0c0000[/COLOR]" />

Credits:

Dzol Cp for providing the .smalis from which my version was derived

smali developers for smali/baksmali

Brut.alll, Connor Tumbleson for APKTool