浏览代码

修改启动提示隐私协议

Pq 3 年之前
父节点
当前提交
49bad40784

+ 56 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/dialog/PrivacyTipDialog.java

@@ -0,0 +1,56 @@
+package com.cooleshow.base.widgets.dialog;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.view.View;
+import android.widget.TextView;
+
+import com.cooleshow.base.R;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2022/7/19.
+ */
+public class PrivacyTipDialog extends Dialog {
+
+    private TextView mTvContent;
+    private TextView mCancel;
+    private TextView mBtnCommit;
+
+    public PrivacyTipDialog(@NonNull Context context) {
+        super(context, R.style.DialogStyle);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialog_privacy_agreement_layout);
+        setCanceledOnTouchOutside(false);
+        setCancelable(false);
+        mTvContent = findViewById(R.id.tv_content);
+        mCancel = findViewById(R.id.btn_cancel);
+        mBtnCommit = findViewById(R.id.btn_commit);
+        mTvContent.setMovementMethod(LinkMovementMethod.getInstance());
+    }
+
+    public void setContent(CharSequence content) {
+        if (mTvContent != null) {
+            mTvContent.setText(content);
+        }
+    }
+
+    public void setOnCancelClickListener(View.OnClickListener onCancelClickListener) {
+        if (mCancel != null) {
+            mCancel.setOnClickListener(onCancelClickListener);
+        }
+    }
+
+    public void setOnConfirmClickListener(View.OnClickListener onConfirmClickListener) {
+        if (mBtnCommit != null) {
+            mBtnCommit.setOnClickListener(onConfirmClickListener);
+        }
+    }
+}

+ 96 - 0
BaseLibrary/src/main/res/layout/dialog_privacy_agreement_layout.xml

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/transparent"
+    android:gravity="center"
+    android:orientation="vertical">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="@dimen/dp_272"
+        android:layout_height="wrap_content"
+        android:background="@drawable/bg_white_10dp">
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:padding="@dimen/dp_15"
+            android:text="温馨提示"
+            android:textColor="@color/color_333333"
+            android:textSize="@dimen/dp_18"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+
+        <com.cooleshow.base.widgets.MaxHeightScrollView
+            android:id="@+id/scroll_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:adjustViewBounds="true"
+            android:scrollbars="none"
+            app:layout_constraintBottom_toTopOf="@id/btn_cancel"
+            app:layout_constraintStart_toStartOf="@id/tv_title"
+            app:layout_constraintTop_toBottomOf="@id/tv_title"
+            app:max_height="@dimen/dp_300">
+
+            <TextView
+                android:id="@+id/tv_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:lineSpacingExtra="@dimen/dp_5"
+                android:paddingStart="@dimen/dp_15"
+                android:paddingTop="@dimen/dp_8"
+                android:paddingEnd="@dimen/dp_15"
+                android:paddingBottom="@dimen/dp_36"
+                android:text=""
+                android:textColor="@color/color_333333"
+                android:textSize="@dimen/dp_15" />
+        </com.cooleshow.base.widgets.MaxHeightScrollView>
+
+        <TextView
+            android:id="@+id/btn_cancel"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray_left_bottom_10dp_shape"
+            android:gravity="center"
+            android:paddingTop="@dimen/dp_13"
+            android:paddingBottom="@dimen/dp_13"
+            android:text="不同意"
+            android:textColor="@color/color_666666"
+            android:textSize="@dimen/dp_16"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toStartOf="@id/btn_commit"
+            app:layout_constraintHorizontal_chainStyle="spread_inside"
+            app:layout_constraintHorizontal_weight="1"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/scroll_layout" />
+
+        <TextView
+            android:id="@+id/btn_commit"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_green_right_bottom_10dp_shape"
+            android:gravity="center"
+            android:paddingTop="@dimen/dp_13"
+            android:paddingBottom="@dimen/dp_13"
+            android:text="同意"
+            android:textColor="@color/white"
+            android:textSize="@dimen/dp_16"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintHorizontal_weight="1"
+            app:layout_constraintStart_toEndOf="@id/btn_cancel"
+            app:layout_constraintTop_toTopOf="@id/btn_cancel" />
+
+        <View
+            style="@style/line_style"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/tv_title" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>

+ 91 - 0
student/src/main/java/com/cooleshow/student/ui/splash/SplashActivity.kt

@@ -2,16 +2,24 @@ package com.cooleshow.student.ui.splash
 
 import android.net.Uri
 import android.os.Bundle
