[Android General] By Zonik:
Guide Network traffic indicator in status bar

A big thanks to [MENTION=4714483]daxgirl[/MENTION] for amazing mod, original post here https://xdaforums.com/showpost.php?p=68067070&postcount=8634

I only made a simple modification to this mod:

••Support tint dark in White Background

••Traffic Data Location (Right/Left)

••Custom color does not work, when I have time I will add custom color for dark backgrounds later, if you have time to add this great you can share it :)

••New icons arrows

Well, we started!!

1.-Decompile you SystemUI and mergue files

==========================================

2.-Go to notification_icon_area.xml (res/layout folder)

before of

<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />

Add this

<com.zonik.switch.mZonikSwtich android:layout_width="wrap_content" android:layout_height="wrap_content" key="Z_network_hide" value="1">
<com.zonik.network.ZNetworkTraffic android:id="@id/z_network_traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</com.zonik.switch.mZonikSwtich>

equal to this

<com.zonik.switch.mZonikSwtich android:layout_width="wrap_content" android:layout_height="wrap_content" key="Z_network_hide" value="1">
<com.zonik.network.ZNetworkTraffic android:id="@id/z_network_traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</com.zonik.switch.mZonikSwtich>
<com.android.systemui.statusbar.StatusBarIconView android:id="@id/moreIcon" android:visibility="gone" android:layout_width="@dimen/status_bar_icon_size" android:layout_height="fill_parent" android:src="@drawable/stat_notify_more" />

3.-Go to status_bar.xml (res/layout folder)

before of

<TextView android:textSize="12.0dip" android:textColor="#ffffffff" android:gravity="center_vertical" android:id="@id/knoxCustomStatusBarText" android:visibility="gone" android:layout_width="0.0dip" android:layout_height="0.0dip" android:includeFontPadding="false" />
<include layout="@layout/system_icons" />

Add this

<com.zonik.switch.mZonikSwtich android:layout_width="wrap_content" android:layout_height="wrap_content" key="Z_network_hide" value="0">
<com.zonik.network.ZNetworkTraffic android:id="@id/z_network_trafficZ" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</com.zonik.switch.mZonikSwtich>

equal to this

<com.zonik.switch.mZonikSwtich android:layout_width="wrap_content" android:layout_height="wrap_content" key="Z_network_hide" value="0">
<com.zonik.network.ZNetworkTraffic android:id="@id/z_network_trafficZ" android:layout_width="wrap_content" android:layout_height="fill_parent" />
</com.zonik.switch.mZonikSwtich>
<TextView android:textSize="12.0dip" android:textColor="#ffffffff" android:gravity="center_vertical" android:id="@id/knoxCustomStatusBarText" android:visibility="gone" android:layout_width="0.0dip" android:layout_height="0.0dip" android:includeFontPadding="false" />
<include layout="@layout/system_icons" />

4.-Go to ids.xml (res/values folder)

Add this

<item type="id" name="z_network_traffic">false</item>
<item type="id" name="z_network_trafficZ">false</item>

5.-Go to dimens.xml (res/values folder)

Add this

<dimen name="z_net_traffic_single_text_size">12.0dip</dimen>
<dimen name="z_net_traffic_multi_text_size">9.0dip</dimen>

Well now compile and decompile for get id public!!

6.-Go to StatusBarIconController.smali (com/android/systemui/statusbar/phone/StatusBarIconController)

add in # instance fields

.field private mZNetworktraffic:Lcom/zonik/network/ZNetworkTraffic;

.field private mZNetworktrafficZ:Lcom/zonik/network/ZNetworkTraffic;

In the method

