首次进入app弹窗提示
This commit is contained in:
parent
8186bc25db
commit
a9123c33ed
@ -14,6 +14,7 @@ object AppConfig {
|
||||
const val ORDER_ID = "DA_HE_ORDER_ID"
|
||||
const val CAR_ID = "DA_HE_CAR_ID"
|
||||
const val IS_SHOW = "DA_HE_IS_SHOW"
|
||||
const val IS_FIRST_OPEN = "DA_HE_IS_FIRST_OPEN"
|
||||
const val WAYBILL_ID = "DA_HE_WAYBILL_ID"
|
||||
const val CHILDRE_ID = "DA_HE_CHILDRE_ID"
|
||||
const val CODE = "DA_HE_PHONE"
|
||||
|
97
app/src/main/java/com/dahe/gldriver/mypop/AgreementAlert.kt
Normal file
97
app/src/main/java/com/dahe/gldriver/mypop/AgreementAlert.kt
Normal file
@ -0,0 +1,97 @@
|
||||
package com.dahe.gldriver.mypop
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextPaint
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import com.dahe.gldriver.R
|
||||
import com.dahe.gldriver.base.WebActivity
|
||||
import com.dahe.gldriver.callback.OnResultListener
|
||||
import com.lxj.xpopup.core.CenterPopupView
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
* @version 1.0.0
|
||||
* @date 2021/10/13 10:30
|
||||
* @description:
|
||||
*/
|
||||
class AgreementAlert(
|
||||
private val con: Context,
|
||||
private val url: String,
|
||||
private val url2: String,
|
||||
private val listener: OnResultListener
|
||||
) : CenterPopupView(
|
||||
con
|
||||
) {
|
||||
override fun getImplLayoutId(): Int {
|
||||
return R.layout.alert_ok_cancel
|
||||
}
|
||||
|
||||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
val tv_title = findViewById<TextView>(R.id.tv_title)
|
||||
val tv_content = findViewById<TextView>(R.id.tv_content)
|
||||
val tv_cancel = findViewById<Button>(R.id.tv_cancel)
|
||||
val tv_confirm = findViewById<Button>(R.id.tv_confirm)
|
||||
tv_content.gravity = Gravity.LEFT
|
||||
tv_confirm.text = "同意"
|
||||
tv_title.text = "用户服务协议和隐私政策"
|
||||
val str = """
|
||||
请你务必审慎阅读、充分理解此内容中的“用户服务协议和隐私政策”各条款、包括但不限于:为了向你提供身份认证、接单、运单查询、消息推送等服务我们需要收集你的设备信息、操作日志等个人信息。
|
||||
你可阅读《用户服务协议》和《隐私政策》了解详细信息。如果你同意,请点击“同意”开始接受我们的服务。
|
||||
""".trimIndent()
|
||||
val ssb = SpannableStringBuilder()
|
||||
ssb.append(str)
|
||||
//第一个出现的位置
|
||||
val start = str.indexOf("《")
|
||||
ssb.setSpan(object : ClickableSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
//用户服务协议点击事件
|
||||
val `in` = Intent(context, WebActivity::class.java)
|
||||
`in`.putExtra("url", url2)
|
||||
`in`.putExtra("title", "用户服务协议")
|
||||
context.startActivity(`in`)
|
||||
}
|
||||
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
//设置文件颜色
|
||||
ds.color = resources.getColor(R.color.theme_color, null)
|
||||
// 去掉下划线
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
}, start, start + 8, 0)
|
||||
val end = str.lastIndexOf("《")
|
||||
ssb.setSpan(object : ClickableSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
//用户服务协议点击事件
|
||||
val `in` = Intent(context, WebActivity::class.java)
|
||||
`in`.putExtra("url", url)
|
||||
`in`.putExtra("title", "隐私政策")
|
||||
context.startActivity(`in`)
|
||||
}
|
||||
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
//设置文件颜色
|
||||
ds.color = resources.getColor(R.color.theme_color, null)
|
||||
// 去掉下划线
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
}, end, end + 6, 0)
|
||||
tv_content.movementMethod = LinkMovementMethod.getInstance()
|
||||
tv_content.setText(ssb, TextView.BufferType.SPANNABLE)
|
||||
tv_cancel.setOnClickListener { v: View? -> System.exit(1) }
|
||||
tv_confirm.setOnClickListener { v: View? ->
|
||||
listener.onResult(true)
|
||||
dismiss() }
|
||||
}
|
||||
}
|
@ -60,8 +60,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(), OnTabSelectListener,
|
||||
}, MessageFragment(), WaybillFragment(), MineFragment())
|
||||
|
||||
override fun initView(savedInstanceState: Bundle?) {
|
||||
updatePrivacyShow(mContext,true,true)
|
||||
updatePrivacyAgree(mContext,true)
|
||||
|
||||
|
||||
|
||||
binding.homeTabLayout.run {
|
||||
|
@ -2,12 +2,16 @@ package com.dahe.gldriver.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.amap.api.location.AMapLocationClient
|
||||
import com.dahe.gldriver.base.AppConfig
|
||||
import com.dahe.gldriver.databinding.ActivityLauncherBinding
|
||||
import com.dahe.mylibrary.base.BaseActivity
|
||||
import com.dahe.mylibrary.utils.ActivityUtils
|
||||
import com.dahe.gldriver.ui.account.LoginActivity
|
||||
import com.dahe.gldriver.ui.account.SelectRoleActivity
|
||||
import com.dahe.gldriver.utils.CommonPopUtils
|
||||
import com.dahe.gldriver.utils.SPUtils
|
||||
import com.dahe.mylibrary.utils.BaseSPUtils
|
||||
import com.dahe.mylibrary.utils.StringUtils
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
@ -34,6 +38,31 @@ class LauncherActivity : BaseActivity<ActivityLauncherBinding>() {
|
||||
// ActivityUtils.startActivity(this@LauncherActivity, LoginActivity::class.java)
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var mDisposable: Disposable? = null
|
||||
|
||||
override fun initDate() {
|
||||
val isFirstOpenApp = SPUtils.instance.getIsFirstOpenApp(mContext)
|
||||
if (isFirstOpenApp) {
|
||||
CommonPopUtils.getInstance().showCenterAgreement(mContext) {
|
||||
SPUtils.instance.setIsFirstOpenApp(mContext, false)
|
||||
AMapLocationClient.updatePrivacyShow(mContext, true, true)
|
||||
AMapLocationClient.updatePrivacyAgree(mContext, true)
|
||||
goNext()
|
||||
}
|
||||
} else {
|
||||
goNext()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mDisposable?.dispose()
|
||||
}
|
||||
|
||||
private fun goNext() {
|
||||
val count = 3
|
||||
mDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -56,32 +85,10 @@ class LauncherActivity : BaseActivity<ActivityLauncherBinding>() {
|
||||
this@LauncherActivity,
|
||||
LoginActivity::class.java
|
||||
)
|
||||
finish()
|
||||
}
|
||||
|
||||
// ActivityUtils.startActivity(
|
||||
// this@LauncherActivity,
|
||||
// LoginActivity::class.java
|
||||
// )
|
||||
|
||||
|
||||
// window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
// window.setFlags(
|
||||
// WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
||||
// WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
|
||||
// finish()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private var mDisposable: Disposable? = null
|
||||
|
||||
override fun initDate() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mDisposable?.dispose()
|
||||
}
|
||||
}
|
@ -49,6 +49,8 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(), View.OnClickListener
|
||||
}
|
||||
// et_pass.setSelection(et_pass.getText().toString().length)
|
||||
}
|
||||
|
||||
binding.ivBack.setOnClickListener { finish() }
|
||||
//
|
||||
// binding.btnLogin.setOnClickListener {
|
||||
// ActivityUtils.startActivity(this, HomeActivity::class.java)
|
||||
@ -67,9 +69,9 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(), View.OnClickListener
|
||||
// ActivityUtils.startActivity(mContext, AuthTrailerActivity::class.java,Bundle().apply {
|
||||
// putString(AppConfig.CAR_ID,"25")
|
||||
// })
|
||||
// ActivityUtils.startActivity(mContext, AuthDrivingActivity::class.java)
|
||||
ActivityUtils.startActivity(mContext, SelectRoleActivity::class.java)
|
||||
|
||||
ActivityUtils.startActivity(mContext, HomeActivity::class.java)
|
||||
// ActivityUtils.startActivity(mContext, HomeActivity::class.java)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
}
|
||||
@ -136,7 +138,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(), View.OnClickListener
|
||||
}
|
||||
|
||||
} else {
|
||||
OneKeyLoginUtils.getInstance().oneLogin(mContext,this)
|
||||
OneKeyLoginUtils.getInstance().oneLogin(mContext, this)
|
||||
// ActivityUtils.startActivity(mContext, SelectRoleActivity::class.java)
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,12 @@ package com.dahe.gldriver.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.dahe.gldriver.bean.CarBean
|
||||
import com.dahe.gldriver.callback.OnResultListener
|
||||
import com.dahe.gldriver.mypop.AgreementAlert
|
||||
import com.dahe.gldriver.mypop.OnCarSelectListener
|
||||
import com.dahe.gldriver.mypop.PopBottomCar
|
||||
import com.dahe.mylibrary.base.SingletonNoPHolder
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.interfaces.OnCancelListener
|
||||
import com.lxj.xpopup.interfaces.OnConfirmListener
|
||||
import com.lxj.xpopup.interfaces.OnInputConfirmListener
|
||||
|
||||
@ -30,19 +31,40 @@ class CommonPopUtils private constructor() {
|
||||
// .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||
.asCustom(PopBottomCar(context, cars, listener))
|
||||
.show()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 首次打开app弹窗
|
||||
* @param context Context
|
||||
* @param listener OnResultListener
|
||||
*/
|
||||
fun showCenterAgreement(context: Context,listener: OnResultListener) {
|
||||
XPopup.Builder(context)
|
||||
.dismissOnBackPressed(false)
|
||||
.dismissOnTouchOutside(false)
|
||||
.asCustom(
|
||||
AgreementAlert(
|
||||
context, "https://agreement.dahehuoyun.com/huawei/#/private",
|
||||
"http://agreement.dahehuoyun.com/#/user"
|
||||
,listener)
|
||||
)
|
||||
.show()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 装货弹框
|
||||
* */
|
||||
fun showLoadPop(context: Context,carBean: CarBean ,listener: OnConfirmListener) {
|
||||
fun showLoadPop(context: Context, carBean: CarBean, listener: OnConfirmListener) {
|
||||
XPopup.Builder(context)
|
||||
.isDestroyOnDismiss(true)
|
||||
.asConfirm(
|
||||
"去装货", """已选择:${carBean.vehicleNum},是否立即装货""",
|
||||
"取消", "确定",
|
||||
listener, null,false
|
||||
listener, null, false
|
||||
)
|
||||
.show()
|
||||
}
|
||||
@ -55,7 +77,12 @@ class CommonPopUtils private constructor() {
|
||||
* @param content String
|
||||
* @param listener OnConfirmListener
|
||||
*/
|
||||
fun showCommCenterPop(context: Context,title:String = "提示" ,content: String,listener: OnConfirmListener) {
|
||||
fun showCommCenterPop(
|
||||
context: Context,
|
||||
title: String = "提示",
|
||||
content: String,
|
||||
listener: OnConfirmListener,
|
||||
) {
|
||||
XPopup.Builder(context)
|
||||
.isDestroyOnDismiss(true)
|
||||
.asConfirm(
|
||||
@ -73,12 +100,12 @@ class CommonPopUtils private constructor() {
|
||||
* @param title String
|
||||
* @param listener OnInputConfirmListener
|
||||
*/
|
||||
fun showCenterInputPop(context: Context,title: String,listener: OnInputConfirmListener){
|
||||
fun showCenterInputPop(context: Context, title: String, listener: OnInputConfirmListener) {
|
||||
XPopup.Builder(context)
|
||||
.hasStatusBarShadow(false)
|
||||
.hasNavigationBar(false)
|
||||
.autoOpenSoftInput(true)
|
||||
.asInputConfirm(title,"","请输入拒绝原因",listener)
|
||||
.asInputConfirm(title, "", "请输入拒绝原因", listener)
|
||||
.show()
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.dahe.gldriver.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.dahe.gldriver.base.AppConfig
|
||||
import com.dahe.glex.bean.UserBean
|
||||
import com.dahe.mylibrary.net.JsonUtils
|
||||
import com.dahe.mylibrary.utils.BaseSPUtils
|
||||
@ -56,6 +57,14 @@ class SPUtils private constructor() : BaseSPUtils() {
|
||||
remove(context, USER_TOKEN_KEY)
|
||||
}
|
||||
|
||||
fun getIsFirstOpenApp(context: Context): Boolean {
|
||||
return get(context, AppConfig.IS_FIRST_OPEN, true) as Boolean
|
||||
}
|
||||
|
||||
fun setIsFirstOpenApp(context: Context,isFirstOpen:Boolean){
|
||||
put(context,AppConfig.IS_FIRST_OPEN,isFirstOpen)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 存服务器类型
|
||||
|
@ -23,6 +23,7 @@
|
||||
android:textSize="@dimen/sp_17" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivBack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
|
62
app/src/main/res/layout/alert_ok_cancel.xml
Normal file
62
app/src/main/res/layout/alert_ok_cancel.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_bai"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/dp_1">
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/dp_33"
|
||||
android:textColor="#333333"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textStyle="bold"
|
||||
tools:text="标题" />
|
||||
<TextView
|
||||
android:layout_marginLeft="@dimen/dp_18"
|
||||
android:layout_marginRight="@dimen/dp_18"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="内容内容内容内,容内容内容内容内容内容内容!"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginTop="@dimen/dp_17"
|
||||
android:layout_marginBottom="@dimen/dp_18"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:layout_marginLeft="@dimen/dp_18"
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_36"
|
||||
android:layout_weight="1"
|
||||
android:text="取消"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textColor="#ffa2a2b3"
|
||||
android:background="@drawable/shape_gray_5"
|
||||
android:layout_marginBottom="@dimen/dp_3"/>
|
||||
<Button
|
||||
android:layout_marginLeft="@dimen/dp_18"
|
||||
android:layout_marginRight="@dimen/dp_18"
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_36"
|
||||
android:layout_weight="1"
|
||||
android:text="确定"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textColor="#ffffff"
|
||||
android:background="@drawable/bg_btn"
|
||||
android:layout_marginBottom="@dimen/dp_3"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user