886 Commits

Author SHA1 Message Date
Philip P. Moltmann
f24285d7b3 Visibility of pageRangeTitle =!= pageRangeText
Before if we had only a single page we showed the title, but not the
text

Change-Id: Ie2c178eaf19885e0b1dcc803b9da23ed687764a7
2016-04-29 16:16:08 -07:00
Philip P. Moltmann
4bd8fac48e Send update notifications when the status of a print job updates and
make sure to only access mPrintServicesChangeListenerRecords when
locked.

Bug: 28315242
Change-Id: Ie41ee695e6b1b0394e55538b9d9edaee0610f1e0
2016-04-21 15:33:42 -07:00
Baligh Uddin
6c9b9a0040 Import translations. DO NOT MERGE
Change-Id: I937913df9ba9c5bcb8ca110826e8bb61730eab93
Auto-generated-cl: translation import
2016-04-14 19:11:22 -07:00
Philip P. Moltmann
d0e1239e81 Add a log if the printing activity died unexpectly.
Bug: 27861927
Change-Id: I431ba996e113043c224039a62a76ae23e9c7494a
2016-04-13 08:57:49 -07:00
Bill Yi
4a1171ea92 Import translations. DO NOT MERGE
Change-Id: If767f0a767da0172ba79fb9d8feaff6c1a8c9157
Auto-generated-cl: translation import
2016-04-09 04:14:00 -07:00
Philip P. Moltmann
1a1f24980c Merge "Prefix printer description with service-label instead of package-label." into nyc-dev 2016-04-06 16:09:02 +00:00
Philip P. Moltmann
6c2bed24ec Merge "Print Activity: Use a single (re-implemented) parsing logig for page ranges." into nyc-dev 2016-04-06 16:08:49 +00:00
Bill Yi
f65a843661 Import translations. DO NOT MERGE
Change-Id: Ib8200b22451664277e49d59489e1727b281fa960
Auto-generated-cl: translation import
2016-04-05 00:18:26 -07:00
Philip P. Moltmann
3df18a9465 Prefix printer description with service-label instead of package-label.
Change-Id: Ibe98e0037ad8d62b27b10b72d75fb2e548d0ee90
2016-04-01 17:16:01 -07:00
Philip P. Moltmann
c6c319e988 Print Activity: Use a single (re-implemented) parsing logig for page ranges.
- Support unbounded ranges, e.g. 4- == 4-pageCount and -2 == 1-2
- Do not allow reverse ranges, i.e. 7-3 is not allowed anymore
- restrict characters that can be typed into field
- force numeric keyboard

- Fix bug that we update the selected pages even if the page ranges are
  invalid

Fixes: 13126748
Change-Id: I515d9346ceb152a41b7260792c5dd9bd91b27cab
2016-04-01 14:35:04 -07:00
Philip P. Moltmann
a97415b0b7 Merge "Make sure to update the selected pages when needed in the right order." into nyc-dev 2016-04-01 16:46:20 +00:00
Philip P. Moltmann
9e4bbc60a9 Do not rely on documentInfo.pageCount when selecting which pages to
scrap

documentInfo.PageCount might be set to "unknown" == -1. Hence we don't
know where the last page to scrap ends. Hence defer this decision all
way until PdfManipulationService.removePages as then we know the actual
pages of the document.

Change-Id: I063c3cd084d65a3ac5c60c3d85cec3a346be2680
Fixed: 27948632
2016-03-31 15:39:16 -07:00
Philip P. Moltmann
7b92d3c04d When we update slow we override the current state. Make sure to reset the state the operation finishes.
Bug: 27945565
Change-Id: If3dc3ad54bbf9bedae0e82aeef7b295ae16e1bf0
2016-03-31 14:18:51 -07:00
Philip P. Moltmann
c309d7155a Make sure to update the selected pages when needed in the right order.
Fixes: 27945066
Change-Id: I9c83a5283d6bf093a35ad835532d3c8690b4b989
2016-03-31 13:49:44 -07:00
Bill Yi
25b12ac54e Merge "Import translations. DO NOT MERGE" into nyc-dev 2016-03-31 04:18:13 +00:00
Bill Yi
30443bf699 Import translations. DO NOT MERGE
Change-Id: Icc3eb7aed5c4991a4628cd3978a0d8339ec785a9
Auto-generated-cl: translation import
2016-03-30 20:09:56 -07:00
Philip P. Moltmann
9dcb86a48d Add the print service recommendation service
This service connects through the print manager to the print spooler:

PrintSpooler.AddPrintersActivity <-> PrintManager <-> PrintManagerService <-> UserState <-> RemotePrintServiceRecommendationService <-> PrintRecommendationService <-> PrintRecommendationServiceImpl

Hence there is a lot of mindless plumming.

The actual changes are only in the AddPrintersActivity which is extended
to show another list of services: The recommended services.

