@capgo/inappbrowser 0.0.5 → 0.0.6
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.
|
@@ -4,24 +4,25 @@ import android.content.ComponentName;
|
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.net.Uri;
|
|
6
6
|
import android.os.Bundle;
|
|
7
|
-
import android.support.customtabs.CustomTabsCallback;
|
|
8
|
-
import android.support.customtabs.CustomTabsClient;
|
|
9
|
-
import android.support.customtabs.CustomTabsIntent;
|
|
10
|
-
import android.support.customtabs.CustomTabsServiceConnection;
|
|
11
|
-
import android.support.customtabs.CustomTabsSession;
|
|
12
7
|
import android.text.TextUtils;
|
|
13
8
|
import android.util.Log;
|
|
14
9
|
|
|
10
|
+
import androidx.browser.customtabs.CustomTabsCallback;
|
|
11
|
+
import androidx.browser.customtabs.CustomTabsClient;
|
|
12
|
+
import androidx.browser.customtabs.CustomTabsIntent;
|
|
13
|
+
import androidx.browser.customtabs.CustomTabsServiceConnection;
|
|
14
|
+
import androidx.browser.customtabs.CustomTabsSession;
|
|
15
|
+
|
|
15
16
|
import com.getcapacitor.JSObject;
|
|
16
|
-
import com.getcapacitor.NativePlugin;
|
|
17
17
|
import com.getcapacitor.Plugin;
|
|
18
18
|
import com.getcapacitor.PluginCall;
|
|
19
19
|
import com.getcapacitor.PluginMethod;
|
|
20
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
20
21
|
|
|
21
22
|
import java.util.Iterator;
|
|
22
23
|
|
|
23
|
-
@
|
|
24
|
-
public class
|
|
24
|
+
@CapacitorPlugin(name = "InAppBrowserPlugin")
|
|
25
|
+
public class InAppBrowserPlugin extends Plugin {
|
|
25
26
|
public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
|
|
26
27
|
private CustomTabsClient customTabsClient;
|
|
27
28
|
private CustomTabsSession currentSession;
|
|
@@ -41,31 +42,30 @@ public class CapBrowser extends Plugin {
|
|
|
41
42
|
|
|
42
43
|
@PluginMethod()
|
|
43
44
|
public void setUrl(PluginCall call) {
|
|
44
|
-
call.
|
|
45
|
+
call.resolve();
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
@PluginMethod()
|
|
48
49
|
public void open(PluginCall call) {
|
|
49
50
|
String url = call.getString("url");
|
|
50
51
|
if(url == null || TextUtils.isEmpty(url)) {
|
|
51
|
-
call.
|
|
52
|
+
call.reject("Invalid URL");
|
|
52
53
|
}
|
|
53
54
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getCustomTabsSession());
|
|
54
|
-
builder.addDefaultShareMenuItem();
|
|
55
55
|
CustomTabsIntent tabsIntent = builder.build();
|
|
56
56
|
tabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
|
|
57
57
|
Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getContext().getPackageName()));
|
|
58
58
|
tabsIntent.intent.putExtra(android.provider.Browser.EXTRA_HEADERS, this.getHeaders(call));
|
|
59
59
|
tabsIntent.launchUrl(getContext(), Uri.parse(url));
|
|
60
60
|
|
|
61
|
-
call.
|
|
61
|
+
call.resolve();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@PluginMethod()
|
|
65
65
|
public void openWebView(PluginCall call) {
|
|
66
66
|
String url = call.getString("url");
|
|
67
67
|
if(url == null || TextUtils.isEmpty(url)) {
|
|
68
|
-
call.
|
|
68
|
+
call.reject("Invalid URL");
|
|
69
69
|
}
|
|
70
70
|
final Options options = new Options();
|
|
71
71
|
options.setUrl(url);
|
|
@@ -111,7 +111,7 @@ public class CapBrowser extends Plugin {
|
|
|
111
111
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
112
112
|
getContext().startActivity(intent);
|
|
113
113
|
}
|
|
114
|
-
call.
|
|
114
|
+
call.resolve();
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
private Bundle getHeaders(PluginCall pluginCall) {
|
|
@@ -157,9 +157,4 @@ public class CapBrowser extends Plugin {
|
|
|
157
157
|
}
|
|
158
158
|
return currentSession;
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
@Override
|
|
162
|
-
protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
|
|
163
|
-
super.handleOnActivityResult(requestCode, resultCode, data);
|
|
164
|
-
}
|
|
165
160
|
}
|
|
@@ -3,7 +3,6 @@ package ee.forgr.capacitor_inappbrowser;
|
|
|
3
3
|
import android.app.Dialog;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.graphics.Bitmap;
|
|
6
|
-
import android.support.v7.widget.Toolbar;
|
|
7
6
|
import android.text.TextUtils;
|
|
8
7
|
import android.view.View;
|
|
9
8
|
import android.view.Window;
|
|
@@ -14,8 +13,7 @@ import android.webkit.WebView;
|
|
|
14
13
|
import android.webkit.WebViewClient;
|
|
15
14
|
import android.widget.ImageButton;
|
|
16
15
|
import android.widget.TextView;
|
|
17
|
-
|
|
18
|
-
import com.cap.browser.plugin.capbrowser.R;
|
|
16
|
+
import android.widget.Toolbar;
|
|
19
17
|
|
|
20
18
|
import java.net.URI;
|
|
21
19
|
import java.net.URISyntaxException;
|