|
|
@@ -1,11 +1,17 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.screen.couponmall;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.net.http.SslError;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.webkit.JavascriptInterface;
|
|
|
+import android.webkit.SslErrorHandler;
|
|
|
+import android.webkit.WebSettings;
|
|
|
import android.webkit.WebView;
|
|
|
import android.webkit.WebViewClient;
|
|
|
|
|
|
@@ -33,6 +39,7 @@ public class CouponMallFragment extends FragmentBase<CouponMallPresenter> implem
|
|
|
return inflater.inflate(R.layout.fragment_coupon_mall, container, false);
|
|
|
}
|
|
|
|
|
|
+ @SuppressLint("JavascriptInterface")
|
|
|
@Override
|
|
|
protected void onAfterActivityCreated(Bundle savedInstanceState) {
|
|
|
webView = findViewById(R.id.web_view);
|
|
|
@@ -42,11 +49,51 @@ public class CouponMallFragment extends FragmentBase<CouponMallPresenter> implem
|
|
|
view.loadUrl(url);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
|
|
+ Log.w("APP# CouponMallFragment | onReceivedSslError", "|" + "message: " + error.toString());
|
|
|
+ handler.proceed();
|
|
|
+ }
|
|
|
});
|
|
|
- webView.getSettings().setJavaScriptEnabled(true);
|
|
|
+
|
|
|
+ init(webView);
|
|
|
+
|
|
|
+ webView.addJavascriptInterface(this, "Android");
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @JavascriptInterface
|
|
|
+ public void requestAuth() {
|
|
|
+ // 인증 요청
|
|
|
+ presenter.onRequestAuth();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void init(WebView webView) {
|
|
|
+ WebSettings settings = webView.getSettings();
|
|
|
+ // Javascript 사용하기
|
|
|
+ settings.setJavaScriptEnabled(true);
|
|
|
+ // WebView 내장 줌 사용여부
|
|
|
+ settings.setBuiltInZoomControls(true);
|
|
|
+ // 화면에 맞게 WebView 사이즈를 정의
|
|
|
+ settings.setLoadWithOverviewMode(true);
|
|
|
+ // ViewPort meta tag를 활성화 여부
|
|
|
+ settings.setUseWideViewPort(true);
|
|
|
+ // 줌 컨트롤 사용 여부
|
|
|
+ settings.setDisplayZoomControls(false);
|
|
|
+ // 사용자 제스처를 통한 줌 기능 활성화 여부
|
|
|
+ settings.setSupportZoom(false);
|
|
|
+ // TextEncoding 이름 정의
|
|
|
+ settings.setDefaultTextEncodingName("UTF-8");
|
|
|
+
|
|
|
+ // Setting Local Storage
|
|
|
+ settings.setDatabaseEnabled(true);
|
|
|
+ settings.setDomStorageEnabled(true);
|
|
|
+
|
|
|
+ // 캐쉬 사용 방법을 정의
|
|
|
+ settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void defineActionBar(ActionBarHelper actionBarHelper) {
|
|
|
actionBarHelper.begin().title(R.string.coupon_mall)
|
|
|
@@ -82,4 +129,45 @@ public class CouponMallFragment extends FragmentBase<CouponMallPresenter> implem
|
|
|
webView.loadUrl(url);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void performAuthConfirmed(boolean isConfirmed) {
|
|
|
+ String value = isConfirmed ? "true" : "false";
|
|
|
+ webView.loadUrl("javascript:onAuthConfirmed('" + value + "')");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loadDate() {
|
|
|
+ if (null != webView && StringUtil.isFull(htmlData)) {
|
|
|
+ webView.loadData(htmlData, "text/html", "UTF-8");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected String htmlData = "<html>\n" +
|
|
|
+ "<head>\n" +
|
|
|
+ "\t<script language=\"JavaScript\">\n" +
|
|
|
+ "\tfunction onAuthConfirmed(arg) {\n" +
|
|
|
+ " \t\tdocument.getElementById('textMessageFromApp').innerHTML = arg;\n" +
|
|
|
+ "\t}\n" +
|
|
|
+ "\tfunction requestAuth(){\n" +
|
|
|
+ "\t\twindow.Android.requestAuth();\n" +
|
|
|
+ "\t}\n" +
|
|
|
+ "\t</script>\n" +
|
|
|
+ "\t<style>\n" +
|
|
|
+ "\t\t\n" +
|
|
|
+ "\t</style>\n" +
|
|
|
+ "</head>\n" +
|
|
|
+ "<body>\n" +
|
|
|
+ "\t<hr/>\n" +
|
|
|
+ "\t\t<h2>Coop Interface test</h2>\n" +
|
|
|
+ "\t<hr/>\n" +
|
|
|
+ "\t<br/>\n" +
|
|
|
+ "\t\t인증 결과 :\n" +
|
|
|
+ "\t\t<p id=\"textMessageFromApp\" style=\"height:200px; overflow-y:auto;\"> \n" +
|
|
|
+ "\t</p>\n" +
|
|
|
+ "\t<hr/>\n" +
|
|
|
+ "\t인증 요청 :\n" +
|
|
|
+ "\t<input type=\"button\" value=\"Request Auth\" onclick=\"requestAuth()\" style=\"left:50%;\"/>\n" +
|
|
|
+ "</body>\n" +
|
|
|
+ "</html>";
|
|
|
}
|