Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C3C217BB9 for ; Wed, 25 Feb 2015 14:36:07 +0000 (UTC) Received: (qmail 92267 invoked by uid 500); 25 Feb 2015 14:36:07 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 92231 invoked by uid 500); 25 Feb 2015 14:36:07 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 92135 invoked by uid 99); 25 Feb 2015 14:36:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Feb 2015 14:36:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F126AE0531; Wed, 25 Feb 2015 14:36:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Date: Wed, 25 Feb 2015 14:36:07 -0000 Message-Id: <1ba12620ce6d46dfbc8f412989a368b2@git.apache.org> In-Reply-To: <3b2c16ceeb514642b0c54b78fe047cf1@git.apache.org> References: <3b2c16ceeb514642b0c54b78fe047cf1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] android commit: CB-8510 Create a new abstraction for sharing common logic of WebView engines CB-8510 Create a new abstraction for sharing common logic of WebView engines Having CordovaWebViewImpl separate from CordovaWebViewEngine is helpful because now each webview doesn't have to re-implement non-webview-specific featrues. e.g.: 1. load timeout 2. keyboard events 3. showCustomView 4. lifecycle events Moved AndroidWebView into its own package to ensure that it doesn't use any package-private symbols (since plugins cannot use them). Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/087ec11e Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/087ec11e Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/087ec11e Branch: refs/heads/master Commit: 087ec11e6abc61acde4e2860f8ee363f3daba578 Parents: 00c0a84 Author: Andrew Grieve Authored: Thu Feb 5 20:46:42 2015 -0500 Committer: Andrew Grieve Committed: Thu Feb 19 12:21:30 2015 -0500 ---------------------------------------------------------------------- .../org/apache/cordova/AndroidChromeClient.java | 268 ------- .../apache/cordova/AndroidCookieManager.java | 60 -- .../org/apache/cordova/AndroidExposedJsApi.java | 50 -- .../src/org/apache/cordova/AndroidWebView.java | 791 ------------------- .../apache/cordova/AndroidWebViewClient.java | 422 ---------- .../src/org/apache/cordova/CordovaActivity.java | 25 +- .../org/apache/cordova/CordovaUriHelper.java | 84 -- .../src/org/apache/cordova/CordovaWebView.java | 30 +- .../apache/cordova/CordovaWebViewEngine.java | 82 ++ .../org/apache/cordova/CordovaWebViewImpl.java | 645 +++++++++++++++ .../apache/cordova/NativeToJsMessageQueue.java | 8 +- .../src/org/apache/cordova/PluginManager.java | 4 +- .../cordova/engine/SystemCookieManager.java | 63 ++ .../cordova/engine/SystemExposedJsApi.java | 53 ++ .../cordova/engine/SystemWebChromeClient.java | 272 +++++++ .../apache/cordova/engine/SystemWebView.java | 88 +++ .../cordova/engine/SystemWebViewClient.java | 374 +++++++++ .../cordova/engine/SystemWebViewEngine.java | 312 ++++++++ .../cordova/test/CordovaActivityTest.java | 6 +- .../apache/cordova/test/InflateLayoutTest.java | 4 +- test/res/layout/main.xml | 2 +- .../test/CordovaWebViewTestActivity.java | 13 +- .../org/apache/cordova/test/userwebview.java | 25 +- 23 files changed, 1957 insertions(+), 1724 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/087ec11e/framework/src/org/apache/cordova/AndroidChromeClient.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/AndroidChromeClient.java b/framework/src/org/apache/cordova/AndroidChromeClient.java deleted file mode 100755 index 2852a20..0000000 --- a/framework/src/org/apache/cordova/AndroidChromeClient.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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 org.apache.cordova; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.Intent; -import android.net.Uri; -import android.os.Build; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.webkit.ConsoleMessage; -import android.webkit.GeolocationPermissions.Callback; -import android.webkit.JsPromptResult; -import android.webkit.JsResult; -import android.webkit.ValueCallback; -import android.webkit.WebChromeClient; -import android.webkit.WebStorage; -import android.webkit.WebView; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; - -/** - * This class is the WebChromeClient that implements callbacks for our web view. - * The kind of callbacks that happen here are on the chrome outside the document, - * such as onCreateWindow(), onConsoleMessage(), onProgressChanged(), etc. Related - * to but different than CordovaWebViewClient. - */ -public class AndroidChromeClient extends WebChromeClient { - - public static final int FILECHOOSER_RESULTCODE = 5173; - private static final String LOG_TAG = "AndroidChromeClient"; - private long MAX_QUOTA = 100 * 1024 * 1024; - protected final CordovaInterface cordova; - protected final AndroidWebView appView; - - // the video progress view - private View mVideoProgressView; - - private CordovaDialogsHelper dialogsHelper; - - public AndroidChromeClient(CordovaInterface ctx, AndroidWebView webView) { - this.cordova = ctx; - this.appView = webView; - dialogsHelper = new CordovaDialogsHelper(webView.getContext()); - } - - /** - * Tell the client to display a javascript alert dialog. - */ - @Override - public boolean onJsAlert(WebView view, String url, String message, final JsResult result) { - dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() { - @Override public void gotResult(boolean success, String value) { - if (success) { - result.confirm(); - } else { - result.cancel(); - } - } - }); - return true; - } - - /** - * Tell the client to display a confirm dialog to the user. - */ - @Override - public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { - dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() { - @Override - public void gotResult(boolean success, String value) { - if (success) { - result.confirm(); - } else { - result.cancel(); - } - } - }); - return true; - } - - /** - * Tell the client to display a prompt dialog to the user. - * If the client returns true, WebView will assume that the client will - * handle the prompt dialog and call the appropriate JsPromptResult method. - * - * Since we are hacking prompts for our own purposes, we should not be using them for - * this purpose, perhaps we should hack console.log to do this instead! - */ - @Override - public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) { - // Unlike the @JavascriptInterface bridge, this method is always called on the UI thread. - String handledRet = appView.bridge.promptOnJsPrompt(origin, message, defaultValue); - if (handledRet != null) { - result.confirm(handledRet); - } else { - dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() { - @Override - public void gotResult(boolean success, String value) { - if (success) { - result.confirm(value); - } else { - result.cancel(); - } - } - }); - } - return true; - } - - /** - * Handle database quota exceeded notification. - */ - @Override - public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, - long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) - { - LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota); - quotaUpdater.updateQuota(MAX_QUOTA); - } - - // console.log in api level 7: http://developer.android.com/guide/developing/debug-tasks.html - // Expect this to not compile in a future Android release! - @SuppressWarnings("deprecation") - @Override - public void onConsoleMessage(String message, int lineNumber, String sourceID) - { - //This is only for Android 2.1 - if(android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1) - { - LOG.d(LOG_TAG, "%s: Line %d : %s", sourceID, lineNumber, message); - super.onConsoleMessage(message, lineNumber, sourceID); - } - } - - @TargetApi(8) - @Override - public boolean onConsoleMessage(ConsoleMessage consoleMessage) - { - if (consoleMessage.message() != null) - LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message()); - return super.onConsoleMessage(consoleMessage); - } - - @Override - /** - * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin. - * - * @param origin - * @param callback - */ - public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) { - super.onGeolocationPermissionsShowPrompt(origin, callback); - callback.invoke(origin, true, false); - } - - // API level 7 is required for this, see if we could lower this using something else - @Override - public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { - this.appView.showCustomView(view, callback); - } - - @Override - public void onHideCustomView() { - this.appView.hideCustomView(); - } - - @Override - /** - * Ask the host application for a custom progress view to show while - * a