[2/2] OmniGears: bring back status nework traffic
Change-Id: I4ddbc4984799e146ef1f057ec87a4bd6609bbadc
diff --git a/res/layout/seek_bar_preference.xml b/res/layout/seek_bar_preference.xml
index 82619ec..bd028cd 100644
--- a/res/layout/seek_bar_preference.xml
+++ b/res/layout/seek_bar_preference.xml
@@ -20,7 +20,7 @@
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingEnd="?android:attr/scrollbarSize"
- android:background="@android:drawable/list_selector_background"
+ android:background="?android:attr/selectableItemBackground"
android:orientation="vertical"
android:focusable="true" >
diff --git a/res/xml/bars_settings.xml b/res/xml/bars_settings.xml
index 90e3dd7..a9144a8 100644
--- a/res/xml/bars_settings.xml
+++ b/res/xml/bars_settings.xml
@@ -55,12 +55,11 @@
</PreferenceScreen>
-->
<!-- Network traffic meter -->
-<!--
<PreferenceScreen
android:key="category_network_traffic"
android:title="@string/network_traffic_title"
android:fragment="org.omnirom.omnigears.interfacesettings.NetworkTraffic" />
-
+<!--
<ListPreference
android:key="status_bar_quick_qs_pulldown"
android:title="@string/status_bar_quick_qs_pulldown_title"
diff --git a/res/xml/network_traffic.xml b/res/xml/network_traffic.xml
index 0f45550..6877985 100644
--- a/res/xml/network_traffic.xml
+++ b/res/xml/network_traffic.xml
@@ -18,7 +18,7 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:key="category_network_traffic"
android:title="@string/network_traffic_title">
-<!--
+
<ListPreference
android:key="network_traffic_state"
android:title="@string/show_network_traffic_state"
@@ -40,13 +40,13 @@
android:entryValues="@array/show_network_traffic_frequency_values"
android:persistent="false" />
- <com.android.settings.preference.SystemCheckBoxPreference
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
android:key="network_traffic_autohide"
android:title="@string/network_traffic_autohide_title"
android:summary="@string/network_traffic_autohide_summary"
android:defaultValue="false"/>
- <com.android.settings.preference.SeekBarPreference
+ <org.omnirom.omnigears.preference.SeekBarPreference
android:key="network_traffic_autohide_threshold"
android:title="@string/network_traffic_autohide_threshold"
android:max="100"
@@ -56,5 +56,4 @@
android:dependency="network_traffic_autohide"
android:persistent="false" />
--->
</PreferenceScreen>
diff --git a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
index 647fade..aa5f02e 100644
--- a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
+++ b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
@@ -95,10 +95,10 @@
//}
// TrafficStats will return UNSUPPORTED if the device does not support it.
- //if (TrafficStats.getTotalTxBytes() == TrafficStats.UNSUPPORTED ||
- // TrafficStats.getTotalRxBytes() == TrafficStats.UNSUPPORTED) {
- // prefScreen.removePreference(findPreference(NETWORK_TRAFFIC_ROOT));
- //}
+ if (TrafficStats.getTotalTxBytes() == TrafficStats.UNSUPPORTED ||
+ TrafficStats.getTotalRxBytes() == TrafficStats.UNSUPPORTED) {
+ prefScreen.removePreference(findPreference(NETWORK_TRAFFIC_ROOT));
+ }
//final boolean customHeaderImage = Settings.System.getInt(getContentResolver(),
// Settings.System.STATUS_BAR_CUSTOM_HEADER, 0) == 1;
diff --git a/src/org/omnirom/omnigears/interfacesettings/NetworkTraffic.java b/src/org/omnirom/omnigears/interfacesettings/NetworkTraffic.java
index 6ea7309..d9331cb 100644
--- a/src/org/omnirom/omnigears/interfacesettings/NetworkTraffic.java
+++ b/src/org/omnirom/omnigears/interfacesettings/NetworkTraffic.java
@@ -13,7 +13,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ */
package org.omnirom.omnigears.interfacesettings;
@@ -25,28 +25,29 @@
import android.net.TrafficStats;
import android.os.Bundle;
import android.os.RemoteException;
-import android.preference.ListPreference;
-import android.preference.Preference;
-import android.preference.PreferenceGroup;
-import android.preference.PreferenceScreen;
-import android.preference.PreferenceCategory;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.PreferenceCategory;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.R;
-import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.util.omni.DeviceUtils;
import com.android.settings.Utils;
-import com.android.settings.preference.SeekBarPreference;
-import com.android.settings.preference.SystemCheckBoxPreference;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import java.util.List;
import java.util.ArrayList;
+import org.omnirom.omnigears.preference.SeekBarPreference;
+import org.omnirom.omnigears.preference.SystemCheckBoxPreference;
+
public class NetworkTraffic extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, Indexable {
private static final String TAG = "NetworkTraffic";
@@ -71,7 +72,7 @@
@Override
protected int getMetricsCategory() {
- return MetricsLogger.OMNI_SETTINGS;
+ return MetricsEvent.OMNI_SETTINGS;
}
@Override
@@ -123,12 +124,6 @@
}
@Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- // If we didn't handle it, let preferences handle it.
- return super.onPreferenceTreeClick(preferenceScreen, preference);
- }
-
- @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
if (preference == mNetTrafficState) {
@@ -204,4 +199,4 @@
return result;
}
};
-}*/
+}
diff --git a/src/org/omnirom/omnigears/preference/SeekBarPreference.java b/src/org/omnirom/omnigears/preference/SeekBarPreference.java
index 5b52844..0e2608f 100644
--- a/src/org/omnirom/omnigears/preference/SeekBarPreference.java
+++ b/src/org/omnirom/omnigears/preference/SeekBarPreference.java
@@ -116,6 +116,7 @@
mSeekBar = (SeekBar) holder.findViewById(R.id.seekbar);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
+ mSeekBar.setEnabled(isEnabled());
mStatusText = (TextView)holder.findViewById(R.id.seekBarPrefValue);
mStatusText.setText(String.valueOf(mCurrentValue));
@@ -194,13 +195,11 @@
mMinValue = value;
}
- public void updateSeekValue() {
- mSeekBar.setMax(mMaxValue - mMinValue);
- }
-
@Override
public void setEnabled (boolean enabled) {
- mSeekBar.setEnabled(enabled);
+ if (mSeekBar != null) {
+ mSeekBar.setEnabled(enabled);
+ }
super.setEnabled(enabled);
}
}