Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java

Issue 2953523002: Add 'Other' category on the Data Saver site-breakdown page (Closed)
Patch Set: fixed message description Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
-}
+}
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698