Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java |
index 8450c91e4fced05e1997bab2228d9f4ac7ea98e9..4b1790811f4c26719b5d1b2a81dab3ddf97d4aeb 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java |
@@ -30,6 +30,13 @@ import java.util.List; |
*/ |
public class DataReductionSiteBreakdownView extends LinearLayout { |
private static final int NUM_DATA_USE_ITEMS_TO_ADD = 10; |
+ |
+ /** |
+ * Hostname used for the other bucket which consists of chrome-services traffic. |
+ * This should be in sync with the same in DataReductionProxyDataUseObserver. |
+ */ |
+ private static final String OTHER_HOST_NAME = "Other"; |
+ |
private int mNumDataUseItemsToDisplay = 10; |
private TableLayout mTableLayout; |
@@ -89,7 +96,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout { |
mDataUseItems = items; |
setTextViewUnsortedAttributes(mDataUsedTitle); |
setTextViewSortedAttributes(mDataSavedTitle); |
- Collections.sort(items, new DataSavedComparator()); |
+ Collections.sort(mDataUseItems, new DataSavedComparator()); |
if (mDataUseItems.size() == 0) { |
setVisibility(GONE); |
} else { |
@@ -130,7 +137,12 @@ public class DataReductionSiteBreakdownView extends LinearLayout { |
implements Comparator<DataReductionDataUseItem>, Serializable { |
@Override |
public int compare(DataReductionDataUseItem lhs, DataReductionDataUseItem rhs) { |
- if (lhs.getDataUsed() < rhs.getDataUsed()) { |
+ // Force the 'Other' category to the bottom of the list. |
+ if (OTHER_HOST_NAME.equals(lhs.getHostname())) { |
+ return 1; |
+ } else if (OTHER_HOST_NAME.equals(rhs.getHostname())) { |
+ return -1; |
+ } else if (lhs.getDataUsed() < rhs.getDataUsed()) { |
return 1; |
} else if (lhs.getDataUsed() > rhs.getDataUsed()) { |
return -1; |
@@ -147,7 +159,12 @@ public class DataReductionSiteBreakdownView extends LinearLayout { |
implements Comparator<DataReductionDataUseItem>, Serializable { |
@Override |
public int compare(DataReductionDataUseItem lhs, DataReductionDataUseItem rhs) { |
- if (lhs.getDataSaved() < rhs.getDataSaved()) { |
+ // Force the 'Other' category to the bottom of the list. |
+ if (OTHER_HOST_NAME.equals(lhs.getHostname())) { |
+ return 1; |
+ } else if (OTHER_HOST_NAME.equals(rhs.getHostname())) { |
+ return -1; |
+ } else if (lhs.getDataSaved() < rhs.getDataSaved()) { |
return 1; |
} else if (lhs.getDataSaved() > rhs.getDataSaved()) { |
return -1; |
@@ -180,7 +197,12 @@ public class DataReductionSiteBreakdownView extends LinearLayout { |
TextView dataUsedView = (TextView) row.findViewById(R.id.site_data_used); |
TextView dataSavedView = (TextView) row.findViewById(R.id.site_data_saved); |
- hostnameView.setText(mDataUseItems.get(i).getHostname()); |
+ String hostName = mDataUseItems.get(i).getHostname(); |
+ if (OTHER_HOST_NAME.equals(hostName)) { |
+ hostName = getResources().getString( |
+ R.string.data_reduction_breakdown_other_host_name); |
+ } |
+ hostnameView.setText(hostName); |
dataUsedView.setText(mDataUseItems.get(i).getFormattedDataUsed(getContext())); |
dataSavedView.setText(mDataUseItems.get(i).getFormattedDataSaved(getContext())); |
@@ -228,4 +250,4 @@ public class DataReductionSiteBreakdownView extends LinearLayout { |
mTableLayout.requestLayout(); |
} |
-} |
+} |