CB-9158 - InAppBrowser zoomControls are always set to true
This commit is contained in:
parent
cb1c6b4d24
commit
74aa099b7e
@ -91,9 +91,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private boolean showLocationBar = true;
|
private boolean showLocationBar = true;
|
||||||
private boolean showZoomControls = true;
|
private boolean showZoomControls = true;
|
||||||
private boolean openWindowHidden = false;
|
private boolean openWindowHidden = false;
|
||||||
private boolean clearAllCache= false;
|
private boolean clearAllCache = false;
|
||||||
private boolean clearSessionCache=false;
|
private boolean clearSessionCache = false;
|
||||||
private boolean hadwareBackButton=true;
|
private boolean hadwareBackButton = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the request and returns PluginResult.
|
* Executes the request and returns PluginResult.
|
||||||
@ -113,9 +113,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
final String target = t;
|
final String target = t;
|
||||||
final HashMap<String, Boolean> features = parseFeature(args.optString(2));
|
final HashMap<String, Boolean> features = parseFeature(args.optString(2));
|
||||||
|
|
||||||
Log.d(LOG_TAG, "target = " + target);
|
Log.d(LOG_TAG, "target = " + target);
|
||||||
|
|
||||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -185,7 +185,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
Log.d(LOG_TAG, "in blank");
|
Log.d(LOG_TAG, "in blank");
|
||||||
result = showWebPage(url, features);
|
result = showWebPage(url, features);
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
|
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
|
||||||
pluginResult.setKeepCallback(true);
|
pluginResult.setKeepCallback(true);
|
||||||
callbackContext.sendPluginResult(pluginResult);
|
callbackContext.sendPluginResult(pluginResult);
|
||||||
@ -251,9 +251,9 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReset() {
|
public void onReset() {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by AccelBroker when listener is to be shut down.
|
* Called by AccelBroker when listener is to be shut down.
|
||||||
* Stop listener.
|
* Stop listener.
|
||||||
@ -261,7 +261,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject an object (script or style) into the InAppBrowser WebView.
|
* Inject an object (script or style) into the InAppBrowser WebView.
|
||||||
*
|
*
|
||||||
@ -306,7 +306,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the list of features into a hash map
|
* Put the list of features into a hash map
|
||||||
*
|
*
|
||||||
* @param optString
|
* @param optString
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -348,7 +348,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
}
|
||||||
intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
|
intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
|
||||||
this.cordova.getActivity().startActivity(intent);
|
this.cordova.getActivity().startActivity(intent);
|
||||||
return "";
|
return "";
|
||||||
} catch (android.content.ActivityNotFoundException e) {
|
} catch (android.content.ActivityNotFoundException e) {
|
||||||
@ -373,12 +373,12 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
childView.setWebViewClient(new WebViewClient() {
|
childView.setWebViewClient(new WebViewClient() {
|
||||||
// NB: wait for about:blank before dismissing
|
// NB: wait for about:blank before dismissing
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// NB: From SDK 19: "If you call methods on WebView from any thread
|
// NB: From SDK 19: "If you call methods on WebView from any thread
|
||||||
// other than your app's UI thread, it can cause unexpected results."
|
// other than your app's UI thread, it can cause unexpected results."
|
||||||
// http://developer.android.com/guide/webapps/migrating.html#Threads
|
// http://developer.android.com/guide/webapps/migrating.html#Threads
|
||||||
childView.loadUrl("about:blank");
|
childView.loadUrl("about:blank");
|
||||||
@ -455,15 +455,6 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return this.showLocationBar;
|
return this.showLocationBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we show the zoom controls?
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private boolean getShowZoomControls() {
|
|
||||||
return this.showZoomControls;
|
|
||||||
}
|
|
||||||
|
|
||||||
private InAppBrowser getInAppBrowser(){
|
private InAppBrowser getInAppBrowser(){
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -487,7 +478,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
Boolean zoom = features.get(ZOOM);
|
Boolean zoom = features.get(ZOOM);
|
||||||
if (zoom != null) {
|
if (zoom != null) {
|
||||||
showZoomControls = zoom.booleanValue();
|
showZoomControls = zoom.booleanValue();
|
||||||
}
|
}
|
||||||
Boolean hidden = features.get(HIDDEN);
|
Boolean hidden = features.get(HIDDEN);
|
||||||
if (hidden != null) {
|
if (hidden != null) {
|
||||||
openWindowHidden = hidden.booleanValue();
|
openWindowHidden = hidden.booleanValue();
|
||||||
@ -506,7 +497,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CordovaWebView thatWebView = this.webView;
|
final CordovaWebView thatWebView = this.webView;
|
||||||
|
|
||||||
// Create dialog in new thread
|
// Create dialog in new thread
|
||||||
@ -540,7 +531,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
|
|
||||||
// Toolbar layout
|
// Toolbar layout
|
||||||
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
|
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
|
||||||
//Please, no more black!
|
//Please, no more black!
|
||||||
toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
|
toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
|
||||||
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
|
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
|
||||||
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
|
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
|
||||||
@ -656,7 +647,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
WebSettings settings = inAppWebView.getSettings();
|
WebSettings settings = inAppWebView.getSettings();
|
||||||
settings.setJavaScriptEnabled(true);
|
settings.setJavaScriptEnabled(true);
|
||||||
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||||
settings.setBuiltInZoomControls(getShowZoomControls());
|
settings.setBuiltInZoomControls(showZoomControls);
|
||||||
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
|
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
|
||||||
|
|
||||||
//Toggle whether this is enabled or not!
|
//Toggle whether this is enabled or not!
|
||||||
@ -733,7 +724,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
*
|
*
|
||||||
* @param obj a JSONObject contain event payload information
|
* @param obj a JSONObject contain event payload information
|
||||||
* @param status the status code to return to the JavaScript environment
|
* @param status the status code to return to the JavaScript environment
|
||||||
*/
|
*/
|
||||||
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
|
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
|
||||||
if (callbackContext != null) {
|
if (callbackContext != null) {
|
||||||
PluginResult result = new PluginResult(status, obj);
|
PluginResult result = new PluginResult(status, obj);
|
||||||
@ -744,7 +735,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The webview client receives notifications about appView
|
* The webview client receives notifications about appView
|
||||||
*/
|
*/
|
||||||
@ -775,7 +766,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
String newloc = "";
|
String newloc = "";
|
||||||
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
|
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
|
||||||
newloc = url;
|
newloc = url;
|
||||||
}
|
}
|
||||||
// If dialing phone (tel:5551212)
|
// If dialing phone (tel:5551212)
|
||||||
else if (url.startsWith(WebView.SCHEME_TEL)) {
|
else if (url.startsWith(WebView.SCHEME_TEL)) {
|
||||||
try {
|
try {
|
||||||
@ -839,37 +830,37 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("type", LOAD_START_EVENT);
|
obj.put("type", LOAD_START_EVENT);
|
||||||
obj.put("url", newloc);
|
obj.put("url", newloc);
|
||||||
|
|
||||||
sendUpdate(obj, true);
|
sendUpdate(obj, true);
|
||||||
} catch (JSONException ex) {
|
} catch (JSONException ex) {
|
||||||
Log.d(LOG_TAG, "Should never happen");
|
Log.d(LOG_TAG, "Should never happen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("type", LOAD_STOP_EVENT);
|
obj.put("type", LOAD_STOP_EVENT);
|
||||||
obj.put("url", url);
|
obj.put("url", url);
|
||||||
|
|
||||||
sendUpdate(obj, true);
|
sendUpdate(obj, true);
|
||||||
} catch (JSONException ex) {
|
} catch (JSONException ex) {
|
||||||
Log.d(LOG_TAG, "Should never happen");
|
Log.d(LOG_TAG, "Should never happen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("type", LOAD_ERROR_EVENT);
|
obj.put("type", LOAD_ERROR_EVENT);
|
||||||
obj.put("url", failingUrl);
|
obj.put("url", failingUrl);
|
||||||
obj.put("code", errorCode);
|
obj.put("code", errorCode);
|
||||||
obj.put("message", description);
|
obj.put("message", description);
|
||||||
|
|
||||||
sendUpdate(obj, true, PluginResult.Status.ERROR);
|
sendUpdate(obj, true, PluginResult.Status.ERROR);
|
||||||
} catch (JSONException ex) {
|
} catch (JSONException ex) {
|
||||||
Log.d(LOG_TAG, "Should never happen");
|
Log.d(LOG_TAG, "Should never happen");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user