Update the message for unavailable printers.
If a printer disappears or we do not get its capabilities, we
show the user a message that the printer is unavailable. This
message was appended after the printer name but they tend to
be very long and the user does not see that the printer is not
available due to ellipsis. Now we append the message after the
subtitle which tends to be much shorter.
bug:10983508
Change-Id: Ib3f7ad3bd82ff6decd49dc45461fb5131338e8c2
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index 3a23b3e..2997707 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -2175,10 +2175,17 @@
mIsPosted = false;
if (mDestinationSpinner.getSelectedItemPosition() >= 0) {
View itemView = mDestinationSpinner.getSelectedView();
- TextView titleView = (TextView) itemView.findViewById(R.id.title);
- String title = getString(R.string.printer_unavailable,
- mCurrentPrinter.getName());
- titleView.setText(title);
+ TextView titleView = (TextView) itemView.findViewById(R.id.subtitle);
+ try {
+ PackageInfo packageInfo = getPackageManager().getPackageInfo(
+ mCurrentPrinter.getId().getServiceName().getPackageName(), 0);
+ CharSequence service = packageInfo.applicationInfo.loadLabel(
+ getPackageManager());
+ String subtitle = getString(R.string.printer_unavailable, service.toString());
+ titleView.setText(subtitle);
+ } catch (NameNotFoundException nnfe) {
+ /* ignore */
+ }
}
}
}