@capgo/inappbrowser 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,4 +55,10 @@ dependencies {
55
55
  testImplementation "junit:junit:$junitVersion"
56
56
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
57
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ implementation 'com.android.support:customtabs:28.0.0'
59
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
60
+ implementation 'com.android.support:design:28.0.0'
61
+ implementation 'com.android.support:appcompat-v7:28.0.0'
62
+ implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
63
+ implementation 'com.google.android.material:material:1.0.0'
58
64
  }
@@ -21,7 +21,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
21
21
 
22
22
  import java.util.Iterator;
23
23
 
24
- @CapacitorPlugin(name = "InAppBrowserPlugin")
24
+ @CapacitorPlugin(name = "InAppBrowser")
25
25
  public class InAppBrowserPlugin extends Plugin {
26
26
  public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
27
27
  private CustomTabsClient customTabsClient;
@@ -42,6 +42,16 @@ public class InAppBrowserPlugin extends Plugin {
42
42
 
43
43
  @PluginMethod()
44
44
  public void setUrl(PluginCall call) {
45
+ String url = call.getString("url");
46
+ if(url == null || TextUtils.isEmpty(url)) {
47
+ call.reject("Invalid URL");
48
+ }
49
+ getActivity().runOnUiThread(new Runnable() {
50
+ @Override
51
+ public void run() {
52
+ webViewDialog.setUrl(url);
53
+ }
54
+ });
45
55
  call.resolve();
46
56
  }
47
57
 
@@ -13,7 +13,7 @@ import android.webkit.WebView;
13
13
  import android.webkit.WebViewClient;
14
14
  import android.widget.ImageButton;
15
15
  import android.widget.TextView;
16
- import android.widget.Toolbar;
16
+ import androidx.appcompat.widget.Toolbar;
17
17
 
18
18
  import java.net.URI;
19
19
  import java.net.URISyntaxException;
@@ -76,6 +76,22 @@ public class WebViewDialog extends Dialog {
76
76
  }
77
77
  }
78
78
 
79
+ public void setUrl(String url) {
80
+ Map<String, String> requestHeaders = new HashMap<>();
81
+ if(_options.getHeaders() != null) {
82
+ Iterator<String> keys = _options.getHeaders().keys();
83
+ while(keys.hasNext()) {
84
+ String key = keys.next();
85
+ if(TextUtils.equals(key, "User-Agent")) {
86
+ _webView.getSettings().setUserAgentString(_options.getHeaders().getString(key));
87
+ } else {
88
+ requestHeaders.put(key, _options.getHeaders().getString(key));
89
+ }
90
+ }
91
+ }
92
+ _webView.loadUrl(url, requestHeaders);
93
+ }
94
+
79
95
  private void setTitle(String newTitleText) {
80
96
  TextView textView = (TextView) _toolbar.findViewById(R.id.titleText);
81
97
  textView.setText(newTitleText);
@@ -1,12 +1,12 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+ <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  xmlns:app="http://schemas.android.com/apk/res-auto"
4
4
  xmlns:tools="http://schemas.android.com/tools"
5
5
  android:layout_width="match_parent"
6
6
  android:layout_height="match_parent"
7
7
  tools:context="com.cap.browser.plugin.WebViewActivity">
8
8
 
9
- <android.support.design.widget.AppBarLayout
9
+ <com.google.android.material.appbar.AppBarLayout
10
10
  android:layout_width="match_parent"
11
11
  android:layout_height="wrap_content"
12
12
  android:theme="@style/AppTheme.AppBarOverlay">
@@ -15,8 +15,8 @@
15
15
  android:id="@+id/tool_bar"
16
16
  layout="@layout/tool_bar" />
17
17
 
18
- </android.support.design.widget.AppBarLayout>
18
+ </com.google.android.material.appbar.AppBarLayout>
19
19
 
20
20
  <include layout="@layout/content_browser" />
21
21
 
22
- </android.support.design.widget.CoordinatorLayout>
22
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+ <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  xmlns:app="http://schemas.android.com/apk/res-auto"
4
4
  xmlns:tools="http://schemas.android.com/tools"
5
5
  android:layout_width="match_parent"
@@ -12,4 +12,4 @@
12
12
  android:layout_width="fill_parent"
13
13
  android:layout_height="fill_parent" />
14
14
 
15
- </android.support.design.widget.CoordinatorLayout>
15
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
2
+ <androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  xmlns:app="http://schemas.android.com/apk/res-auto"
4
4
  android:layout_width="match_parent"
5
5
  android:layout_height="wrap_content"
@@ -47,4 +47,4 @@
47
47
  android:contentDescription="@string/back_button"
48
48
  android:paddingRight="10dp"
49
49
  android:src="@drawable/arrow_back_disabled" />
50
- </android.support.v7.widget.Toolbar>
50
+ </androidx.appcompat.widget.Toolbar>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",