Cherish:Status network traffic [2/2]

arrow-edits:
 - migrate to androidx

Change-Id: I1769659ce44be6be0187757627b82a8dabbc743d
This commit is contained in:
ezio84
2020-01-22 17:16:51 +01:00
committed by Hưng Phan
parent 26ffd19b79
commit d749919f35
5 changed files with 77 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="m448.477,87.289c-40.531,-46.227 -96.207,-76.348 -156.781,-84.813 -4.102,-0.578 -7.891,2.289 -8.465,6.391 -0.574,4.102 2.289,7.891 6.391,8.465 57.008,7.969 109.418,36.324 147.574,79.848 38.516,43.926 59.723,100.328 59.723,158.82 0,64.375 -25.063,124.895 -70.574,170.414 -45.516,45.516 -106.023,70.586 -170.383,70.586 -56.898,0 -112.117,-20.203 -155.496,-56.891 -3.16,-2.672 -7.895,-2.277 -10.57,0.887 -2.676,3.16 -2.277,7.895 0.883,10.566 46.082,38.973 104.746,60.438 165.184,60.438 68.367,0 132.645,-26.629 180.988,-74.98 48.344,-48.352 74.969,-112.641 74.969,-181.02 0,-62.133 -22.531,-122.047 -63.441,-168.711zM448.477,87.289"/>
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="m255.961,15c4.141,0 7.5,-3.355 7.5,-7.5s-3.359,-7.5 -7.5,-7.5c-68.371,0 -132.648,26.629 -180.992,74.98 -48.344,48.352 -74.969,112.641 -74.969,181.02 0,61.383 22.055,120.75 62.098,167.164 1.48,1.719 3.578,2.602 5.68,2.602 1.738,0 3.48,-0.602 4.898,-1.824 3.137,-2.703 3.484,-7.438 0.777,-10.578 -37.695,-43.688 -58.453,-99.578 -58.453,-157.363 0,-64.375 25.063,-124.895 70.574,-170.414 45.516,-45.516 106.023,-70.586 170.387,-70.586zM255.961,15"/>
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="m229.438,116 l-44.602,44.609c-12.391,12.395 -12.391,32.563 0,44.953l44.047,44.051c5.27,5.273 12.262,8.195 19.711,8.25 -2.121,1.223 -4.098,2.727 -5.871,4.5l-0.09,0.09c-10.57,10.574 -10.945,27.539 -1.125,38.566h-37.809c-15.535,0 -28.172,12.641 -28.172,28.176 0,15.539 12.641,28.176 28.172,28.176h38.324c-9.801,11.055 -9.414,28.027 1.168,38.609 5.32,5.324 12.395,8.254 19.922,8.254 7.527,0 14.602,-2.93 19.922,-8.254l44.043,-44.051c12.395,-12.395 12.395,-32.563 0,-44.953l-7.086,-7.09c-2.93,-2.93 -7.68,-2.93 -10.605,0 -2.93,2.926 -2.93,7.676 0,10.605l7.086,7.086c6.543,6.547 6.547,17.199 0,23.742l-44.043,44.055c-2.488,2.488 -5.797,3.859 -9.316,3.859 -3.516,0 -6.824,-1.371 -9.313,-3.859 -5.141,-5.137 -5.141,-13.496 0,-18.637l11.563,-11.563c2.145,-2.145 2.785,-5.371 1.625,-8.172 -1.164,-2.805 -3.898,-4.633 -6.93,-4.633h-56.355c-7.266,0 -13.176,-5.91 -13.176,-13.176 0,-7.266 5.91,-13.176 13.176,-13.176h55.844c3.031,0 5.766,-1.828 6.93,-4.633 1.16,-2.801 0.516,-6.027 -1.625,-8.172l-11.609,-11.609c-5.109,-5.113 -5.109,-13.434 0,-18.547l0.09,-0.09c2.477,-2.477 5.77,-3.84 9.27,-3.84s6.793,1.363 9.27,3.84l12.957,12.957c2.93,2.93 7.68,2.93 10.609,0.004 2.926,-2.93 2.926,-7.68 0,-10.609l-12.957,-12.957c-5.258,-5.254 -12.227,-8.172 -19.652,-8.227 2.129,-1.23 4.117,-2.738 5.898,-4.523 10.582,-10.582 10.973,-27.555 1.168,-38.605h38.324c15.535,0 28.172,-12.641 28.172,-28.18 0,-15.535 -12.637,-28.176 -28.172,-28.176h-37.809c9.82,-11.027 9.445,-27.992 -1.125,-38.566l-0.09,-0.086c-5.309,-5.313 -12.371,-8.234 -19.879,-8.234 -7.508,0 -14.566,2.922 -19.879,8.234zM258.676,126.691c5.113,5.113 5.113,13.438 0,18.551l-11.605,11.609c-2.145,2.145 -2.789,5.371 -1.625,8.172 1.16,2.801 3.895,4.629 6.926,4.629h55.848c7.262,0 13.172,5.91 13.172,13.176 0,7.27 -5.91,13.18 -13.172,13.18h-56.359c-3.031,0 -5.766,1.828 -6.926,4.629 -1.164,2.801 -0.52,6.027 1.625,8.172l11.563,11.566c5.137,5.137 5.137,13.496 0,18.637 -2.488,2.484 -5.797,3.855 -9.316,3.855 -3.516,0 -6.824,-1.371 -9.313,-3.855l-44.047,-44.055c-6.543,-6.547 -6.543,-17.195 0,-23.742l44.605,-44.609c2.477,-2.477 5.766,-3.84 9.27,-3.84 3.5,0 6.793,1.363 9.27,3.84zM258.676,126.691"/>
</vector>

