| | |
| | | import android.view.View |
| | | import android.view.ViewGroup |
| | | import android.webkit.WebChromeClient |
| | | import android.webkit.WebSettings |
| | | import android.webkit.WebView |
| | | import androidx.fragment.app.DialogFragment |
| | | import cn.sinata.xldutils.utils.SPUtils |
| | | import cn.sinata.xldutils.utils.screenWidth |
| | | import com.fuban.user.R |
| | | import com.fuban.user.utils.Const |
| | | import com.fuban.user.utils.InnerJsInterface |
| | | import kotlinx.android.synthetic.main.dialog_user_rule.* |
| | | import org.jetbrains.anko.wrapContent |
| | | |
| | |
| | | super.onViewCreated(view, savedInstanceState) |
| | | val settings = sc_content.settings |
| | | settings.javaScriptEnabled = true |
| | | settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK |
| | | settings.javaScriptCanOpenWindowsAutomatically = true |
| | | settings.builtInZoomControls = true |
| | | settings.useWideViewPort = false //将图片调整到适合webview的大小 |
| | | settings.setSupportZoom(false) //支持缩放 |
| | | settings.supportMultipleWindows() //多窗口 |
| | | settings.loadWithOverviewMode = true // 页面支持缩放: |
| | | settings.useWideViewPort = true //设置此属性,可任意比例缩放 |
| | | settings.defaultTextEncodingName = "utf-8" |
| | | settings.domStorageEnabled = true |
| | | settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK //关闭webview中缓存 |
| | | settings.allowFileAccess = true //设置可以访问文件 |
| | | settings.setNeedInitialFocus(true) //当webview调用requestFocus时为webview设置节点 |
| | | settings.javaScriptCanOpenWindowsAutomatically = true //支持通过JS打开新窗口 |
| | | settings.loadsImagesAutomatically = true //支持自动加载图片 |
| | | sc_content.isScrollContainer = false |
| | | sc_content.isScrollbarFadingEnabled = false |
| | | sc_content.scrollBarStyle = View.SCROLLBARS_OUTSIDE_OVERLAY |
| | | sc_content.webChromeClient = object : WebChromeClient() {} |
| | | sc_content.loadData(privacy,"text/html; charset=utf-8", "utf-8") |
| | | val sHead = |
| | | "<html><head><meta name=\"viewport\" content=\"width=device-width, " + "initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" />" + "<style>img{max-width:100% !important;height:auto !important;}</style>" + "<style>body{max-width:100% !important;}</style>" + "</head><body>" |
| | | sc_content.loadDataWithBaseURL(null, sHead + privacy, "text/html", "utf-8", null) |
| | | tv_cancel.setOnClickListener { |
| | | dismiss() |
| | | } |
| | | |
| | | rg_title.setOnCheckedChangeListener { _, i -> |
| | | if (i == R.id.rb_privacy) |
| | | sc_content.loadData(privacy,"text/html; charset=utf-8", "utf-8") |
| | | sc_content.loadDataWithBaseURL(null, sHead + privacy, "text/html", "utf-8", null) |
| | | else |
| | | sc_content.loadData(user,"text/html; charset=utf-8", "utf-8") |
| | | sc_content.loadDataWithBaseURL(null, sHead + user, "text/html", "utf-8", null) |
| | | } |
| | | tv_ok.setOnClickListener { |
| | | SPUtils.instance().put(Const.User.IS_AGREE,true).apply() |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | interface OnDismiss{ |
| | | fun onDismiss() |
| | | } |