From 42c6250c9db71d1a1d0c36c560954831fc1dacbc Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Wed, 30 Oct 2013 12:08:33 -0700 Subject: [PATCH] Add print samples to the ApiDemos app. 1. Added a sample for printing a bitmap. 2. Added a sample for printing an on-screen WebView. 3. Added s sample for printing an off-screen WebView. 4. Fixed a bug in the custom layout print sample. Change-Id: I35b2bbf8c7fd9bc39be795b1f793d9ea7bdfc8a0 --- samples/ApiDemos/Android.mk | 2 + samples/ApiDemos/AndroidManifest.xml | 27 ++ samples/ApiDemos/res/layout/print_bitmap.xml | 23 ++ .../res/layout/print_html_from_screen.xml | 22 ++ .../res/layout/print_html_off_screen.xml | 24 ++ samples/ApiDemos/res/raw/android_logo.png | Bin 0 -> 10722 bytes samples/ApiDemos/res/raw/motogp_stats.html | 333 ++++++++++++++++++ samples/ApiDemos/res/values/strings.xml | 6 + .../example/android/apis/app/PrintBitmap.java | 82 +++++ .../android/apis/app/PrintCustomContent.java | 4 +- .../android/apis/app/PrintHtmlFromScreen.java | 93 +++++ .../android/apis/app/PrintHtmlOffScreen.java | 89 +++++ 12 files changed, 703 insertions(+), 2 deletions(-) create mode 100644 samples/ApiDemos/res/layout/print_bitmap.xml create mode 100644 samples/ApiDemos/res/layout/print_html_from_screen.xml create mode 100644 samples/ApiDemos/res/layout/print_html_off_screen.xml create mode 100644 samples/ApiDemos/res/raw/android_logo.png create mode 100644 samples/ApiDemos/res/raw/motogp_stats.html create mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PrintBitmap.java create mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlFromScreen.java create mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlOffScreen.java diff --git a/samples/ApiDemos/Android.mk b/samples/ApiDemos/Android.mk index 066c497cb..ca48f581d 100644 --- a/samples/ApiDemos/Android.mk +++ b/samples/ApiDemos/Android.mk @@ -12,6 +12,8 @@ LOCAL_SRC_FILES += \ LOCAL_JAVA_LIBRARIES := telephony-common mms-common +LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 + LOCAL_PACKAGE_NAME := ApiDemos LOCAL_SDK_VERSION := current diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index ff7db377d..d7bda3125 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -996,6 +996,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/layout/print_bitmap.xml b/samples/ApiDemos/res/layout/print_bitmap.xml new file mode 100644 index 000000000..cce522acb --- /dev/null +++ b/samples/ApiDemos/res/layout/print_bitmap.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/samples/ApiDemos/res/layout/print_html_from_screen.xml b/samples/ApiDemos/res/layout/print_html_from_screen.xml new file mode 100644 index 000000000..535bcb2d1 --- /dev/null +++ b/samples/ApiDemos/res/layout/print_html_from_screen.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/samples/ApiDemos/res/layout/print_html_off_screen.xml b/samples/ApiDemos/res/layout/print_html_off_screen.xml new file mode 100644 index 000000000..799b07927 --- /dev/null +++ b/samples/ApiDemos/res/layout/print_html_off_screen.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/ApiDemos/res/raw/android_logo.png b/samples/ApiDemos/res/raw/android_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f970c262ecfe85f2aad38d079964f640ed52c904 GIT binary patch literal 10722 zcmeHtXE>a1x36A<=)r`92%|^KU=X6jMD#K`(FxIw-Uf*>Li8@84+asv%_JmB5G_R1 zj9y0XawhNjpLg$1=kva<{a)8IU!MC}Ykq63d)@bHuXVK4X{gw#2nYyhG@hvF5fBgx z{rypp;ok&=Abbf3?ht6GC>g+VxATH>0rpwDUE02m;x`^MJWtTLMgM?1Hj1Lf<82$v zGE|IyMg)V@rtvv2-jVF zxf^lSx@J)DeZdb>0217cOK=S%(?2fS#43@=%Hc9Z`dhg%1FZza?y&G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Ts19MW(x}GQvb&HomYJ8awyKNarCekLf38^o_ t4_SPRcKf-oKhRLqiyx2t!uyA~e{{^0mQQd3Kf6hwp{k`)qih}de*hydup9sY literal 0 HcmV?d00001 diff --git a/samples/ApiDemos/res/raw/motogp_stats.html b/samples/ApiDemos/res/raw/motogp_stats.html new file mode 100644 index 000000000..b55ed9eb3 --- /dev/null +++ b/samples/ApiDemos/res/raw/motogp_stats.html @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
500cc/MotoGP champions
Season +Rider +Constructor +
2012Jorge LorenzoYamaha
2011Casey StonerHonda
2010Jorge LorenzoYamaha
2009Valentino RossiYamaha
2008Valentino RossiYamaha
2007Casey StonerDucati
2006Nicky HaydenHonda
2005Valentino RossiYamaha
2004Valentino RossiYamaha
2003Valentino RossiHonda
2002Valentino RossiHonda
2001Valentino RossiHonda
2000Kenny Roberts, Jr.Suzuki
1999Ëlex CrivillŽHonda
1998Michael DoohanHonda
1997Michael DoohanHonda
1996Michael DoohanHonda
1995Michael DoohanHonda
1994Michael DoohanHonda
1993Kevin SchwantzSuzuki
1992Wayne RaineyYamaha
1991Wayne RaineyYamaha
1990Wayne RaineyYamaha
1989Eddie LawsonHonda
1988Eddie LawsonYamaha
1987Wayne GardnerHonda
1986Eddie LawsonYamaha
1985Freddie SpencerHonda
1984Eddie LawsonYamaha
1983Freddie SpencerHonda
1982Franco UnciniSuzuki
1981Marco LucchinelliSuzuki
1980Kenny RobertsYamaha
1979Kenny RobertsYamaha
1978Kenny RobertsYamaha
1977Barry SheeneSuzuki
1976Barry SheeneSuzuki
1975Giacomo AgostiniYamaha
1974Phil ReadMV Agusta
1973Phil ReadMV Agusta
1972Giacomo AgostiniMV Agusta
1971Giacomo AgostiniMV Agusta
1970Giacomo AgostiniMV Agusta
1969Giacomo AgostiniMV Agusta
1968Giacomo AgostiniMV Agusta
1967Giacomo AgostiniMV Agusta
1966Giacomo AgostiniMV Agusta
1965Mike HailwoodMV Agusta
1964Mike HailwoodMV Agusta
1963Mike HailwoodMV Agusta
1962Mike HailwoodMV Agusta
1961Gary HockingMV Agusta
1960John SurteesMV Agusta
1959John SurteesMV Agusta
1958John SurteesMV Agusta
1957Libero LiberatiGilera
1956John SurteesMV Agusta
1955Geoff DukeGilera
1954Geoff DukeGilera
1953Geoff DukeGilera
1952Umberto MasettiGilera
1951Geoff DukeNorton
1950Umberto MasettiGilera
1949Leslie GrahamAJS
+ + \ No newline at end of file diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index b9502e534..804087dd5 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -875,8 +875,14 @@ + App/Print/Print Bitmap + App/Print/Print HTML from screen + App/Print/Print HTML off screen App/Print/Print Custom Layout Print + From the overflow menu you can print some + off screen content. + Android logo diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PrintBitmap.java b/samples/ApiDemos/src/com/example/android/apis/app/PrintBitmap.java new file mode 100644 index 000000000..762478a99 --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/app/PrintBitmap.java @@ -0,0 +1,82 @@ +package com.example.android.apis.app; +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import android.app.Activity; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.os.Bundle; +import android.print.PrintManager; +import android.support.v4.print.PrintHelper; +import android.view.Menu; +import android.view.MenuItem; +import android.webkit.WebView; +import android.widget.ImageView; + +import com.example.android.apis.R; + +/** + * This class demonstrates how to implement bitmap printing. + *

+ * This activity shows an image and offers a print option in the overflow + * menu. When the user chooses to print a helper class from the support + * library is used to print the image. + *

+ * + * @see PrintManager + * @see WebView + */ +public class PrintBitmap extends Activity { + + private ImageView mImageView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.print_bitmap); + mImageView = (ImageView) findViewById(R.id.image); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.print_custom_content, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.menu_print) { + print(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void print() { + // Get the print manager. + PrintHelper printHelper = new PrintHelper(this); + + // Set the desired scale mode. + printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT); + + // Get the bitmap for the ImageView's drawable. + Bitmap bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap(); + + // Print the bitmap. + printHelper.printBitmap("Print Bitmap", bitmap); + } +} diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PrintCustomContent.java b/samples/ApiDemos/src/com/example/android/apis/app/PrintCustomContent.java index 0a7715c25..7a7e7ed80 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/PrintCustomContent.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/PrintCustomContent.java @@ -376,9 +376,9 @@ public class PrintCustomContent extends ListActivity { // Add the height but if the view crosses the page // boundary we will put it to the next one. - pageContentHeight += view.getHeight(); + pageContentHeight += view.getMeasuredHeight(); if (currentPage < 0 || pageContentHeight > mRenderPageHeight) { - pageContentHeight = view.getHeight(); + pageContentHeight = view.getMeasuredHeight(); currentPage++; // Done with the current page - finish it. if (page != null) { diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlFromScreen.java b/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlFromScreen.java new file mode 100644 index 000000000..55c98ffc9 --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlFromScreen.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.app; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.print.PrintManager; +import android.view.Menu; +import android.view.MenuItem; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +import com.example.android.apis.R; + +/** + * This class demonstrates how to implement HTML content printing + * from a {@link WebView} which is shown on the screen. + *

+ * This activity shows a simple HTML content in a {@link WebView} + * and allows the user to print that content via an action in the + * action bar. The shown {@link WebView} is doing the printing. + *

+ * + * @see PrintManager + * @see WebView + */ +public class PrintHtmlFromScreen extends Activity { + + private WebView mWebView; + + private boolean mDataLoaded; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.print_html_from_screen); + mWebView = (WebView) findViewById(R.id.web_view); + + // Important: Only enable the print option after the page is loaded. + mWebView.setWebViewClient(new WebViewClient() { + @Override + public void onPageFinished(WebView view, String url) { + // Data loaded, so now we want to show the print option. + mDataLoaded = true; + invalidateOptionsMenu(); + } + }); + + // Load an HTML page. + mWebView.loadUrl("file:///android_res/raw/motogp_stats.html"); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + if (mDataLoaded) { + getMenuInflater().inflate(R.menu.print_custom_content, menu); + } + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.menu_print) { + print(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void print() { + // Get the print manager. + PrintManager printManager = (PrintManager) getSystemService( + Context.PRINT_SERVICE); + // Pass in the ViewView's document adapter. + printManager.print("MotoGP stats", mWebView.createPrintDocumentAdapter(), null); + } +} diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlOffScreen.java b/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlOffScreen.java new file mode 100644 index 000000000..3625784cd --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/app/PrintHtmlOffScreen.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.app; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.print.PrintManager; +import android.view.Menu; +import android.view.MenuItem; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +import com.example.android.apis.R; + +/** + * This class demonstrates how to implement HTML content printing + * from a {@link WebView} which is not shown on the screen. + *

+ * This activity shows a text prompt and when the user chooses the + * print option from the overflow menu an HTML page with content that + * is not on the screen is printed via an off-screen {@link WebView}. + *

+ * + * @see PrintManager + * @see WebView + */ +public class PrintHtmlOffScreen extends Activity { + + private WebView mWebView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.print_html_off_screen); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.print_custom_content, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.menu_print) { + print(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void print() { + // Create a WebView and hold on to it as the printing will start when + // load completes and we do not want the WbeView to be garbage collected. + mWebView = new WebView(this); + + // Important: Only after the page is loaded we will do the print. + mWebView.setWebViewClient(new WebViewClient() { + @Override + public void onPageFinished(WebView view, String url) { + // Get the print manager. + PrintManager printManager = (PrintManager) getSystemService( + Context.PRINT_SERVICE); + // Pass in the ViewView's document adapter. + printManager.print("MotoGP stats", mWebView.createPrintDocumentAdapter(), + null); + } + }); + + // Load an HTML page. + mWebView.loadUrl("file:///android_res/raw/motogp_stats.html"); + } +}