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()
......
......@@ -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,12 +14,15 @@ 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>() {
class ProductSupportActivity : BaseActivity<ActivityProtocolBinding>() {
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
}
......@@ -36,6 +39,7 @@ class ProductSupportActivity: BaseActivity<ActivityProtocolBinding>() {
@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() {
......@@ -46,8 +50,12 @@ class ProductSupportActivity: BaseActivity<ActivityProtocolBinding>() {
}
}
webView.webViewClient = webViewClient
webView.webChromeClient = object: WebChromeClient() {
override fun onShowFileChooser(webView: WebView?, filePathCallback: ValueCallback<Array<Uri>>?, fileChooserParams: FileChooserParams?): Boolean {
webView.webChromeClient = object : WebChromeClient() {
override fun onShowFileChooser(
webView: WebView?,
filePathCallback: ValueCallback<Array<Uri>>?,
fileChooserParams: FileChooserParams?
): Boolean {
uploadMessageAboveL = filePathCallback
openImageChooserActivity()
return true
......@@ -63,6 +71,10 @@ class ProductSupportActivity: BaseActivity<ActivityProtocolBinding>() {
webView.postUrl(url, postData.toByteArray())
}
private fun initTitle() {
initTitleBar(viewBind.include.toolbar, viewBind.include.tvTitle, resources.getString(R.string.my_staff))
}
private fun openImageChooserActivity() {
val i = Intent(Intent.ACTION_GET_CONTENT)
i.addCategory(Intent.CATEGORY_OPENABLE)
......@@ -78,7 +90,7 @@ class ProductSupportActivity: BaseActivity<ActivityProtocolBinding>() {
val dataString = intent.dataString
val clipData: ClipData? = intent.clipData
if (clipData != null) {
results = Array(clipData.itemCount){
results = Array(clipData.itemCount) {
Uri.EMPTY
}
for (i in 0 until clipData.itemCount) {
......
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>() {
private lateinit var webView: XWebView
class ProtocolActivity: BaseActivity<ActivityProtocolBinding>() {
override fun createViewBinding(): ActivityProtocolBinding {
return ActivityProtocolBinding.inflate(layoutInflater)
}
......@@ -19,21 +25,34 @@ class ProtocolActivity: BaseActivity<ActivityProtocolBinding>() {
return PROTOCOL
}
companion object{
const val ProtocolUrlKey = "protocol_url"
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)
}
}
private lateinit var webView: XWebView
private fun initTitle(protocolTitle: String?) {
initTitleBar(viewBind.include.toolbar, viewBind.include.tvTitle, protocolTitle ?: "协议")
}
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")
private fun initWebView(protocolUrl: String?) {
if (protocolUrl.isNullOrBlank()) {
ToastUtils.showShortSafe("链接地址为空")
return
}
webView = XBridManager.getWebView(this, "testidenfier", viewBind.wvProtocol)
webView.loadUrl(protocolUrl)
}
companion object {
const val ProtocolTitleKey = "protocol_title"
const val ProtocolUrlKey = "protocol_url"
}
}
......@@ -25,8 +25,11 @@ 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) {
/**
* 用户协议 & 隐私政策 弹框
*/
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
......@@ -36,7 +39,7 @@ class ProtocolDialog(private val activity: Activity, themeResId: Int, private va
setDialog()
}
private fun setDialog(){
private fun setDialog() {
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_dialog)
this.setOwnerActivity(activity)
......@@ -47,18 +50,24 @@ class ProtocolDialog(private val activity: Activity, themeResId: Int, private va
setClickListener()
}
private fun setSpannableString(){
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(){
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
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)
}
......@@ -68,15 +77,26 @@ class ProtocolDialog(private val activity: Activity, themeResId: Int, private va
}
}, 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)
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(){
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
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)
}
......@@ -86,13 +106,19 @@ class ProtocolDialog(private val activity: Activity, themeResId: Int, private va
}
}, 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)
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)
tvPrivacyPolicyTwo.text =
textSpannedBuilder.append(textSpanned1).append(textSpanned2).append(textSpanned3).append(textSpanned4).append(textSpanned5)
}
private fun setClickListener(){
tvAgree.setOnClickListener{
private fun setClickListener() {
tvAgree.setOnClickListener {
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
......@@ -101,7 +127,7 @@ class ProtocolDialog(private val activity: Activity, themeResId: Int, private va
}, 1000)
}
tvDisagree.setOnClickListener{
tvDisagree.setOnClickListener {
dismiss()
val protocolHintDialog = ProtocolHintDialog(activity, R.style.normal_dialog, paramsMap)
protocolHintDialog.show()
......
......@@ -24,8 +24,11 @@ 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) {
/**
* 用户协议 & 隐私政策的 详细内容提示弹框
*/
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
......@@ -35,7 +38,7 @@ class ProtocolHintDialog(private val activity: Activity, themeResId: Int, privat
setDialog()
}
private fun setDialog(){
private fun setDialog() {
this.setCanceledOnTouchOutside(false)
this.setContentView(R.layout.protocol_hint_dialog)
this.setOwnerActivity(activity)
......@@ -46,18 +49,24 @@ class ProtocolHintDialog(private val activity: Activity, themeResId: Int, privat
setClickListener()
}
private fun setSpannableString(){
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(){
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
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)
}
......@@ -67,13 +76,18 @@ class ProtocolHintDialog(private val activity: Activity, themeResId: Int, privat
}
}, 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)
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{
private fun setClickListener() {
tvAgree.setOnClickListener {
Hawk.put(HawkConfig.ProtocolIsAgree, true)
dismiss()
Handler().postDelayed({
......@@ -82,7 +96,7 @@ class ProtocolHintDialog(private val activity: Activity, themeResId: Int, privat
}, 1000)
}
tvDisagree.setOnClickListener{
tvDisagree.setOnClickListener {
dismiss()
Handler().postDelayed({
activity.finish()
......
......@@ -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