mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
Merge branch 'CordovaWebView' of https://git-wip-us.apache.org/repos/asf/incubator-cordova-android into CordovaWebView
This commit is contained in:
@@ -39,6 +39,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebSettings.LayoutAlgorithm;
|
||||
@@ -76,40 +77,38 @@ public class CordovaWebView extends WebView {
|
||||
*/
|
||||
public CordovaWebView(Context context) {
|
||||
super(context);
|
||||
if(CordovaInterface.class.isInstance(context))
|
||||
if (CordovaInterface.class.isInstance(context))
|
||||
{
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* @param attrs
|
||||
*/
|
||||
public CordovaWebView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
if(CordovaInterface.class.isInstance(context))
|
||||
{
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
|
||||
this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
super(context, attrs);
|
||||
if (CordovaInterface.class.isInstance(context))
|
||||
{
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
|
||||
this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,15 +119,15 @@ public class CordovaWebView extends WebView {
|
||||
* @param defStyle
|
||||
*
|
||||
*/
|
||||
public CordovaWebView(Context context, AttributeSet attrs, int defStyle) {
|
||||
public CordovaWebView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
if(CordovaInterface.class.isInstance(context))
|
||||
if (CordovaInterface.class.isInstance(context))
|
||||
{
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this));
|
||||
this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this));
|
||||
@@ -146,13 +145,13 @@ public class CordovaWebView extends WebView {
|
||||
*/
|
||||
public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
|
||||
super(context, attrs, defStyle, privateBrowsing);
|
||||
if(CordovaInterface.class.isInstance(context))
|
||||
if (CordovaInterface.class.isInstance(context))
|
||||
{
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
this.mCtx = (CordovaInterface) context;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
this.setWebChromeClient(new CordovaChromeClient(this.mCtx));
|
||||
this.setWebViewClient(new CordovaWebViewClient(this.mCtx));
|
||||
@@ -192,10 +191,10 @@ public class CordovaWebView extends WebView {
|
||||
|
||||
//Start up the plugin manager
|
||||
try {
|
||||
this.pluginManager = new PluginManager(this, mCtx);
|
||||
this.pluginManager = new PluginManager(this, this.mCtx);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,6 +636,11 @@ public class CordovaWebView extends WebView {
|
||||
else {
|
||||
this.useBrowserHistory = false;
|
||||
}
|
||||
|
||||
if ("true".equals(this.getProperty("fullscreen", "false"))) {
|
||||
this.mCtx.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
this.mCtx.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -250,15 +250,8 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
// TODO @bc - What about fullscreen?
|
||||
//if (preferences.prefMatches("fullscreen", "true")) {
|
||||
// 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);
|
||||
//}
|
||||
|
||||
// This builds the view. We could probably get away with NOT having a LinearLayout, but I like having a bucket!
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
@@ -337,10 +330,8 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
this.init();
|
||||
}
|
||||
|
||||
// TODO @bc - background color doesn't work
|
||||
// If backgroundColor
|
||||
// Set backgroundColor
|
||||
this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
|
||||
LOG.e(TAG, "Setting background color=" + this.backgroundColor);
|
||||
this.root.setBackgroundColor(this.backgroundColor);
|
||||
|
||||
// If keepRunning
|
||||
@@ -464,7 +455,18 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
if (bundle == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean p = (Boolean) bundle.get(name);
|
||||
Boolean p;
|
||||
try {
|
||||
p = (Boolean) bundle.get(name);
|
||||
} catch (ClassCastException e) {
|
||||
String s = bundle.get(name).toString();
|
||||
if ("true".equals(s)) {
|
||||
p = true;
|
||||
}
|
||||
else {
|
||||
p = false;
|
||||
}
|
||||
}
|
||||
if (p == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
@@ -483,7 +485,12 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
if (bundle == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Integer p = (Integer) bundle.get(name);
|
||||
Integer p;
|
||||
try {
|
||||
p = (Integer) bundle.get(name);
|
||||
} catch (ClassCastException e) {
|
||||
p = Integer.parseInt(bundle.get(name).toString());
|
||||
}
|
||||
if (p == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
@@ -521,7 +528,12 @@ public class DroidGap extends Activity implements CordovaInterface {
|
||||
if (bundle == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Double p = (Double) bundle.get(name);
|
||||
Double p;
|
||||
try {
|
||||
p = (Double) bundle.get(name);
|
||||
} catch (ClassCastException e) {
|
||||
p = Double.parseDouble(bundle.get(name).toString());
|
||||
}
|
||||
if (p == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user