+import android.text.Spannable
+import android.text.SpannableStringBuilder
+import android.text.TextPaint
 import android.text.TextUtils
+import android.text.style.ClickableSpan
 import android.util.Log
+import android.view.View
 import com.alibaba.android.arouter.launcher.ARouter
 import com.cooleshow.base.bean.RouteBean
 import com.cooleshow.base.common.ConstantKey
+import com.cooleshow.base.common.WebConstants
 import com.cooleshow.base.router.RouterPath
 import com.cooleshow.base.ui.activity.BaseActivity
 import com.cooleshow.base.utils.GsonUtils
 import com.cooleshow.base.utils.JumpUtils
 import com.cooleshow.base.utils.SPUtils
+import com.cooleshow.base.utils.ToastUtil
+import com.cooleshow.base.widgets.dialog.PrivacyTipDialog
 import com.cooleshow.student.databinding.ActivitySplashLayoutBinding
 import com.cooleshow.usercenter.constants.UserConstants
 import com.cooleshow.usercenter.helper.UserHelper
@@ -37,6 +45,89 @@ class SplashActivity : BaseActivity<ActivitySplashLayoutBinding>() {
 
     override fun initData() {
         super.initData()
+        var privacyMode = UserHelper.getAppPrivacyMode()
+        if (privacyMode == 0) {
+            //显示隐私协议提示弹窗
+            showPrivacyTipDialog()
+        } else {
+            goIntent()
+        }
+    }
+
+
+    private fun showPrivacyTipDialog() {
+        val contentStart = "亲爱的用户,感谢您的信任并使用酷乐秀APP!\n    在使用我们的产品和服务前,请您先阅读并了解"
+        val userProtocol = "《用户协议》"
+        val privacy = "和《隐私政策》"
+        val contentEnd = """
+            。请您在点击同意之前充分理解相关条款,其中的重点条款已为您标注,方便您了解自己的权利。
+            我们将通过《隐私政策》向您说明 :
+            1.为了您可以更好的学习器乐,我们会需要您填写您的 基本信息,我们会根据您填写内容,收集和使用对应的必要信息(如手机号,声部信息等)。
+            2.您可以对上述信息进行访问、更正、删除以及注销账户,我们也将提供专门的个人信息保护联系方式。
+            3.未经您的授权同意,我们不会将上述信息共享给第三方或用于您未授权的其他用途。
+            
+            我们将严格按照上述协议为您提供服务,保护您的信息安全,点击“同意”即表示您已阅读并同意全部条款,可以继续使用我们的产品和服务。
+            
+            """.trimIndent()
+
+        val spannableStringBuilder =
+            SpannableStringBuilder(contentStart + userProtocol + privacy + contentEnd)
+        val userProtocolSpan: ClickableSpan = object : ClickableSpan() {
+            override fun updateDrawState(ds: TextPaint) {
+                ds.linkColor = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
+                super.updateDrawState(ds)
+            }
+
+            override fun onClick(view: View) {
+                //跳转用户协议
+                ARouter.getInstance()
+                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                    .withString(WebConstants.WEB_URL, WebConstants.REGISTRATION_AGREEMENT)
+                    .navigation()
+            }
+        }
+        val privacySpan: ClickableSpan = object : ClickableSpan() {
+            override fun updateDrawState(ds: TextPaint) {
+                ds.linkColor = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
+                super.updateDrawState(ds)
+            }
+
+            override fun onClick(view: View) {
+                //跳转隐私协议
+                ARouter.getInstance()
+                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                    .withString(WebConstants.WEB_URL, WebConstants.PRIVACY_AGREEMENT)
+                    .navigation()
+            }
+        }
+
+        val startIndex = contentStart.length
+        spannableStringBuilder.setSpan(
+            userProtocolSpan,
+            startIndex,
+            startIndex + 6,
+            Spannable.SPAN_EXCLUSIVE_INCLUSIVE
+        )
+        spannableStringBuilder.setSpan(
+            privacySpan,
+            startIndex + 7,
+            startIndex + 13,
+            Spannable.SPAN_EXCLUSIVE_INCLUSIVE
+        )
+        var dialog: PrivacyTipDialog = PrivacyTipDialog(this)
+        dialog.show()
+        dialog.setContent(spannableStringBuilder)
+        dialog.setOnCancelClickListener {
+            ToastUtil.getInstance().showShort("不同意用户协议及隐私协议将无法正常使用酷乐秀哦")
+            finish()
+        }
+        dialog.setOnConfirmClickListener {
+            UserHelper.setAppPrivacyModeIsAgree()
+            goIntent()
+        }
+    }
+
+    private fun goIntent() {
         val isFirstLaunch = SPUtils.getInstance().getBoolean(ConstantKey.IS_FIRST_LAUNCH, false)
         if (isFirstLaunch) {
             if (UserHelper.isLogin()) {

+ 91 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/splash/SplashActivity.kt

@@ -1,7 +1,12 @@
 package com.cooleshow.teacher.ui.splash
 
 import android.net.Uri
+import android.text.Spannable
+import android.text.SpannableStringBuilder
+import android.text.TextPaint
 import android.text.TextUtils
+import android.text.style.ClickableSpan
+import android.view.View
 import com.alibaba.android.arouter.launcher.ARouter
 import com.cooleshow.base.bean.RouteBean
 import com.cooleshow.base.common.ConstantKey
@@ -11,6 +16,9 @@ import com.cooleshow.base.ui.activity.BaseActivity
 import com.cooleshow.base.utils.GsonUtils
 import com.cooleshow.base.utils.JumpUtils
 import com.cooleshow.base.utils.SPUtils
+import com.cooleshow.base.utils.ToastUtil
+import com.cooleshow.base.widgets.dialog.PrivacyTipDialog
+import com.cooleshow.teacher.R
 import com.cooleshow.teacher.databinding.ActivitySplashLayoutBinding
 import com.cooleshow.usercenter.constants.UserConstants
 import com.cooleshow.usercenter.helper.UserHelper
@@ -31,6 +39,88 @@ class SplashActivity : BaseActivity<ActivitySplashLayoutBinding>() {
 
     override fun initData() {
         super.initData()
+        var privacyMode = UserHelper.getAppPrivacyMode()
+        if (privacyMode == 0) {
+            //显示隐私协议提示弹窗
+            showPrivacyTipDialog()
+        } else {
+            goIntent()
+        }
+    }
+
+    private fun showPrivacyTipDialog() {
+        val contentStart = "亲爱的用户,感谢您的信任并使用酷乐秀学院APP!\n    在使用我们的产品和服务前,请您先阅读并了解"
+        val userProtocol = "《用户协议》"
+        val privacy = "和《隐私政策》"
+        val contentEnd = """
+            。请您在点击同意之前充分理解相关条款,其中的重点条款已为您标注,方便您了解自己的权利。
+            我们将通过《隐私政策》向您说明 :
+            1.为了您可以更好的学习器乐,我们会需要您填写您的 基本信息,我们会根据您填写内容,收集和使用对应的必要信息(如手机号,声部信息等)。
+            2.您可以对上述信息进行访问、更正、删除以及注销账户,我们也将提供专门的个人信息保护联系方式。
+            3.未经您的授权同意,我们不会将上述信息共享给第三方或用于您未授权的其他用途。
+            
+            我们将严格按照上述协议为您提供服务,保护您的信息安全,点击“同意”即表示您已阅读并同意全部条款,可以继续使用我们的产品和服务。
+            
+            """.trimIndent()
+
+        val spannableStringBuilder =
+            SpannableStringBuilder(contentStart + userProtocol + privacy + contentEnd)
+        val userProtocolSpan: ClickableSpan = object : ClickableSpan() {
+            override fun updateDrawState(ds: TextPaint) {
+                ds.linkColor = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
+                super.updateDrawState(ds)
+            }
+
+            override fun onClick(view: View) {
+                //跳转用户协议
+                ARouter.getInstance()
+                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                    .withString(WebConstants.WEB_URL, WebConstants.REGISTRATION_AGREEMENT)
+                    .navigation()
+            }
+        }
+        val privacySpan: ClickableSpan = object : ClickableSpan() {
+            override fun updateDrawState(ds: TextPaint) {
+                ds.linkColor = resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
+                super.updateDrawState(ds)
+            }
+
+            override fun onClick(view: View) {
+                //跳转隐私协议
+                ARouter.getInstance()
+                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                    .withString(WebConstants.WEB_URL, WebConstants.PRIVACY_AGREEMENT)
+                    .navigation()
+            }
+        }
+
+        val startIndex = contentStart.length
+        spannableStringBuilder.setSpan(
+            userProtocolSpan,
+            startIndex,
+            startIndex + 6,
+            Spannable.SPAN_EXCLUSIVE_INCLUSIVE
+        )
+        spannableStringBuilder.setSpan(
+            privacySpan,
+            startIndex + 7,
+            startIndex + 13,
+            Spannable.SPAN_EXCLUSIVE_INCLUSIVE
+        )
+        var dialog: PrivacyTipDialog = PrivacyTipDialog(this)
+        dialog.show()
+        dialog.setContent(spannableStringBuilder)
+        dialog.setOnCancelClickListener {
+            ToastUtil.getInstance().showShort("不同意用户协议及隐私协议将无法正常使用酷乐秀学院哦")
+            finish()
+        }
+        dialog.setOnConfirmClickListener {
+            UserHelper.setAppPrivacyModeIsAgree()
+            goIntent()
+        }
+    }
+
+    private fun goIntent() {
         val isFirstLaunch = SPUtils.getInstance().getBoolean(ConstantKey.IS_FIRST_LAUNCH, false)
         if (isFirstLaunch) {
             if (UserHelper.isLogin()) {
@@ -66,7 +156,7 @@ class SplashActivity : BaseActivity<ActivitySplashLayoutBinding>() {
 
     private fun jumpLogin() {
         ARouter.getInstance().build(RouterPath.UserCenter.PATH_VERIFY_LOGIN)
-            .withInt(UserConstants.LOGIN_ITEM,VerifyCodeLoginActivity.TEACHER_ITEM)
+            .withInt(UserConstants.LOGIN_ITEM, VerifyCodeLoginActivity.TEACHER_ITEM)
             .navigation()
     }
 

+ 18 - 1
usercenter/src/main/java/com/cooleshow/usercenter/helper/UserHelper.java

@@ -21,6 +21,23 @@ public class UserHelper {
     public static final String USER_AVATAR = "avatar";
     public static final String TEACHER_CERT_STATUS = "teacherCert";
     public static final String TEACHER_LIVE_FLAG_STATUS = "teacherLiveFlag";
+    public static final String PRIVACY_KEY = "privacy_key";
+
+    /**
+     * 获取用户是否同意app隐私协议
+     */
+    public static int getAppPrivacyMode() {
+        //0是未同意 1是已同意
+        return SPUtils.getInstance().getInt(PRIVACY_KEY, 0);
+    }
+
+    /**
+     * 设置用户已同意app隐私协议
+     */
+    public static void setAppPrivacyModeIsAgree() {
+        ////0是未同意 1是已同意
+        SPUtils.getInstance().put(PRIVACY_KEY, 1);
+    }
 
     public static boolean isLogin() {
         return !TextUtils.isEmpty(getUserToken());
@@ -78,7 +95,7 @@ public class UserHelper {
      * 老师直播权限状态
      */
     public static int getTeacherLiveFlag() {
-        return SPUtils.getInstance().getInt(TEACHER_LIVE_FLAG_STATUS + "_" + getUserId(),0);
+        return SPUtils.getInstance().getInt(TEACHER_LIVE_FLAG_STATUS + "_" + getUserId(), 0);
     }
 
 

+ 1 - 1
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/LoginActivity.kt

@@ -18,7 +18,6 @@ import com.cooleshow.base.ui.activity.BaseMVPActivity
 import com.cooleshow.base.utils.PhoneUtils
 import com.cooleshow.base.utils.SpannableStringUtils
 import com.cooleshow.base.utils.ToastUtil
-import com.cooleshow.base.utils.ToastUtils
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper
 import com.cooleshow.usercenter.R
 import com.cooleshow.usercenter.bean.UserLoginInfo
@@ -60,6 +59,7 @@ class LoginActivity : BaseMVPActivity<ActivityLoginBinding, LoginPresenter>(),
         } else {
             viewBinding.tvHeaderTitle.text = "您好, \n欢迎使用酷乐秀"
         }
+        viewBinding.cbPrivacy.isChecked = UserHelper.getAppPrivacyMode() == 1
 
         setPrivacyText()
         mLoginBtn.setOnClickListener {

+ 6 - 0
usercenter/src/main/java/com/cooleshow/usercenter/ui/activity/VerifyCodeLoginActivity.java

@@ -70,6 +70,12 @@ public class VerifyCodeLoginActivity extends BaseMVPActivity<ActivityVerifyCodeL
         if (!TextUtils.isEmpty(phoneNum)) {
             viewBinding.etPhoneNum.setText(phoneNum);
         }
+        if (UserHelper.getAppPrivacyMode() == 1) {
+            //已同意隐私协议及用户协议
+            viewBinding.cbPrivacy.setChecked(true);
+        } else {
+            viewBinding.cbPrivacy.setChecked(false);
+        }
         setPrivacyText();
     }