2022-10-02 23:06:56 +02:00
|
|
|
package android.webkit;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2024-10-03 22:42:12 +02:00
|
|
|
import android.content.res.AssetManager;
|
2024-08-05 17:17:53 +02:00
|
|
|
import android.util.AttributeSet;
|
2023-06-18 11:03:43 +02:00
|
|
|
import android.view.View;
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2023-06-18 11:03:43 +02:00
|
|
|
public class WebView extends View {
|
2023-06-22 11:45:46 +02:00
|
|
|
public WebView(Context context) {
|
2024-09-13 20:29:56 +02:00
|
|
|
this(context, null);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-05 17:17:53 +02:00
|
|
|
public WebView(Context context, AttributeSet attrs) {
|
2024-09-13 20:29:56 +02:00
|
|
|
this(context, attrs, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WebView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
|
super(context, attrs, defStyleAttr);
|
2024-08-05 17:17:53 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
public WebSettings getSettings() {
|
|
|
|
|
return new WebSettings();
|
|
|
|
|
}
|
2023-06-18 11:03:43 +02:00
|
|
|
|
2024-04-26 14:49:37 +02:00
|
|
|
public void setDownloadListener(DownloadListener downloadListener) {}
|
2023-06-18 11:03:43 +02:00
|
|
|
|
2024-04-26 14:49:37 +02:00
|
|
|
public void setScrollBarStyle(int scrollBarStyle) {}
|
2023-06-18 11:03:43 +02:00
|
|
|
|
2024-04-26 14:49:37 +02:00
|
|
|
public void setWebViewClient(WebViewClient webViewClient) {}
|
|
|
|
|
|
|
|
|
|
public void setVerticalScrollBarEnabled(boolean enabled) {}
|
|
|
|
|
|
2024-10-03 22:38:34 +02:00
|
|
|
public void addJavascriptInterface(Object object, String name) {
|
|
|
|
|
// HACK: directly call onRenderingDone for OctoDroid, as the javascript interface is not implemented yet
|
|
|
|
|
if (object.getClass().getName().startsWith("com.gh4a") && "NativeClient".equals(name)) {
|
|
|
|
|
try {
|
|
|
|
|
object.getClass().getMethod("onRenderingDone").invoke(object);
|
|
|
|
|
} catch (ReflectiveOperationException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-26 14:49:37 +02:00
|
|
|
|
|
|
|
|
public void setWebChromeClient(WebChromeClient dummy) {}
|
|
|
|
|
|
|
|
|
|
public void removeAllViews() {}
|
|
|
|
|
|
|
|
|
|
public void destroy() {}
|
|
|
|
|
|
2024-09-13 20:29:56 +02:00
|
|
|
public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
|
2024-10-03 22:42:12 +02:00
|
|
|
// webkit doesn't allow overwriting the file:// uri scheme. So we replace it with the android-asset:// scheme
|
|
|
|
|
data = data.replace("file:///android_asset/", "android-asset:///assets/");
|
2024-09-13 20:29:56 +02:00
|
|
|
native_loadDataWithBaseURL(widget, baseUrl, data, mimeType, encoding);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void loadUrl(String url) {
|
2024-10-03 22:38:34 +02:00
|
|
|
if (url.startsWith("javascript:")) {
|
|
|
|
|
System.out.println("loadUrl: " + url + " - not implemented yet");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-09-13 20:29:56 +02:00
|
|
|
native_loadUrl(widget, url);
|
|
|
|
|
}
|
2024-04-26 14:49:37 +02:00
|
|
|
|
|
|
|
|
public void stopLoading() {}
|
2024-08-05 17:17:53 +02:00
|
|
|
|
2024-10-03 22:42:12 +02:00
|
|
|
// to be used by native code
|
|
|
|
|
AssetManager internalGetAssetManager() {
|
|
|
|
|
return getContext().getResources().getAssets();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 20:29:56 +02:00
|
|
|
@Override
|
|
|
|
|
protected native long native_constructor(Context context, AttributeSet attrs);
|
|
|
|
|
private native void native_loadDataWithBaseURL(long widget, String baseUrl, String data, String mimeType, String encoding);
|
|
|
|
|
private native void native_loadUrl(long widget, String url);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|