Commit 617a6db6 authored by shiyl's avatar shiyl

用户协议和隐私政策页面添加title

parent 126cf715
......@@ -85,8 +85,7 @@ dependencies {
api "com.yidian.xarc:xevent:0.0.3"
api "com.yidian.xpage:xpagenative:0.0.1"
//https://github.com/CymChad/BaseRecyclerViewAdapterHelper
api "com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4"
implementation('com.yidian.android:CommonComponent:0.0.88') {
exclude(group: 'com.yidian.android', module: 'NetworkImageLib')
}
......
package com.yidian.shenghuoquan.newscontent.bean
package com.yidian.common.widget.blank
interface IBlankViewLoadAgainCallback {
fun loadAgainCallback()
}
\ No newline at end of file
}
......@@ -179,16 +179,18 @@ class ManagerChangeActivity : BaseActivity<ActivityManagerChangeBinding>() {
it.setSpan(ForegroundColorSpan(Color.parseColor("#1852F1")), 28, 39, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
it.setSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.user_protocol)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
}
}, 28, 33, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
it.setSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.privacy_policy_statement)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
}
}, 33, 39, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
......
......@@ -129,15 +129,17 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>(), IGetLifeAc
}
viewBind.tvProtocol.setOnClickListener {
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.userProtocol
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.user_protocol)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.userProtocol
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
}
viewBind.tvPrivacy.setOnClickListener {
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.privacy_policy_statement)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
}
}
......
......@@ -14,92 +14,104 @@ import com.orhanobut.hawk.Hawk
import com.yidian.common.HawkConfig
import com.yidian.common.XRouterPathConstants.Companion.SUPPORT
import com.yidian.common.base.BaseActivity
import com.yidian.common.extensions.initTitleBar
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.databinding.ActivityProtocolBinding
import com.yidian.xarc.xbrid.XBridManager
import com.yidian.xarc.xbrid.XWebView
class ProductSupportActivity: BaseActivity<ActivityProtocolBinding>() {
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
}
class ProductSupportActivity : BaseActivity<ActivityProtocolBinding>() {
override fun getXPageName(): String {
return SUPPORT
}
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
}
private val FILE_CHOOSER_RESULT_CODE = 666
private var uploadMessageAboveL: ValueCallback<Array<Uri>>? = null
override fun getXPageName(): String {
return SUPPORT
}
private lateinit var webView: XWebView
private val FILE_CHOOSER_RESULT_CODE = 666
private var uploadMessageAboveL: ValueCallback<Array<Uri>>? = null
@SuppressLint("SetJavaScriptEnabled")
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
webView = XBridManager.getWebView(this, "testidenfier", viewBind.wvProtocol)
webView.settings.javaScriptEnabled = true
val webViewClient: WebViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
super.shouldOverrideUrlLoading(view, url)
view.loadUrl(url)
return true
}
}
webView.webViewClient = webViewClient
webView.webChromeClient = object: WebChromeClient() {
override fun onShowFileChooser(webView: WebView?, filePathCallback: ValueCallback<Array<Uri>>?, fileChooserParams: FileChooserParams?): Boolean {
uploadMessageAboveL = filePathCallback
openImageChooserActivity()
return true
}
}
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
val url = "https://support.qq.com/product/304954"
val nickname = Hawk.get(HawkConfig.Nickname, "")
val profileUrl = Hawk.get(HawkConfig.ProfileUrl, "")
val username = Hawk.get(HawkConfig.Username, "")
val postData = "nickname=$nickname&avatar=$profileUrl&openid=$username"
webView.postUrl(url, postData.toByteArray())
}
private lateinit var webView: XWebView
private fun openImageChooserActivity() {
val i = Intent(Intent.ACTION_GET_CONTENT)
i.addCategory(Intent.CATEGORY_OPENABLE)
i.type = "image/*"
startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILE_CHOOSER_RESULT_CODE)
@SuppressLint("SetJavaScriptEnabled")
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
initTitle()
webView = XBridManager.getWebView(this, "testidenfier", viewBind.wvProtocol)
webView.settings.javaScriptEnabled = true
val webViewClient: WebViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
super.shouldOverrideUrlLoading(view, url)
view.loadUrl(url)
return true
}
}
webView.webViewClient = webViewClient
webView.webChromeClient = object : WebChromeClient() {
override fun onShowFileChooser(
webView: WebView?,
filePathCallback: ValueCallback<Array<Uri>>?,
fileChooserParams: FileChooserParams?
): Boolean {
uploadMessageAboveL = filePathCallback
openImageChooserActivity()
return true
}
}
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
val url = "https://support.qq.com/product/304954"
val nickname = Hawk.get(HawkConfig.Nickname, "")
val profileUrl = Hawk.get(HawkConfig.ProfileUrl, "")
val username = Hawk.get(HawkConfig.Username, "")
val postData = "nickname=$nickname&avatar=$profileUrl&openid=$username"
webView.postUrl(url, postData.toByteArray())
}
private fun initTitle() {
initTitleBar(viewBind.include.toolbar, viewBind.include.tvTitle, resources.getString(R.string.my_staff))
}
private fun onActivityResultAboveL(requestCode: Int, resultCode: Int, intent: Intent?) {
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null) return
var results: Array<Uri>? = null
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
val dataString = intent.dataString
val clipData: ClipData? = intent.clipData
if (clipData != null) {
results = Array(clipData.itemCount){
Uri.EMPTY
}
for (i in 0 until clipData.itemCount) {
val item: ClipData.Item = clipData.getItemAt(i)
results[i] = item.uri
}
}
if (dataString != null) results = arrayOf(Uri.parse(dataString))
}
private fun openImageChooserActivity() {
val i = Intent(Intent.ACTION_GET_CONTENT)
i.addCategory(Intent.CATEGORY_OPENABLE)
i.type = "image/*"
startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILE_CHOOSER_RESULT_CODE)
}
private fun onActivityResultAboveL(requestCode: Int, resultCode: Int, intent: Intent?) {
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null) return
var results: Array<Uri>? = null
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
val dataString = intent.dataString
val clipData: ClipData? = intent.clipData
if (clipData != null) {
results = Array(clipData.itemCount) {
Uri.EMPTY
}
for (i in 0 until clipData.itemCount) {
val item: ClipData.Item = clipData.getItemAt(i)
results[i] = item.uri
}
}
uploadMessageAboveL?.onReceiveValue(results)
uploadMessageAboveL = null
if (dataString != null) results = arrayOf(Uri.parse(dataString))
}
}
uploadMessageAboveL?.onReceiveValue(results)
uploadMessageAboveL = null
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == FILE_CHOOSER_RESULT_CODE) {
if (uploadMessageAboveL != null) {
onActivityResultAboveL(requestCode, resultCode, data)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == FILE_CHOOSER_RESULT_CODE) {
if (uploadMessageAboveL != null) {
onActivityResultAboveL(requestCode, resultCode, data)
}
}
}
}
package com.yidian.shenghuoquan.newscontent.ui
import android.os.Bundle
import android.util.Log
import com.yidian.common.XRouterPathConstants
import com.yidian.common.XRouterPathConstants.Companion.PROTOCOL
import com.yidian.common.base.BaseActivity
import com.yidian.common.extensions.initTitleBar
import com.yidian.common.utils.ToastUtils
import com.yidian.shenghuoquan.newscontent.databinding.ActivityProtocolBinding
import com.yidian.xarc.xbrid.XBridManager
import com.yidian.xarc.xbrid.XWebView
class ProtocolActivity: BaseActivity<ActivityProtocolBinding>() {
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
/**
* 用户协议 & 隐私政策
*/
class ProtocolActivity : BaseActivity<ActivityProtocolBinding>() {
private lateinit var webView: XWebView
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
}
override fun getXPageName(): String {
return PROTOCOL
}
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
val serializableExtra = intent.getSerializableExtra(XRouterPathConstants.ParamsKey)
serializableExtra?.let {
val paramsMap = serializableExtra as HashMap<*, *>
val protocolTitle = paramsMap[ProtocolTitleKey] as String?
val protocolUrl = paramsMap[ProtocolUrlKey] as String?
initTitle(protocolTitle)
initWebView(protocolUrl)
}
}
override fun getXPageName(): String {
return PROTOCOL
}
private fun initTitle(protocolTitle: String?) {
initTitleBar(viewBind.include.toolbar, viewBind.include.tvTitle, protocolTitle ?: "协议")
}
companion object{
const val ProtocolUrlKey = "protocol_url"
private fun initWebView(protocolUrl: String?) {
if (protocolUrl.isNullOrBlank()) {
ToastUtils.showShortSafe("链接地址为空")
return
}
webView = XBridManager.getWebView(this, "testidenfier", viewBind.wvProtocol)
webView.loadUrl(protocolUrl)
}
private lateinit var webView: XWebView
companion object {
const val ProtocolTitleKey = "protocol_title"
const val ProtocolUrlKey = "protocol_url"
}
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
if(intent.getSerializableExtra(XRouterPathConstants.ParamsKey) !=null){
val paramsMap = intent.getSerializableExtra(XRouterPathConstants.ParamsKey) as HashMap<*, *>
val protocolUrl = paramsMap[ProtocolUrlKey] as String
Log.e("zhb-yd", "protocolUrl:$protocolUrl")
webView = XBridManager.getWebView(this, "testidenfier", viewBind.wvProtocol)
webView.loadUrl(protocolUrl)
}
}
}
\ No newline at end of file
}
......@@ -25,95 +25,121 @@ import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.ui.ProtocolActivity
import com.yidian.xpage.XPageManager
/**
* 用户协议 & 隐私政策 弹框
*/
class ProtocolDialog(private val activity: Activity, themeResId: Int, private val paramsMap: HashMap<String, Any?>?) :
Dialog(activity, themeResId) {
private lateinit var tvPrivacyPolicyTwo: YdTextView
private lateinit var tvAgree: YdTextView
private lateinit var tvDisagree: YdTextView
private var lastClickTime = 0L
class ProtocolDialog(private val activity: Activity, themeResId: Int, private val paramsMap: HashMap<String, Any?>?): Dialog(activity, themeResId) {
private lateinit var tvPrivacyPolicyTwo: YdTextView
private lateinit var tvAgree: YdTextView
private lateinit var tvDisagree: YdTextView
private var lastClickTime = 0L
init {
setDialog()
}
init {
setDialog()
}
private fun setDialog() {
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_dialog)
this.setOwnerActivity(activity)
tvPrivacyPolicyTwo = findViewById(R.id.tv_privacyPolicyTwo)
tvAgree = findViewById(R.id.tv_agree)
tvDisagree = findViewById(R.id.tv_disagree)
setSpannableString()
setClickListener()
}
private fun setDialog(){
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_dialog)
this.setOwnerActivity(activity)
tvPrivacyPolicyTwo = findViewById(R.id.tv_privacyPolicyTwo)
tvAgree = findViewById(R.id.tv_agree)
tvDisagree = findViewById(R.id.tv_disagree)
setSpannableString()
setClickListener()
}
private fun setSpannableString() {
tvPrivacyPolicyTwo.highlightColor = Color.TRANSPARENT
val textSpannedBuilder = SpannableStringBuilder()
val textSpanned1 = SpannableString(activity.getString(R.string.privacy_policy_two_first))
val textSpanned2 = SpannableString(activity.getString(R.string.privacy_policy_statement))
textSpanned2.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)),
0,
textSpanned2.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
textSpanned2.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if (currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolTitleKey] = activity.getString(R.string.privacy_policy_statement)
urlMap[ProtocolActivity.ProtocolUrlKey] = privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
private fun setSpannableString(){
tvPrivacyPolicyTwo.highlightColor = Color.TRANSPARENT
val textSpannedBuilder = SpannableStringBuilder()
val textSpanned1 = SpannableString(activity.getString(R.string.privacy_policy_two_first))
val textSpanned2 = SpannableString(activity.getString(R.string.privacy_policy_statement))
textSpanned2.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)), 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
textSpanned2.setSpan(object: ClickableSpan(){
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if(currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned3 = SpannableString(activity.getString(R.string.and))
textSpanned3.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)),
0,
textSpanned3.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
val textSpanned4 = SpannableString(activity.getString(R.string.user_protocol))
textSpanned4.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)),
0,
textSpanned4.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
textSpanned4.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if (currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolTitleKey] = activity.getString(R.string.user_protocol)
urlMap[ProtocolActivity.ProtocolUrlKey] = userProtocol
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned3 = SpannableString(activity.getString(R.string.and))
textSpanned3.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)), 0, textSpanned3.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned4 = SpannableString(activity.getString(R.string.user_protocol))
textSpanned4.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)), 0, textSpanned4.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
textSpanned4.setSpan(object: ClickableSpan(){
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if(currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = userProtocol
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned4.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned5 = SpannableString(activity.getString(R.string.privacy_policy_two_second))
textSpanned5.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)),
0,
textSpanned5.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
tvPrivacyPolicyTwo.movementMethod = LinkMovementMethod.getInstance()
tvPrivacyPolicyTwo.text =
textSpannedBuilder.append(textSpanned1).append(textSpanned2).append(textSpanned3).append(textSpanned4).append(textSpanned5)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned4.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned5 = SpannableString(activity.getString(R.string.privacy_policy_two_second))
textSpanned5.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)), 0, textSpanned5.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
tvPrivacyPolicyTwo.movementMethod = LinkMovementMethod.getInstance()
tvPrivacyPolicyTwo.text = textSpannedBuilder.append(textSpanned1).append(textSpanned2).append(textSpanned3).append(textSpanned4).append(textSpanned5)
private fun setClickListener() {
tvAgree.setOnClickListener {
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
XPageManager.push(XRouterPathConstants.NEWS_MAIN, paramsMap)
activity.finish()
}, 1000)
}
private fun setClickListener(){
tvAgree.setOnClickListener{
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
XPageManager.push(XRouterPathConstants.NEWS_MAIN, paramsMap)
activity.finish()
}, 1000)
}
tvDisagree.setOnClickListener{
dismiss()
val protocolHintDialog = ProtocolHintDialog(activity, R.style.normal_dialog, paramsMap)
protocolHintDialog.show()
}
tvDisagree.setOnClickListener {
dismiss()
val protocolHintDialog = ProtocolHintDialog(activity, R.style.normal_dialog, paramsMap)
protocolHintDialog.show()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val params: WindowManager.LayoutParams? = window?.attributes
params?.width = WindowManager.LayoutParams.MATCH_PARENT
params?.height = WindowManager.LayoutParams.WRAP_CONTENT
window?.attributes = params
window?.attributes?.gravity = Gravity.BOTTOM
}
}
\ No newline at end of file
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val params: WindowManager.LayoutParams? = window?.attributes
params?.width = WindowManager.LayoutParams.MATCH_PARENT
params?.height = WindowManager.LayoutParams.WRAP_CONTENT
window?.attributes = params
window?.attributes?.gravity = Gravity.BOTTOM
}
}
......@@ -24,78 +24,92 @@ import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.ui.ProtocolActivity
import com.yidian.xpage.XPageManager
/**
* 用户协议 & 隐私政策的 详细内容提示弹框
*/
class ProtocolHintDialog(private val activity: Activity, themeResId: Int, private val paramsMap: HashMap<String, Any?>?) :
Dialog(activity, themeResId) {
private lateinit var tvContent: YdTextView
private lateinit var tvAgree: YdTextView
private lateinit var tvDisagree: YdTextView
private var lastClickTime = 0L
class ProtocolHintDialog(private val activity: Activity, themeResId: Int, private val paramsMap: HashMap<String, Any?>?): Dialog(activity, themeResId) {
private lateinit var tvContent: YdTextView
private lateinit var tvAgree: YdTextView
private lateinit var tvDisagree: YdTextView
private var lastClickTime = 0L
init {
setDialog()
}
init {
setDialog()
}
private fun setDialog() {
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_hint_dialog)
this.setOwnerActivity(activity)
tvContent = findViewById(R.id.tv_content)
tvAgree = findViewById(R.id.tv_agree)
tvDisagree = findViewById(R.id.tv_disagree)
setSpannableString()
setClickListener()
}
private fun setDialog(){
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_hint_dialog)
this.setOwnerActivity(activity)
tvContent = findViewById(R.id.tv_content)
tvAgree = findViewById(R.id.tv_agree)
tvDisagree = findViewById(R.id.tv_disagree)
setSpannableString()
setClickListener()
}
private fun setSpannableString() {
tvContent.highlightColor = Color.TRANSPARENT
val textSpannedBuilder = SpannableStringBuilder()
val textSpanned1 = SpannableString(activity.getString(R.string.protocol_hint_content_one))
val textSpanned2 = SpannableString(activity.getString(R.string.privacy_policy))
textSpanned2.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)),
0,
textSpanned2.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
textSpanned2.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if (currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolTitleKey] = activity.resources.getString(R.string.privacy_policy_statement)
urlMap[ProtocolActivity.ProtocolUrlKey] = privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
private fun setSpannableString(){
tvContent.highlightColor = Color.TRANSPARENT
val textSpannedBuilder = SpannableStringBuilder()
val textSpanned1 = SpannableString(activity.getString(R.string.protocol_hint_content_one))
val textSpanned2 = SpannableString(activity.getString(R.string.privacy_policy))
textSpanned2.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.lightBlueColor)), 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
textSpanned2.setSpan(object: ClickableSpan(){
override fun onClick(view: View) {
val currentClickTime = System.currentTimeMillis()
if(currentClickTime - lastClickTime < 1000) return
lastClickTime = currentClickTime
val urlMap = HashMap<String, String>()
urlMap[ProtocolActivity.ProtocolUrlKey] = privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, urlMap)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned3 = SpannableString(activity.getString(R.string.protocol_hint_content_two))
textSpanned3.setSpan(
ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)),
0,
textSpanned3.length,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
tvContent.movementMethod = LinkMovementMethod.getInstance()
tvContent.text = textSpannedBuilder.append(textSpanned1).append(textSpanned2).append(textSpanned3)
}
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = false
}
}, 0, textSpanned2.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
val textSpanned3 = SpannableString(activity.getString(R.string.protocol_hint_content_two))
textSpanned3.setSpan(ForegroundColorSpan(activity.resources.getColor(R.color.mainBlackColor)), 0, textSpanned3.length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE)
tvContent.movementMethod = LinkMovementMethod.getInstance()
tvContent.text = textSpannedBuilder.append(textSpanned1).append(textSpanned2).append(textSpanned3)
private fun setClickListener() {
tvAgree.setOnClickListener {
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
XPageManager.push(XRouterPathConstants.NEWS_MAIN, paramsMap)
activity.finish()
}, 1000)
}
private fun setClickListener(){
tvAgree.setOnClickListener{
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
XPageManager.push(XRouterPathConstants.NEWS_MAIN, paramsMap)
activity.finish()
}, 1000)
}
tvDisagree.setOnClickListener{
dismiss()
Handler().postDelayed({
activity.finish()
}, 200)
}
tvDisagree.setOnClickListener {
dismiss()
Handler().postDelayed({
activity.finish()
}, 200)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val params: WindowManager.LayoutParams? = window?.attributes
params?.width = WindowManager.LayoutParams.MATCH_PARENT
params?.height = WindowManager.LayoutParams.WRAP_CONTENT
window?.attributes = params
window?.attributes?.gravity = Gravity.BOTTOM
}
}
\ No newline at end of file
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val params: WindowManager.LayoutParams? = window?.attributes
params?.width = WindowManager.LayoutParams.MATCH_PARENT
params?.height = WindowManager.LayoutParams.WRAP_CONTENT
window?.attributes = params
window?.attributes?.gravity = Gravity.BOTTOM
}
}
......@@ -44,10 +44,16 @@ class PrivacyAgreementView @JvmOverloads constructor(
val id = v?.id
if (id == R.id.tv_privacy_policy) {
// 隐私政策
XPageManager.push(XRouterPathConstants.PROTOCOL, hashMapOf(Pair(ProtocolActivity.ProtocolUrlKey, AppConfig.privacyPolicyStatement)))
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.privacy_policy_statement)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.privacyPolicyStatement
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
} else if (id == R.id.tv_user_agreement) {
// 用户协议
XPageManager.push(XRouterPathConstants.PROTOCOL, hashMapOf(Pair(ProtocolActivity.ProtocolUrlKey, AppConfig.userProtocol)))
val map = HashMap<String, String>()
map[ProtocolActivity.ProtocolTitleKey] = resources.getString(R.string.user_protocol)
map[ProtocolActivity.ProtocolUrlKey] = AppConfig.userProtocol
XPageManager.push(XRouterPathConstants.PROTOCOL, map)
}
}
......
......@@ -53,7 +53,7 @@
</com.yidian.nightmode.widget.YdRelativeLayout>
<com.yidian.shenghuoquan.newscontent.widget.BlankPageView
<com.yidian.common.widget.blank.BlankPageView
android:id="@+id/fly_blank"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/lly_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.yidian.subway.newscontent.ui.NewsContentActivity">
android:orientation="vertical">
<FrameLayout
android:id="@+id/fly_webContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.yidian.nightmode.widget.YdFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/mainBgColor"
android:fitsSystemWindows="true"
tools:ignore="MissingDefaultResource">
android:orientation="vertical">
<com.yidian.shenghuoquan.newscontent.ui.webview.YiDianWebView
<include
android:id="@+id/include"
layout="@layout/layout_common_toolbar" />
<com.yidian.common.webview.YiDianWebView
android:id="@+id/wv_protocol"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"/>
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="none" />
</com.yidian.nightmode.widget.YdFrameLayout>
</LinearLayout>
......
......@@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:background="@color/mainBgColor">
<com.yidian.shenghuoquan.newscontent.widget.BlankPageView
<com.yidian.common.widget.blank.BlankPageView
android:id="@+id/fly_blank"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@color/mainBgColor">
<com.yidian.shenghuoquan.newscontent.widget.BlankPageView
<com.yidian.common.widget.blank.BlankPageView
android:id="@+id/fly_blank"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:background="@color/white">
<com.yidian.shenghuoquan.newscontent.widget.BlankPageView
<com.yidian.common.widget.blank.BlankPageView
android:id="@+id/fly_blank"
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -9,7 +9,7 @@
android:orientation="vertical">
<com.yidian.shenghuoquan.newscontent.widget.BlankPageView
<com.yidian.common.widget.blank.BlankPageView
android:id="@+id/fly_blank"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<com.yidian.shenghuoquan.newscontent.ui.webview.YiDianWebView
<com.yidian.common.webview.YiDianWebView
android:id="@+id/comment_web"
android:layout_width="match_parent"
android:layout_height="0dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment