NetworkTraffic: Show single traffic for statusbar & allow custom font size [2/2].

Based on commits by idoybh, SKULSHADY and SDB:
* https://github.com/pixeldust-project-caf/android_packages_apps_PixelDustSettings/commit/8f52988
* https://github.com/pixeldust-project-caf/android_packages_apps_PixelDustSettings/commit/0a5424b

Co-authored-by: Ido Ben-Hur <idoybh2@gmail.com>
Co-authored-by: SuperDroidBond <superdroidbond@yahoo.com>
Signed-off-by: spezi77 <spezi7713@gmx.net>
Change-Id: I26c826066569af2cb07c2a9e6c03f6c71f8a18f7
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
SKULSHADY
2022-02-03 20:48:33 +01:00
committed by Hưng Phan
parent a855197418
commit 3b1960c6ea
3 changed files with 27 additions and 1 deletions

View File

@@ -59,10 +59,12 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
private static final String NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD = "network_traffic_autohide_threshold";
private static final String NETWORK_TRAFFIC_LOCATION = "network_traffic_location";
private static final String NETWORK_TRAFFIC_REFRESH_INTERVAL = "network_traffic_refresh_interval";
private static final String NETWORK_TRAFFIC_FONT_SIZE = "network_traffic_font_size";
private CustomSeekBarPreference mThreshold;
private SystemSettingSeekBarPreference mInterval;
private ListPreference mNetTrafficLocation;
private CustomSeekBarPreference mNetTrafficSize;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -91,6 +93,12 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
mInterval.setValue(val);
mInterval.setOnPreferenceChangeListener(this);
int fontSize = Settings.System.getInt(resolver,
Settings.System.NETWORK_TRAFFIC_FONT_SIZE, 18);
mNetTrafficSize = (CustomSeekBarPreference) findPreference(NETWORK_TRAFFIC_FONT_SIZE);
mNetTrafficSize.setValue(fontSize / 1);
mNetTrafficSize.setOnPreferenceChangeListener(this);
int netMonitorEnabled = Settings.System.getIntForUser(resolver,
Settings.System.NETWORK_TRAFFIC_STATE, 0, UserHandle.USER_CURRENT);
if (netMonitorEnabled == 1) {
@@ -145,6 +153,11 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
Settings.System.NETWORK_TRAFFIC_REFRESH_INTERVAL, val,
UserHandle.USER_CURRENT);
return true;
} else if (preference == mNetTrafficSize) {
int fontSize = ((Integer)objValue).intValue();
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.NETWORK_TRAFFIC_FONT_SIZE, fontSize);
return true;
}
return false;
}
@@ -154,11 +167,15 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
case 0:
mThreshold.setEnabled(false);
mInterval.setEnabled(false);
mNetTrafficSize.setEnabled(false);
break;
case 1:
mNetTrafficSize.setEnabled(true);
break;
case 2:
mThreshold.setEnabled(true);
mInterval.setEnabled(true);
mNetTrafficSize.setEnabled(false);
break;
default:
break;