Skip to content

Commit

Permalink
新增 网速指示器-交换上下行网速与图标位置
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Aug 20, 2023
1 parent bfb54ad commit 42efe5c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ object NetworkSpeed : BaseHook() {
// 上下行网速双排显示
val doubleUpDown =
mPrefsMap.getBoolean("system_ui_statusbar_network_speed_show_up_down")
// 网速图标
// 交换图标与网速位置
val swapPlaces =
mPrefsMap.getBoolean("system_ui_statusbar_network_speed_swap_places")
// 网速图标
val icons =
mPrefsMap.getString("system_ui_statusbar_network_speed_icon", "2").toInt()
var txArrow = ""
Expand Down Expand Up @@ -193,10 +196,24 @@ object NetworkSpeed : BaseHook() {

// 计算上行网速
val tx =
if (hideLow && !allHideLow && txSpeed < lowLevel) "" else "${humanReadableByteCount(it.args[0] as Context, txSpeed)}$txArrow"
if (hideLow && !allHideLow && txSpeed < lowLevel)
""
else {
if (swapPlaces)
"$txArrow${humanReadableByteCount(it.args[0] as Context, txSpeed)}"
else
"${humanReadableByteCount(it.args[0] as Context, txSpeed)}$txArrow"
}
// 计算下行网速
val rx =
if (hideLow && !allHideLow && rxSpeed < lowLevel) "" else "${humanReadableByteCount(it.args[0] as Context, rxSpeed)}$rxArrow"
if (hideLow && !allHideLow && rxSpeed < lowLevel)
""
else {
if (swapPlaces)
"$rxArrow${humanReadableByteCount(it.args[0] as Context, rxSpeed)}"
else
"${humanReadableByteCount(it.args[0] as Context, rxSpeed)}$rxArrow"
}
// 计算总网速
val ax =
humanReadableByteCount(it.args[0] as Context, newTxBytesFixed + newRxBytesFixed)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@
<string name="system_ui_statusbar_network_speed_fakedualrow">值和单位双排显示</string>
<string name="system_ui_statusbar_network_speed_show_up_down">显示上下行网速</string>
<string name="system_ui_statusbar_network_speed_detailed">双排显示上下行网速</string>
<string name="system_ui_statusbar_network_speed_swap_places">交换上下行网速与图标位置</string>
<string name="system_ui_statusbar_network_speed_detailed_desc">分别显示传入和传出的网络速度</string>
<string name="system_ui_statusbar_network_speed_hide">隐藏慢速</string>
<string name="system_ui_statusbar_network_speed_hide_all">当上下行均为慢速时隐藏</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1169,4 +1169,5 @@
<string name="security_center_gms_open_more">When it is turned on, a tile will be created. You can manage the Google service switch with one click in the Taskbar</string>
<string name="security_center_dolby_open">Close the Dolby pop-up window</string>
<string name="system_ui_hide_navigation_bar">Hide Navigation Bar</string>
<string name="system_ui_statusbar_network_speed_swap_places">Swap uplink and downlink speeds and icon positions</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
android:key="prefs_key_system_ui_statusbar_network_speed_font_size_enable"
android:title="@string/system_ui_statusbar_network_speed_font_size" />

<SeekBarPreferenceEx
android:layout="@layout/preference_seekbar_no_padding"
<SeekBarPreferenceEx
android:layout="@layout/preference_seekbar_no_padding"
android:key="prefs_key_system_ui_statusbar_network_speed_font_size"
android:dependency="prefs_key_system_ui_statusbar_network_speed_font_size_enable"
android:defaultValue="13"
app:defaultValueText="@string/array_default"
android:defaultValue="13"
app:defaultValueText="@string/array_default"
app:maxValue="40"
app:minValue="8"
app:stepValue="1"
app:format="%s dp"
app:displayDividerValue="2"
app:displayDividerValue="2"
app:showSeekBarValue="true" />

<SwitchPreference
Expand All @@ -35,15 +35,15 @@
android:key="prefs_key_system_ui_status_bar_no_netspeed_separator"
android:summary="@string/system_ui_status_bar_no_netspeed_separator_desc"
android:title="@string/system_ui_status_bar_no_netspeed_separator_title" />
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_update_spacing"
android:title="@string/system_ui_statusbar_network_speed_update_spacing"
android:defaultValue="3"
app:defaultValueText="@string/array_default"

<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_update_spacing"
android:title="@string/system_ui_statusbar_network_speed_update_spacing"
android:defaultValue="3"
app:defaultValueText="@string/array_default"
app:maxValue="10"
app:minValue="1"
app:stepValue="1"
app:stepValue="1"
app:format="%d s"
app:showSeekBarValue="true" />

Expand All @@ -68,12 +68,12 @@
android:key="prefs_key_system_ui_statusbar_network_speed_hide_all"
android:title="@string/system_ui_statusbar_network_speed_hide_all" />

<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_hide_slow"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_hide_slow"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:title="@string/system_ui_statusbar_network_speed_hide_slow"
android:summary="@string/system_ui_statusbar_network_speed_hide_slow_desc"
android:defaultValue="64"
android:defaultValue="64"
app:defaultValueText="@string/array_default"
app:maxValue="1024"
app:minValue="1"
Expand Down Expand Up @@ -101,6 +101,12 @@
android:key="prefs_key_system_ui_statusbar_network_speed_detailed"
android:title="@string/system_ui_statusbar_network_speed_detailed" />

<SwitchPreference
android:defaultValue="false"
android:dependency="prefs_key_system_ui_statusbar_network_speed_show_up_down"
android:key="prefs_key_system_ui_statusbar_network_speed_swap_places"
android:title="@string/system_ui_statusbar_network_speed_swap_places" />

<DropDownPreference
android:defaultValue="2"
android:dependency="prefs_key_system_ui_statusbar_network_speed_show_up_down"
Expand All @@ -117,9 +123,9 @@
app:entries="@array/system_ui_status_bar_horizontal_align"
app:entryValues="@array/system_ui_status_bar_horizontal_align_value" />

<SeekBarPreferenceEx
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_fixedcontent_width"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:title="@string/system_ui_statusbar_indicator_fixedcontent_width"
android:summary="@string/system_ui_statusbar_indicator_fixedcontent_width_desc"
android:defaultValue="10"
Expand All @@ -130,19 +136,19 @@
app:format="%d dp"
app:showSeekBarValue="true" />

<SeekBarPreferenceEx
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_left_margin"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:title="@string/left_margin"
android:defaultValue="0"
android:defaultValue="0"
app:defaultValueText="@string/array_default"
app:maxValue="10"
app:stepValue="1"
app:displayDividerValue="2"
app:format="%d dp"
app:format="%d dp"
app:showSeekBarValue="true" />

<SeekBarPreferenceEx
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_statusbar_network_speed_right_margin"
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:title="@string/right_margin"
Expand All @@ -154,17 +160,17 @@
app:format="%d dp"
app:showSeekBarValue="true" />

<SeekBarPreferenceEx
<SeekBarPreferenceEx
android:dependency="prefs_key_system_ui_statusbar_network_speed_enable_custom"
android:key="prefs_key_system_ui_statusbar_network_speed_vertical_offset"
android:title="@string/vertical_offset"
android:title="@string/vertical_offset"
android:defaultValue="8"
app:defaultValueText="@string/array_default"
app:maxValue="16"
app:stepValue="1"
app:negativeShift="8"
app:displayDividerValue="2"
app:format="%d dp"
app:format="%d dp"
app:showSeekBarValue="true" />

</PreferenceCategory>
Expand Down

0 comments on commit 42efe5c

Please sign in to comment.