Skip to content

Commit f03f64d

Browse files
Steve BlockAndroid (Google) Code Review
authored andcommitted
Merge "Update WebViewClassic JavaDoc to refer to WebView"
2 parents 26ed99f + 406aeb2 commit f03f64d

File tree

2 files changed

+7
-215
lines changed

2 files changed

+7
-215
lines changed

core/java/android/webkit/WebView.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,13 @@
253253
* and {@link WebChromeClient#onHideCustomView()} are required,
254254
* {@link WebChromeClient#getVideoLoadingProgressView()} is optional.
255255
* </p>
256-
*
257-
*
258-
*/
259-
/*
260-
* Implementation notes.
261-
* The WebView is a thin API class that delegates its public API to a backend WebViewProvider
262-
* class instance. WebView extends {@link AbsoluteLayout} for backward compatibility reasons.
263-
* Methods are delegated to the provider implementation: all public API methods introduced in this
264-
* file are fully delegated, whereas public and protected methods from the View base classes are
265-
* only delegated where a specific need exists for them to do so.
266256
*/
257+
// Implementation notes.
258+
// The WebView is a thin API class that delegates its public API to a backend WebViewProvider
259+
// class instance. WebView extends {@link AbsoluteLayout} for backward compatibility reasons.
260+
// Methods are delegated to the provider implementation: all public API methods introduced in this
261+
// file are fully delegated, whereas public and protected methods from the View base classes are
262+
// only delegated where a specific need exists for them to do so.
267263
@Widget
268264
public class WebView extends AbsoluteLayout
269265
implements ViewTreeObserver.OnGlobalFocusChangeListener,

core/java/android/webkit/WebViewClassic.java

Lines changed: 1 addition & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -138,211 +138,7 @@
138138
import java.util.regex.Pattern;
139139

140140
/**
141-
* <p>A View that displays web pages. This class is the basis upon which you
142-
* can roll your own web browser or simply display some online content within your Activity.
143-
* It uses the WebKit rendering engine to display
144-
* web pages and includes methods to navigate forward and backward
145-
* through a history, zoom in and out, perform text searches and more.</p>
146-
* <p>To enable the built-in zoom, set
147-
* {@link #getSettings() WebSettings}.{@link WebSettings#setBuiltInZoomControls(boolean)}
148-
* (introduced in API version 3).
149-
* <p>Note that, in order for your Activity to access the Internet and load web pages
150-
* in a WebView, you must add the {@code INTERNET} permissions to your
151-
* Android Manifest file:</p>
152-
* <pre>&lt;uses-permission android:name="android.permission.INTERNET" /></pre>
153-
*
154-
* <p>This must be a child of the <a
155-
* href="{@docRoot}guide/topics/manifest/manifest-element.html">{@code <manifest>}</a>
156-
* element.</p>
157-
*
158-
* <p>See the <a href="{@docRoot}resources/tutorials/views/hello-webview.html">Web View
159-
* tutorial</a>.</p>
160-
*
161-
* <h3>Basic usage</h3>
162-
*
163-
* <p>By default, a WebView provides no browser-like widgets, does not
164-
* enable JavaScript and web page errors are ignored. If your goal is only
165-
* to display some HTML as a part of your UI, this is probably fine;
166-
* the user won't need to interact with the web page beyond reading
167-
* it, and the web page won't need to interact with the user. If you
168-
* actually want a full-blown web browser, then you probably want to
169-
* invoke the Browser application with a URL Intent rather than show it
170-
* with a WebView. For example:
171-
* <pre>
172-
* Uri uri = Uri.parse("http://www.example.com");
173-
* Intent intent = new Intent(Intent.ACTION_VIEW, uri);
174-
* startActivity(intent);
175-
* </pre>
176-
* <p>See {@link android.content.Intent} for more information.</p>
177-
*
178-
* <p>To provide a WebView in your own Activity, include a {@code <WebView>} in your layout,
179-
* or set the entire Activity window as a WebView during {@link
180-
* android.app.Activity#onCreate(Bundle) onCreate()}:</p>
181-
* <pre class="prettyprint">
182-
* WebView webview = new WebView(this);
183-
* setContentView(webview);
184-
* </pre>
185-
*
186-
* <p>Then load the desired web page:</p>
187-
* <pre>
188-
* // Simplest usage: note that an exception will NOT be thrown
189-
* // if there is an error loading this page (see below).
190-
* webview.loadUrl("http://slashdot.org/");
191-
*
192-
* // OR, you can also load from an HTML string:
193-
* String summary = "&lt;html>&lt;body>You scored &lt;b>192&lt;/b> points.&lt;/body>&lt;/html>";
194-
* webview.loadData(summary, "text/html", null);
195-
* // ... although note that there are restrictions on what this HTML can do.
196-
* // See the JavaDocs for {@link #loadData(String,String,String) loadData()} and {@link
197-
* #loadDataWithBaseURL(String,String,String,String,String) loadDataWithBaseURL()} for more info.
198-
* </pre>
199-
*
200-
* <p>A WebView has several customization points where you can add your
201-
* own behavior. These are:</p>
202-
*
203-
* <ul>
204-
* <li>Creating and setting a {@link android.webkit.WebChromeClient} subclass.
205-
* This class is called when something that might impact a
206-
* browser UI happens, for instance, progress updates and
207-
* JavaScript alerts are sent here (see <a
208-
* href="{@docRoot}guide/developing/debug-tasks.html#DebuggingWebPages">Debugging Tasks</a>).
209-
* </li>
210-
* <li>Creating and setting a {@link android.webkit.WebViewClient} subclass.
211-
* It will be called when things happen that impact the
212-
* rendering of the content, eg, errors or form submissions. You
213-
* can also intercept URL loading here (via {@link
214-
* android.webkit.WebViewClient#shouldOverrideUrlLoading(WebView,String)
215-
* shouldOverrideUrlLoading()}).</li>
216-
* <li>Modifying the {@link android.webkit.WebSettings}, such as
217-
* enabling JavaScript with {@link android.webkit.WebSettings#setJavaScriptEnabled(boolean)
218-
* setJavaScriptEnabled()}. </li>
219-
* <li>Injecting Java objects into the WebView using the
220-
* {@link android.webkit.WebView#addJavascriptInterface} method. This
221-
* method allows you to inject Java objects into a page's JavaScript
222-
* context, so that they can be accessed by JavaScript in the page.</li>
223-
* </ul>
224-
*
225-
* <p>Here's a more complicated example, showing error handling,
226-
* settings, and progress notification:</p>
227-
*
228-
* <pre class="prettyprint">
229-
* // Let's display the progress in the activity title bar, like the
230-
* // browser app does.
231-
* getWindow().requestFeature(Window.FEATURE_PROGRESS);
232-
*
233-
* webview.getSettings().setJavaScriptEnabled(true);
234-
*
235-
* final Activity activity = this;
236-
* webview.setWebChromeClient(new WebChromeClient() {
237-
* public void onProgressChanged(WebView view, int progress) {
238-
* // Activities and WebViews measure progress with different scales.
239-
* // The progress meter will automatically disappear when we reach 100%
240-
* activity.setProgress(progress * 1000);
241-
* }
242-
* });
243-
* webview.setWebViewClient(new WebViewClient() {
244-
* public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
245-
* Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
246-
* }
247-
* });
248-
*
249-
* webview.loadUrl("http://slashdot.org/");
250-
* </pre>
251-
*
252-
* <h3>Cookie and window management</h3>
253-
*
254-
* <p>For obvious security reasons, your application has its own
255-
* cache, cookie store etc.&mdash;it does not share the Browser
256-
* application's data. Cookies are managed on a separate thread, so
257-
* operations like index building don't block the UI
258-
* thread. Follow the instructions in {@link android.webkit.CookieSyncManager}
259-
* if you want to use cookies in your application.
260-
* </p>
261-
*
262-
* <p>By default, requests by the HTML to open new windows are
263-
* ignored. This is true whether they be opened by JavaScript or by
264-
* the target attribute on a link. You can customize your
265-
* {@link WebChromeClient} to provide your own behaviour for opening multiple windows,
266-
* and render them in whatever manner you want.</p>
267-
*
268-
* <p>The standard behavior for an Activity is to be destroyed and
269-
* recreated when the device orientation or any other configuration changes. This will cause
270-
* the WebView to reload the current page. If you don't want that, you
271-
* can set your Activity to handle the {@code orientation} and {@code keyboardHidden}
272-
* changes, and then just leave the WebView alone. It'll automatically
273-
* re-orient itself as appropriate. Read <a
274-
* href="{@docRoot}guide/topics/resources/runtime-changes.html">Handling Runtime Changes</a> for
275-
* more information about how to handle configuration changes during runtime.</p>
276-
*
277-
*
278-
* <h3>Building web pages to support different screen densities</h3>
279-
*
280-
* <p>The screen density of a device is based on the screen resolution. A screen with low density
281-
* has fewer available pixels per inch, where a screen with high density
282-
* has more &mdash; sometimes significantly more &mdash; pixels per inch. The density of a
283-
* screen is important because, other things being equal, a UI element (such as a button) whose
284-
* height and width are defined in terms of screen pixels will appear larger on the lower density
285-
* screen and smaller on the higher density screen.
286-
* For simplicity, Android collapses all actual screen densities into three generalized densities:
287-
* high, medium, and low.</p>
288-
* <p>By default, WebView scales a web page so that it is drawn at a size that matches the default
289-
* appearance on a medium density screen. So, it applies 1.5x scaling on a high density screen
290-
* (because its pixels are smaller) and 0.75x scaling on a low density screen (because its pixels
291-
* are bigger).
292-
* Starting with API Level 5 (Android 2.0), WebView supports DOM, CSS, and meta tag features to help
293-
* you (as a web developer) target screens with different screen densities.</p>
294-
* <p>Here's a summary of the features you can use to handle different screen densities:</p>
295-
* <ul>
296-
* <li>The {@code window.devicePixelRatio} DOM property. The value of this property specifies the
297-
* default scaling factor used for the current device. For example, if the value of {@code
298-
* window.devicePixelRatio} is "1.0", then the device is considered a medium density (mdpi) device
299-
* and default scaling is not applied to the web page; if the value is "1.5", then the device is
300-
* considered a high density device (hdpi) and the page content is scaled 1.5x; if the
301-
* value is "0.75", then the device is considered a low density device (ldpi) and the content is
302-
* scaled 0.75x. However, if you specify the {@code "target-densitydpi"} meta property
303-
* (discussed below), then you can stop this default scaling behavior.</li>
304-
* <li>The {@code -webkit-device-pixel-ratio} CSS media query. Use this to specify the screen
305-
* densities for which this style sheet is to be used. The corresponding value should be either
306-
* "0.75", "1", or "1.5", to indicate that the styles are for devices with low density, medium
307-
* density, or high density screens, respectively. For example:
308-
* <pre>
309-
* &lt;link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1.5)" href="hdpi.css" /&gt;</pre>
310-
* <p>The {@code hdpi.css} stylesheet is only used for devices with a screen pixel ration of 1.5,
311-
* which is the high density pixel ratio.</p>
312-
* </li>
313-
* <li>The {@code target-densitydpi} property for the {@code viewport} meta tag. You can use
314-
* this to specify the target density for which the web page is designed, using the following
315-
* values:
316-
* <ul>
317-
* <li>{@code device-dpi} - Use the device's native dpi as the target dpi. Default scaling never
318-
* occurs.</li>
319-
* <li>{@code high-dpi} - Use hdpi as the target dpi. Medium and low density screens scale down
320-
* as appropriate.</li>
321-
* <li>{@code medium-dpi} - Use mdpi as the target dpi. High density screens scale up and
322-
* low density screens scale down. This is also the default behavior.</li>
323-
* <li>{@code low-dpi} - Use ldpi as the target dpi. Medium and high density screens scale up
324-
* as appropriate.</li>
325-
* <li><em>{@code <value>}</em> - Specify a dpi value to use as the target dpi (accepted
326-
* values are 70-400).</li>
327-
* </ul>
328-
* <p>Here's an example meta tag to specify the target density:</p>
329-
* <pre>&lt;meta name="viewport" content="target-densitydpi=device-dpi" /&gt;</pre></li>
330-
* </ul>
331-
* <p>If you want to modify your web page for different densities, by using the {@code
332-
* -webkit-device-pixel-ratio} CSS media query and/or the {@code
333-
* window.devicePixelRatio} DOM property, then you should set the {@code target-densitydpi} meta
334-
* property to {@code device-dpi}. This stops Android from performing scaling in your web page and
335-
* allows you to make the necessary adjustments for each density via CSS and JavaScript.</p>
336-
*
337-
* <h3>HTML5 Video support</h3>
338-
*
339-
* <p>In order to support inline HTML5 video in your application, you need to have hardware
340-
* acceleration turned on, and set a {@link android.webkit.WebChromeClient}. For full screen support,
341-
* implementations of {@link WebChromeClient#onShowCustomView(View, WebChromeClient.CustomViewCallback)}
342-
* and {@link WebChromeClient#onHideCustomView()} are required,
343-
* {@link WebChromeClient#getVideoLoadingProgressView()} is optional.
344-
* </p>
345-
*
141+
* Implements a backend provider for the {@link WebView} public API.
346142
* @hide
347143
*/
348144
// TODO: Check if any WebView published API methods are called from within here, and if so

0 commit comments

Comments
 (0)