From ebec46847d4bbd72161fb32282ab7a68effa00a7 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 8 Oct 2013 17:17:08 -0700 Subject: [PATCH] Sometimes the print button not enabled and an accessibility fix. 1. Sometimes the print button is not enabled after selecting a printer from the all printers activity. This was happening after a printer was selected, we had to do a layout due to changed print attributes (because of the new printer's capabilities), and the content did not change. In this case we did not call the updateUi function which enables the print button after layout is completed. 2. The accessibility code in the all printers activity was not checking whether accessibility is on and doing some unnecessary work - not sending events though but still. Further, the delayed runnable that was doing the accessibilty announcements was not removed when the activity was paused. bug:10983508 Change-Id: Ib263116a3e21e4c75a25aa051cecbd9194417319 --- .../printspooler/PrintJobConfigActivity.java | 1 + .../printspooler/SelectPrinterFragment.java | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java index 0bd8344d5b3d3..d6ebc2df0450f 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java @@ -456,6 +456,7 @@ public class PrintJobConfigActivity extends Activity { // Then update the print jobs's pages as we will not do a write // and we usually update the pages in the write complete callback. updatePrintJobPages(mDocument.pages, mRequestedPages); + mEditor.updateUi(); if (mEditor.isDone()) { requestCreatePdfFileOrFinish(); } diff --git a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java index 7a91cef275b23..d68893236ca84 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java +++ b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java @@ -167,6 +167,14 @@ public final class SelectPrinterFragment extends ListFragment { super.onResume(); } + @Override + public void onPause() { + if (mAnnounceFilterResult != null) { + mAnnounceFilterResult.remove(); + } + super.onPause(); + } + @Override public void onListItemClick(ListView list, View view, int position, long id) { PrinterInfo printer = (PrinterInfo) list.getAdapter().getItem(position); @@ -266,11 +274,13 @@ public final class SelectPrinterFragment extends ListFragment { } } - private void announceSearchResult() { - if (mAnnounceFilterResult == null) { - mAnnounceFilterResult = new AnnounceFilterResult(); + private void announceSearchResultIfNeeded() { + if (AccessibilityManager.getInstance(getActivity()).isEnabled()) { + if (mAnnounceFilterResult == null) { + mAnnounceFilterResult = new AnnounceFilterResult(); + } + mAnnounceFilterResult.post(); } - mAnnounceFilterResult.post(); } public static class AddPrinterAlertDialogFragment extends DialogFragment { @@ -397,7 +407,7 @@ public final class SelectPrinterFragment extends ListFragment { resultCountChanged = (oldPrinterCount != mFilteredPrinters.size()); } if (resultCountChanged) { - announceSearchResult(); + announceSearchResultIfNeeded(); } notifyDataSetChanged(); }