The PrintServiceRecommendationService is based on the experimenal print
service stubs provider. This provider was contributed the Android by
Mopria. As this services uses Android own network discovery service most
code from the experimental provider goes away. In fact the only logic
left over is the selections of mdns-txt fields to look at and the
printer vendor configuration.

This relies on the Android MDNS to get fixed (Bug: 27696905). This also
does not deal with how to update the recommendation service.

Bug: 24533249
Change-Id: I6edc6e25fc08a50d478b61c71bb8ea158b08624c
2016-03-30 17:21:07 -07:00
Philip P. Moltmann
02add6aa91 Merge "Rewrite workflow on how the destination printer is selected." into nyc-dev 2016-03-30 22:42:49 +00:00
Philip P. Moltmann
456f1e33b8 Merge "Update print preview when option is changed and clear ranges when they layout changes" into nyc-dev 2016-03-30 21:44:19 +00:00
Philip P. Moltmann
7134fcc07c RemotePrintDocument might get destroyed in constructor
... if it cannot connect to remote PrintDocumentAdapter. Then the state
will be set to destroyed and the print activity will be aborted via the
onDied callback.

Bug: 27899066
Change-Id: Ieb287b92ac21fc71a56b491a1035feaff6cd2837
2016-03-29 14:47:04 -07:00
Philip P. Moltmann
c7927cb648 Merge "Update printers even if there are no printers found." into nyc-dev 2016-03-28 21:59:40 +00:00
Geoff Mendal
60e532a47f Import translations. DO NOT MERGE
Change-Id: If53b6bafc90089964ee5de76e683bf196160c171
Auto-generated-cl: translation import
2016-03-28 07:27:25 -07:00
Philip P. Moltmann
b5be5ec3b7 Merge "Handle all configuration changes in PrintActivity as it cannot be destroyed synchronously." into nyc-dev 2016-03-26 18:13:24 +00:00
Bill Yi
397fb345ba Import translations. DO NOT MERGE
Change-Id: I311ab683a598426efc4739408be109d766aad721
Auto-generated-cl: translation import
2016-03-25 19:34:39 -07:00
Philip P. Moltmann
ebf397625e Merge "Change hasCustomPrintIcon and setStatus as requested by API council." into nyc-dev 2016-03-25 16:50:36 +00:00
Philip P. Moltmann
d74d1e5491 Change hasCustomPrintIcon and setStatus as requested by API council.
Bonus: null advanced keys produced a exception deep in the print
       spooler. Hence prevent null keys on the surface from now on.

Bug: 27716355
Change-Id: I3c064956f4e670cd7091437ade06605aa8d797b0
2016-03-24 16:53:36 -07:00
Philip P. Moltmann
4ef83c4647 Update print preview when option is changed and clear ranges when they
layout changes

Before we updated the print preview when the paper size changed but not
when the page ranges changed. This is not consistent. We always change.

Also if there is a change to the options that changes the layout (i.e.
papersize, orientation, minMargins) then clear the selected ranges as
this does not make sense anymore.

This also fixes a bug that when having pages selected while we reduce
the number of pages in the preview we got a NPE.

Bonus: do not constantly re-update the options UI when range or copies
text is updated.

Bug: 27830850, 27741420
Change-Id: I7abe4a74b44ac5c5ee54d12cc0c1ca1540793f0e
2016-03-24 16:20:20 -07:00
Joe Onorato
13460a6cba Turn off verbose logs and remove log that is covered by verbose logs.
Bug: 27744135
Change-Id: I436cfd325f87b3b9205d50e92e2a70a50dd33344
2016-03-24 11:32:17 -07:00
Philip P. Moltmann
940fa80cd1 Handle all configuration changes in PrintActivity as it cannot be
destroyed synchronously.

Also: Always destroy print spooler provider when it was initialized to
      avoid service leakage if print activity was finished after
      onCreate but before onPrinterRegistryReady.

Bug: 27814338
Change-Id: I8401dc6e447cbd726b1a8f7c361b4ddf42e7e11d
2016-03-23 17:04:35 -07:00
Philip P. Moltmann
30b0752ef5 Remove unnecessary strings and labels.
Bug: 27815807
Change-Id: I6388055938afbbadc954c913ce0554f9a4a313e8
2016-03-23 13:32:35 -07:00
Philip P. Moltmann
49435a7295 Merge "Deal with print-preview renderings that do not match the correct number of pages." into nyc-dev 2016-03-23 17:17:40 +00:00
Philip P. Moltmann
b170c08387 Don't mix UI and print job state
In PrintActivity.OnPause we set the print job state based on the
PrintActivity state. The issue was that FINISHED was interpreted as
"cancel print job". Actually with FINISHED does not tell what state the
job should be in.

The only purpose of the finished state was to guard against
double-invocation of doFinish().

