You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/07/10 17:37:41 UTC
[4/5] android commit: Un-deprecate CordovaActivity.init() - it's
needed to tweak prefs in onCreate
Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/a14c7942
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/a14c7942
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/a14c7942
Branch: refs/heads/master
Commit: a14c7942557fbaea41438bd3fe104b47997d8371
Parents: aef96e9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:29:44 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:20 2014 -0400
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaActivity.java | 78 ++++++++++----------
1 file changed, 38 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a14c7942/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index d69dd59..1367f1c 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -207,37 +207,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
}
loadConfig();
-
- if(!preferences.getBoolean("ShowTitle", false))
- {
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- }
-
- if(preferences.getBoolean("SetFullscreen", false))
- {
- Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- } else if (preferences.getBoolean("Fullscreen", false)) {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- } else {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- }
-
- appView = makeWebView();
- appView.init(this, makeWebViewClient(appView), makeChromeClient(appView), pluginEntries, whitelist, preferences);
-
- // TODO: Have the views set this themselves.
- if (preferences.getBoolean("DisallowOverscroll", false)) {
- appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
- }
- createViews();
-
- // TODO: Make this a preference (CB-6153)
- // Setup the hardware volume controls to handle volume control
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
@SuppressWarnings("deprecation")
@@ -323,32 +292,58 @@ public class CordovaActivity extends Activity implements CordovaInterface {
return webView.makeWebChromeClient(this);
}
- @Deprecated // No need to call init() anymore.
public void init() {
this.init(appView, null, null);
}
@SuppressLint("NewApi")
- @Deprecated // No need to call init() anymore.
+ @Deprecated // Call init() instead and override makeWebView() to customize.
public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
LOG.d(TAG, "CordovaActivity.init()");
- appView = webView;
+ if(!preferences.getBoolean("ShowTitle", false))
+ {
+ getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+ }
+
+ if(preferences.getBoolean("SetFullscreen", false))
+ {
+ Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ } else if (preferences.getBoolean("Fullscreen", false)) {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ } else {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ }
- if (webViewClient != null) {
- this.appView.setWebViewClient(webViewClient);
- webViewClient.setWebView(this.appView);
+ appView = webView != null ? webView : makeWebView();
+ if (appView.pluginManager == null) {
+ appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
+ webChromeClient != null ? webChromeClient : makeChromeClient(appView),
+ pluginEntries, whitelist, preferences);
}
- if (webChromeClient != null) {
- this.appView.setWebChromeClient(webChromeClient);
- webChromeClient.setWebView(this.appView);
+
+ // TODO: Have the views set this themselves.
+ if (preferences.getBoolean("DisallowOverscroll", false)) {
+ appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
+ createViews();
+
+ // TODO: Make this a preference (CB-6153)
+ // Setup the hardware volume controls to handle volume control
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
/**
* Load the url into the webview.
*/
public void loadUrl(String url) {
+ if (appView == null) {
+ init();
+ }
this.splashscreenTime = preferences.getInteger("SplashScreenDelay", this.splashscreenTime);
String splash = preferences.getString("SplashScreen", null);
if(this.splashscreenTime > 0 && splash != null)
@@ -436,6 +431,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
*/
@Deprecated // Call method on appView directly.
public void clearCache() {
+ if (appView == null) {
+ init();
+ }
this.appView.clearCache(true);
}