package circlebinder.common.circle;

import android.os.Build;
import android.webkit.WebView;

import circlebinder.common.event.Circle;
import circlebinder.common.event.CircleLink;

public final class CircleWebContainer {

    private final WebView webView;

    public CircleWebContainer(WebView webView) {
        this.webView = webView;

        webView.setWebViewClient(new CircleWebClient(webView));
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setBuiltInZoomControls(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            webView.getSettings().setJavaScriptEnabled(true);
        } else {
            webView.getSettings().setJavaScriptEnabled(false);
        }
        webView.setOnKeyListener(new CircleWebOnKeyListener(webView));
    }

    public void loadUrl(CircleLink link) {
        loadUrl(link.getUri().toString());
    }

    public void loadUrl(String url) {
        webView.loadUrl(url);
    }

    public void load(Circle circle) {
        webView.loadUrl(
                "https://google.co.jp/search?q="
                        + "\"" + circle.getName() + "\""
                        + "%20"
                        + "\"" + circle.getPenName() + "\""
        );
    }

    public String getCurrentUrl() {
        return webView.getUrl();
    }

    public void onDestroy() {
        webView.getSettings().setBuiltInZoomControls(false);
    }
}

@@ -1485,20 +1485,176 @@
 ols(false);%0A
+        //%E3%81%BB%E3%82%93%E3%81%A8%E3%81%AF%E6%9C%80%E5%A4%A7%E3%82%B5%E3%82%A4%E3%82%BA%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%97%E3%81%A6%E5%88%B6%E5%BE%A1%E3%81%97%E3%81%9F%E3%81%84%E3%81%8C%E3%80%81%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%81%AE%E6%9C%80%E5%A4%A7%E3%82%B5%E3%82%A4%E3%82%BA%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8BAPI%E3%81%8C%E8%A6%8B%E3%81%A4%E3%81%8B%E3%82%89%E3%81%AA%E3%81%84%0A        //%E4%BD%95%E3%82%82%E3%81%97%E3%81%AA%E3%81%84%E3%81%A7%E3%83%87%E3%82%A3%E3%82%B9%E3%82%AF%E5%AE%B9%E9%87%8F%E3%81%8C%E8%86%A8%E3%82%8C%E4%B8%8A%E3%81%8C%E3%82%8B%E3%82%88%E3%82%8A%E3%81%AF%E3%80%81%E3%81%9F%E3%81%A8%E3%81%88%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%81%AE%E6%81%A9%E6%81%B5%E3%81%8C%E5%8F%97%E3%81%91%E3%82%89%E3%82%8C%E3%81%AA%E3%81%8F%E3%81%A6%E3%82%82%E6%8E%A7%E3%81%88%E3%82%81%E3%81%AA%E3%82%A2%E3%83%97%E3%83%AA%E3%81%A7%E3%81%84%E3%81%9F%E3%81%84%0A        webView.clearCache(true);%0A
     %7D%0A%7D%0A

remove WebView cache because don't know set limit size