Hence remove this recently introduced state and use a simple boolean to
guard against doule invocation of doFinish().

Bug: 27760331
Change-Id: I0767c2b0b9c28e8904647cc832c236f67f92bcfe
2016-03-21 12:53:06 -07:00
Geoff Mendal
c07f2d99da Import translations. DO NOT MERGE
Change-Id: I0d693f0c99347f9d04c7240e07bdd6ea526cb987
Auto-generated-cl: translation import
2016-03-19 14:01:30 +05:30
Philip P. Moltmann
066bf81b98 Deal with print-preview renderings that do not match the correct number
of pages.

If the printing app declares more pages than the print preview pdf has
we used to throw an exception in the PDFManupulationService. This caused
the bitmap to be never written and the read-bitmap function to hang
forever. This was because read() return 0 meaning "pipe is closed" which
lead to an infinite loop. Now a read of 0 page might cause an exception
if the page is not fully read. This exception then causes the
preview_page_error to be displayed.

Bug: 27556666
Change-Id: I7b9de50dce930629e8d38efd4e2659a00b70cc4e
2016-03-18 10:57:32 -07:00
Philip P. Moltmann
27db6611a7 Treat all remotedocumentadapter-command results as cancel in the case we
are canceling the command.

Before it could happen that we have a pending cancel on a layout command
but the layout command finishes normally. This enqueued a new write
command before the PrintActivity is notified. This in turn prevented the
printactivity from finishing as the write command was still pending.

Bug: 27642724
Change-Id: I3c532d53b0c66c40d2e48ab8b4419251ff473a79
2016-03-18 09:44:28 -07:00
Philip P. Moltmann
74f9a2fc2e Merge "Do not finish multiple times." into nyc-dev 2016-03-18 16:19:45 +00:00
Philip P. Moltmann
5849f20124 Merge "If we finish before the the remotePrintedDocument is initialized" into nyc-dev 2016-03-18 14:25:25 +00:00
Philip P. Moltmann
e7f06a874a The PageAdapter update might be caused by the RecylerView.
In this case it cannot call back into the recyclerView and update the
data. For the call path please see the bug.

Bug: 27614499
Change-Id: I84733fea30429c20a2c96085efb47d4da5e1948a
2016-03-16 16:24:38 -07:00
Philip P. Moltmann
63ce0b737c Rewrite workflow on how the destination printer is selected.
This fixes two bugs
(1)
1. Printer was unknown when "all printer" activity was opened
2. Printer gets selected in "all printers" activity
3. Printer is unknown at the time the activity returns and thereby does
not get selected

(2)
If a print service gets disabled _all_ printers of the print service
will be marked as "removed" but do not removed from the adapter. This
is superflous as none of them can be selected anymore. The only thing
we want to make sure of is that the currently selected printer does
not get removed.

The workflow is now always:
- set mCurrentPrinter if needed
- Adjust mPrinterHolders
- adapter.notifyDataSetChanged()
  -> PrintersObserver.onChanged()
     -> onItemSelected

Bug: 27643305
Change-Id: I35ea7078367ad5a918c6362c04a26c4326e6c3f4
2016-03-14 10:18:23 -07:00
Philip P. Moltmann
ada5a047ba Update printers even if there are no printers found.
It can happen that before we stopped we reported a set of printers. Then
while the loader is stopped, we lost all printers. Then on re-start we
need to tell the clients that there are no printers anymore.

There is one issue: The fused-printers-provider might be started
before the printer registry is fully created. In this case we get a callback
and get all king of NPEs. Hence enqueue the first load behind the
current thread. This makes sure that the current operation - creation of
the printer registry - is finished.

Bug: 27643300
Change-Id: Ife6993d57457f23a0a4a54a11869c742c05da850
2016-03-14 10:16:08 -07:00
Geoff Mendal
03a76f7c9e Import translations. DO NOT MERGE
Change-Id: Iebdb30818688a27d0c8edb60c5686a37e69f3444
Auto-generated-cl: translation import
2016-03-14 07:19:18 -07:00
Bill Yi
f4735aa23a Import translations. DO NOT MERGE
Change-Id: I72b2693c21cc8536a5642b6c0526f611a28631bc
Auto-generated-cl: translation import
2016-03-10 18:50:20 -08:00
Geoff Mendal
70431d0653 Import translations. DO NOT MERGE
Change-Id: If1e61e7ff8623456b114a06e38ecaa4e7b65e7b8
Auto-generated-cl: translation import
2016-03-09 07:19:29 -08:00
Philip P. Moltmann
ba245f98d6 Update 'more options' button when changing the printer.
Change-Id: I1bf71629027c18e297426e26db2923c447e47734
2016-03-07 13:44:59 -08:00
Philip P. Moltmann
0ad7fc5250 Do not finish multiple times.
It can happen that multiple async calls fail and we end up calling
doFinish from all of them. We should just ignore the later ones.