.method public constructor <init>(Landroid/content/Context;Landroid/view/View;Landroid/view/View;Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

after of

iput-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mClock:Lcom/android/systemui/statusbar/policy/Clock;

add this and replace you id public

const v2, 0x7f1304ae [COLOR="Red"]<public type="id" name="z_network_traffic" id="0x7f1304ae" />[/COLOR]

invoke-virtual {p2, v2}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v2

check-cast v2, Lcom/zonik/network/ZNetworkTraffic;

iput-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mZNetworktraffic:Lcom/zonik/network/ZNetworkTraffic;

const v2, 0x7f1304af [COLOR="red"]<public type="id" name="z_network_trafficZ" id="0x7f1304af" />[/COLOR]

invoke-virtual {p2, v2}, Landroid/view/View;->findViewById(I)Landroid/view/View;

move-result-object v2

check-cast v2, Lcom/zonik/network/ZNetworkTraffic;

iput-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mZNetworktrafficZ:Lcom/zonik/network/ZNetworkTraffic;

In the method

.method protected applyIconTint()V

after of

invoke-virtual {v2, v3}, Lcom/android/systemui/BatteryMeterView;->setDarkIntensity(F)V

Add this

iget-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mZNetworktraffic:Lcom/zonik/network/ZNetworkTraffic;

iget v3, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mIconTint:I

invoke-virtual {v2, v3}, Lcom/zonik/network/ZNetworkTraffic;->setTextColor(I)V

iget-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mZNetworktrafficZ:Lcom/zonik/network/ZNetworkTraffic;

iget v3, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mIconTint:I

invoke-virtual {v2, v3}, Lcom/zonik/network/ZNetworkTraffic;->setTextColor(I)V

Ready now compile :fingers-crossed:

7.-Rom Control

in arrays.xml

<string-array name="arrow_position_entries">
<item>Right</item>
<item>Left</item>
</string-array>
<string-array name="arrow_position_values">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="traffic_state_items">
<item>Disabled</item>
<item>Show only uploads</item>
<item>Show only download</item>
<item>Upload and download</item>
</string-array>
<string-array name="traffic_state_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<string-array name="traffic_style_entries">
<item>Normal</item>
<item>Bold</item>
<item>Italic</item>
<item>Bold italic</item>
</string-array>
<string-array name="traffic_style_entry_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<string-array name="z_network_entries">
<item>On the right</item>
<item>On the left</item>
<item>Hide</item>
</string-array>
<string-array name="z_network_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>

Preferences

<PreferenceScreen android:title="Network Traffic">
<PreferenceCategory android:title="Network Traffic data">
<com.wubydax.romcontrol.v2.prefs.MyListPreference android:entries="@array/traffic_state_items" android:title="Displayed traffic info" android:key="z_network_traffic_state" android:defaultValue="3" android:entryValues="@array/traffic_state_values" />
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Display data in Bytes" android:key="z_network_traffic_unit" android:dependency="z_network_traffic_state" android:defaultValue="false" android:summaryOn="Show bytes" android:summaryOff="default" />
</PreferenceCategory>
<PreferenceCategory android:title="Network Traffic data Position">
<com.wubydax.romcontrol.v2.prefs.MyListPreference android:entries="@array/z_network_entries" android:title="Network Position" android:key="Z_network_hide" android:defaultValue="0" android:entryValues="@array/z_network_values" />
</PreferenceCategory>
<PreferenceCategory android:title="Arrows display preferences" android:dependency="z_network_traffic_state">
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Show traffic arrows" android:key="z_network_traffic_show_arrows" android:dependency="z_network_traffic_state" android:defaultValue="true" android:summaryOn="Arrows shown" android:summaryOff="Arrows hidden" />
<com.wubydax.romcontrol.v2.prefs.MyListPreference android:entries="@array/arrow_position_entries" android:title="Arrows position" android:key="z_network_traffic_arrows_position" android:dependency="z_network_traffic_show_arrows" android:defaultValue="1" android:entryValues="@array/arrow_position_values" />
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Enable Traffic arrows color" android:key="z_network_traffic_global_color" android:defaultValue="true" android:summaryOn="Active custom color for Arrows" android:summaryOff="Desactive custom color for Arrows" />
<com.wubydax.romcontrol.v2.prefs.ColorPickerPreference android:title="Traffic arrows color" android:key="z_network_traffic_arrow_color" android:dependency="z_network_traffic_global_color" android:defaultValue="\#ffffff" />
</PreferenceCategory>
<PreferenceCategory android:title="Display options" android:dependency="z_network_traffic_state">
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Low traffic is automatically hidden" android:key="z_network_traffic_autohide" android:defaultValue="false" android:summaryOn="Auto Hide Enable" android:summaryOff="Always show" />
<com.wubydax.romcontrol.v2.prefs.MySeekBarPreference android:max="100" android:title="Automatically hide" android:key="z_network_traffic_threshold" android:dependency="z_network_traffic_autohide" android:defaultValue="10" />
<com.wubydax.romcontrol.v2.prefs.MyListPreference android:entries="@array/traffic_style_entries" android:title="Font style" android:key="z_network_traffic_text_style" android:defaultValue="0" android:entryValues="@array/traffic_style_entry_values" />
<com.wubydax.romcontrol.v2.prefs.MySeekBarPreference android:max="10" android:title="Text size ratio" android:key="z_network_traffic_scale" android:defaultValue="10" />
</PreferenceCategory>
</PreferenceScreen>

Done Compile you RC

Captures: