am 9470cd95: Merge "Polish print dialog accessibility." into klp-dev
* commit '9470cd95dcf691eec33839065948bd32aab06fc6': Polish print dialog accessibility.
This commit is contained in:
@@ -21,14 +21,14 @@
|
||||
android:title="@string/search"
|
||||
android:icon="@*android:drawable/ic_menu_search_holo_light"
|
||||
android:actionViewClass="android.widget.SearchView"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:alphabeticShortcut="f"
|
||||
android:imeOptions="actionSearch">
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_printer"
|
||||
android:title="@null"
|
||||
android:title="@string/print_add_printer"
|
||||
android:icon="@*android:drawable/create_contact"
|
||||
android:showAsAction="ifRoom"
|
||||
android:alphabeticShortcut="a">
|
||||
|
||||
@@ -67,6 +67,9 @@
|
||||
<!-- Title for the open all printers UI option in the printer list. [CHAR LIMIT=30] -->
|
||||
<string name="all_printers">All printers…</string>
|
||||
|
||||
<!-- Title for the print dialog announced to the user for accessibility. Not shown in the UI. [CHAR LIMIT=none] -->
|
||||
<string name="print_dialog">Print dialog</string>
|
||||
|
||||
<!-- Select printer activity -->
|
||||
|
||||
<!-- Title for the share action bar menu item. [CHAR LIMIT=20] -->
|
||||
@@ -78,6 +81,21 @@
|
||||
<!-- Title of the button to install a print service. [CHAR LIMIT=25] -->
|
||||
<string name="add_print_service_label">Add service</string>
|
||||
|
||||
<!-- Utterance to announce that the search box is shown. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||
<string name="print_search_box_shown_utterance">Search box shown</string>
|
||||
|
||||
<!-- Utterance to announce that the search box is hidden. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||
<string name="print_search_box_hidden_utterance">Search box hidden</string>
|
||||
|
||||
<!-- Title of the action bar button to got to add a printer. [CHAR LIMIT=25] -->
|
||||
<string name="print_add_printer">Add printer</string>
|
||||
|
||||
<!-- Utterance to announce a change in the number of matches during a search. This is spoken to a blind user. [CHAR LIMIT=none] -->
|
||||
<plurals name="print_search_result_count_utterance">
|
||||
<item quantity="one"><xliff:g id="count" example="1">%1$s</xliff:g> printer found</item>
|
||||
<item quantity="other"><xliff:g id="count" example="2">%1$s</xliff:g> printers found</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Add printer dialog -->
|
||||
|
||||
<!-- Title for the alert dialog for selecting a print service. [CHAR LIMIT=50] -->
|
||||
|
||||
@@ -178,6 +178,8 @@ public class PrintJobConfigActivity extends Activity {
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
setTitle(R.string.print_dialog);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
PrintJobInfo printJob = extras.getParcelable(EXTRA_PRINT_JOB);
|
||||
|
||||
@@ -82,6 +82,8 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
private final ArrayList<PrintServiceInfo> mAddPrinterServices =
|
||||
new ArrayList<PrintServiceInfo>();
|
||||
|
||||
private AnnounceFilterResult mAnnounceFilterResult;
|
||||
|
||||
public static interface OnPrinterSelectedListener {
|
||||
public void onPrinterSelected(PrinterId printerId);
|
||||
}
|
||||
@@ -133,6 +135,18 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View view) {
|
||||
view.announceForAccessibility(getString(
|
||||
R.string.print_search_box_shown_utterance));
|
||||
}
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View view) {
|
||||
view.announceForAccessibility(getString(
|
||||
R.string.print_search_box_hidden_utterance));
|
||||
}
|
||||
});
|
||||
|
||||
if (mAddPrinterServices.isEmpty()) {
|
||||
menu.removeItem(R.id.action_add_printer);
|
||||
@@ -245,6 +259,13 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void announceSearchResult() {
|
||||
if (mAnnounceFilterResult == null) {
|
||||
mAnnounceFilterResult = new AnnounceFilterResult();
|
||||
}
|
||||
mAnnounceFilterResult.post();
|
||||
}
|
||||
|
||||
public static class AddPrinterAlertDialogFragment extends DialogFragment {
|
||||
|
||||
private String mAddPrintServiceItem;
|
||||
@@ -355,7 +376,9 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
final boolean resultCountChanged;
|
||||
synchronized (mLock) {
|
||||
final int oldPrinterCount = mFilteredPrinters.size();
|
||||
mLastSearchString = constraint;
|
||||
mFilteredPrinters.clear();
|
||||
if (results == null) {
|
||||
@@ -364,6 +387,10 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
List<PrinterInfo> printers = (List<PrinterInfo>) results.values;
|
||||
mFilteredPrinters.addAll(printers);
|
||||
}
|
||||
resultCountChanged = (oldPrinterCount != mFilteredPrinters.size());
|
||||
}
|
||||
if (resultCountChanged) {
|
||||
announceSearchResult();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@@ -480,4 +507,30 @@ public final class SelectPrinterFragment extends ListFragment {
|
||||
notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
private final class AnnounceFilterResult implements Runnable {
|
||||
private static final int SEARCH_RESULT_ANNOUNCEMENT_DELAY = 1000; // 1 sec
|
||||
|
||||
public void post() {
|
||||
remove();
|
||||
getListView().postDelayed(this, SEARCH_RESULT_ANNOUNCEMENT_DELAY);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
getListView().removeCallbacks(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final int count = getListView().getAdapter().getCount();
|
||||
final String text;
|
||||
if (count <= 0) {
|
||||
text = getString(R.string.print_no_printers);
|
||||
} else {
|
||||
text = getActivity().getResources().getQuantityString(
|
||||
R.plurals.print_search_result_count_utterance, count, count);
|
||||
}
|
||||
getListView().announceForAccessibility(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user