use of android.print.PrintDocumentAdapter in project Osmand by osmandapp.
the class PrintDialogActivity method createWebPrintJob.
@SuppressLint("NewApi")
private void createWebPrintJob(WebView webView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
String jobName = "OsmAnd route info";
PrintJob printJob = printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
printJobId = printJob.getId();
}
}
use of android.print.PrintDocumentAdapter in project gh4a by slapperwan.
the class WebViewerActivity method doPrintHtml.
@TargetApi(19)
private void doPrintHtml() {
if (!isFinishing()) {
final String title = getDocumentTitle();
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = getPrintAdapterForWebView(mPrintWebView, title);
printManager.print(title, printAdapter, new PrintAttributes.Builder().build());
}
mPrintWebView = null;
supportInvalidateOptionsMenu();
}
use of android.print.PrintDocumentAdapter in project opacclient by opacapp.
the class SearchResultDetailFragment method print.
@TargetApi(Build.VERSION_CODES.KITKAT)
private void print() {
WebView webView = new WebView(getActivity());
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView webView, String url) {
PrintManager printManager = (PrintManager) getActivity().getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
String jobName = getItem().getTitle();
if (jobName == null || jobName.equals("")) {
jobName = getString(R.string.no_title);
}
printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
}
});
String templateDetailles = PrintUtils.printDetails(getItem(), getContext());
webView.loadDataWithBaseURL(null, templateDetailles, "text/HTML", "UTF-8", null);
}
use of android.print.PrintDocumentAdapter in project Notepad by farmerbb.
the class MainActivity method createWebPrintJob.
@TargetApi(Build.VERSION_CODES.KITKAT)
private void createWebPrintJob(WebView webView) {
// Get a PrintManager instance
PrintManager printManager = (PrintManager) getSystemService(PRINT_SERVICE);
// Get a print adapter instance
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
// Create a print job with name and adapter instance
String jobName = getString(R.string.document, getString(R.string.app_name));
printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
}
use of android.print.PrintDocumentAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PrintJobSettingsActivityTest method viewPrintJobSettings.
@Test
@LargeTest
public void viewPrintJobSettings() throws Exception {
UUID uuid = UUID.randomUUID();
Object isWriteCalled = new Object();
// Create adapter that is good enough to start a print preview
PrintDocumentAdapter adapter = new PrintDocumentAdapter() {
@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) {
callback.onLayoutFinished(new PrintDocumentInfo.Builder(uuid.toString()).build(), true);
}
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
synchronized (isWriteCalled) {
isWriteCalled.notify();
}
callback.onWriteFailed(null);
}
};
Activity activity = mActivityRule.getActivity();
PrintManager pm = mActivityRule.getActivity().getSystemService(PrintManager.class);
// Start printing
PrintJob printJob = pm.print(uuid.toString(), adapter, null);
// Wait until print preview is up
synchronized (isWriteCalled) {
isWriteCalled.wait();
}
// Start print job settings
Intent intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
intent.putExtra(EXTRA_PRINT_JOB_ID, printJob.getId().flattenToString());
intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
activity.startActivity(intent);
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject2 printPrefTitle = uiDevice.wait(Until.findObject(By.text("Configuring " + uuid.toString())), 5000);
assertNotNull(printPrefTitle);
Log.i(LOG_TAG, "Found " + printPrefTitle.getText());
}
Aggregations