Bug: 27198033
Change-Id: Ica596b966f96e9ade6409cc45c50fd62c4018b1e
2016-03-07 11:36:10 -08:00
Philip P. Moltmann
32e0755afc If we finish before the the remotePrintedDocument is initialized
... we should not check if it is updating. As it is not initailized,
we do not have to check either, hence we can just ignore this.

Bug: 27516795
Change-Id: If618f2a10563e83074e38f0b37342a648d54202a
2016-03-07 10:31:52 -08:00
Philip P. Moltmann
66c96591e2 Add "app printer activity" and always keep the print service state
updated. Also fiddle with the UI to use more standard values.

To be sure the print service state alwasy updated I changed
PrintManager.getPrintServices to return a loader which just wraps a
registerListener/getList/removeListener combo.

I also added a new function to enabled/disable a print service to be
keep all updating logic inside the PrintManagerService->UserState.

Then I changed all code to use this new interface.

Detailed comments:

PrintServiceInfo:
- I had to add the enabled state to the PrintServiceInfo as some users
  of PrintManager.getPrintServices want all services but then display
  different data depending on the enabled state. Of course I could have
  created two PrintManager.getPrintServices-loaders to load the two
  separate list of services. I think it is much easier to add this
  property though. It is updated every time new data is returned to the
  PrintManager.getPrintServices-loader.

AddPrinterActivity:
- This is shown as a dialog-style overlay to indicate that the user will
  return to the select-printers activity. It contains of three list that
  are updated via separate loaders.
- The recommended services will be added later to keep this path set
  small.

PrintActivity:
- There are two small places where we have to update the data when we
  get a new list of print services.
  - In very, very rare conditions it can happen that the print service
    of the current printer gains or looses the "advancedOptions"
    activity
  - If we have no enabled print services we want to show "Add printer"
    instead of "All printers...".
- Also the print registry is not the only loader anymore, hence we have
  to assign loader ids to it to not conflict with the other loaders in
  this activity.
- Small bug in onPrintersChanged: If a printer is selected and the print
  service of this printer gets disabled the holder goes into "removed"
  state which disables the printer. When the print service is then
  enabled again, we forgot to re-enable the holder.

PrinterRegistry:
- The registry assumed that the FusedPrinterProvider was the only loader
  in the activity. This is not true anymore, hence it has to assign the
  appropriate loader ids.
- The FusedPrinterProvider has an internal loader, hence we have to
  forward a loader Id into it.
- The PrintRegistry is only called backed for a single loader, hence no
  need to check the loader-id.

SelectPrinterActivity:
- The AddPrinterDialog was removed as we now have the
  AddPrinterActivity.
- Added a loader for the enabled services to update the empty state.
- Added dedicated loader Id for the PrinterRegistry again.
- If we have no enabled services, the SelectPrinterActivity chainloads
  the AddPrinterActivity as this is the only thing the user can do
  anyway. "Save a click". This should only happen when the activity is
  create the first time.
- Moved the "add printer" from the menu item to the list of printers as
  suggested by UX and Zach.

PrintManagerService, UserState and IPrintManagerParamtersTest:
- As the only place where the print service state is updated is now the
  userstate, we have no more sychronization problems. Whohoo.
- The users can now register for changes to the print services similar
  as they can register for changes to the print jobs.
- UserState.getPrintServices is the only function can exposes any
  knowledge of the print services to the outside world.

Change-Id: I9be2c7300431e06aaff9bdf7eb36120d869b56ac
2016-03-07 09:58:08 -08:00
Philip P. Moltmann
59d12c6a27 Merge "Update print document view if printer capabilities changed" into nyc-dev 2016-03-07 16:45:36 +00:00
Philip P. Moltmann
8eb451597d Redraw the UI when a print page preview is updated
When switching between two printers with different margins but with the
same paper size we were missing updates of the print preview. This
change triggers these updates.

The issue was the we reuse the a bitmap when a page is rewritten. This
causes View.setBackground(drawable) to do nothing as the old
background is the same as the new one. This function only checks the
background drawable object reference, not the content. Hence we need to
add a call that notifies the listeners to the changes on the content of
the drawable.

Bug: 26961677
Change-Id: Id8b9be59c9ca7220f40ac59168f78bfdcccb2761
2016-03-03 16:21:24 -08:00
Philip P. Moltmann
1bb7f3638a Update print document view if printer capabilities changed
Bonus: Remove Printer-onChange listener before other state gets cleaned
       up. Otherwise onChange callbacks at the wrong time cause into
       destroyed data.

Bug: 27219320
Change-Id: I8335b9d8dd71112b76aa684f00524d4d8aad3f94
2016-03-03 15:08:46 -08:00