Commit 860a42e2 authored by pichillilorenzo's avatar pichillilorenzo

v0.4.0

parent c7356f33
This diff is collapsed.
## 0.4.0
- removed `target` parameter to `InAppBrowser.open()` method. To open the url on the system browser, use the `openWithSystemBrowser: true` option
- fixes for the `_ChannelManager` private class
- fixed `EXC_BAD_INSTRUCTION` onLoadStart in Swift
- added `openWithSystemBrowser` and `isLocalFile` options
- added `InAppBrowser.openWithSystemBrowser` method
- added `InAppBrowser.openOnLocalhost` method
- added `InAppBrowser.loadFile` method
## 0.3.2 ## 0.3.2
- fixed WebView.storyboard path for iOS - fixed WebView.storyboard path for iOS
......
This diff is collapsed.
...@@ -2,29 +2,31 @@ package com.pichillilorenzo.flutter_inappbrowser; ...@@ -2,29 +2,31 @@ package com.pichillilorenzo.flutter_inappbrowser;
public class InAppBrowserOptions extends Options { public class InAppBrowserOptions extends Options {
final static String LOG_TAG = "InAppBrowserOptions"; static final String LOG_TAG = "InAppBrowserOptions";
public boolean useShouldOverrideUrlLoading = false; public boolean useShouldOverrideUrlLoading = false;
public boolean useOnLoadResource = false; public boolean useOnLoadResource = false;
public boolean clearCache = false; public boolean openWithSystemBrowser = false;
public String userAgent = ""; public boolean clearCache = false;
public boolean javaScriptEnabled = true; public String userAgent = "";
public boolean javaScriptCanOpenWindowsAutomatically = false; public boolean javaScriptEnabled = true;
public boolean hidden = false; public boolean javaScriptCanOpenWindowsAutomatically = false;
public boolean toolbarTop = true; public boolean hidden = false;
public String toolbarTopBackgroundColor = ""; public boolean toolbarTop = true;
public String toolbarTopFixedTitle = ""; public String toolbarTopBackgroundColor = "";
public boolean hideUrlBar = false; public String toolbarTopFixedTitle = "";
public boolean mediaPlaybackRequiresUserGesture = true; public boolean hideUrlBar = false;
public boolean mediaPlaybackRequiresUserGesture = true;
public boolean isLocalFile = false;
public boolean hideTitleBar = false; public boolean hideTitleBar = false;
public boolean closeOnCannotGoBack = true; public boolean closeOnCannotGoBack = true;
public boolean clearSessionCache = false; public boolean clearSessionCache = false;
public boolean builtInZoomControls = false; public boolean builtInZoomControls = false;
public boolean supportZoom = true; public boolean supportZoom = true;
public boolean databaseEnabled = false; public boolean databaseEnabled = false;
public boolean domStorageEnabled = false; public boolean domStorageEnabled = false;
public boolean useWideViewPort = true; public boolean useWideViewPort = true;
public boolean safeBrowsingEnabled = true; public boolean safeBrowsingEnabled = true;
public boolean progressBar = true; public boolean progressBar = true;
} }
...@@ -16,112 +16,111 @@ import java.util.Map; ...@@ -16,112 +16,111 @@ import java.util.Map;
public class InAppBrowserWebChromeClient extends WebChromeClient { public class InAppBrowserWebChromeClient extends WebChromeClient {
protected static final String LOG_TAG = "IABWebChromeClient"; protected static final String LOG_TAG = "IABWebChromeClient";
private WebViewActivity activity; private WebViewActivity activity;
private ValueCallback<Uri[]> mUploadMessageArray; private ValueCallback<Uri[]> mUploadMessageArray;
private ValueCallback<Uri> mUploadMessage; private ValueCallback<Uri> mUploadMessage;
private final static int FILECHOOSER_RESULTCODE=1; private final static int FILECHOOSER_RESULTCODE = 1;
public InAppBrowserWebChromeClient(WebViewActivity activity) { public InAppBrowserWebChromeClient(WebViewActivity activity) {
super(); super();
this.activity = activity; this.activity = activity;
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Map<String, Object> obj = new HashMap<>();
obj.put("uuid", activity.uuid);
obj.put("sourceURL", consoleMessage.sourceId());
obj.put("lineNumber", consoleMessage.lineNumber());
obj.put("message", consoleMessage.message());
obj.put("messageLevel", consoleMessage.messageLevel().toString());
InAppBrowserFlutterPlugin.channel.invokeMethod("onConsoleMessage", obj);
return true;
}
@Override
public void onProgressChanged(WebView view, int progress) {
if (activity.progressBar != null) {
activity.progressBar.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
activity.progressBar.setProgress(progress, true);
} else {
activity.progressBar.setProgress(progress);
}
if (progress == 100) {
activity.progressBar.setVisibility(View.GONE);
}
} }
super.onProgressChanged(view, progress);
@Override }
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Map<String, Object> obj = new HashMap<>(); @Override
obj.put("uuid", activity.uuid); public void onReceivedTitle(WebView view, String title) {
obj.put("sourceURL", consoleMessage.sourceId()); super.onReceivedTitle(view, title);
obj.put("lineNumber", consoleMessage.lineNumber()); if (activity.actionBar != null && activity.options.toolbarTopFixedTitle.isEmpty())
obj.put("message", consoleMessage.message()); activity.actionBar.setTitle(title);
obj.put("messageLevel", consoleMessage.messageLevel().toString()); }
InAppBrowserFlutterPlugin.channel.invokeMethod("onConsoleMessage", obj);
return true; @Override
} public void onReceivedIcon(WebView view, Bitmap icon) {
super.onReceivedIcon(view, icon);
@Override }
public void onProgressChanged(WebView view, int progress) {
if (activity.progressBar != null) { //The undocumented magic method override
activity.progressBar.setVisibility(View.VISIBLE); //Eclipse will swear at you if you try to put @Override here
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // For Android 3.0+
activity.progressBar.setProgress(progress, true); public void openFileChooser(ValueCallback<Uri> uploadMsg) {
}
else { mUploadMessage = uploadMsg;
activity.progressBar.setProgress(progress); Intent i = new Intent(Intent.ACTION_GET_CONTENT);
} i.addCategory(Intent.CATEGORY_OPENABLE);
if (progress == 100) { i.setType("image/*");
activity.progressBar.setVisibility(View.GONE); activity.startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
}
} }
super.onProgressChanged(view, progress);
} // For Android 3.0+
public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
@Override mUploadMessage = uploadMsg;
public void onReceivedTitle(WebView view, String title) { Intent i = new Intent(Intent.ACTION_GET_CONTENT);
super.onReceivedTitle(view, title); i.addCategory(Intent.CATEGORY_OPENABLE);
if (activity.actionBar != null && activity.options.toolbarTopFixedTitle.isEmpty()) i.setType("*/*");
activity.actionBar.setTitle(title); activity.startActivityForResult(
} Intent.createChooser(i, "File Browser"),
FILECHOOSER_RESULTCODE);
@Override }
public void onReceivedIcon(WebView view, Bitmap icon) {
super.onReceivedIcon(view, icon); //For Android 4.1
} public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
mUploadMessage = uploadMsg;
//The undocumented magic method override Intent i = new Intent(Intent.ACTION_GET_CONTENT);
//Eclipse will swear at you if you try to put @Override here i.addCategory(Intent.CATEGORY_OPENABLE);
// For Android 3.0+ i.setType("image/*");
public void openFileChooser(ValueCallback<Uri> uploadMsg) { activity.startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
mUploadMessage = uploadMsg; }
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE); //For Android 5.0+
i.setType("image/*"); public boolean onShowFileChooser(
activity.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE); WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
} if (mUploadMessageArray != null) {
mUploadMessageArray.onReceiveValue(null);
// For Android 3.0+
public void openFileChooser( ValueCallback uploadMsg, String acceptType ) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
activity.startActivityForResult(
Intent.createChooser(i, "File Browser"),
FILECHOOSER_RESULTCODE);
}
//For Android 4.1
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture){
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
activity.startActivityForResult( Intent.createChooser( i, "File Chooser" ), FILECHOOSER_RESULTCODE );
}
//For Android 5.0+
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams){
if(mUploadMessageArray != null){
mUploadMessageArray.onReceiveValue(null);
}
mUploadMessageArray = filePathCallback;
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("*/*");
Intent[] intentArray;
intentArray = new Intent[0];
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
activity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
return true;
} }
mUploadMessageArray = filePathCallback;
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("*/*");
Intent[] intentArray;
intentArray = new Intent[0];
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
activity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
return true;
}
} }
...@@ -10,9 +10,9 @@ public class JavaScriptBridgeInterface { ...@@ -10,9 +10,9 @@ public class JavaScriptBridgeInterface {
static final String name = "flutter_inappbrowser"; static final String name = "flutter_inappbrowser";
WebViewActivity activity; WebViewActivity activity;
static final String flutterInAppBroserJSClass = "window." + name + ".callHandler = function(handlerName, ...args) {\n" + static final String flutterInAppBroserJSClass = "window." + name + ".callHandler = function(handlerName, ...args) {" +
"window." + name + "._callHandler(handlerName, JSON.stringify(args));\n" + "window." + name + "._callHandler(handlerName, JSON.stringify(args));" +
"}\n"; "}";
JavaScriptBridgeInterface(WebViewActivity a) { JavaScriptBridgeInterface(WebViewActivity a) {
activity = a; activity = a;
......
...@@ -9,32 +9,33 @@ import java.util.HashMap; ...@@ -9,32 +9,33 @@ import java.util.HashMap;
public class Options { public class Options {
final static String LOG_TAG = ""; static String LOG_TAG = "";
public void parse(HashMap<String, Object> options) { public Options parse(HashMap<String, Object> options) {
Iterator it = options.entrySet().iterator(); Iterator it = options.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<String, Object> pair = (Map.Entry<String, Object>)it.next(); Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next();
try { try {
this.getClass().getDeclaredField(pair.getKey()).set(this, pair.getValue()); this.getClass().getDeclaredField(pair.getKey()).set(this, pair.getValue());
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
Log.d(LOG_TAG, e.getMessage()); Log.d(LOG_TAG, e.getMessage());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage()); Log.d(LOG_TAG, e.getMessage());
} }
}
} }
return this;
}
public HashMap<String, Object> getHashMap() { public HashMap<String, Object> getHashMap() {
HashMap<String, Object> options = new HashMap<>(); HashMap<String, Object> options = new HashMap<>();
for (Field f: this.getClass().getDeclaredFields()) { for (Field f : this.getClass().getDeclaredFields()) {
try { try {
options.put(f.getName(), f.get(this)); options.put(f.getName(), f.get(this));
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage()); Log.d(LOG_TAG, e.getMessage());
} }
}
return options;
} }
return options;
}
} }
...@@ -17,99 +17,78 @@ import java.util.Map; ...@@ -17,99 +17,78 @@ import java.util.Map;
public class ChromeCustomTabsActivity extends Activity { public class ChromeCustomTabsActivity extends Activity {
protected static final String LOG_TAG = "CustomTabsActivity"; protected static final String LOG_TAG = "CustomTabsActivity";
String uuid; String uuid;
String uuidFallback; CustomTabsIntent.Builder builder;
CustomTabsIntent.Builder builder; ChromeCustomTabsOptions options;
ChromeCustomTabsOptions options; private CustomTabActivityHelper customTabActivityHelper;
Map<String, String> headersFallback; private final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;
InAppBrowserOptions optionsFallback;
private CustomTabActivityHelper customTabActivityHelper;
private final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chrome_custom_tabs_layout);
Bundle b = getIntent().getExtras();
uuid = b.getString("uuid");
uuidFallback = b.getString("uuidFallback");
String url = b.getString("url");
options = new ChromeCustomTabsOptions();
options.parse((HashMap<String, Object>) b.getSerializable("options"));
headersFallback = (HashMap<String, String>) b.getSerializable("headers");
optionsFallback = new InAppBrowserOptions();
optionsFallback.parse((HashMap<String, Object>) b.getSerializable("optionsFallback"));
InAppBrowserFlutterPlugin.chromeCustomTabsActivities.put(uuid, this);
customTabActivityHelper = new CustomTabActivityHelper();
builder = new CustomTabsIntent.Builder();
prepareCustomTabs();
CustomTabsIntent customTabsIntent = builder.build();
boolean chromeCustomTabsOpened = customTabActivityHelper.openCustomTab(this, customTabsIntent, Uri.parse(url), CHROME_CUSTOM_TAB_REQUEST_CODE,
new CustomTabActivityHelper.CustomTabFallback() {
@Override
public void openUri(Activity activity, Uri uri) {
if (!uuidFallback.isEmpty())
InAppBrowserFlutterPlugin.open(uuidFallback, null, uri.toString(), optionsFallback, headersFallback, false, null);
else {
Log.d(LOG_TAG, "No WebView fallback declared.");
activity.finish();
}
}
});
if (chromeCustomTabsOpened) {
Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid);
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserOpened", obj);
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserLoaded", obj);
}
}
private void prepareCustomTabs() { @Override
if (options.addShareButton) protected void onCreate(Bundle savedInstanceState) {
builder.addDefaultShareMenuItem(); super.onCreate(savedInstanceState);
if (!options.toolbarBackgroundColor.isEmpty()) setContentView(R.layout.chrome_custom_tabs_layout);
builder.setToolbarColor(Color.parseColor(options.toolbarBackgroundColor));
builder.setShowTitle(options.showTitle); Bundle b = getIntent().getExtras();
assert b != null;
uuid = b.getString("uuid");
String url = b.getString("url");
if (options.enableUrlBarHiding) options = new ChromeCustomTabsOptions();
builder.enableUrlBarHiding(); options.parse((HashMap<String, Object>) b.getSerializable("options"));
builder.setInstantAppsEnabled(options.instantAppsEnabled); InAppBrowserFlutterPlugin.chromeCustomTabsActivities.put(uuid, this);
}
@Override customTabActivityHelper = new CustomTabActivityHelper();
protected void onStart() { builder = new CustomTabsIntent.Builder();
super.onStart();
customTabActivityHelper.bindCustomTabsService(this);
}
@Override prepareCustomTabs();
protected void onStop() {
super.onStop(); CustomTabsIntent customTabsIntent = builder.build();
customTabActivityHelper.unbindCustomTabsService(this);
} CustomTabActivityHelper.openCustomTab(this, customTabsIntent, Uri.parse(url), CHROME_CUSTOM_TAB_REQUEST_CODE);
Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid);
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserOpened", obj);
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserLoaded", obj);
}
private void prepareCustomTabs() {
if (options.addShareButton)
builder.addDefaultShareMenuItem();
if (!options.toolbarBackgroundColor.isEmpty())
builder.setToolbarColor(Color.parseColor(options.toolbarBackgroundColor));
builder.setShowTitle(options.showTitle);
if (options.enableUrlBarHiding)
builder.enableUrlBarHiding();
builder.setInstantAppsEnabled(options.instantAppsEnabled);
}
@Override
protected void onStart() {
super.onStart();
customTabActivityHelper.bindCustomTabsService(this);
}
@Override
protected void onStop() {
super.onStop();
customTabActivityHelper.unbindCustomTabsService(this);
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) { if (requestCode == CHROME_CUSTOM_TAB_REQUEST_CODE) {
finish(); finish();
Map<String, Object> obj = new HashMap<>(); Map<String, Object> obj = new HashMap<>();
obj.put("uuid", uuid); obj.put("uuid", uuid);
InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserClosed", obj); InAppBrowserFlutterPlugin.channel.invokeMethod("onChromeSafariBrowserClosed", obj);
}
} }
}
} }
...@@ -27,26 +27,13 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback { ...@@ -27,26 +27,13 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
* @param activity The host activity. * @param activity The host activity.
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available. * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available.
* @param uri the Uri to be opened. * @param uri the Uri to be opened.
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available.
*/ */
public static boolean openCustomTab(Activity activity, public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent, CustomTabsIntent customTabsIntent,
Uri uri, Uri uri,
int requestCode, int requestCode) {
CustomTabFallback fallback) { customTabsIntent.intent.setData(uri);
//If we cant find a package name, it means theres no browser that supports activity.startActivityForResult(customTabsIntent.intent, requestCode);
//Chrome Custom Tabs installed. So, we fallback to the webview
if (!isAvailable(activity)) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
//customTabsIntent.intent.setPackage(packageName);
customTabsIntent.intent.setData(uri);
activity.startActivityForResult(customTabsIntent.intent, requestCode);
return true;
}
return false;
} }
public static boolean isAvailable(Activity activity) { public static boolean isAvailable(Activity activity) {
...@@ -144,16 +131,4 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback { ...@@ -144,16 +131,4 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
void onCustomTabsDisconnected(); void onCustomTabsDisconnected();
} }
/**
* To be used as a fallback to open the Uri when Custom Tabs is not available.
*/
public interface CustomTabFallback {
/**
*
* @param activity The Activity that wants to open the Uri.
* @param uri The uri to be opened by the fallback.
*/
void openUri(Activity activity, Uri uri);
}
} }
\ No newline at end of file
body {
background-color: #333;
color: #fff;
}
img {
max-width: 100%;
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 439 137.29" enable-background="new 0 0 439 137.29" xml:space="preserve">
<g>
<g opacity="0.54">
<path d="M207.08,20.2h27.55c9.35,0,17.51,1.93,24.49,5.8c6.97,3.87,12.33,9.25,16.07,16.13c3.74,6.89,5.61,14.79,5.61,23.72
s-1.87,16.83-5.61,23.72s-9.1,12.26-16.07,16.13c-6.97,3.87-15.13,5.8-24.49,5.8h-27.55V20.2z M234.63,101.19
c10.8,0,19.36-3.1,25.7-9.31c6.33-6.21,9.5-14.88,9.5-26.02s-3.17-19.81-9.5-26.02c-6.33-6.21-14.9-9.31-25.7-9.31H217.8v70.65
h16.83V101.19z"/>
<path d="M297.49,110.75c-3.74-1.87-6.63-4.44-8.67-7.72c-2.04-3.27-3.06-6.99-3.06-11.16c0-6.89,2.59-12.26,7.78-16.13
c5.18-3.87,11.73-5.8,19.64-5.8c3.91,0,7.54,0.43,10.9,1.28s5.93,1.83,7.72,2.93V70.2c0-4.85-1.7-8.74-5.1-11.67
c-3.4-2.93-7.7-4.4-12.88-4.4c-3.66,0-7.01,0.79-10.08,2.36c-3.06,1.57-5.48,3.76-7.27,6.57l-8.16-6.12
c2.55-3.91,6.06-6.97,10.52-9.18c4.46-2.21,9.42-3.32,14.86-3.32c8.84,0,15.79,2.32,20.85,6.95c5.06,4.64,7.59,10.95,7.59,18.94
v41.19H331.8v-9.31h-0.51c-1.87,3.15-4.68,5.82-8.42,8.03c-3.74,2.21-7.95,3.32-12.63,3.32
C305.49,113.56,301.24,112.62,297.49,110.75z M321.47,101.19c3.14-1.87,5.65-4.38,7.52-7.52s2.81-6.59,2.81-10.33
c-2.04-1.36-4.55-2.47-7.52-3.32c-2.98-0.85-6.12-1.28-9.44-1.28c-5.95,0-10.44,1.23-13.45,3.7c-3.02,2.47-4.53,5.66-4.53,9.56
c0,3.57,1.36,6.46,4.08,8.67c2.72,2.21,6.16,3.32,10.33,3.32C314.92,103.99,318.33,103.06,321.47,101.19z"/>
<path d="M353.57,47.5h10.33v10.33h0.51c1.53-3.83,4.12-6.8,7.78-8.93c3.65-2.12,7.65-3.19,11.99-3.19c1.87,0,3.44,0.13,4.72,0.38
v11.1c-1.45-0.34-3.4-0.51-5.87-0.51c-5.53,0-10.01,1.83-13.45,5.48c-3.44,3.66-5.17,8.42-5.17,14.28v36.09h-10.84V47.5
L353.57,47.5z M420.89,112.26c-2.25-0.86-4.14-2.03-5.68-3.51c-1.7-1.64-2.98-3.55-3.83-5.71c-0.85-2.16-1.28-4.8-1.28-7.92V56.3
h-11.35v-9.82h11.35V28.12h10.84v18.36h15.81v9.82h-15.81v36.24c0,3.65,0.68,6.34,2.04,8.08c1.61,1.91,3.95,2.87,7.01,2.87
c2.46,0,4.85-0.72,7.14-2.17v10.59c-1.28,0.59-2.57,1.02-3.89,1.28s-3,0.38-5.04,0.38C425.59,113.56,423.15,113.12,420.89,112.26z
"/>
</g>
<g>
<path fill="#01579B" d="M29.64,108.94L6.36,85.66c-2.76-2.84-4.48-6.84-4.48-10.75c0-1.81,1.02-4.64,1.79-6.27l21.49-44.77
L29.64,108.94z"/>
<path fill="#40C4FF" d="M109.34,28.35L86.06,5.07c-2.03-2.04-6.27-4.48-9.85-4.48c-3.08,0-6.1,0.62-8.06,1.79L25.17,23.87
L109.34,28.35z"/>
<polygon fill="#40C4FF" points="57.4,136.7 113.82,136.7 113.82,112.52 71.73,99.09 33.23,112.52 "/>
<path fill="#29B6F6" d="M25.17,96.41c0,7.18,0.9,8.95,4.48,12.54l3.58,3.58h80.59l-39.4-44.77L25.17,23.88V96.41z"/>
<path fill="#01579B" d="M96.8,23.87H25.16l88.65,88.65h24.18V57l-28.65-28.65C105.32,24.31,101.74,23.87,96.8,23.87z"/>
<path opacity="0.2" fill="#FFFFFF" enable-background="new " d="M30.54,109.84c-3.58-3.6-4.48-7.14-4.48-13.43V24.77l-0.9-0.9
V96.4C25.17,102.7,25.17,104.44,30.54,109.84l2.69,2.69l0,0L30.54,109.84z"/>
<polygon opacity="0.2" fill="#263238" enable-background="new " points="137.1,56.11 137.1,111.63 112.92,111.63
113.82,112.52 138,112.52 138,57.01 "/>
<path opacity="0.2" fill="#FFFFFF" enable-background="new " d="M109.34,28.35c-4.44-4.44-8.08-4.48-13.43-4.48H25.17l0.9,0.9
h69.85C98.58,24.77,105.33,24.32,109.34,28.35L109.34,28.35z"/>
<radialGradient id="SVGID_1_" cx="69.955" cy="60.8864" r="68.065" gradientTransform="matrix(1 0 0 -1 0 129.5328)" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#FFFFFF;stop-opacity:0.1"/>
<stop offset="1" style="stop-color:#FFFFFF;stop-opacity:0"/>
</radialGradient>
<path opacity="0.2" fill="url(#SVGID_1_)" enable-background="new " d="M137.1,56.11l-27.76-27.76L86.06,5.07
c-2.03-2.04-6.27-4.48-9.85-4.48c-3.08,0-6.1,0.62-8.06,1.79L25.17,23.87L3.68,68.64c-0.77,1.63-1.79,4.46-1.79,6.27
c0,3.91,1.72,7.91,4.48,10.75l21.46,21.3c0.51,0.63,1.11,1.27,1.83,1.98l0.9,0.9l2.69,2.69l23.28,23.28l0.9,0.9h55.52h0.9v-24.18
h24.18v-0.06V57.01L137.1,56.11z"/>
</g>
</g>
</svg>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<div class="container">
<div class="container">
<img src="images/dart.svg" alt="dart logo">
<div class="row">
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
</div>
</div>
<script>
console.log("hello");
</script>
</div>
</body>
</html>
\ No newline at end of file
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
......
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInAppBrowser extends InAppBrowser { class MyInAppBrowser extends InAppBrowser {
@override @override
Future onLoadStart(String url) async { Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n"); print("\n\nStarted $url\n\n");
...@@ -13,6 +13,8 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -13,6 +13,8 @@ class MyInAppBrowser extends InAppBrowser {
Future onLoadStop(String url) async { Future onLoadStop(String url) async {
print("\n\nStopped $url\n\n"); print("\n\nStopped $url\n\n");
//print("\n\n ${await this.isHidden()} \n\n");
// await this.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest', 1, 5,'string', {'key': 5}, [4,6,8]);"); // await this.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest', 1, 5,'string', {'key': 5}, [4,6,8]);");
// await this.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest2', false, null, undefined);"); // await this.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerTest2', false, null, undefined);");
// await this.injectScriptCode("setTimeout(function(){window.flutter_inappbrowser.callHandler('handlerTest', 'anotherString');}, 1000);"); // await this.injectScriptCode("setTimeout(function(){window.flutter_inappbrowser.callHandler('handlerTest', 'anotherString');}, 1000);");
...@@ -40,8 +42,7 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -40,8 +42,7 @@ class MyInAppBrowser extends InAppBrowser {
// var x = {"as":4, "dfdfg": 6}; // var x = {"as":4, "dfdfg": 6};
// x; // x;
// """)); // """));
//print("\n\n ${await this.isHidden()} \n\n"); //
// await this.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js"); // await this.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
// this.injectScriptCode(""" // this.injectScriptCode("""
// \$( "body" ).html( "Next Step..." ) // \$( "body" ).html( "Next Step..." )
...@@ -73,29 +74,33 @@ class MyInAppBrowser extends InAppBrowser { ...@@ -73,29 +74,33 @@ class MyInAppBrowser extends InAppBrowser {
} }
@override @override
void onLoadResource(WebResourceResponse response, WebResourceRequest request) { void onLoadResource(
WebResourceResponse response, WebResourceRequest request) {
print("Started at: " + response.startTime.toString() + "ms ---> duration: " + response.duration.toString() + "ms " + response.url); print("Started at: " +
response.startTime.toString() +
"ms ---> duration: " +
response.duration.toString() +
"ms " +
response.url);
// if (response.headers["content-length"] != null) // if (response.headers["content-length"] != null)
// print(response.headers["content-length"] + " length"); // print(response.headers["content-length"] + " length");
} }
@override @override
void onConsoleMessage(ConsoleMessage consoleMessage) { void onConsoleMessage(ConsoleMessage consoleMessage) {
// print(""" print("""
// console output: console output:
// sourceURL: ${consoleMessage.sourceURL} sourceURL: ${consoleMessage.sourceURL}
// lineNumber: ${consoleMessage.lineNumber} lineNumber: ${consoleMessage.lineNumber}
// message: ${consoleMessage.message} message: ${consoleMessage.message}
// messageLevel: ${consoleMessage.messageLevel} messageLevel: ${consoleMessage.messageLevel}
// """); """);
} }
} }
MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser(); MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser();
class MyChromeSafariBrowser extends ChromeSafariBrowser { class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(browserFallback); MyChromeSafariBrowser(browserFallback) : super(browserFallback);
@override @override
...@@ -115,9 +120,10 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser { ...@@ -115,9 +120,10 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
} }
// adding a webview fallback // adding a webview fallback
MyChromeSafariBrowser chromeSafariBrowser = new MyChromeSafariBrowser(inAppBrowserFallback); MyChromeSafariBrowser chromeSafariBrowser =
new MyChromeSafariBrowser(inAppBrowserFallback);
void main() { Future main() async {
runApp(new MyApp()); runApp(new MyApp());
} }
...@@ -127,11 +133,11 @@ class MyApp extends StatefulWidget { ...@@ -127,11 +133,11 @@ class MyApp extends StatefulWidget {
} }
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// int indexTest = inAppBrowserFallback.addJavaScriptHandler("handlerTest", (arguments) async { // int indexTest = inAppBrowserFallback.addJavaScriptHandler("handlerTest",
// (arguments) async {
// print("handlerTest arguments"); // print("handlerTest arguments");
// print(arguments); // print(arguments);
// }); // });
...@@ -150,21 +156,45 @@ class _MyAppState extends State<MyApp> { ...@@ -150,21 +156,45 @@ class _MyAppState extends State<MyApp> {
title: const Text('Flutter InAppBrowser Plugin example app'), title: const Text('Flutter InAppBrowser Plugin example app'),
), ),
body: new Center( body: new Center(
child: new RaisedButton(onPressed: () { child: new RaisedButton(
//chromeSafariBrowser.open("https://flutter.io/"); onPressed: () async {
inAppBrowserFallback.open(url: "https://flutter.io/", options: { // await chromeSafariBrowser.open("https://flutter.io/");
//"useOnLoadResource": true,
//"hidden": true, // await InAppBrowser.openWithSystemBrowser("https://flutter.io/");
//"toolbarTopFixedTitle": "Fixed title",
//"useShouldOverrideUrlLoading": true await inAppBrowserFallback.openOnLocalhost("assets/index.html", options: {
//"hideUrlBar": true, "useOnLoadResource": true,
//"toolbarTop": false, //"hidden": true,
//"toolbarBottom": false //"toolbarTopFixedTitle": "Fixed title",
}); //"useShouldOverrideUrlLoading": true
//"hideUrlBar": true,
}, //"toolbarTop": false,
child: Text("Open InAppBrowser") //"toolbarBottom": false
), });
// await inAppBrowserFallback.open(url: "assets/index.html", options: {
// "isLocalFile": true,
// "useOnLoadResource": true,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title",
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": true,
// //"toolbarTop": false,
// //"toolbarBottom": false
// });
// await inAppBrowserFallback.open(url: "https://flutter.io/", options: {
// //"useOnLoadResource": true,
// //"hidden": true,
// //"toolbarTopFixedTitle": "Fixed title",
// //"useShouldOverrideUrlLoading": true
// //"hideUrlBar": true,
// //"toolbarTop": false,
// //"toolbarBottom": false
// });
//await inAppBrowserFallback.openOnLocalhost("assets/index.html");
},
child: Text("Open InAppBrowser")),
), ),
), ),
); );
......
...@@ -38,6 +38,11 @@ flutter: ...@@ -38,6 +38,11 @@ flutter:
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
assets:
- assets/index.html
- assets/css/
- assets/images/
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
<excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/.dart_tool" /> <excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/.pub" /> <excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/build" /> <excludeFolder url="file://$MODULE_DIR$/example/flutter_plugin/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappbrowser/example/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/flutter_assets/packages" /> <excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/flutter_assets/packages" />
</content> </content>
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
...@@ -12,6 +12,7 @@ public class InAppBrowserOptions: Options { ...@@ -12,6 +12,7 @@ public class InAppBrowserOptions: Options {
var useShouldOverrideUrlLoading = false var useShouldOverrideUrlLoading = false
var useOnLoadResource = false var useOnLoadResource = false
var openWithSystemBrowser = false;
var clearCache = false var clearCache = false
var userAgent = "" var userAgent = ""
var javaScriptEnabled = true var javaScriptEnabled = true
...@@ -21,6 +22,7 @@ public class InAppBrowserOptions: Options { ...@@ -21,6 +22,7 @@ public class InAppBrowserOptions: Options {
var toolbarTopBackgroundColor = "" var toolbarTopBackgroundColor = ""
var hideUrlBar = false var hideUrlBar = false
var mediaPlaybackRequiresUserGesture = true var mediaPlaybackRequiresUserGesture = true
var isLocalFile = false
var disallowOverScroll = false var disallowOverScroll = false
var toolbarBottom = true var toolbarBottom = true
......
...@@ -81,7 +81,6 @@ func convertToDictionary(text: String) -> [String: Any]? { ...@@ -81,7 +81,6 @@ func convertToDictionary(text: String) -> [String: Any]? {
return nil return nil
} }
//extension WKWebView{ //extension WKWebView{
// //
// var keyboardDisplayRequiresUserAction: Bool? { // var keyboardDisplayRequiresUserAction: Bool? {
...@@ -139,6 +138,7 @@ class WKWebView_IBWrapper: WKWebView { ...@@ -139,6 +138,7 @@ class WKWebView_IBWrapper: WKWebView {
} }
class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate, UITextFieldDelegate, WKScriptMessageHandler { class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate, UITextFieldDelegate, WKScriptMessageHandler {
@IBOutlet var webView: WKWebView_IBWrapper! @IBOutlet var webView: WKWebView_IBWrapper!
@IBOutlet var closeButton: UIButton! @IBOutlet var closeButton: UIButton!
@IBOutlet var reloadButton: UIBarButtonItem! @IBOutlet var reloadButton: UIBarButtonItem!
...@@ -200,7 +200,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -200,7 +200,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
spinner.hidesWhenStopped = true spinner.hidesWhenStopped = true
spinner.isHidden = false spinner.isHidden = false
spinner.stopAnimating() spinner.stopAnimating()
loadUrl(url: self.currentURL!, headers: self.initHeaders) loadUrl(url: self.currentURL!, headers: self.initHeaders)
} }
...@@ -421,11 +421,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -421,11 +421,7 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
} }
@objc func close() { @objc func close() {
currentURL = nil //currentURL = nil
if (navigationDelegate != nil) {
navigationDelegate?.browserExit(uuid: self.uuid)
}
weak var weakSelf = self weak var weakSelf = self
...@@ -435,12 +431,18 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -435,12 +431,18 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
weakSelf?.presentingViewController?.dismiss(animated: true, completion: {() -> Void in weakSelf?.presentingViewController?.dismiss(animated: true, completion: {() -> Void in
self.tmpWindow?.windowLevel = 0.0 self.tmpWindow?.windowLevel = 0.0
UIApplication.shared.delegate?.window??.makeKeyAndVisible() UIApplication.shared.delegate?.window??.makeKeyAndVisible()
if (self.navigationDelegate != nil) {
self.navigationDelegate?.browserExit(uuid: self.uuid)
}
}) })
} }
else { else {
weakSelf?.parent?.dismiss(animated: true, completion: {() -> Void in weakSelf?.parent?.dismiss(animated: true, completion: {() -> Void in
self.tmpWindow?.windowLevel = 0.0 self.tmpWindow?.windowLevel = 0.0
UIApplication.shared.delegate?.window??.makeKeyAndVisible() UIApplication.shared.delegate?.window??.makeKeyAndVisible()
if (self.navigationDelegate != nil) {
self.navigationDelegate?.browserExit(uuid: self.uuid)
}
}) })
} }
}) })
...@@ -527,7 +529,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -527,7 +529,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
} }
if navigationAction.navigationType == .linkActivated && (browserOptions?.useShouldOverrideUrlLoading)! { if navigationAction.navigationType == .linkActivated && (browserOptions?.useShouldOverrideUrlLoading)! {
navigationDelegate?.shouldOverrideUrlLoading(uuid: self.uuid, webView: webView, url: url) if navigationDelegate != nil {
navigationDelegate?.shouldOverrideUrlLoading(uuid: self.uuid, webView: webView, url: url)
}
decisionHandler(.cancel) decisionHandler(.cancel)
return return
} }
...@@ -606,7 +610,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -606,7 +610,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
spinner.startAnimating() spinner.startAnimating()
} }
return (navigationDelegate?.onLoadStart(uuid: self.uuid, webView: webView))! if navigationDelegate != nil {
navigationDelegate?.onLoadStart(uuid: self.uuid, webView: webView)
}
} }
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
...@@ -617,7 +623,10 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -617,7 +623,10 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
backButton.isEnabled = webView.canGoBack backButton.isEnabled = webView.canGoBack
forwardButton.isEnabled = webView.canGoForward forwardButton.isEnabled = webView.canGoForward
spinner.stopAnimating() spinner.stopAnimating()
navigationDelegate?.onLoadStop(uuid: self.uuid, webView: webView)
if navigationDelegate != nil {
navigationDelegate?.onLoadStop(uuid: self.uuid, webView: webView)
}
} }
func webView(_ view: WKWebView, func webView(_ view: WKWebView,
...@@ -627,15 +636,19 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -627,15 +636,19 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
} }
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
print("webView:didFailNavigationWithError - \(Int(error._code)): \(error.localizedDescription)")
backButton.isEnabled = webView.canGoBack backButton.isEnabled = webView.canGoBack
forwardButton.isEnabled = webView.canGoForward forwardButton.isEnabled = webView.canGoForward
spinner.stopAnimating() spinner.stopAnimating()
navigationDelegate?.onLoadError(uuid: self.uuid, webView: webView, error: error)
if navigationDelegate != nil {
navigationDelegate?.onLoadError(uuid: self.uuid, webView: webView, error: error)
}
} }
func didReceiveResourceResponse(_ response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int, duration: Int) { func didReceiveResourceResponse(_ response: URLResponse, fromRequest request: URLRequest?, withData data: Data, startTime: Int, duration: Int) {
navigationDelegate?.onLoadResource(uuid: self.uuid, webView: webView, response: response, fromRequest: request, withData: data, startTime: startTime, duration: duration) if navigationDelegate != nil {
navigationDelegate?.onLoadResource(uuid: self.uuid, webView: webView, response: response, fromRequest: request, withData: data, startTime: startTime, duration: duration)
}
} }
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
...@@ -663,7 +676,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -663,7 +676,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
messageLevel = "LOG" messageLevel = "LOG"
break; break;
} }
navigationDelegate?.onConsoleMessage(uuid: self.uuid, sourceURL: "", lineNumber: 1, message: message.body as! String, messageLevel: messageLevel) if navigationDelegate != nil {
navigationDelegate?.onConsoleMessage(uuid: self.uuid, sourceURL: "", lineNumber: 1, message: message.body as! String, messageLevel: messageLevel)
}
} }
else if message.name == "resourceLoaded" { else if message.name == "resourceLoaded" {
if let resource = convertToDictionary(text: message.body as! String) { if let resource = convertToDictionary(text: message.body as! String) {
...@@ -695,7 +710,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio ...@@ -695,7 +710,9 @@ class InAppBrowserWebViewController: UIViewController, WKUIDelegate, WKNavigatio
let body = message.body as! [String: Any] let body = message.body as! [String: Any]
let handlerName = body["handlerName"] as! String let handlerName = body["handlerName"] as! String
let args = body["args"] as! String let args = body["args"] as! String
self.navigationDelegate?.onCallJsHandler(uuid: self.uuid, webView: webView, handlerName: handlerName, args: args) if navigationDelegate != nil {
self.navigationDelegate?.onCallJsHandler(uuid: self.uuid, webView: webView, handlerName: handlerName, args: args)
}
} }
} }
} }
...@@ -14,12 +14,13 @@ public class Options: NSObject { ...@@ -14,12 +14,13 @@ public class Options: NSObject {
super.init() super.init()
} }
public func parse(options: [String: Any]) { public func parse(options: [String: Any]) -> Options {
for (key, value) in options { for (key, value) in options {
if self.responds(to: Selector(key)) { if self.responds(to: Selector(key)) {
self.setValue(value, forKey: key) self.setValue(value, forKey: key)
} }
} }
return self
} }
} }
...@@ -40,15 +40,15 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega ...@@ -40,15 +40,15 @@ class SafariViewController: SFSafariViewController, SFSafariViewControllerDelega
} }
func close() { func close() {
if (statusDelegate != nil) {
statusDelegate?.safariExit(uuid: self.uuid)
}
dismiss(animated: true) dismiss(animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(400), execute: {() -> Void in DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(400), execute: {() -> Void in
self.tmpWindow?.windowLevel = 0.0 self.tmpWindow?.windowLevel = 0.0
UIApplication.shared.delegate?.window??.makeKeyAndVisible() UIApplication.shared.delegate?.window??.makeKeyAndVisible()
if (self.statusDelegate != nil) {
self.statusDelegate?.safariExit(uuid: self.uuid)
}
}) })
} }
......
This diff is collapsed.
This diff is collapsed.
name: flutter_inappbrowser name: flutter_inappbrowser
description: A Flutter plugin that allows you to open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser). description: A Flutter plugin that allows you to open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
version: 0.3.2 version: 0.4.0
author: Lorenzo Pichilli <pichillilorenzo@gmail.com> author: Lorenzo Pichilli <pichillilorenzo@gmail.com>
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser homepage: https://github.com/pichillilorenzo/flutter_inappbrowser
...@@ -11,6 +11,7 @@ dependencies: ...@@ -11,6 +11,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
uuid: ^1.0.3 uuid: ^1.0.3
mime: ^0.9.6+2
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec # following page: https://www.dartlang.org/tools/pub/pubspec
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment