NetworkTraffic positioning: Adapt to new settings flags.
Partially based on:1146bf83despezi77 edits: -Clean up the code -Refactorized to work with our new commit:c11cb77923Change-Id: I5fc55ed94a1c9fabacde19e128baaa172a4b4a4c Signed-off-by: spezi77 <spezi7713@gmx.net> Signed-off-by: Arghya Chanda <arghyac35@gmail.com> Signed-off-by: Jayant-Deshmukh <jayantdeshmuk008@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -352,7 +352,7 @@
|
|||||||
<string name="network_traffic_location">Show net activity</string>
|
<string name="network_traffic_location">Show net activity</string>
|
||||||
<string name="traffic_disabled">Disabled</string>
|
<string name="traffic_disabled">Disabled</string>
|
||||||
<string name="traffic_statusbar">Statusbar</string>
|
<string name="traffic_statusbar">Statusbar</string>
|
||||||
<string name="traffic_expanded_statusbar">Expanded Statusbar</string>
|
<string name="traffic_expanded_statusbar">Expanded header</string>
|
||||||
<string name="network_traffic_autohide_threshold_title">Net activity autohide threshold (KB/s)</string>
|
<string name="network_traffic_autohide_threshold_title">Net activity autohide threshold (KB/s)</string>
|
||||||
<string name="network_traffic_arrow">Show arrows</string>
|
<string name="network_traffic_arrow">Show arrows</string>
|
||||||
<string name="network_traffic_arrow_summary">Show the network traffic indicator arrows</string>
|
<string name="network_traffic_arrow_summary">Show the network traffic indicator arrows</string>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/network_traffic_state_title"
|
android:title="@string/network_traffic"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
|
|||||||
|
|
||||||
mNetTrafficLocation = (ListPreference) findPreference("network_traffic_location");
|
mNetTrafficLocation = (ListPreference) findPreference("network_traffic_location");
|
||||||
int location = Settings.System.getIntForUser(resolver,
|
int location = Settings.System.getIntForUser(resolver,
|
||||||
Settings.System.NETWORK_TRAFFIC_LOCATION, 0, UserHandle.USER_CURRENT);
|
Settings.System.NETWORK_TRAFFIC_VIEW_LOCATION, 0, UserHandle.USER_CURRENT);
|
||||||
mNetTrafficLocation.setValue(String.valueOf(location));
|
|
||||||
mNetTrafficLocation.setSummary(mNetTrafficLocation.getEntry());
|
|
||||||
mNetTrafficLocation.setOnPreferenceChangeListener(this);
|
mNetTrafficLocation.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
int trafvalue = Settings.System.getIntForUser(resolver,
|
int trafvalue = Settings.System.getIntForUser(resolver,
|
||||||
@@ -78,7 +76,16 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
|
|||||||
mThreshold.setOnPreferenceChangeListener(this);
|
mThreshold.setOnPreferenceChangeListener(this);
|
||||||
mShowArrows = (SystemSettingSwitchPreference) findPreference("network_traffic_arrow");
|
mShowArrows = (SystemSettingSwitchPreference) findPreference("network_traffic_arrow");
|
||||||
|
|
||||||
updateTrafficLocation(location);
|
int netMonitorEnabled = Settings.System.getIntForUser(resolver,
|
||||||
|
Settings.System.NETWORK_TRAFFIC_STATE, 0, UserHandle.USER_CURRENT);
|
||||||
|
if (netMonitorEnabled == 1) {
|
||||||
|
mNetTrafficLocation.setValue(String.valueOf(location+1));
|
||||||
|
updateTrafficLocation(location+1);
|
||||||
|
} else {
|
||||||
|
mNetTrafficLocation.setValue("0");
|
||||||
|
updateTrafficLocation(0);
|
||||||
|
}
|
||||||
|
mNetTrafficLocation.setSummary(mNetTrafficLocation.getEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,10 +103,20 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
|
|||||||
if (preference == mNetTrafficLocation) {
|
if (preference == mNetTrafficLocation) {
|
||||||
int location = Integer.valueOf((String) objValue);
|
int location = Integer.valueOf((String) objValue);
|
||||||
int index = mNetTrafficLocation.findIndexOfValue((String) objValue);
|
int index = mNetTrafficLocation.findIndexOfValue((String) objValue);
|
||||||
Settings.System.putIntForUser(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_LOCATION, location, UserHandle.USER_CURRENT);
|
|
||||||
mNetTrafficLocation.setSummary(mNetTrafficLocation.getEntries()[index]);
|
mNetTrafficLocation.setSummary(mNetTrafficLocation.getEntries()[index]);
|
||||||
updateTrafficLocation(location);
|
if (location > 0) {
|
||||||
|
// Convert the selected location mode from our list {0,1,2} and store it to "view location" setting: 0=sb; 1=expanded sb
|
||||||
|
Settings.System.putIntForUser(getActivity().getContentResolver(),
|
||||||
|
Settings.System.NETWORK_TRAFFIC_VIEW_LOCATION, location-1, UserHandle.USER_CURRENT);
|
||||||
|
// And also enable the net monitor
|
||||||
|
Settings.System.putIntForUser(getActivity().getContentResolver(),
|
||||||
|
Settings.System.NETWORK_TRAFFIC_STATE, 1, UserHandle.USER_CURRENT);
|
||||||
|
updateTrafficLocation(location+1);
|
||||||
|
} else { // Disable net monitor completely
|
||||||
|
Settings.System.putIntForUser(getActivity().getContentResolver(),
|
||||||
|
Settings.System.NETWORK_TRAFFIC_STATE, 0, UserHandle.USER_CURRENT);
|
||||||
|
updateTrafficLocation(location);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (preference == mThreshold) {
|
} else if (preference == mThreshold) {
|
||||||
int val = (Integer) objValue;
|
int val = (Integer) objValue;
|
||||||
@@ -116,26 +133,11 @@ public class Traffic extends SettingsPreferenceFragment implements OnPreferenceC
|
|||||||
case 0:
|
case 0:
|
||||||
mThreshold.setEnabled(false);
|
mThreshold.setEnabled(false);
|
||||||
mShowArrows.setEnabled(false);
|
mShowArrows.setEnabled(false);
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_STATE, 0);
|
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_EXPANDED_STATUS_BAR_STATE, 0);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mThreshold.setEnabled(true);
|
|
||||||
mShowArrows.setEnabled(true);
|
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_STATE, 1);
|
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_EXPANDED_STATUS_BAR_STATE, 0);
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
mThreshold.setEnabled(true);
|
mThreshold.setEnabled(true);
|
||||||
mShowArrows.setEnabled(true);
|
mShowArrows.setEnabled(true);
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_STATE, 0);
|
|
||||||
Settings.System.putInt(getActivity().getContentResolver(),
|
|
||||||
Settings.System.NETWORK_TRAFFIC_EXPANDED_STATUS_BAR_STATE, 1);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user