Skip to content

Commit

Permalink
腾讯连连合规
Browse files Browse the repository at this point in the history
http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192868776255

Change-Id: Ic4512e90df9361582f2f4a8d78e63f7559466955
  • Loading branch information
SundoggyNew committed Oct 22, 2021
1 parent 89899f5 commit 03fa80e
Show file tree
Hide file tree
Showing 36 changed files with 2,371 additions and 975 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<activity android:name=".kitlink.activity.AddTimerActivity" />
<activity android:name=".kitlink.activity.FamilyActivity" />
<activity android:name=".kitlink.activity.RoomListActivity" />
<activity android:name=".kitlink.activity.ControlPermissionActivity" />
<activity android:name=".kitlink.activity.AddRoomActivity" />
<activity android:name=".kitlink.activity.AddFamilyActivity" />
<activity android:name=".kitlink.activity.CommentDetailsActivity" />
Expand Down Expand Up @@ -163,6 +164,7 @@
<activity android:name=".kitlink.activity.ForgotPasswordActivity" />
<activity android:name=".kitlink.activity.CountryCodeActivity" />
<activity android:name=".kitlink.activity.RegisterActivity" />
<activity android:name=".kitlink.activity.ChooseCountryActivity" />
<activity android:name=".kitlink.activity.MessageActivity" /> <!-- 微信回调 -->
<activity android:name=".kitlink.activity.DevicePanelActivity" />
<activity android:name=".kitlink.activity.FeedbackForH5Activity" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/tencent/iot/explorer/link/AppData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AppData private constructor() {
var userInfo = UserInfo()
var userSetting = UserSetting()
var regionId = "1"
var conutryCode = "1" // 当前的登录的国家码
var conutryCode = "86" // 当前的登录的国家码
var bleDevice: BleDevice? = null // 用于标记将要被索引的蓝牙设备
var region = "ap-guangzhou"
var appLifeCircleId = "0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.tencent.iot.explorer.link.customview.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.tencent.iot.explorer.link.R;
import com.tencent.iot.explorer.link.customview.dialog.entity.UpgradeInfo;

public class PermissionDialog extends IosCenterStyleDialog implements View.OnClickListener {

private TextView detail;
private TextView detailLips;
private TextView btnRefuse;
private TextView btnOK;
private ConstraintLayout outLayout;
private String detailString;
private String detailLipsString;

public PermissionDialog(Context context, String detail, String detailLips) {
super(context, R.layout.popup_permission_layout);
this.detailString = detail;
this.detailLipsString = detailLips;
}

@Override
public void initView() {
outLayout = view.findViewById(R.id.permission_dialog_layout);
detail = view.findViewById(R.id.tv_detail);
detailLips = view.findViewById(R.id.tv_detail_lips);
btnRefuse = view.findViewById(R.id.tv_refuse);
btnOK = view.findViewById(R.id.tv_ok);

btnRefuse.setOnClickListener(this);
btnOK.setOnClickListener(this);

detail.setText(detailString);
detailLips.setText(detailLipsString);
outLayout.setBackgroundColor(getContext().getResources().getColor(R.color.dialog_background));
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_refuse:
dismiss();
if (onDismisListener != null) {
onDismisListener.OnClickRefuse();
}
break;
case R.id.tv_ok:
dismiss();
if (onDismisListener != null) {
onDismisListener.OnClickOK();
}
break;
default:
break;
}
}

private volatile OnDismisListener onDismisListener;

public interface OnDismisListener {
void OnClickRefuse();
void OnClickOK();
}

public void setOnDismisListener(OnDismisListener onDismisListener) {
this.onDismisListener = onDismisListener;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package com.tencent.iot.explorer.link.customview.dialog

import android.content.Context
import android.content.DialogInterface
import android.os.Build
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.util.Log
import android.view.KeyEvent
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.annotation.RequiresApi
import com.tencent.iot.explorer.link.R

class UserAgreeDialog(context: Context) : IosCenterStyleDialog(context, R.layout.popup_user_agree_layout), View.OnClickListener, DialogInterface.OnKeyListener {
private var tip_title: TextView? = null
private var tv_tip_content: TextView? = null
private var tv_register_tip: TextView? = null
private var tv_confirm: TextView? = null
private var tv_cancel: TextView? = null
private var select_tag_layout: RelativeLayout? = null
private var iv_agreement: ImageView? = null
private var iv_agreement_status: ImageView? = null
@Volatile
private var readed = false

private fun freshReadState() {
if (readed) {
iv_agreement?.setImageResource(R.mipmap.dev_mode_sel)
iv_agreement_status?.visibility = View.VISIBLE
} else {
iv_agreement?.setImageResource(R.mipmap.dev_mode_unsel)
iv_agreement_status?.visibility = View.GONE
}
}

override fun initView() {
tip_title = view.findViewById(R.id.tip_title)
tv_tip_content = view.findViewById(R.id.tv_tip_content)
tv_register_tip = view.findViewById(R.id.tv_register_tip)
tv_confirm = view.findViewById(R.id.tv_confirm)
tv_cancel = view.findViewById(R.id.tv_cancel)
select_tag_layout = view.findViewById(R.id.select_tag_layout)
iv_agreement = view.findViewById(R.id.iv_agreement)
iv_agreement_status = view.findViewById(R.id.iv_agreement_status)

val partStr0 = context.getString(R.string.register_agree_1)
val partStr1 = context.getString(R.string.register_agree_2)
val partStr2 = context.getString(R.string.register_agree_3)
val partStr3 = context.getString(R.string.register_agree_4)
var showStr = partStr1 + partStr2 + partStr3
tip_title?.text = showStr

var agreeStr = partStr0 + showStr
var spannable = SpannableStringBuilder(agreeStr)
spannable.setSpan(IndexClickableSpan(context, 1),
partStr0.length, partStr0.length + partStr1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
spannable.setSpan(IndexClickableSpan(context, 2),
agreeStr.length - partStr1.length, agreeStr.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
tv_register_tip?.movementMethod = LinkMovementMethod.getInstance()
tv_register_tip?.text = spannable

val agreeContentStrPrefix = context.getString(R.string.rule_content_prefix)
val agreeContentStrSuffix = context.getString(R.string.rule_content_suffix)
var agreeContentStr = agreeContentStrPrefix + showStr + agreeContentStrSuffix
var agreeContentSpannable = SpannableStringBuilder(agreeContentStr)
agreeContentSpannable.setSpan(IndexClickableSpan(context, 1),
agreeContentStrPrefix.length, agreeContentStrPrefix.length + partStr1.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
val start = agreeContentStrPrefix.length + partStr1.length + partStr2.length
agreeContentSpannable.setSpan(IndexClickableSpan(context, 2),
start, start + partStr3.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
tv_tip_content?.movementMethod = LinkMovementMethod.getInstance()
tv_tip_content?.text = agreeContentSpannable

select_tag_layout?.setOnClickListener(this)
tv_cancel?.setOnClickListener(this)
tv_confirm?.setOnClickListener(this)
this.setOnKeyListener(this)
freshReadState()
}

override fun onClick(v: View?) {
when(v) {
select_tag_layout -> {
readed =! readed
freshReadState()
}

tv_cancel -> {
onDismisListener?.onDismised()
}

tv_confirm -> {
if (!readed) return
onDismisListener?.onOkClicked()
dismiss()
}
}
}

@Volatile
private var onDismisListener: OnDismisListener? = null

interface OnDismisListener {
fun onDismised()
fun onOkClicked()
fun onOkClickedUserAgreement()
fun onOkClickedPrivacyPolicy()
}

fun setOnDismisListener(onDismisListener: OnDismisListener?) {
this.onDismisListener = onDismisListener
}

inner class IndexClickableSpan(context: Context, index: Int): ClickableSpan() {
private var index = 0
private var context: Context? = null

init {
this.index = index
this.context = context
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onClick(widget: View) {
context?.let {
tv_tip_content?.highlightColor = it.getColor(android.R.color.transparent)
tv_register_tip?.highlightColor = it.getColor(android.R.color.transparent)
}
if (index == 1) {
onDismisListener?.onOkClickedUserAgreement()
} else if (index == 2) {
onDismisListener?.onOkClickedPrivacyPolicy()
}
}

@RequiresApi(Build.VERSION_CODES.M)
override fun updateDrawState(ds: TextPaint) {
super.updateDrawState(ds)
context?.let {
ds.color = it.getColor(R.color.blue_0066FF)
}
ds.isUnderlineText = false
}
}

override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK) {
onDismisListener?.onDismised()
}
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.tencent.iot.explorer.link.T
import com.tencent.iot.explorer.link.core.auth.callback.MyCallback
import com.tencent.iot.explorer.link.core.auth.response.BaseResponse
import com.tencent.iot.explorer.link.core.utils.Utils
import com.tencent.iot.explorer.link.customview.dialog.PermissionDialog
import kotlinx.android.synthetic.main.activity_account_and_safety.*
import kotlinx.android.synthetic.main.menu_back_layout.*

Expand Down Expand Up @@ -49,6 +50,7 @@ class AccountAndSafetyActivity : PActivity(), AccountAndSafetyView, View.OnClick
tv_wechat.setOnClickListener(this)
tv_modify_passwd.setOnClickListener(this)
tv_account_logout.setOnClickListener(this)
tv_controller_of_permission.setOnClickListener(this)
}

override fun onClick(v: View?) {
Expand All @@ -71,7 +73,18 @@ class AccountAndSafetyActivity : PActivity(), AccountAndSafetyView, View.OnClick
if (App.data.userInfo.HasWxOpenID == "1") {
T.show(getString(R.string.wechat_bind_already)) //微信已经绑定过了, 请勿重复绑定
} else {
WeChatLogin.getInstance().login(this, this)
var dlg = PermissionDialog(this@AccountAndSafetyActivity, getString(R.string.permission_of_wechat), getString(R.string.permission_of_wechat_lips))
dlg.show()
dlg.setOnDismisListener(object : PermissionDialog.OnDismisListener {
override fun OnClickRefuse() {

}

override fun OnClickOK() {
WeChatLogin.getInstance().login(this@AccountAndSafetyActivity, this@AccountAndSafetyActivity)
}

})
}
}
tv_modify_passwd -> {// 修改密码
Expand All @@ -80,6 +93,9 @@ class AccountAndSafetyActivity : PActivity(), AccountAndSafetyView, View.OnClick
tv_account_logout -> {// 注销账号
jumpActivity(LogoutActivity::class.java)
}
tv_controller_of_permission -> {
jumpActivity(ControlPermissionActivity::class.java)
}
}
}

Expand Down
Loading

0 comments on commit 03fa80e

Please sign in to comment.