Loading packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java +22 −17 Original line number Original line Diff line number Diff line Loading @@ -18,12 +18,11 @@ package com.android.printspooler.ui; import android.app.Activity; import android.app.Activity; import android.app.LoaderManager; import android.app.LoaderManager; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.content.IntentSender.SendIntentException; import android.content.Loader; import android.content.Loader; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.database.DataSetObserver; import android.database.DataSetObserver; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Bundle; Loading @@ -34,6 +33,7 @@ import android.print.PrinterInfo; import android.printservice.PrintServiceInfo; import android.printservice.PrintServiceInfo; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import android.util.TypedValue; import android.util.TypedValue; import android.view.ContextMenu; import android.view.ContextMenu; Loading Loading @@ -80,8 +80,8 @@ public final class SelectPrinterActivity extends Activity implements private static final String KEY_NOT_FIRST_CREATE = "KEY_NOT_FIRST_CREATE"; private static final String KEY_NOT_FIRST_CREATE = "KEY_NOT_FIRST_CREATE"; /** If there are any enabled print services */ /** The currently enabled print services by their ComponentName */ private boolean mHasEnabledPrintServices; private ArrayMap<ComponentName, PrintServiceInfo> mEnabledPrintServices; private PrinterRegistry mPrinterRegistry; private PrinterRegistry mPrinterRegistry; Loading @@ -100,6 +100,8 @@ public final class SelectPrinterActivity extends Activity implements setContentView(R.layout.select_printer_activity); setContentView(R.layout.select_printer_activity); mEnabledPrintServices = new ArrayMap<>(); mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, LOADER_ID_PRINT_REGISTRY_INT); LOADER_ID_PRINT_REGISTRY_INT); Loading Loading @@ -317,7 +319,7 @@ public final class SelectPrinterActivity extends Activity implements } } TextView titleView = (TextView) findViewById(R.id.title); TextView titleView = (TextView) findViewById(R.id.title); View progressBar = findViewById(R.id.progress_bar); View progressBar = findViewById(R.id.progress_bar); if (!mHasEnabledPrintServices) { if (mEnabledPrintServices.size() > 0) { titleView.setText(R.string.print_no_print_services); titleView.setText(R.string.print_no_print_services); progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); } else if (adapter.getUnfilteredCount() <= 0) { } else if (adapter.getUnfilteredCount() <= 0) { Loading Loading @@ -346,11 +348,16 @@ public final class SelectPrinterActivity extends Activity implements @Override @Override public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, List<PrintServiceInfo> data) { List<PrintServiceInfo> services) { if (data == null || data.isEmpty()) { mEnabledPrintServices.clear(); mHasEnabledPrintServices = false; } else { if (services != null && !services.isEmpty()) { mHasEnabledPrintServices = true; final int numServices = services.size(); for (int i = 0; i < numServices; i++) { PrintServiceInfo service = services.get(i); mEnabledPrintServices.put(service.getComponentName(), service); } } } onPrintServicesUpdate(); onPrintServicesUpdate(); Loading Loading @@ -533,14 +540,12 @@ public final class SelectPrinterActivity extends Activity implements CharSequence title = printer.getName(); CharSequence title = printer.getName(); Drawable icon = printer.loadIcon(SelectPrinterActivity.this); Drawable icon = printer.loadIcon(SelectPrinterActivity.this); CharSequence printServiceLabel; PrintServiceInfo service = mEnabledPrintServices.get(printer.getId().getServiceName()); try { PackageInfo packageInfo = getPackageManager().getPackageInfo( printer.getId().getServiceName().getPackageName(), 0); printServiceLabel = packageInfo.applicationInfo.loadLabel(getPackageManager()); CharSequence printServiceLabel = null; } catch (NameNotFoundException e) { if (service != null) { printServiceLabel = null; printServiceLabel = service.getResolveInfo().loadLabel(getPackageManager()) .toString(); } } CharSequence description = printer.getDescription(); CharSequence description = printer.getDescription(); Loading Loading
packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java +22 −17 Original line number Original line Diff line number Diff line Loading @@ -18,12 +18,11 @@ package com.android.printspooler.ui; import android.app.Activity; import android.app.Activity; import android.app.LoaderManager; import android.app.LoaderManager; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.content.IntentSender.SendIntentException; import android.content.Loader; import android.content.Loader; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.database.DataSetObserver; import android.database.DataSetObserver; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Bundle; Loading @@ -34,6 +33,7 @@ import android.print.PrinterInfo; import android.printservice.PrintServiceInfo; import android.printservice.PrintServiceInfo; import android.provider.Settings; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import android.util.TypedValue; import android.util.TypedValue; import android.view.ContextMenu; import android.view.ContextMenu; Loading Loading @@ -80,8 +80,8 @@ public final class SelectPrinterActivity extends Activity implements private static final String KEY_NOT_FIRST_CREATE = "KEY_NOT_FIRST_CREATE"; private static final String KEY_NOT_FIRST_CREATE = "KEY_NOT_FIRST_CREATE"; /** If there are any enabled print services */ /** The currently enabled print services by their ComponentName */ private boolean mHasEnabledPrintServices; private ArrayMap<ComponentName, PrintServiceInfo> mEnabledPrintServices; private PrinterRegistry mPrinterRegistry; private PrinterRegistry mPrinterRegistry; Loading @@ -100,6 +100,8 @@ public final class SelectPrinterActivity extends Activity implements setContentView(R.layout.select_printer_activity); setContentView(R.layout.select_printer_activity); mEnabledPrintServices = new ArrayMap<>(); mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, LOADER_ID_PRINT_REGISTRY_INT); LOADER_ID_PRINT_REGISTRY_INT); Loading Loading @@ -317,7 +319,7 @@ public final class SelectPrinterActivity extends Activity implements } } TextView titleView = (TextView) findViewById(R.id.title); TextView titleView = (TextView) findViewById(R.id.title); View progressBar = findViewById(R.id.progress_bar); View progressBar = findViewById(R.id.progress_bar); if (!mHasEnabledPrintServices) { if (mEnabledPrintServices.size() > 0) { titleView.setText(R.string.print_no_print_services); titleView.setText(R.string.print_no_print_services); progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); } else if (adapter.getUnfilteredCount() <= 0) { } else if (adapter.getUnfilteredCount() <= 0) { Loading Loading @@ -346,11 +348,16 @@ public final class SelectPrinterActivity extends Activity implements @Override @Override public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, List<PrintServiceInfo> data) { List<PrintServiceInfo> services) { if (data == null || data.isEmpty()) { mEnabledPrintServices.clear(); mHasEnabledPrintServices = false; } else { if (services != null && !services.isEmpty()) { mHasEnabledPrintServices = true; final int numServices = services.size(); for (int i = 0; i < numServices; i++) { PrintServiceInfo service = services.get(i); mEnabledPrintServices.put(service.getComponentName(), service); } } } onPrintServicesUpdate(); onPrintServicesUpdate(); Loading Loading @@ -533,14 +540,12 @@ public final class SelectPrinterActivity extends Activity implements CharSequence title = printer.getName(); CharSequence title = printer.getName(); Drawable icon = printer.loadIcon(SelectPrinterActivity.this); Drawable icon = printer.loadIcon(SelectPrinterActivity.this); CharSequence printServiceLabel; PrintServiceInfo service = mEnabledPrintServices.get(printer.getId().getServiceName()); try { PackageInfo packageInfo = getPackageManager().getPackageInfo( printer.getId().getServiceName().getPackageName(), 0); printServiceLabel = packageInfo.applicationInfo.loadLabel(getPackageManager()); CharSequence printServiceLabel = null; } catch (NameNotFoundException e) { if (service != null) { printServiceLabel = null; printServiceLabel = service.getResolveInfo().loadLabel(getPackageManager()) .toString(); } } CharSequence description = printer.getDescription(); CharSequence description = printer.getDescription(); Loading