View File

@@ -213,5 +213,18 @@
<item>2</item>
<item>3</item>
</string-array>
<!-- Network Traffic Type -->
<string-array name="show_network_traffic_type_entries" translatable="false">
<item>@string/show_network_traffic_up</item>
<item>@string/show_network_traffic_down</item>
<item>@string/show_network_traffic_all</item>
</string-array>
<string-array name="show_network_traffic_type_values" translatable="false">
<item>1</item>
<item>2</item>
<item>0</item>
</string-array>
</resources>

View File

@@ -184,5 +184,16 @@
<string name="battery_percentage_next">Enabled</string>
<string name="battery_percentage_inside">Enabled (inside icon)</string>
<string name="battery_percentage_estimate">Enabled (estimate)</string>
<!-- Network traffic -->
<string name="traffic_title">Traffic indicators</string>
<string name="traffic_title_summary">Customize network traffic indicators</string>
<string name="network_traffic_title">Network traffic</string>
<string name="network_traffic_type">Select net activity type</string>
<string name="show_network_traffic_up">Uplink</string>
<string name="show_network_traffic_down">Downlink</string>
<string name="show_network_traffic_all">Uplink and Downlink</string>
<string name="network_traffic_state_title">Show net activity in statusbar</string>
<string name="network_traffic_autohide_threshold_title">Net activity autohide threshold (KB/s)</string>
</resources>

View File

@@ -25,8 +25,21 @@
android:summary="@string/status_bar_system_icons_summary">
<intent android:action="com.android.settings.action.STATUS_BAR_TUNER" />
</Preference>
</PreferenceCategory>
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="network_traffic_state"
android:icon="@drawable/ic_network_traffic"
android:title="@string/network_traffic_state_title"
android:defaultValue="false" />
<com.cherish.settings.preferences.CustomSeekBarPreference
android:key="network_traffic_autohide_threshold"
android:icon="@drawable/ic_network_traffic"
android:title="@string/network_traffic_autohide_threshold_title"
android:max="10"
settings:min="0"
settings:units="" />
<com.cherish.settings.preferences.SystemSettingMasterSwitchPreference
android:key="status_bar_clock"
android:icon="@drawable/ic_clock"
@@ -34,6 +47,8 @@
android:title="@string/status_bar_clock_title"
android:summary="@string/status_bar_clock_summary"
android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory

View File

@@ -55,6 +55,8 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
private ListPreference mBatteryPercent;
private ListPreference mBatteryStyle;
private SwitchPreference mBatteryCharging;
private CustomSeekBarPreference mThreshold;
private SystemSettingSwitchPreference mNetMonitor;
@Override
public void onCreate(Bundle icicle) {
@@ -80,6 +82,19 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
mBatteryStyle.setOnPreferenceChangeListener(this);
updateBatteryOptions(batterystyle);
boolean isNetMonitorEnabled = Settings.System.getIntForUser(resolver,
Settings.System.NETWORK_TRAFFIC_STATE, 1, UserHandle.USER_CURRENT) == 1;
mNetMonitor = (SystemSettingSwitchPreference) findPreference("network_traffic_state");
mNetMonitor.setChecked(isNetMonitorEnabled);
mNetMonitor.setOnPreferenceChangeListener(this);
int value = Settings.System.getIntForUser(resolver,
Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD, 1, UserHandle.USER_CURRENT);
mThreshold = (CustomSeekBarPreference) findPreference("network_traffic_autohide_threshold");
mThreshold.setValue(value);
mThreshold.setOnPreferenceChangeListener(this);
mThreshold.setEnabled(isNetMonitorEnabled);
}
@Override
@@ -93,7 +108,22 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
int value = Integer.parseInt((String) objValue);
updateBatteryOptions(value);
return true;
}
} else if (preference == mNetMonitor) {
boolean value = (Boolean) objValue;
Settings.System.putIntForUser(getActivity().getContentResolver(),
Settings.System.NETWORK_TRAFFIC_STATE, value ? 1 : 0,
UserHandle.USER_CURRENT);
mNetMonitor.setChecked(value);
mThreshold.setEnabled(value);
return true;
} else if (preference == mThreshold) {
int val = (Integer) objValue;
Settings.System.putIntForUser(getContentResolver(),
Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD, val,
UserHandle.USER_CURRENT);
return true;
}
return false;
}