|
1 | | -package com.sunny.CustomWebView; |
2 | | -import android.app.Activity; |
3 | | -import android.content.Intent; |
4 | | -import android.net.Uri; |
5 | | -import com.google.appinventor.components.annotations.androidmanifest.*; |
6 | | -import com.google.appinventor.components.runtime.*; |
7 | | -import com.google.appinventor.components.annotations.*; |
8 | | -import com.google.appinventor.components.common.ComponentCategory; |
9 | | -@DesignerComponent(version = 1, |
10 | | - versionName = "1.2", |
11 | | - description ="Helper class of CustomWebView extension to add app to browsers list<br> Developed by Sunny Gupta", |
12 | | - category = ComponentCategory.EXTENSION, |
13 | | - nonVisible = true, |
14 | | - iconName = "https://res.cloudinary.com/andromedaviewflyvipul/image/upload/c_scale,h_20,w_20/v1571472765/ktvu4bapylsvnykoyhdm.png", |
15 | | - helpUrl="https://github.com/vknow360/CustomWebView", |
16 | | - androidMinSdk = 21) |
17 | | -@UsesActivities(activities = {@ActivityElement(intentFilters = {@IntentFilterElement(actionElements = {@ActionElement(name = "android.intent.action.VIEW")}, categoryElements = {@CategoryElement(name = "android.intent.category.DEFAULT"), @CategoryElement(name = "android.intent.category.BROWSABLE")}, dataElements = {@DataElement(scheme = "http"), @DataElement(scheme = "https")}), @IntentFilterElement(actionElements = {@ActionElement(name = "android.intent.action.VIEW")}, categoryElements = {@CategoryElement(name = "android.intent.category.DEFAULT"), @CategoryElement(name = "android.intent.category.BROWSABLE")}, dataElements = {@DataElement(scheme = "http"), @DataElement(scheme = "https"), @DataElement(mimeType = "text/html"), @DataElement(mimeType = "text/plain"), @DataElement(mimeType = "application/xhtml+xml")})},name="appinventor.ai_vknow360.CustomWebView.Screen1",launchMode = "singleTop")}) |
18 | | -@SimpleObject(external=true) |
19 | | -public class BrowserPromptHelper extends AndroidNonvisibleComponent implements OnNewIntentListener { |
20 | | - public Activity activity; |
21 | | - public BrowserPromptHelper(ComponentContainer container){ |
22 | | - super(container.$form()); |
23 | | - activity = container.$context(); |
24 | | - form.registerForOnNewIntent(this); |
25 | | - } |
26 | | - public String getUrl(Intent intent){ |
27 | | - Uri uri = intent.getData(); |
28 | | - if (uri != null && uri.toString() != null){ |
29 | | - return uri.toString(); |
30 | | - } |
31 | | - return ""; |
32 | | - } |
33 | | - @SimpleFunction(description = "Returns the url which started the current activity") |
34 | | - public String GetStartUrl(){ |
35 | | - return getUrl(activity.getIntent()); |
36 | | - } |
37 | | - |
38 | | - @SimpleEvent(description = "Event raised when app gets resumed and gives the url which started this activity/screen if there is any else empty string") |
39 | | - public void OnResume(String url){ |
40 | | - EventDispatcher.dispatchEvent(this,"OnResume",url); |
41 | | - } |
42 | | - |
43 | | - @Override |
44 | | - public void onNewIntent(Intent intent) { |
45 | | - OnResume(getUrl(intent)); |
46 | | - } |
47 | | -} |
| 1 | +package com.sunny.CustomWebView; |
| 2 | +import android.app.Activity; |
| 3 | +import android.content.Intent; |
| 4 | +import android.net.Uri; |
| 5 | +import com.google.appinventor.components.annotations.androidmanifest.*; |
| 6 | +import com.google.appinventor.components.runtime.*; |
| 7 | +import com.google.appinventor.components.annotations.*; |
| 8 | +import com.google.appinventor.components.common.ComponentCategory; |
| 9 | +@DesignerComponent(version = 1, |
| 10 | + versionName = "1.2", |
| 11 | + description ="Helper class of CustomWebView extension to add app to browsers list<br> Developed by Sunny Gupta", |
| 12 | + category = ComponentCategory.EXTENSION, |
| 13 | + nonVisible = true, |
| 14 | + iconName = "https://res.cloudinary.com/andromedaviewflyvipul/image/upload/c_scale,h_20,w_20/v1571472765/ktvu4bapylsvnykoyhdm.png", |
| 15 | + helpUrl="https://github.com/vknow360/CustomWebView", |
| 16 | + androidMinSdk = 21) |
| 17 | +@UsesActivities(activities = {@ActivityElement(intentFilters = {@IntentFilterElement(actionElements = {@ActionElement(name = "android.intent.action.VIEW")}, categoryElements = {@CategoryElement(name = "android.intent.category.DEFAULT"), @CategoryElement(name = "android.intent.category.BROWSABLE")}, dataElements = {@DataElement(scheme = "http"), @DataElement(scheme = "https")}), @IntentFilterElement(actionElements = {@ActionElement(name = "android.intent.action.VIEW")}, categoryElements = {@CategoryElement(name = "android.intent.category.DEFAULT"), @CategoryElement(name = "android.intent.category.BROWSABLE")}, dataElements = {@DataElement(scheme = "http"), @DataElement(scheme = "https"), @DataElement(mimeType = "text/html"), @DataElement(mimeType = "text/plain"), @DataElement(mimeType = "application/xhtml+xml")})},exported="true",name=".Screen1",launchMode = "singleTop")}) |
| 18 | +@SimpleObject(external=true) |
| 19 | +public class BrowserPromptHelper extends AndroidNonvisibleComponent implements OnNewIntentListener { |
| 20 | + public Activity activity; |
| 21 | + public BrowserPromptHelper(ComponentContainer container){ |
| 22 | + super(container.$form()); |
| 23 | + activity = container.$context(); |
| 24 | + form.registerForOnNewIntent(this); |
| 25 | + } |
| 26 | + public String getUrl(Intent intent){ |
| 27 | + Uri uri = intent.getData(); |
| 28 | + if (uri != null && uri.toString() != null){ |
| 29 | + return uri.toString(); |
| 30 | + } |
| 31 | + return ""; |
| 32 | + } |
| 33 | + @SimpleFunction(description = "Returns the url which started the current activity") |
| 34 | + public String GetStartUrl(){ |
| 35 | + return getUrl(activity.getIntent()); |
| 36 | + } |
| 37 | + |
| 38 | + @SimpleEvent(description = "Event raised when app gets resumed and gives the url which started this activity/screen if there is any else empty string") |
| 39 | + public void OnResume(String url){ |
| 40 | + EventDispatcher.dispatchEvent(this,"OnResume",url); |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public void onNewIntent(Intent intent) { |
| 45 | + OnResume(getUrl(intent)); |
| 46 | + } |
| 47 | +} |
0 commit comments