mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:42:53 +08:00
Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate
This commit is contained in:
parent
aef96e95e8
commit
a14c794255
@ -207,37 +207,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadConfig();
|
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")
|
@SuppressWarnings("deprecation")
|
||||||
@ -323,32 +292,58 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
return webView.makeWebChromeClient(this);
|
return webView.makeWebChromeClient(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated // No need to call init() anymore.
|
|
||||||
public void init() {
|
public void init() {
|
||||||
this.init(appView, null, null);
|
this.init(appView, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@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) {
|
public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
|
||||||
LOG.d(TAG, "CordovaActivity.init()");
|
LOG.d(TAG, "CordovaActivity.init()");
|
||||||
|
|
||||||
appView = webView;
|
if(!preferences.getBoolean("ShowTitle", false))
|
||||||
|
{
|
||||||
|
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
if (webViewClient != null) {
|
if(preferences.getBoolean("SetFullscreen", false))
|
||||||
this.appView.setWebViewClient(webViewClient);
|
{
|
||||||
webViewClient.setWebView(this.appView);
|
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 (webChromeClient != null) {
|
|
||||||
this.appView.setWebChromeClient(webChromeClient);
|
appView = webView != null ? webView : makeWebView();
|
||||||
webChromeClient.setWebView(this.appView);
|
if (appView.pluginManager == null) {
|
||||||
|
appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
|
||||||
|
webChromeClient != null ? webChromeClient : 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the url into the webview.
|
* Load the url into the webview.
|
||||||
*/
|
*/
|
||||||
public void loadUrl(String url) {
|
public void loadUrl(String url) {
|
||||||
|
if (appView == null) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
this.splashscreenTime = preferences.getInteger("SplashScreenDelay", this.splashscreenTime);
|
this.splashscreenTime = preferences.getInteger("SplashScreenDelay", this.splashscreenTime);
|
||||||
String splash = preferences.getString("SplashScreen", null);
|
String splash = preferences.getString("SplashScreen", null);
|
||||||
if(this.splashscreenTime > 0 && splash != null)
|
if(this.splashscreenTime > 0 && splash != null)
|
||||||
@ -436,6 +431,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
*/
|
*/
|
||||||
@Deprecated // Call method on appView directly.
|
@Deprecated // Call method on appView directly.
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
|
if (appView == null) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
this.appView.clearCache(true);
|
this.appView.clearCache(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user