Commit 3684f1d6 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Fix DataSaver TalkBack issues

Also adds an option to sort by hostname on the DataSaver settings page
so that the TalkBack navigation experience is consistent with the other
table headers.

Bug: 836018
Change-Id: Ic837d520ea613185398b0b2214640b80a41bcfa4
Reviewed-on: https://chromium-review.googlesource.com/1077588Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563052}
parent 4f46cc0e
...@@ -37,10 +37,14 @@ ...@@ -37,10 +37,14 @@
android:layout_width="match_parent"> android:layout_width="match_parent">
<TextView <TextView
android:id="@+id/data_reduction_breakdown_site_title"
android:text="@string/data_reduction_breakdown_site_title" android:text="@string/data_reduction_breakdown_site_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0" android:layout_weight="0"
android:layout_gravity="start" android:layout_gravity="start"
android:contentDescription="@string/data_reduction_breakdown_site_header_content_description"
android:drawablePadding="3dp"
android:drawableEnd="@drawable/data_reduction_breakdown_sort_arrow"
style="@style/DataUsageBreakdownColumnLabel" /> style="@style/DataUsageBreakdownColumnLabel" />
<TextView <TextView
...@@ -48,6 +52,7 @@ ...@@ -48,6 +52,7 @@
android:text="@string/data_reduction_breakdown_used_title" android:text="@string/data_reduction_breakdown_used_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
android:contentDescription="@string/data_reduction_breakdown_used_header_content_description"
android:drawablePadding="3dp" android:drawablePadding="3dp"
android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow" android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow"
android:gravity="end" android:gravity="end"
...@@ -58,6 +63,7 @@ ...@@ -58,6 +63,7 @@
android:text="@string/data_reduction_breakdown_saved_title" android:text="@string/data_reduction_breakdown_saved_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
android:contentDescription="@string/data_reduction_breakdown_saved_header_content_description"
android:drawablePadding="3dp" android:drawablePadding="3dp"
android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow" android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow"
android:gravity="end" android:gravity="end"
......
...@@ -50,7 +50,8 @@ public class DataReductionProxyUma { ...@@ -50,7 +50,8 @@ public class DataReductionProxyUma {
public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED = 24; public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED = 24;
public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED = 25; public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED = 25;
public static final int ACTION_SITE_BREAKDOWN_EXPANDED = 26; public static final int ACTION_SITE_BREAKDOWN_EXPANDED = 26;
public static final int ACTION_INDEX_BOUNDARY = 27; public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_HOSTNAME = 27;
public static final int ACTION_INDEX_BOUNDARY = 28;
// Represent the possible Lo-Fi context menu user actions. This must remain in sync with // Represent the possible Lo-Fi context menu user actions. This must remain in sync with
// Previews.ContextMenuAction.LoFi in tools/metrics/histograms/histograms.xml. // Previews.ContextMenuAction.LoFi in tools/metrics/histograms/histograms.xml.
......
...@@ -39,6 +39,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -39,6 +39,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
private int mNumDataUseItemsToDisplay = 10; private int mNumDataUseItemsToDisplay = 10;
private TableLayout mTableLayout; private TableLayout mTableLayout;
private TextView mHostnameTitle;
private TextView mDataUsedTitle; private TextView mDataUsedTitle;
private TextView mDataSavedTitle; private TextView mDataSavedTitle;
private List<DataReductionDataUseItem> mDataUseItems; private List<DataReductionDataUseItem> mDataUseItems;
...@@ -52,14 +53,29 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -52,14 +53,29 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
mTableLayout = (TableLayout) findViewById(R.id.data_reduction_proxy_breakdown_table); mTableLayout = (TableLayout) findViewById(R.id.data_reduction_proxy_breakdown_table);
mHostnameTitle = (TextView) findViewById(R.id.data_reduction_breakdown_site_title);
mDataUsedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_used_title); mDataUsedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_used_title);
mDataSavedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_saved_title); mDataSavedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_saved_title);
mHostnameTitle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
DataReductionProxyUma.dataReductionProxyUIAction(
DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_HOSTNAME);
setTextViewUnsortedAttributes(mDataSavedTitle);
setTextViewUnsortedAttributes(mDataUsedTitle);
setTextViewSortedAttributes(mHostnameTitle);
Collections.sort(mDataUseItems, new HostnameComparator());
updateSiteBreakdown();
}
});
mDataUsedTitle.setOnClickListener(new OnClickListener() { mDataUsedTitle.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
DataReductionProxyUma.dataReductionProxyUIAction( DataReductionProxyUma.dataReductionProxyUIAction(
DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED); DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED);
setTextViewUnsortedAttributes(mHostnameTitle);
setTextViewUnsortedAttributes(mDataSavedTitle); setTextViewUnsortedAttributes(mDataSavedTitle);
setTextViewSortedAttributes(mDataUsedTitle); setTextViewSortedAttributes(mDataUsedTitle);
Collections.sort(mDataUseItems, new DataUsedComparator()); Collections.sort(mDataUseItems, new DataUsedComparator());
...@@ -72,6 +88,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -72,6 +88,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
public void onClick(View v) { public void onClick(View v) {
DataReductionProxyUma.dataReductionProxyUIAction( DataReductionProxyUma.dataReductionProxyUIAction(
DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED); DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED);
setTextViewUnsortedAttributes(mHostnameTitle);
setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewUnsortedAttributes(mDataUsedTitle);
setTextViewSortedAttributes(mDataSavedTitle); setTextViewSortedAttributes(mDataSavedTitle);
Collections.sort(mDataUseItems, new DataSavedComparator()); Collections.sort(mDataUseItems, new DataSavedComparator());
...@@ -85,6 +102,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -85,6 +102,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mTextViewsNeedAttributesSet) { if (mTextViewsNeedAttributesSet) {
mTextViewsNeedAttributesSet = false; mTextViewsNeedAttributesSet = false;
setTextViewUnsortedAttributes(mHostnameTitle);
setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewUnsortedAttributes(mDataUsedTitle);
setTextViewSortedAttributes(mDataSavedTitle); setTextViewSortedAttributes(mDataSavedTitle);
} }
...@@ -96,6 +114,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -96,6 +114,7 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
*/ */
public void setAndDisplayDataUseItems(List<DataReductionDataUseItem> items) { public void setAndDisplayDataUseItems(List<DataReductionDataUseItem> items) {
mDataUseItems = items; mDataUseItems = items;
setTextViewUnsortedAttributes(mHostnameTitle);
setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewUnsortedAttributes(mDataUsedTitle);
setTextViewSortedAttributes(mDataSavedTitle); setTextViewSortedAttributes(mDataSavedTitle);
Collections.sort(mDataUseItems, new DataSavedComparator()); Collections.sort(mDataUseItems, new DataSavedComparator());
...@@ -147,6 +166,23 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -147,6 +166,23 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
return drawables[2]; return drawables[2];
} }
/**
* Sorts the DataReductionDataUseItems by hostname.
*/
private static final class HostnameComparator
implements Comparator<DataReductionDataUseItem>, Serializable {
@Override
public int compare(DataReductionDataUseItem lhs, DataReductionDataUseItem rhs) {
// 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;
}
return lhs.getHostname().compareTo(rhs.getHostname());
}
}
/** /**
* Sorts the DataReductionDataUseItems by most to least data used. * Sorts the DataReductionDataUseItems by most to least data used.
*/ */
...@@ -220,8 +256,18 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -220,8 +256,18 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
R.string.data_reduction_breakdown_other_host_name); R.string.data_reduction_breakdown_other_host_name);
} }
hostnameView.setText(hostName); hostnameView.setText(hostName);
dataUsedView.setText(mDataUseItems.get(i).getFormattedDataUsed(getContext()));
dataSavedView.setText(mDataUseItems.get(i).getFormattedDataSaved(getContext())); final CharSequence dataUsed =
mDataUseItems.get(i).getFormattedDataUsed(getContext());
dataUsedView.setText(dataUsed);
dataUsedView.setContentDescription(getResources().getString(
R.string.data_reduction_breakdown_used_content_description, dataUsed));
final CharSequence dataSaved =
mDataUseItems.get(i).getFormattedDataSaved(getContext());
dataSavedView.setText(dataSaved);
dataSavedView.setContentDescription(getResources().getString(
R.string.data_reduction_breakdown_saved_content_description, dataSaved));
mTableLayout.addView(row, i + 1); mTableLayout.addView(row, i + 1);
} else { } else {
......
...@@ -155,9 +155,14 @@ public class DataReductionStatsPreference extends Preference { ...@@ -155,9 +155,14 @@ public class DataReductionStatsPreference extends Preference {
} }
private void setDetailText() { private void setDetailText() {
final Context context = getContext();
updateDetailData(); updateDetailData();
mStartDateTextView.setText(mStartDatePhrase); mStartDateTextView.setText(mStartDatePhrase);
mStartDateTextView.setContentDescription(context.getString(
R.string.data_reduction_start_date_content_description, mStartDatePhrase));
mEndDateTextView.setText(mEndDatePhrase); mEndDateTextView.setText(mEndDatePhrase);
mEndDateTextView.setContentDescription(context.getString(
R.string.data_reduction_end_date_content_description, mEndDatePhrase));
if (mDataUsageTextView != null) mDataUsageTextView.setText(mReceivedTotalPhrase); if (mDataUsageTextView != null) mDataUsageTextView.setText(mReceivedTotalPhrase);
if (mDataSavingsTextView != null) mDataSavingsTextView.setText(mSavingsTotalPhrase); if (mDataSavingsTextView != null) mDataSavingsTextView.setText(mSavingsTotalPhrase);
} }
......
...@@ -1129,15 +1129,36 @@ To obtain new licenses, connect to the internet and play your downloaded content ...@@ -1129,15 +1129,36 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_DATA_REDUCTION_USAGE_LABEL" desc="Data Reduction statistics label that states the amount of data that was used by Chrome when Data Saver is enabled."> <message name="IDS_DATA_REDUCTION_USAGE_LABEL" desc="Data Reduction statistics label that states the amount of data that was used by Chrome when Data Saver is enabled.">
data used data used
</message> </message>
<message name="IDS_DATA_REDUCTION_START_DATE_CONTENT_DESCRIPTION" desc="This label is used in the device screen reader to describe the starting date that data savings are computed from. This will always be used in the form 'Start date: February 28'.">
Start date <ph name="date">%1$s<ex>Feb 28</ex></ph>
</message>
<message name="IDS_DATA_REDUCTION_END_DATE_CONTENT_DESCRIPTION" desc="This label is used in the device screen reader to describe the end date that data savings are computed until. This will always be used in the form 'End date: February 28'..">
End date <ph name="date">%1$s<ex>Feb 28</ex></ph>
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_SITE_TITLE" desc="Title for the sites column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved."> <message name="IDS_DATA_REDUCTION_BREAKDOWN_SITE_TITLE" desc="Title for the sites column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved.">
Site Site
</message> </message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_SITE_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted by website domain name. This is used in the device's screen reader and is not displayed visually to the user.">
Sort by site
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_TITLE" desc="Title for the data used column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved."> <message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_TITLE" desc="Title for the data used column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved.">
Used Used
</message> </message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted descending by the amount of mobile data that was used when viewing a webpage. This is used in the device's screen reader and is not displayed visually to the user.">
Sort by amount of data used
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_TITLE" desc="Title for the data saved column on the Data Reduction statistics page. The breakdown lists for the top ten sites with the greatest amount of data usage or mobile data that was saved. Data Saver allows users to to reduce their mobile data usage by compressing network traffic."> <message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_TITLE" desc="Title for the data saved column on the Data Reduction statistics page. The breakdown lists for the top ten sites with the greatest amount of data usage or mobile data that was saved. Data Saver allows users to to reduce their mobile data usage by compressing network traffic.">
Saved Saved
</message> </message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted descending by the amount of mobile data that was saved when viewing a webpage by using Chrome's Data Saver feature. This is used in the device's screen reader and is not displayed visually to the user.">
Sort by amount of data saved
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_CONTENT_DESCRIPTION" desc="This label is used as a suffix to describe the amount of mobile data that was used to view a webpage. It is used in the form '0 bytes used'.">
<ph name="amount">%1$s<ex>0 bytes</ex></ph> used
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_CONTENT_DESCRIPTION" desc="This label is used as a suffix to describe the amount of mobile data that was saved when viewing a webpage by using Chrome's Data Saver feature. It is used in the form '0 bytes used'.">
<ph name="amount">%1$s<ex>0 bytes</ex></ph> saved
</message>
<message name="IDS_DATA_REDUCTION_BREAKDOWN_REMAINING_SITES_LABEL" desc="Title for the the remaining sites on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved and then groups the remaining sites together."> <message name="IDS_DATA_REDUCTION_BREAKDOWN_REMAINING_SITES_LABEL" desc="Title for the the remaining sites on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved and then groups the remaining sites together.">
Remaining sites (<ph name="NUMBER_OF_SITES">%1$d<ex>35</ex></ph>) Remaining sites (<ph name="NUMBER_OF_SITES">%1$d<ex>35</ex></ph>)
</message> </message>
......
...@@ -9057,6 +9057,7 @@ Called by update_net_error_codes.py.--> ...@@ -9057,6 +9057,7 @@ Called by update_net_error_codes.py.-->
<int value="24" label="Site breakdown sorted by data saved"/> <int value="24" label="Site breakdown sorted by data saved"/>
<int value="25" label="Site breakdown sorted by data used"/> <int value="25" label="Site breakdown sorted by data used"/>
<int value="26" label="Site breakdown expanded to see more sites"/> <int value="26" label="Site breakdown expanded to see more sites"/>
<int value="27" label="Site breakdown sorted by hostname"/>
</enum> </enum>
<enum name="DataReductionProxyWarmupURLFetchAttemptEvent"> <enum name="DataReductionProxyWarmupURLFetchAttemptEvent">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment