-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomWebView.java
More file actions
61 lines (48 loc) · 1.92 KB
/
CustomWebView.java
File metadata and controls
61 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package dolostar.dolostar;
import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
/**
* Created by Admin on 07-03-2017.
*/
public class CustomWebView extends WebView {
public CustomWebView(Context context) {
super(context);
initView();
}
public CustomWebView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
super(context, attrs, defStyleAttr, privateBrowsing);
initView();
}
private void initView() {
getSettings().setJavaScriptEnabled(true);
// setBackgroundColor(Color.parseColor("#808080"));
getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
//Set whether the DOM storage API is enabled.
getSettings().setDomStorageEnabled(true);
setWebViewClient(new WebViewClient());
WebSettings webSettings = getSettings();
webSettings.setDomStorageEnabled(true);
getSettings().setJavaScriptEnabled(true);
getSettings().setDomStorageEnabled(true);
//setBuiltInZoomControls = false, removes +/- controls on screen
getSettings().setBuiltInZoomControls(false);
getSettings().setPluginState(WebSettings.PluginState.ON);
getSettings().setAllowFileAccess(true);
getSettings().setAppCacheMaxSize(1024 * 8);
getSettings().setAppCacheEnabled(true);
getSettings().setUseWideViewPort(false);
setWebChromeClient(new WebChromeClient());
}
}