Search in sources :

Example 31 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.

the class PrintActivity method onLoadFinished.

@Override
public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, List<PrintServiceInfo> services) {
    ComponentName newAdvancedPrintOptionsActivity = null;
    if (mCurrentPrinter != null && services != null) {
        final int numServices = services.size();
        for (int i = 0; i < numServices; i++) {
            PrintServiceInfo service = services.get(i);
            if (service.getComponentName().equals(mCurrentPrinter.getId().getServiceName())) {
                String advancedOptionsActivityName = service.getAdvancedOptionsActivityName();
                if (!TextUtils.isEmpty(advancedOptionsActivityName)) {
                    newAdvancedPrintOptionsActivity = new ComponentName(service.getComponentName().getPackageName(), advancedOptionsActivityName);
                    break;
                }
            }
        }
    }
    if (!Objects.equals(newAdvancedPrintOptionsActivity, mAdvancedPrintOptionsActivity)) {
        mAdvancedPrintOptionsActivity = newAdvancedPrintOptionsActivity;
        updateOptionsUi();
    }
    boolean newArePrintServicesEnabled = services != null && !services.isEmpty();
    if (mArePrintServicesEnabled != newArePrintServicesEnabled) {
        mArePrintServicesEnabled = newArePrintServicesEnabled;
        // reads that in DestinationAdapter#getMoreItemTitle
        if (mDestinationSpinnerAdapter != null) {
            mDestinationSpinnerAdapter.notifyDataSetChanged();
        }
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName)

Example 32 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.

the class UserState method setPrintServiceEnabled.

public void setPrintServiceEnabled(@NonNull ComponentName serviceName, boolean isEnabled) {
    synchronized (mLock) {
        boolean isChanged = false;
        if (isEnabled) {
            isChanged = mDisabledServices.remove(serviceName);
        } else {
            // Make sure to only disable services that are currently installed
            final int numServices = mInstalledServices.size();
            for (int i = 0; i < numServices; i++) {
                PrintServiceInfo service = mInstalledServices.get(i);
                if (service.getComponentName().equals(serviceName)) {
                    mDisabledServices.add(serviceName);
                    isChanged = true;
                    break;
                }
            }
        }
        if (isChanged) {
            writeDisabledPrintServicesLocked(mDisabledServices);
            onConfigurationChangedLocked();
        }
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo)

Aggregations

PrintServiceInfo (android.printservice.PrintServiceInfo)32 ComponentName (android.content.ComponentName)18 ResolveInfo (android.content.pm.ResolveInfo)9 DataSetObserver (android.database.DataSetObserver)5 PrintManager (android.print.PrintManager)5 PrinterInfo (android.print.PrinterInfo)5 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 AdapterView (android.widget.AdapterView)5 ImageView (android.widget.ImageView)5 ListView (android.widget.ListView)5 SearchView (android.widget.SearchView)5 TextView (android.widget.TextView)5 Nullable (android.annotation.Nullable)4 HashSet (java.util.HashSet)4 Intent (android.content.Intent)1