use of android.webkit.JavascriptInterface in project MaterialFBook by ZeeRooo.
the class MainActivity method LoadVideo.
@JavascriptInterface
@SuppressWarnings("unused")
public void LoadVideo(final String video_url) {
Intent Video = new Intent(this, Video.class);
Video.putExtra("video_url", video_url);
startActivity(Video);
}
use of android.webkit.JavascriptInterface in project Awful.apk by Awful.
the class AnnouncementsFragment method initialiseWebView.
private void initialiseWebView() {
webView.setJavascriptHandler(new WebViewJsInterface() {
// TODO: 27/01/2017 work out which of these we can drop, or maybe make special announcements HTML instead of reusing the thread one
@JavascriptInterface
public String getBodyHtml() {
return bodyHtml;
}
@JavascriptInterface
public String getCSS() {
return AwfulTheme.forForum(null).getCssPath();
}
@JavascriptInterface
public String getIgnorePostHtml(String id) {
return null;
}
@JavascriptInterface
public String getPostJump() {
return "";
}
@JavascriptInterface
public void loadIgnoredPost(final String ignorePost) {
}
@JavascriptInterface
public void haltSwipe() {
}
@JavascriptInterface
public void resumeSwipe() {
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (webView != null && !bodyHtml.isEmpty()) {
webView.refreshPageContents(true);
}
}
// this lets links open back in the main activity if we handle them (e.g. 'look at this thread'),
// and opens them in a browser or whatever if we don't (e.g. 'click here to buy a thing on the site')
@Override
public boolean shouldOverrideUrlLoading(WebView aView, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
}
});
webView.setContent(ThreadDisplay.getContainerHtml(getPrefs(), -1));
}
use of android.webkit.JavascriptInterface in project AgentWeb by Justson.
the class JsBaseInterfaceHolder method checkObject.
@Override
public boolean checkObject(Object v) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
return true;
}
if (mWebCreator.getWebViewType() == AgentWebConfig.WEBVIEW_AGENTWEB_SAFE_TYPE) {
return true;
}
boolean tag = false;
Class clazz = v.getClass();
Method[] mMethods = clazz.getMethods();
for (Method mMethod : mMethods) {
Annotation[] mAnnotations = mMethod.getAnnotations();
for (Annotation mAnnotation : mAnnotations) {
if (mAnnotation instanceof JavascriptInterface) {
tag = true;
break;
}
}
if (tag) {
break;
}
}
return tag;
}
use of android.webkit.JavascriptInterface in project Gadgetbridge by Freeyourgadget.
the class JSInterface method saveAppStoredPreset.
@JavascriptInterface
public void saveAppStoredPreset(String msg) {
Writer writer;
try {
File destDir = PebbleUtils.getPbwCacheDir();
File presetsFile = new File(destDir, this.mUuid.toString() + "_preset.json");
writer = new BufferedWriter(new FileWriter(presetsFile));
writer.write(msg);
writer.close();
GB.toast("Presets stored", Toast.LENGTH_SHORT, GB.INFO);
} catch (IOException e) {
GB.toast("Error storing presets", Toast.LENGTH_LONG, GB.ERROR);
LOG.warn("Error storing presets", e);
}
}
use of android.webkit.JavascriptInterface in project Gadgetbridge by Freeyourgadget.
the class JSInterface method getAppConfigurationFile.
@JavascriptInterface
public String getAppConfigurationFile() {
LOG.debug("WEBVIEW loading config file of " + this.mUuid.toString());
try {
File destDir = PebbleUtils.getPbwCacheDir();
File configurationFile = new File(destDir, this.mUuid.toString() + "_config.js");
if (configurationFile.exists()) {
return "file:///" + configurationFile.getAbsolutePath();
}
} catch (IOException e) {
LOG.warn("Error loading config file", e);
}
return null;
}
Aggregations